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>
45 #include "wxbconfigpanel.h"
46 #include "wxbtreectrl.h"
47 #include "wxblistctrl.h"
49 class wxbTreeListPanel;
52 * wxbPanel for restoring files
54 class wxbRestorePanel : public wxbPanel
57 wxbRestorePanel(wxWindow* parent);
60 /* wxbPanel overloadings */
61 virtual wxString GetTitle();
62 virtual void EnablePanel(bool enable = true);
65 /* Commands called by events handler */
67 /* The main button has been clicked */
70 /* The cancel button has been clicked */
73 /* Apply configuration changes */
74 void CmdConfigApply();
77 void CmdConfigCancel();
79 /* List jobs for a specified client */
82 /* List files and directories for a specified tree item */
83 void CmdList(wxTreeItemId item);
85 /* Mark a treeitem (directory) or a listitem (file or directory) */
86 void CmdMark(wxTreeItemId treeitem, long listitem);
88 /* General functions and variables */
89 //bool ended; /* The last command send has finished */
91 //long filemessages; /* When restoring, number of files restored */
92 long totfilemessages; /* When restoring, number of files to be restored */
95 /* Parse a table in tableParser */
96 wxbTableParser* CreateAndWaitForParser(wxString cmd);
98 /* Run a command, and waits until result is fully received,
99 * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
100 * containing the data. */
101 wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
103 /* Run a command, and waits until prompt result is fully received,
104 * if keepresults is true, returns a valid pointer to a wxbPromptParser
105 * containing the data. */
106 wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
108 /* Run a dir command, and waits until result is fully received. */
109 void UpdateTreeItem(wxTreeItemId item, bool updatelist);
111 /* Parse dir command results. */
112 wxString* ParseList(wxString line);
114 /* Sets a list item state, and update its parents and children if it is a directory */
115 void SetListItemState(long listitem, int newstate);
117 /* Sets a tree item state, and update its children, parents and list (if necessary) */
118 void SetTreeItemState(wxTreeItemId item, int newstate);
120 /* Update a tree item parents' state */
121 void UpdateTreeItemState(wxTreeItemId item);
123 /* Refresh a tree item, and all its children. */
124 void RefreshTree(wxTreeItemId item);
126 /* Update first config, adapting settings to the job name selected */
127 void UpdateFirstConfig();
129 /* Update second config */
130 bool UpdateSecondConfig(wxbDataTokenizer* dt);
135 disabled, // The panel is not activatable
136 activable, // The panel is activable, but not activated
137 entered, // The panel is activated
138 choosing, // The user is choosing files to restore
139 listing, // Dir listing is in progress
140 configuring, // The user is configuring restore process
141 restoring, // Bacula is restoring files
142 finished // Retore done (state will change in activable)
147 /* Cancelled status :
149 * - 1 - will be cancelled
150 * - 2 - has been cancelled */
153 /* Set current status by enabling/disabling components */
154 void SetStatus(status_enum newstatus);
157 bool working; // A command is running, discard GUI events
158 bool markWhenListingDone;
159 wxTreeItemId currentTreeItem; // Currently selected tree item
161 /* Enable or disable config controls status */
162 void EnableConfig(bool enable);
165 void OnStart(wxCommandEvent& WXUNUSED(event));
166 void OnCancel(wxCommandEvent& WXUNUSED(event));
167 void OnTreeChanging(wxTreeEvent& event);
168 void OnTreeExpanding(wxTreeEvent& event);
169 void OnTreeChanged(wxTreeEvent& event);
170 void OnTreeMarked(wxbTreeMarkedEvent& event);
171 void OnListMarked(wxbListMarkedEvent& event);
172 void OnListActivated(wxListEvent& event);
173 void OnConfigUpdated(wxCommandEvent& event);
174 void OnConfigOk(wxCommandEvent& WXUNUSED(event));
175 void OnConfigApply(wxCommandEvent& WXUNUSED(event));
176 void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
179 wxBoxSizer *centerSizer; /* Center sizer */
180 wxbTreeListPanel *treelistPanel; /* Panel which contains tree and list */
181 wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
182 wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
184 wxImageList* imagelist; //image list for tree and list
194 wxButton* cfgCancel;*/
196 long cfgUpdated; //keeps which config fields have been updated
198 /*wxStaticText* cfgJobname;
199 wxStaticText* cfgBootstrap;
200 wxTextCtrl* cfgWhere;
201 wxChoice* cfgReplace;
202 wxChoice* cfgFileset;
204 wxStaticText* cfgStorage;
206 wxTextCtrl* cfgPriority;*/
208 friend class wxbTreeListPanel;
210 DECLARE_EVENT_TABLE();
213 class wxbTreeListPanel: public wxPanel {
215 wxbTreeListPanel(wxbRestorePanel* parent);
217 void OnTreeMarked(wxbTreeMarkedEvent& event);
218 void OnListMarked(wxbListMarkedEvent& event);
219 DECLARE_EVENT_TABLE();
220 wxbRestorePanel* parent;
223 #endif // WXBRESTOREPANEL_H