]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/wx-console/wxbrestorepanel.h
- Implement restore of a single directory.
[bacula/bacula] / bacula / src / wx-console / wxbrestorepanel.h
index cc185ac4c67bdbc41ef8ef08ab2ecdb5881a44d8..0473927fbd718e60f6f29f6fcef694826494d6f9 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ *
+ *   wxbPanel for restoring files
+ *
+ *    Nicolas Boichat, April-May 2004
+ *
+ *    Version $Id$
+ */
 /*
    Copyright (C) 2004 Kern Sibbald and John Walker
 
 #include <wx/listctrl.h>
 #include <wx/treectrl.h>
 #include <wx/gauge.h>
+#include <wx/stattext.h>
+#include <wx/splitter.h>
 
-#include "wxbpanel.h"
+#include "wxbutils.h"
 
+#include "wxbconfigpanel.h"
 #include "wxbtreectrl.h"
 #include "wxblistctrl.h"
 
+WX_DECLARE_LIST(wxEvent, wxbEventList);
+
 /*
  * wxbPanel for restoring files
  */
@@ -48,7 +61,7 @@ class wxbRestorePanel : public wxbPanel
 
       /* wxbPanel overloadings */
       virtual wxString GetTitle();
-      virtual void Print(wxString str, int status);
+      virtual void EnablePanel(bool enable = true);
 
    private:
 /* Commands called by events handler */
@@ -56,36 +69,35 @@ class wxbRestorePanel : public wxbPanel
       /* The main button has been clicked */
       void CmdStart();
 
+      /* The cancel button has been clicked */
+      void CmdCancel();
+
+      /* Apply configuration changes */
+      void CmdConfigApply();
+
+      /* Cancel restore */
+      void CmdConfigCancel();
+
        /* List jobs for a specified client */
       void CmdListJobs();
 
       /* List files and directories for a specified tree item */
       void CmdList(wxTreeItemId item);
 
-      /* Mark a treeitem (directory) or a listitem (file or directory) */
-      void CmdMark(wxTreeItemId treeitem, long listitem);
+      /* Mark a treeitem (directory) or several listitems (file or directory),
+       * state defines if it should mark (1), unmark (0), or switch state (-1) */
+      void CmdMark(wxTreeItemId treeitem, long* listitems, int listsize, int state = -1);
 
 /* General functions and variables */
-      bool ended; /* The last command send has finished */
+      //bool ended; /* The last command send has finished */
 
-      long filemessages; /* When restoring, number of files restored */
+      //long filemessages; /* When restoring, number of files restored */
       long totfilemessages; /* When restoring, number of files to be restored */
+      wxString jobid;
 
-      /* When listing a directory, sets if file list must be updated
-       * (otherwise only the tree structure is updated)
-       */
-      bool updatelist;
-
-      wxbTableParser* tableParser; /* Used to parse tables */
-
-      /* Parse a table in tableParser */
-      void CreateAndWaitForParser(wxString cmd);
-
-      /* Run a command, and waits until result is fully received. */
-      void WaitForEnd(wxString cmd);
-
-      /* Run a dir command, and waits until result is fully received. */
-      void WaitForList(wxTreeItemId item, bool updatelist);
+      /* Run a dir command, and waits until result is fully received.
+       * If recurse is true, update the children too. */
+      void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
 
       /* Parse dir command results. */
       wxString* ParseList(wxString line);
@@ -95,55 +107,114 @@ class wxbRestorePanel : public wxbPanel
 
       /* Sets a tree item state, and update its children, parents and list (if necessary) */
       void SetTreeItemState(wxTreeItemId item, int newstate);
-      
+
       /* Update a tree item parents' state */
       void UpdateTreeItemState(wxTreeItemId item);
 
-      /* Refresh a tree item, and all its children. */
-      void RefreshTree(wxTreeItemId item);
+      /* Refresh the whole tree. */
+      void RefreshTree();
+
+      /* Refresh file list */
+      void RefreshList();
+
+      /* Update first config, adapting settings to the job name selected */
+      void UpdateFirstConfig();
+
+      /* Update second config */
+      bool UpdateSecondConfig(wxbDataTokenizer* dt);
 
 /* Status related */
       enum status_enum
       {
-         disabled,  // The panel is not activated
-         entered,   // The panel is activated
-         choosing,  // The user is choosing files to restore
-         listing,   // Dir listing is in progress
-         restoring, // Bacula is restoring files
-         finished   // Retore done
+        disabled,    // The panel is not activatable
+        activable,   // The panel is activable, but not activated
+        entered,     // The panel is activated
+        choosing,    // The user is choosing files to restore
+        listing,     // Dir listing is in progress
+        configuring, // The user is configuring restore process
+        restoring,   // Bacula is restoring files
+        finished     // Retore done (state will change in activable)
       };
 
       status_enum status;
 
+      /* Cancelled status :
+       *  - 0 - !cancelled
+       *  - 1 - will be cancelled
+       *  - 2 - has been cancelled */
+      int cancelled;
+
       /* Set current status by enabling/disabling components */
-      void setStatus(status_enum newstatus);
+      void SetStatus(status_enum newstatus);
 
 /* UI related */
       bool working; // A command is running, discard GUI events
+      void SetWorking(bool working);
+      bool IsWorking();
+      bool markWhenCommandDone; //If an item should be (un)marked after the current listing/marking is done
       wxTreeItemId currentTreeItem; // Currently selected tree item
 
+      /* Enable or disable config controls status */
+      void EnableConfig(bool enable);
+
 /* Event handling */
-      void OnStart(wxEvent& WXUNUSED(event));
+//      wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
+//      bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
+
+//      virtual void AddPendingEvent(wxEvent& event);
+//      virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
+
+      void OnStart(wxCommandEvent& event);
+      void OnCancel(wxCommandEvent& event);
+
       void OnTreeChanging(wxTreeEvent& event);
       void OnTreeExpanding(wxTreeEvent& event);
       void OnTreeChanged(wxTreeEvent& event);
       void OnTreeMarked(wxbTreeMarkedEvent& event);
+      void OnTreeAdd(wxCommandEvent& event);
+      void OnTreeRemove(wxCommandEvent& event);
+      void OnTreeRefresh(wxCommandEvent& event);
+
       void OnListMarked(wxbListMarkedEvent& event);
       void OnListActivated(wxListEvent& event);
-      void OnClientChoiceChanged(wxCommandEvent& event);
+      void OnListChanged(wxListEvent& event);
+      void OnListAdd(wxCommandEvent& event);
+      void OnListRemove(wxCommandEvent& event);
+      void OnListRefresh(wxCommandEvent& event);
+
+      void OnConfigUpdated(wxCommandEvent& event);
+      void OnConfigOk(wxCommandEvent& WXUNUSED(event));
+      void OnConfigApply(wxCommandEvent& WXUNUSED(event));
+      void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
 
 /* Components */
+      wxBoxSizer *centerSizer; /* Center sizer */
+      wxSplitterWindow *treelistPanel; /* Panel which contains tree and list */
+      wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
+      wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
+
       wxImageList* imagelist; //image list for tree and list
 
       wxButton* start;
-      wxChoice* clientChoice;
-      wxChoice* jobChoice;
+      wxButton* cancel;
+
       wxbTreeCtrl* tree;
+      wxButton* treeadd;
+      wxButton* treeremove;
+      wxButton* treerefresh;
+
       wxbListCtrl* list;
+      wxButton* listadd;
+      wxButton* listremove;
+      wxButton* listrefresh;
+
       wxGauge* gauge;
 
+      long cfgUpdated; //keeps which config fields have been updated
+
+      friend class wxbSplitterWindow;
+
       DECLARE_EVENT_TABLE();
 };
 
 #endif // WXBRESTOREPANEL_H
-