2 Copyright (C) 2004 Kern Sibbald and John Walker
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.
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.
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.
19 #ifndef WXBRESTOREPANEL_H
20 #define WXBRESTOREPANEL_H
22 #include "wx/wxprec.h"
28 #include "wxbtableparser.h"
30 #include <wx/thread.h>
31 #include <wx/listctrl.h>
32 #include <wx/treectrl.h>
34 #include <wx/stattext.h>
38 #include "wxbconfigpanel.h"
39 #include "wxbtreectrl.h"
40 #include "wxblistctrl.h"
42 class wxbTreeListPanel;
45 * wxbPanel for restoring files
47 class wxbRestorePanel : public wxbPanel
50 wxbRestorePanel(wxWindow* parent);
53 /* wxbPanel overloadings */
54 virtual wxString GetTitle();
55 virtual void EnablePanel(bool enable = true);
58 /* Commands called by events handler */
60 /* The main button has been clicked */
63 /* Apply configuration changes */
64 void CmdConfigApply();
67 void CmdConfigCancel();
69 /* List jobs for a specified client */
72 /* List files and directories for a specified tree item */
73 void CmdList(wxTreeItemId item);
75 /* Mark a treeitem (directory) or a listitem (file or directory) */
76 void CmdMark(wxTreeItemId treeitem, long listitem);
78 /* General functions and variables */
79 bool ended; /* The last command send has finished */
81 long filemessages; /* When restoring, number of files restored */
82 long totfilemessages; /* When restoring, number of files to be restored */
84 /* Parse a table in tableParser */
85 wxbTableParser* CreateAndWaitForParser(wxString cmd);
87 /* Run a command, and waits until result is fully received,
88 * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
89 * containing the data. */
90 wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
92 /* Run a command, and waits until prompt result is fully received,
93 * if keepresults is true, returns a valid pointer to a wxbPromptParser
94 * containing the data. */
95 wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
97 /* Run a dir command, and waits until result is fully received. */
98 void UpdateTreeItem(wxTreeItemId item, bool updatelist);
100 /* Parse dir command results. */
101 wxString* ParseList(wxString line);
103 /* Sets a list item state, and update its parents and children if it is a directory */
104 void SetListItemState(long listitem, int newstate);
106 /* Sets a tree item state, and update its children, parents and list (if necessary) */
107 void SetTreeItemState(wxTreeItemId item, int newstate);
109 /* Update a tree item parents' state */
110 void UpdateTreeItemState(wxTreeItemId item);
112 /* Refresh a tree item, and all its children. */
113 void RefreshTree(wxTreeItemId item);
116 bool UpdateConfig(wxbDataTokenizer* dt);
121 disabled, // The panel is not activatable
122 activable, // The panel is activable, but not activated
123 entered, // The panel is activated
124 choosing, // The user is choosing files to restore
125 listing, // Dir listing is in progress
126 configuring, // The user is configuring restore process
127 restoring, // Bacula is restoring files
128 finished // Retore done (state will change in activable)
133 /* Set current status by enabling/disabling components */
134 void SetStatus(status_enum newstatus);
137 bool working; // A command is running, discard GUI events
138 bool markWhenListingDone;
139 wxTreeItemId currentTreeItem; // Currently selected tree item
141 /* Enable or disable config controls status */
142 void EnableConfig(bool enable);
145 void OnStart(wxEvent& WXUNUSED(event));
146 void OnTreeChanging(wxTreeEvent& event);
147 void OnTreeExpanding(wxTreeEvent& event);
148 void OnTreeChanged(wxTreeEvent& event);
149 void OnTreeMarked(wxbTreeMarkedEvent& event);
150 void OnListMarked(wxbListMarkedEvent& event);
151 void OnListActivated(wxListEvent& event);
152 void OnClientChoiceChanged(wxCommandEvent& event);
153 void OnConfigUpdated(wxCommandEvent& event);
154 void OnConfigOk(wxEvent& WXUNUSED(event));
155 void OnConfigApply(wxEvent& WXUNUSED(event));
156 void OnConfigCancel(wxEvent& WXUNUSED(event));
159 wxBoxSizer *centerSizer; /* Center sizer */
160 wxbTreeListPanel *treelistPanel; /* Panel which contains tree and list */
161 wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
162 wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
164 wxImageList* imagelist; //image list for tree and list
173 wxButton* cfgCancel;*/
175 long cfgUpdated; //keeps which config fields have been updated
177 /*wxStaticText* cfgJobname;
178 wxStaticText* cfgBootstrap;
179 wxTextCtrl* cfgWhere;
180 wxChoice* cfgReplace;
181 wxChoice* cfgFileset;
183 wxStaticText* cfgStorage;
185 wxTextCtrl* cfgPriority;*/
187 friend class wxbTreeListPanel;
189 DECLARE_EVENT_TABLE();
192 class wxbTreeListPanel: public wxPanel {
194 wxbTreeListPanel(wxbRestorePanel* parent);
196 void OnTreeMarked(wxbTreeMarkedEvent& event);
197 void OnListMarked(wxbListMarkedEvent& event);
198 DECLARE_EVENT_TABLE();
199 wxbRestorePanel* parent;
202 #endif // WXBRESTOREPANEL_H