From e2d0631a9bae958680f52a545c026e98042c71b8 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sat, 1 May 2004 15:39:12 +0000 Subject: [PATCH] - wxbRestorePanel : Corrected a problem when you double-clicked an a folder in the list, the list was then refreshed two times (instead of one) in the new directory - wxbRestorePanel : Improved configuration panels' look - wxbRestorePanel : Added titles to configuration panels git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1336 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/CHANGELOG | 5 +++++ bacula/src/wx-console/TODO | 18 ++---------------- bacula/src/wx-console/wxbconfigpanel.cpp | 11 ++++++++--- bacula/src/wx-console/wxbconfigpanel.h | 2 +- bacula/src/wx-console/wxbmainframe.cpp | 9 +++++++-- bacula/src/wx-console/wxbrestorepanel.cpp | 22 ++++++++++++---------- 6 files changed, 35 insertions(+), 32 deletions(-) diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index 6f706d5b45..85b7e8d433 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,4 +1,9 @@ 31-04-2004 : + - wxbRestorePanel : Corrected a problem when you double-clicked an + a folder in the list, the list was then refreshed two times + (instead of one) in the new directory + - wxbRestorePanel : Improved configuration panels' look + - wxbRestorePanel : Added titles to configuration panels - wxbMainFrame : If the connection drops unexpectedly, it should say it lost the connection to the Director and then wait for you to either manually exit or (when it becomes possible) reconnect. diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index 90ce28fc1b..e71fd51014 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -1,10 +1,6 @@ FEATURES -------- -wxbRestorePanel : Reconsider start button's labels. - -wxbRestorePanel : Add titles to configuration panels - wxbRestorePanel : When cancelling, check for commands results general : Show nice messages boxes when errors occurs. @@ -16,7 +12,8 @@ wxbRestorePanel : Add a way to cancel restore when building tree wxbMainFrame : set focus to type control when clicking on console -global : create a general class which keeps clients, jobs, filesets, pools... list. +global : create a general class which keeps clients, jobs, + filesets, pools... list, and with functions like WaitForEnd. wxbConfigPanel : Create a dialog for selecting dates and paths. @@ -30,10 +27,6 @@ wxbRestorePanel : Add buttons to mark/unmark directories/files. wxbRestorePanel : Add a button to force to refresh the whole tree -wxbRestorePanel : Put titles above the Client drop down - box and the Backup date drop down box. It isn't immediately - obvious that the dates correspond to the backup dates. - wxbRestorePanel : There needs to be some way of marking/unmarking a range of files selected with shift-click or multiple files selected with ctl-click. The GTX console uses a button to mark/unmark @@ -88,10 +81,3 @@ bacula-dir : correct director to handle correctly + marked status (not a file), and then unmark it, its parents keep the "+" status.) general : make a good documentation with snapshots - -BUGS ----- - -wxRestorePanel : When you double-click an a folder in the list, - the list is then refreshed two times (instead of one) - in the new directory diff --git a/bacula/src/wx-console/wxbconfigpanel.cpp b/bacula/src/wx-console/wxbconfigpanel.cpp index f743b8c799..2fb9802609 100644 --- a/bacula/src/wx-console/wxbconfigpanel.cpp +++ b/bacula/src/wx-console/wxbconfigpanel.cpp @@ -64,7 +64,7 @@ wxbConfigParam::~wxbConfigParam() { } void wxbConfigParam::AddControl(wxWindow* parent, wxSizer* sizer) { - sizer->Add(new wxStaticText(parent, -1, title + ": ", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT), 1, wxEXPAND | wxALIGN_CENTER_HORIZONTAL); + sizer->Add(new wxStaticText(parent, -1, title + ": ", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT), 0, wxEXPAND | wxALIGN_CENTER_HORIZONTAL); switch (type) { case text: statictext = new wxStaticText(parent, -1, value, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); @@ -75,7 +75,7 @@ void wxbConfigParam::AddControl(wxWindow* parent, wxSizer* sizer) { sizer->Add(textctrl, 1, wxEXPAND | wxADJUST_MINSIZE); break; case choice: - choicectrl = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize, nvalues, values); + choicectrl = new wxChoice(parent, id, wxDefaultPosition, wxSize(150, 20), nvalues, values); sizer->Add(choicectrl, 1, wxEXPAND); break; } @@ -154,12 +154,17 @@ void wxbConfigParam::Add(wxString value) { } /* Creates a new config panel, config must be allocated with new */ -wxbConfigPanel::wxbConfigPanel(wxWindow* parent, wxbConfig* config, +wxbConfigPanel::wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxString title, wxWindowID ok, wxWindowID cancel, wxWindowID apply): wxPanel(parent) { this->config = config; wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + + mainSizer->Add( + new wxStaticText(this, -1, title, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER), + 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); + wxFlexGridSizer* cfgSizer = new wxFlexGridSizer(config->GetCount()+1, 2, 8, 5); unsigned int i; for (i = 0; i < config->GetCount(); i++) { diff --git a/bacula/src/wx-console/wxbconfigpanel.h b/bacula/src/wx-console/wxbconfigpanel.h index 14c6bbe04b..baaead91fd 100644 --- a/bacula/src/wx-console/wxbconfigpanel.h +++ b/bacula/src/wx-console/wxbconfigpanel.h @@ -81,7 +81,7 @@ WX_DECLARE_OBJARRAY(wxbConfigParam, wxbConfig); class wxbConfigPanel : public wxPanel { public: /* Creates a new config panel, config must be allocated with new */ - wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxWindowID ok, wxWindowID cancel, wxWindowID apply = -1); + wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxString title, wxWindowID ok, wxWindowID cancel, wxWindowID apply = -1); ~wxbConfigPanel(); void SetRowString(const char* title, wxString value); diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index 4399a3a5e9..3e64a2c138 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -171,6 +171,7 @@ wxbMainFrame::~wxbMainFrame() if (ct != NULL) { // && (!ct->IsRunning()) ct->Delete(); } + frame = NULL; } /* @@ -313,6 +314,7 @@ void wxbMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) ct->Delete(); ct = NULL; } + frame = NULL; Close(TRUE); } @@ -359,6 +361,7 @@ void wxbMainFrame::Print(wxString str, int status) int answer = wxMessageBox("Connection to the director lost. Quit program?", "Connection lost", wxYES_NO | wxICON_EXCLAMATION, this); if (answer == wxYES) { + frame = NULL; Close(true); } return; @@ -542,8 +545,10 @@ void firePrintEvent(wxString str, int status) wxbThreadEvent evt(Thread); evt.SetEventPrintObject(po); - - wxbMainFrame::GetInstance()->AddPendingEvent(evt); + + if (wxbMainFrame::GetInstance()) { + wxbMainFrame::GetInstance()->AddPendingEvent(evt); + } } //wxString csBuffer; /* Temporary buffer for receiving data from console thread */ diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 1a4f12a8fe..4a2d2e6eda 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -308,7 +308,7 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { config->Add(new wxbConfigParam("Storage", ConfigStorage, choice, 0, elist)); config->Add(new wxbConfigParam("Before", ConfigWhen, choice, 0, elist)); - configPanel = new wxbConfigPanel(this, config, RestoreStart, RestoreCancel, -1); + configPanel = new wxbConfigPanel(this, config, "Please configure parameters concerning files to restore :", RestoreStart, RestoreCancel, -1); configPanel->Show(true); configPanel->Enable(false); @@ -325,7 +325,7 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { config->Add(new wxbConfigParam("When", ConfigWhen, modifiableText, "")); config->Add(new wxbConfigParam("Priority", ConfigPriority, modifiableText, "")); - restorePanel = new wxbConfigPanel(this, config, ConfigOk, ConfigCancel, ConfigApply); + restorePanel = new wxbConfigPanel(this, config, "Please configure parameters concerning files restoration :", ConfigOk, ConfigCancel, ConfigApply); restorePanel->Show(false); @@ -653,6 +653,7 @@ void wxbRestorePanel::CmdStart() { WaitForEnd("unmark *\n"); wxTreeItemId root = tree->AddRoot(configPanel->GetRowString("Client"), -1, -1, new wxbTreeItemData("/", configPanel->GetRowString("Client"), 0)); + currentTreeItem = root; tree->Refresh(); UpdateTreeItem(root, true); wxbMainFrame::GetInstance()->SetStatusText("Right click on a file or on a directory, or double-click on its mark to add it to the restore list."); @@ -859,7 +860,6 @@ void wxbRestorePanel::CmdCancel() { cancelled = 1; if (status == restoring) { - int n = 0; if (jobid != "") { wxbMainFrame::GetInstance()->Send(wxString("cancel job=") << jobid << "\n"); } @@ -1246,12 +1246,10 @@ wxbDataTokenizer* wxbRestorePanel::WaitForEnd(wxString cmd, bool keepresults, bo /* Run a dir command, and waits until result is fully received. */ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist) { // this->updatelist = updatelist; - currentTreeItem = item; - wxbDataTokenizer* dt; dt = WaitForEnd(wxString("cd \"") << - static_cast(tree->GetItemData(currentTreeItem)) + static_cast(tree->GetItemData(item)) ->GetPath() << "\"\n", false); /* TODO: check command result */ @@ -1286,7 +1284,7 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist) { wxString itemStr; long cookie; - treeid = tree->GetFirstChild(currentTreeItem, cookie); + treeid = tree->GetFirstChild(item, cookie); bool updated = false; @@ -1302,12 +1300,12 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist) { updated = true; break; } - treeid = tree->GetNextChild(currentTreeItem, cookie); + treeid = tree->GetNextChild(item, cookie); } if (!updated) { int img = wxbTreeItemData::GetMarkedStatus(file[6]); - treeid = tree->AppendItem(currentTreeItem, file[8], img, img, new wxbTreeItemData(file[7], file[8], file[6])); + treeid = tree->AppendItem(item, file[8], img, img, new wxbTreeItemData(file[7], file[8], file[6])); } } @@ -1804,9 +1802,13 @@ void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) { if (working) { return; } + if (currentTreeItem == event.GetItem()) { + return; + } SetCursor(*wxHOURGLASS_CURSOR); markWhenListingDone = false; working = true; + currentTreeItem = event.GetItem(); CmdList(event.GetItem()); if (markWhenListingDone) { CmdMark(event.GetItem(), -1); @@ -1876,7 +1878,7 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { SetCursor(*wxSTANDARD_CURSOR); tree->Expand(currentTreeItem); tree->SelectItem(currentChild); - tree->Refresh(); + //tree->Refresh(); return; } currentChild = tree->GetNextChild(currentTreeItem, cookie); -- 2.39.5