From 9476967534b3d887fba353b56a82a3b3269de310 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 25 Apr 2004 18:31:37 +0000 Subject: [PATCH] - general : status text is more often used - wxbRestorePanel : restore aborted if there's no client or no fileset - wxbRestorePanel : corrected problem if one double clicks on a directory X in the left "tree" window when the directory is not yet open, instead of selecting the directory and everything below, it opens the directory and nothing is selected. - wxbRestorePanel : first client is selected when restore mode starts. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1305 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/CHANGELOG | 8 +++ bacula/src/wx-console/TODO | 23 ++++---- bacula/src/wx-console/main.cpp | 4 +- bacula/src/wx-console/wxbmainframe.cpp | 8 +-- bacula/src/wx-console/wxbrestorepanel.cpp | 64 +++++++++++++++++++---- bacula/src/wx-console/wxbrestorepanel.h | 1 + 6 files changed, 82 insertions(+), 26 deletions(-) diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index 6bc4025303..dc3c35c7ef 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,4 +1,12 @@ 25-04-2003 : + - general : status text is more often used + - wxbRestorePanel : restore aborted if there's no client or no fileset + - wxbRestorePanel : corrected problem if one double clicks on a + directory X in the left "tree" window when the directory is + not yet open, instead of selecting the directory and everything + below, it opens the directory and nothing is selected. + - wxbRestorePanel : first client is selected when restore + mode starts. - wxbRestorePanel : when the director is building tree, changes are made to the status in the gauge. - wxbRestorePanel : Cursor set to hourglass when working diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index 878344c7da..d56fd38159 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -5,32 +5,30 @@ GTK : Fix 100% CPU usage when waiting for results wxbMainFrame : Add some text in front of the command window such as "Command: " so that the user knows he can type into the - command window (or command line) + command line -wxbRestorePanel : Select the first client when clicked on start button. - wxbRestorePanel : Reconsider start button's labels. general : Show nice messages when errors occurs. -wxbMainFrame : use more often status text +wxbMainFrame : set focus to type control when clicking on console wxbRestorePanel : Add a Cancel Restore button (may need to implement BNET_BREAK to break current command) -wxbRestorePanel : However, if one double clicks on a directory X in the left - "tree" window when the directory is not yet open, instead of - selecting the directory and everything below, it opens the - directory and nothing is selected. - -wxbRestorePanel : abort restore if there's no client. - general : Allow the user to quit however the state is (kill thread if necessary) VC++ : crashing when there's no configuration file, or server is unreachable + (on every error ?) [postponed to July:] +wxbMainFrame : use more often status text + +wxbRestorePanel : Ask Kern for a dot command which gives restore + dates for a client (with an interval, last 20 for example, or last + 40 excluding last 20). + wxbRestorePanel : Add buttons to mark/unmark directories/files. wxbRestorePanel : Add a button to force to refresh the whole tree @@ -55,6 +53,9 @@ wxbRestorePanel : Use ".default job=RestoreFiles" to get defaults parameters console_thread : Allow the user to choose his config file. +console_thread : Allow the user to choose his director when there's multiple + directors. + wxbDataParser : Add a boolean in the constructor to avoid storing data is will not be used. diff --git a/bacula/src/wx-console/main.cpp b/bacula/src/wx-console/main.cpp index 56aac33f6d..af6d299a06 100644 --- a/bacula/src/wx-console/main.cpp +++ b/bacula/src/wx-console/main.cpp @@ -75,9 +75,9 @@ bool MyApp::OnInit() frame->Show(TRUE); - frame->StartConsoleThread(); + frame->Print(wxString("Welcome to bacula wx-console ") << VERSION << " (" << BDATE << ")!\n", CS_DEBUG); - csprint("Bacula wx-console started !\n"); + frame->StartConsoleThread(); return TRUE; } diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index d3f25bd8e9..d557cc709f 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -200,9 +200,8 @@ wxbMainFrame::wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSi #endif // wxUSE_MENUS #if wxUSE_STATUSBAR - // create a status bar just for fun (by default with 1 pane only) - CreateStatusBar(2); - SetStatusText(_T("Welcome to Bacula wx-console!")); + CreateStatusBar(1); + SetStatusText(wxString("Welcome to bacula wx-console ") << VERSION << " (" << BDATE << ")!\n"); #endif // wxUSE_STATUSBAR wxPanel* global = new wxPanel(this, -1); @@ -271,6 +270,7 @@ void wxbMainFrame::StartConsoleThread() ct = new console_thread(); ct->Create(); ct->Run(); + SetStatusText("Connecting to the director..."); } /* Register a new wxbDataParser */ @@ -326,10 +326,12 @@ void wxbMainFrame::OnPrint(wxbThreadEvent& event) { void wxbMainFrame::Print(wxString str, int status) { if (status == CS_CONNECTED) { + SetStatusText("Connected to the director."); EnablePanels(); return; } if (status == CS_DISCONNECTED) { + SetStatusText("Disconnected of the director."); DisablePanels(); return; } diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index a16455a80a..39ae756b66 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -365,6 +365,8 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { working = false; SetCursor(*wxSTANDARD_CURSOR); + + markWhenListingDone = false; } /* @@ -401,11 +403,18 @@ void wxbRestorePanel::EnablePanel(bool enable) { void wxbRestorePanel::CmdStart() { unsigned int i; if (status == activable) { + wxbMainFrame::GetInstance()->SetStatusText("Getting clients and filesets list."); wxbDataTokenizer* dt = WaitForEnd(".clients\n", true, false); wxString str; clientChoice->Clear(); cfgClient->Clear(); + + if (dt->GetCount() == 0) { + wxbMainFrame::GetInstance()->SetStatusText("Error : no clients returned by the director."); + return; + } + for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); @@ -418,6 +427,12 @@ void wxbRestorePanel::CmdStart() { dt = WaitForEnd(".filesets\n", true, false); cfgFileset->Clear(); + + if (dt->GetCount() == 0) { + wxbMainFrame::GetInstance()->SetStatusText("Error : no filesets returned by the director."); + return; + } + for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); @@ -427,12 +442,27 @@ void wxbRestorePanel::CmdStart() { delete dt; SetStatus(entered); + + clientChoice->Enable(false); + jobChoice->Enable(false); + clientChoice->SetSelection(0); + CmdListJobs(); + jobChoice->Enable(true); + clientChoice->Enable(true); + + wxbMainFrame::GetInstance()->SetStatusText("Please select a client and a date at which the files you'll select were backed up."); } else if (status == entered) { - if (jobChoice->GetStringSelection().Length() < 1) { + if (clientChoice->GetStringSelection().Length() < 1) { wxbMainFrame::GetInstance()->SetStatusText("Please select a client."); return; } + if (jobChoice->GetStringSelection().Length() < 1) { + wxbMainFrame::GetInstance()->SetStatusText("Please select a restore date."); + return; + } + wxbMainFrame::GetInstance()->SetStatusText("Building restore tree..."); + WaitForPrompt("restore\n"); WaitForPrompt("6\n"); wxbPromptParser *pp = WaitForPrompt(wxString() << jobChoice->GetStringSelection() << "\n", true); @@ -449,7 +479,6 @@ void wxbRestorePanel::CmdStart() { long l; wxString str; - unsigned int i; for (i = 0; i < tableparser->size(); i++) { str = (*tableparser)[i][2]; str.Replace(",", ""); @@ -481,7 +510,7 @@ void wxbRestorePanel::CmdStart() { if (((*dt)[lastindex].Find("Building directory tree for JobId ") == 0) && ((i = (*dt)[lastindex].Find(" ...")) > 0)) { str = (*dt)[lastindex].Mid(34, i-34); - for (unsigned int i = 0; i < tableparser->size(); i++) { + for (i = 0; i < tableparser->size(); i++) { if (str == (*tableparser)[i][0]) { str = (*tableparser)[i][2]; str.Replace(",", ""); @@ -515,7 +544,9 @@ void wxbRestorePanel::CmdStart() { } wxTheApp->Yield(true); } - + + gauge->SetValue(tot); + wxTheApp->Yield(); gauge->SetValue(0); delete dt; @@ -530,9 +561,7 @@ void wxbRestorePanel::CmdStart() { } else if (status == choosing) { SetStatus(configuring); - - wxbMainFrame::GetInstance()->SetStatusText("Please configure your restore..."); - + EnableConfig(false); totfilemessages = 0; @@ -543,7 +572,7 @@ void wxbRestorePanel::CmdStart() { dt = new wxbDataTokenizer(true); WaitForPrompt("done\n"); - for (unsigned int i = 0; i < dt->GetCount(); i++) { + for (i = 0; i < dt->GetCount(); i++) { if ((j = (*dt)[i].Find(" files selected to be restored.")) > -1) { (*dt)[i].Mid(0, j).ToLong(&totfilemessages); break; @@ -555,6 +584,10 @@ void wxbRestorePanel::CmdStart() { } } + wxbMainFrame::GetInstance()->SetStatusText( + wxString("Please configure your restore (") + << totfilemessages << " files selected to be restored)..."); + UpdateConfig(dt); delete dt; @@ -677,6 +710,8 @@ void wxbRestorePanel::CmdStart() { void wxbRestorePanel::CmdConfigApply() { if (cfgUpdated == 0) return; + wxbMainFrame::GetInstance()->SetStatusText("Applying restore configuration changes..."); + EnableConfig(false); wxbDataTokenizer* dt = NULL; @@ -763,7 +798,9 @@ void wxbRestorePanel::CmdConfigApply() { UpdateConfig(dt); /* TODO: Check result */ EnableConfig(true); - + + wxbMainFrame::GetInstance()->SetStatusText("Restore configuration changes were applied."); + delete dt; } @@ -1496,15 +1533,22 @@ void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) { return; } SetCursor(*wxHOURGLASS_CURSOR); + markWhenListingDone = false; working = true; CmdList(event.GetItem()); + if (markWhenListingDone) { + CmdMark(event.GetItem(), -1); + tree->Refresh(); + } working = false; SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) { if (working) { - //event.Skip(); + if (tree->GetSelection() == event.GetItem()) { + markWhenListingDone = !markWhenListingDone; + } return; } SetCursor(*wxHOURGLASS_CURSOR); diff --git a/bacula/src/wx-console/wxbrestorepanel.h b/bacula/src/wx-console/wxbrestorepanel.h index 509db0b405..c6aa33e70d 100644 --- a/bacula/src/wx-console/wxbrestorepanel.h +++ b/bacula/src/wx-console/wxbrestorepanel.h @@ -134,6 +134,7 @@ class wxbRestorePanel : public wxbPanel /* UI related */ bool working; // A command is running, discard GUI events + bool markWhenListingDone; wxTreeItemId currentTreeItem; // Currently selected tree item /* Enable or disable config controls status */ -- 2.39.5