3 * wxbPanel for restoring files
5 * Nicolas Boichat, April-May 2004
10 Copyright (C) 2004 Kern Sibbald and John Walker
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.
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.
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.
27 #ifndef WXBRESTOREPANEL_H
28 #define WXBRESTOREPANEL_H
30 #include "wx/wxprec.h"
36 #include "wxbtableparser.h"
38 #include <wx/thread.h>
39 #include <wx/listctrl.h>
40 #include <wx/treectrl.h>
42 #include <wx/stattext.h>
43 #include <wx/splitter.h>
47 #include "wxbconfigpanel.h"
48 #include "wxbtreectrl.h"
49 #include "wxblistctrl.h"
51 WX_DECLARE_LIST(wxEvent, wxbEventList);
54 * wxbPanel for restoring files
56 class wxbRestorePanel : public wxbPanel
59 wxbRestorePanel(wxWindow* parent);
62 /* wxbPanel overloadings */
63 virtual wxString GetTitle();
64 virtual void EnablePanel(bool enable = true);
67 /* Commands called by events handler */
69 /* The main button has been clicked */
72 /* The cancel button has been clicked */
75 /* Apply configuration changes */
76 void CmdConfigApply();
79 void CmdConfigCancel();
81 /* List jobs for a specified client */
84 /* List files and directories for a specified tree item */
85 void CmdList(wxTreeItemId item);
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);
91 /* General functions and variables */
92 //bool ended; /* The last command send has finished */
94 //long filemessages; /* When restoring, number of files restored */
95 long totfilemessages; /* When restoring, number of files to be restored */
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);
102 /* Parse dir command results. */
103 wxString* ParseList(wxString line);
105 /* Sets a list item state, and update its parents and children if it is a directory */
106 void SetListItemState(long listitem, int newstate);
108 /* Sets a tree item state, and update its children, parents and list (if necessary) */
109 void SetTreeItemState(wxTreeItemId item, int newstate);
111 /* Update a tree item parents' state */
112 void UpdateTreeItemState(wxTreeItemId item);
114 /* Refresh the whole tree. */
117 /* Refresh file list */
120 /* Update first config, adapting settings to the job name selected */
121 void UpdateFirstConfig();
123 /* Update second config */
124 bool UpdateSecondConfig(wxbDataTokenizer* dt);
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)
141 /* Cancelled status :
143 * - 1 - will be cancelled
144 * - 2 - has been cancelled */
147 /* Set current status by enabling/disabling components */
148 void SetStatus(status_enum newstatus);
151 bool working; // A command is running, discard GUI events
152 void SetWorking(bool working);
154 bool markWhenListingDone;
155 wxTreeItemId currentTreeItem; // Currently selected tree item
157 /* Enable or disable config controls status */
158 void EnableConfig(bool enable);
161 // wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
162 // bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
164 // virtual void AddPendingEvent(wxEvent& event);
165 // virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
167 void OnStart(wxCommandEvent& event);
168 void OnCancel(wxCommandEvent& event);
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);
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);
185 void OnConfigUpdated(wxCommandEvent& event);
186 void OnConfigOk(wxCommandEvent& WXUNUSED(event));
187 void OnConfigApply(wxCommandEvent& WXUNUSED(event));
188 void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
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 */
196 wxImageList* imagelist; //image list for tree and list
203 wxButton* treeremove;
204 wxButton* treerefresh;
208 wxButton* listremove;
209 wxButton* listrefresh;
213 long cfgUpdated; //keeps which config fields have been updated
215 friend class wxbSplitterWindow;
217 DECLARE_EVENT_TABLE();
220 #endif // WXBRESTOREPANEL_H