]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbrestorepanel.h
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / wx-console / wxbrestorepanel.h
1 /*
2  *
3  *   wxbPanel for restoring files
4  *
5  *    Nicolas Boichat, April-May 2004
6  *
7  *    Version $Id$
8  */
9 /*
10    Copyright (C) 2004 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    as published by the Free Software Foundation; either version 2
15    of the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef WXBRESTOREPANEL_H
28 #define WXBRESTOREPANEL_H
29
30 #include "wx/wxprec.h"
31
32 #ifndef WX_PRECOMP
33    #include "wx/wx.h"
34 #endif
35
36 #include "wxbtableparser.h"
37
38 #include <wx/thread.h>
39 #include <wx/listctrl.h>
40 #include <wx/treectrl.h>
41 #include <wx/gauge.h>
42 #include <wx/stattext.h>
43 #include <wx/splitter.h>
44
45 #include "wxbutils.h"
46
47 #include "wxbconfigpanel.h"
48 #include "wxbtreectrl.h"
49 #include "wxblistctrl.h"
50
51 WX_DECLARE_LIST(wxEvent, wxbEventList);
52
53 /*
54  * wxbPanel for restoring files
55  */
56 class wxbRestorePanel : public wxbPanel
57 {
58    public:
59       wxbRestorePanel(wxWindow* parent);
60       ~wxbRestorePanel();
61
62       /* wxbPanel overloadings */
63       virtual wxString GetTitle();
64       virtual void EnablePanel(bool enable = true);
65
66    private:
67 /* Commands called by events handler */
68
69       /* The main button has been clicked */
70       void CmdStart();
71
72       /* The cancel button has been clicked */
73       void CmdCancel();
74
75       /* Apply configuration changes */
76       void CmdConfigApply();
77
78       /* Cancel restore */
79       void CmdConfigCancel();
80
81        /* List jobs for a specified client */
82       void CmdListJobs();
83
84       /* List files and directories for a specified tree item */
85       void CmdList(wxTreeItemId item);
86
87       /* Mark a treeitem (directory) or several listitems (file or directory),
88        * state defines if it should mark (1), unmark (0), or switch state (-1) */
89       void CmdMark(wxTreeItemId treeitem, long* listitems, int listsize, int state = -1);
90
91 /* General functions and variables */
92       //bool ended; /* The last command send has finished */
93
94       //long filemessages; /* When restoring, number of files restored */
95       long totfilemessages; /* When restoring, number of files to be restored */
96       wxString jobid;
97
98       /* Run a dir command, and waits until result is fully received.
99        * If recurse is true, update the children too. */
100       void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
101
102       /* Parse dir command results. */
103       wxString* ParseList(wxString line);
104
105       /* Sets a list item state, and update its parents and children if it is a directory */
106       void SetListItemState(long listitem, int newstate);
107
108       /* Sets a tree item state, and update its children, parents and list (if necessary) */
109       void SetTreeItemState(wxTreeItemId item, int newstate);
110       
111       /* Update a tree item parents' state */
112       void UpdateTreeItemState(wxTreeItemId item);
113
114       /* Refresh the whole tree. */
115       void RefreshTree();
116       
117       /* Refresh file list */
118       void RefreshList();
119       
120       /* Update first config, adapting settings to the job name selected */
121       void UpdateFirstConfig();
122       
123       /* Update second config */
124       bool UpdateSecondConfig(wxbDataTokenizer* dt);
125       
126 /* Status related */
127       enum status_enum
128       {
129          disabled,    // The panel is not activatable
130          activable,   // The panel is activable, but not activated
131          entered,     // The panel is activated
132          choosing,    // The user is choosing files to restore
133          listing,     // Dir listing is in progress
134          configuring, // The user is configuring restore process
135          restoring,   // Bacula is restoring files
136          finished     // Retore done (state will change in activable)
137       };
138
139       status_enum status;
140
141       /* Cancelled status :
142        *  - 0 - !cancelled
143        *  - 1 - will be cancelled
144        *  - 2 - has been cancelled */
145       int cancelled;
146
147       /* Set current status by enabling/disabling components */
148       void SetStatus(status_enum newstatus);
149
150 /* UI related */
151       bool working; // A command is running, discard GUI events
152       void SetWorking(bool working);
153       bool IsWorking();
154       bool markWhenCommandDone; //If an item should be (un)marked after the current listing/marking is done
155       wxTreeItemId currentTreeItem; // Currently selected tree item
156
157       /* Enable or disable config controls status */
158       void EnableConfig(bool enable);
159
160 /* Event handling */
161 //      wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
162 //      bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
163
164 //      virtual void AddPendingEvent(wxEvent& event);
165 //      virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
166
167       void OnStart(wxCommandEvent& event);
168       void OnCancel(wxCommandEvent& event);
169       
170       void OnTreeChanging(wxTreeEvent& event);
171       void OnTreeExpanding(wxTreeEvent& event);
172       void OnTreeChanged(wxTreeEvent& event);
173       void OnTreeMarked(wxbTreeMarkedEvent& event);
174       void OnTreeAdd(wxCommandEvent& event);
175       void OnTreeRemove(wxCommandEvent& event);
176       void OnTreeRefresh(wxCommandEvent& event);
177       
178       void OnListMarked(wxbListMarkedEvent& event);
179       void OnListActivated(wxListEvent& event);
180       void OnListChanged(wxListEvent& event);
181       void OnListAdd(wxCommandEvent& event);
182       void OnListRemove(wxCommandEvent& event);
183       void OnListRefresh(wxCommandEvent& event);
184       
185       void OnConfigUpdated(wxCommandEvent& event);
186       void OnConfigOk(wxCommandEvent& WXUNUSED(event));
187       void OnConfigApply(wxCommandEvent& WXUNUSED(event));
188       void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
189
190 /* Components */
191       wxBoxSizer *centerSizer; /* Center sizer */
192       wxSplitterWindow *treelistPanel; /* Panel which contains tree and list */
193       wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
194       wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
195
196       wxImageList* imagelist; //image list for tree and list
197
198       wxButton* start;
199       wxButton* cancel;
200       
201       wxbTreeCtrl* tree;
202       wxButton* treeadd;
203       wxButton* treeremove;
204       wxButton* treerefresh;
205       
206       wxbListCtrl* list;
207       wxButton* listadd;
208       wxButton* listremove;
209       wxButton* listrefresh;
210       
211       wxGauge* gauge;
212      
213       long cfgUpdated; //keeps which config fields have been updated
214
215       friend class wxbSplitterWindow;
216
217       DECLARE_EVENT_TABLE();    
218 };
219
220 #endif // WXBRESTOREPANEL_H