]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbrestorepanel.h
Added wxbutils.cpp, win32 test corrected.
[bacula/bacula] / bacula / src / wx-console / wxbrestorepanel.h
1 /*
2    Copyright (C) 2004 Kern Sibbald and John Walker
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License
6    as published by the Free Software Foundation; either version 2
7    of the License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #ifndef WXBRESTOREPANEL_H
20 #define WXBRESTOREPANEL_H
21
22 #include "wx/wxprec.h"
23
24 #ifndef WX_PRECOMP
25    #include "wx/wx.h"
26 #endif
27
28 #include "wxbtableparser.h"
29
30 #include <wx/thread.h>
31 #include <wx/listctrl.h>
32 #include <wx/treectrl.h>
33 #include <wx/gauge.h>
34
35 #include "wxbutils.h"
36
37 #include "wxbtreectrl.h"
38 #include "wxblistctrl.h"
39
40 /*
41  * wxbPanel for restoring files
42  */
43 class wxbRestorePanel : public wxbPanel
44 {
45    public:
46       wxbRestorePanel(wxWindow* parent);
47       ~wxbRestorePanel();
48
49       /* wxbPanel overloadings */
50       virtual wxString GetTitle();
51       virtual void EnablePanel(bool enable = true);
52
53    private:
54 /* Commands called by events handler */
55
56       /* The main button has been clicked */
57       void CmdStart();
58
59        /* List jobs for a specified client */
60       void CmdListJobs();
61
62       /* List files and directories for a specified tree item */
63       void CmdList(wxTreeItemId item);
64
65       /* Mark a treeitem (directory) or a listitem (file or directory) */
66       void CmdMark(wxTreeItemId treeitem, long listitem);
67
68 /* General functions and variables */
69       bool ended; /* The last command send has finished */
70
71       long filemessages; /* When restoring, number of files restored */
72       long totfilemessages; /* When restoring, number of files to be restored */
73
74       /* Parse a table in tableParser */
75       wxbTableParser* CreateAndWaitForParser(wxString cmd);
76
77       /* Run a command, and waits until result is fully received,
78        * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
79        * containing the data. */
80       wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false);
81
82       /* Run a dir command, and waits until result is fully received. */
83       void UpdateTreeItem(wxTreeItemId item, bool updatelist);
84
85       /* Parse dir command results. */
86       wxString* ParseList(wxString line);
87
88       /* Sets a list item state, and update its parents and children if it is a directory */
89       void SetListItemState(long listitem, int newstate);
90
91       /* Sets a tree item state, and update its children, parents and list (if necessary) */
92       void SetTreeItemState(wxTreeItemId item, int newstate);
93       
94       /* Update a tree item parents' state */
95       void UpdateTreeItemState(wxTreeItemId item);
96
97       /* Refresh a tree item, and all its children. */
98       void RefreshTree(wxTreeItemId item);
99
100 /* Status related */
101       enum status_enum
102       {
103          disabled,  // The panel is not activatable
104          activable, // The panel is activable, but not activated
105          entered,   // The panel is activated
106          choosing,  // The user is choosing files to restore
107          listing,   // Dir listing is in progress
108          restoring, // Bacula is restoring files
109          finished   // Retore done (state will change in activable)
110       };
111
112       status_enum status;
113
114       /* Set current status by enabling/disabling components */
115       void SetStatus(status_enum newstatus);
116
117 /* UI related */
118       bool working; // A command is running, discard GUI events
119       wxTreeItemId currentTreeItem; // Currently selected tree item
120
121 /* Event handling */
122       void OnStart(wxEvent& WXUNUSED(event));
123       void OnTreeChanging(wxTreeEvent& event);
124       void OnTreeExpanding(wxTreeEvent& event);
125       void OnTreeChanged(wxTreeEvent& event);
126       void OnTreeMarked(wxbTreeMarkedEvent& event);
127       void OnListMarked(wxbListMarkedEvent& event);
128       void OnListActivated(wxListEvent& event);
129       void OnClientChoiceChanged(wxCommandEvent& event);
130
131 /* Components */
132       wxImageList* imagelist; //image list for tree and list
133
134       wxButton* start;
135       wxChoice* clientChoice;
136       wxChoice* jobChoice;
137       wxbTreeCtrl* tree;
138       wxbListCtrl* list;
139       wxGauge* gauge;
140
141       DECLARE_EVENT_TABLE();
142 };
143
144 #endif // WXBRESTOREPANEL_H
145