3 * wxbPanel for restoring files
5 * Nicolas Boichat, April-May 2004
9 Copyright (C) 2004 Kern Sibbald and John Walker
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #ifndef WXBRESTOREPANEL_H
27 #define WXBRESTOREPANEL_H
29 #include "wx/wxprec.h"
35 #include "wxbtableparser.h"
37 #include <wx/thread.h>
38 #include <wx/listctrl.h>
39 #include <wx/treectrl.h>
41 #include <wx/stattext.h>
42 #include <wx/splitter.h>
46 #include "wxbconfigpanel.h"
47 #include "wxbtreectrl.h"
48 #include "wxblistctrl.h"
50 WX_DECLARE_LIST(wxEvent, wxbEventList);
53 * wxbPanel for restoring files
55 class wxbRestorePanel : public wxbPanel
58 wxbRestorePanel(wxWindow* parent);
61 /* wxbPanel overloadings */
62 virtual wxString GetTitle();
63 virtual void EnablePanel(bool enable = true);
66 /* Commands called by events handler */
68 /* The main button has been clicked */
71 /* The cancel button has been clicked */
74 /* Apply configuration changes */
75 void CmdConfigApply();
78 void CmdConfigCancel();
80 /* List jobs for a specified client */
83 /* List files and directories for a specified tree item */
84 void CmdList(wxTreeItemId item);
86 /* Mark a treeitem (directory) or several listitems (file or directory),
87 * state defines if it should mark (1), unmark (0), or switch state (-1) */
88 void CmdMark(wxTreeItemId treeitem, long* listitems, int listsize, int state = -1);
90 /* General functions and variables */
91 //bool ended; /* The last command send has finished */
93 //long filemessages; /* When restoring, number of files restored */
94 long totfilemessages; /* When restoring, number of files to be restored */
97 /* Run a dir command, and waits until result is fully received.
98 * If recurse is true, update the children too. */
99 void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
101 /* Parse dir command results. */
102 wxString* ParseList(wxString line);
104 /* Sets a list item state, and update its parents and children if it is a directory */
105 void SetListItemState(long listitem, int newstate);
107 /* Sets a tree item state, and update its children, parents and list (if necessary) */
108 void SetTreeItemState(wxTreeItemId item, int newstate);
110 /* Update a tree item parents' state */
111 void UpdateTreeItemState(wxTreeItemId item);
113 /* Refresh the whole tree. */
116 /* Refresh file list */
119 /* Update first config, adapting settings to the job name selected */
120 void UpdateFirstConfig();
122 /* Update second config */
123 bool UpdateSecondConfig(wxbDataTokenizer* dt);
128 disabled, // The panel is not activatable
129 activable, // The panel is activable, but not activated
130 entered, // The panel is activated
131 choosing, // The user is choosing files to restore
132 listing, // Dir listing is in progress
133 configuring, // The user is configuring restore process
134 restoring, // Bacula is restoring files
135 finished // Retore done (state will change in activable)
140 /* Cancelled status :
142 * - 1 - will be cancelled
143 * - 2 - has been cancelled */
146 /* Set current status by enabling/disabling components */
147 void SetStatus(status_enum newstatus);
150 bool working; // A command is running, discard GUI events
151 void SetWorking(bool working);
153 bool markWhenListingDone;
154 wxTreeItemId currentTreeItem; // Currently selected tree item
156 /* Enable or disable config controls status */
157 void EnableConfig(bool enable);
160 // wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
161 // bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
163 // virtual void AddPendingEvent(wxEvent& event);
164 // virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
166 void OnStart(wxCommandEvent& event);
167 void OnCancel(wxCommandEvent& event);
169 void OnTreeChanging(wxTreeEvent& event);
170 void OnTreeExpanding(wxTreeEvent& event);
171 void OnTreeChanged(wxTreeEvent& event);
172 void OnTreeMarked(wxbTreeMarkedEvent& event);
173 void OnTreeAdd(wxCommandEvent& event);
174 void OnTreeRemove(wxCommandEvent& event);
175 void OnTreeRefresh(wxCommandEvent& event);
177 void OnListMarked(wxbListMarkedEvent& event);
178 void OnListActivated(wxListEvent& event);
179 void OnListChanged(wxListEvent& event);
180 void OnListAdd(wxCommandEvent& event);
181 void OnListRemove(wxCommandEvent& event);
182 void OnListRefresh(wxCommandEvent& event);
184 void OnConfigUpdated(wxCommandEvent& event);
185 void OnConfigOk(wxCommandEvent& WXUNUSED(event));
186 void OnConfigApply(wxCommandEvent& WXUNUSED(event));
187 void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
190 wxBoxSizer *centerSizer; /* Center sizer */
191 wxSplitterWindow *treelistPanel; /* Panel which contains tree and list */
192 wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
193 wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
195 wxImageList* imagelist; //image list for tree and list
202 wxButton* treeremove;
203 wxButton* treerefresh;
207 wxButton* listremove;
208 wxButton* listrefresh;
212 long cfgUpdated; //keeps which config fields have been updated
214 friend class wxbSplitterWindow;
216 DECLARE_EVENT_TABLE();
219 #endif // WXBRESTOREPANEL_H