From 130400493a51a3e7e1417f8cce196017ab971eba Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 25 Apr 2004 10:51:15 +0000 Subject: [PATCH] - wxbRestorePanel : when the director is building tree, changes are made to the status in the gauge. - wxbRestorePanel : Cursor set to hourglass when working - wxbMainFrame : Automatically scrolling to the bottom of console text control. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1300 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/CHANGELOG | 7 ++ bacula/src/wx-console/TODO | 14 ++- bacula/src/wx-console/wxbmainframe.cpp | 16 ++-- bacula/src/wx-console/wxbmainframe.h | 2 - bacula/src/wx-console/wxbrestorepanel.cpp | 102 +++++++++++++++++++++- 5 files changed, 122 insertions(+), 19 deletions(-) diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index eaa4b0477a..6bc4025303 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,3 +1,10 @@ +25-04-2003 : + - wxbRestorePanel : when the director is building tree, + changes are made to the status in the gauge. + - wxbRestorePanel : Cursor set to hourglass when working + - wxbMainFrame : Automatically scrolling to the bottom of + console text control. + 24-04-2003 : - wxbMainFrame : When starting wx-console, the initial key input focus is set into the command window. diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index eec0d6e172..878344c7da 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -3,10 +3,6 @@ FEATURES GTK : Fix 100% CPU usage when waiting for results -wxbRestorePanel : when the director is building tree, change the cursor to a - wait type cursor, make changes to the status in the gauge (need to parse the - table). - 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) @@ -15,11 +11,9 @@ wxbRestorePanel : Select the first client when clicked on start button. wxbRestorePanel : Reconsider start button's labels. -console_thread : Show a nice message when config file is not found. - -wxbMainFrame : Automatically scroll to the bottom of console control. +general : Show nice messages when errors occurs. -wxbMainFrame : use more often the status text +wxbMainFrame : use more often status text wxbRestorePanel : Add a Cancel Restore button (may need to implement BNET_BREAK to break current command) @@ -33,6 +27,8 @@ 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 + [postponed to July:] wxbRestorePanel : Add buttons to mark/unmark directories/files. @@ -93,4 +89,4 @@ 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 \ No newline at end of file + in the new directory diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index be01d4f11b..d3f25bd8e9 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -255,8 +255,6 @@ wxbMainFrame::wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSi sizer->SetSizeHints( this ); this->SetSize(size); EnableConsole(false); - - nlines = 0; } /* @@ -398,12 +396,17 @@ void wxbMainFrame::Print(wxString str, int status) else { consoleCtrl->SetDefaultStyle(wxTextAttr(*wxBLACK)); } - (*consoleCtrl) << str; + consoleCtrl->AppendText(str); if (status == CS_PROMPT) { - (*consoleCtrl) << "

"; + consoleCtrl->AppendText("

"); } + + consoleCtrl->ScrollLines(3); + +// consoleCtrl->ShowPosition(consoleCtrl->GetLastPosition()); + /*if (status != CS_DEBUG) { - (*consoleCtrl) << "@"; + consoleCtrl->AppendText("@"); }*/ //consoleCtrl->SetInsertionPointEnd(); @@ -424,7 +427,8 @@ void wxbMainFrame::Send(wxString str) ct->Write((const char*)str); typeCtrl->SetValue(""); consoleCtrl->SetDefaultStyle(wxTextAttr(*wxRED)); - (*consoleCtrl) << str; + consoleCtrl->AppendText(str); + consoleCtrl->ScrollLines(3); /* if ((consoleCtrl->GetNumberOfLines()-1) > nlines) { nlines = consoleCtrl->GetNumberOfLines()-1; diff --git a/bacula/src/wx-console/wxbmainframe.h b/bacula/src/wx-console/wxbmainframe.h index 9b6c068699..a22c8cd18b 100644 --- a/bacula/src/wx-console/wxbmainframe.h +++ b/bacula/src/wx-console/wxbmainframe.h @@ -141,8 +141,6 @@ private: static wxbMainFrame *frame; /* this */ - int nlines; /* number of lines in the console */ - // any class wishing to process wxWindows events must use this macro DECLARE_EVENT_TABLE() }; diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 2b209a47d6..ceff310329 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -364,6 +364,7 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { } working = false; + SetCursor(*wxSTANDARD_CURSOR); } /* @@ -440,7 +441,84 @@ void wxbRestorePanel::CmdStart() { return; } delete pp; - WaitForEnd(wxString() << client << "\n"); + + wxbDataTokenizer* dt = new wxbDataTokenizer(true); + wxbTableParser* tableparser = CreateAndWaitForParser(wxString() << client << "\n"); + int tot = 0; + long l; + wxString str; + + unsigned int i; + for (i = 0; i < tableparser->size(); i++) { + str = (*tableparser)[i][2]; + str.Replace(",", ""); + if (str.ToLong(&l)) { + tot += l; + } + } + + gauge->SetValue(0); + gauge->SetRange(tot); + + /*wxbMainFrame::GetInstance()->Print( + wxString("[") << tot << "]", CS_DEBUG);*/ + + wxDateTime base = wxDateTime::Now(); + wxDateTime newdate; + int done = 0; + int willdo = 0; + unsigned int lastindex = 0; + + int var = 0; + + while (!dt->hasFinished()) { + newdate = wxDateTime::Now(); + if ( ( (1000*(newdate.GetTicks()-base.GetTicks())) + + (newdate.GetMillisecond()-base.GetMillisecond()) ) > 10 ) { + base = newdate; + for (; lastindex < dt->GetCount(); lastindex++) { + 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++) { + if (str == (*tableparser)[i][0]) { + str = (*tableparser)[i][2]; + str.Replace(",", ""); + if (str.ToLong(&l)) { + done += willdo; + willdo += l; + var = (willdo-done)/3; + } + break; + } + } + } + } + + if (gauge->GetValue() <= done) { + gauge->SetValue(done); + if (var < 0) + var = -var; + } + else if (gauge->GetValue() >= willdo) { + gauge->SetValue(willdo); + if (var > 0) + var = -var; + } + + gauge->SetValue(gauge->GetValue()+var); + + /*wxbMainFrame::GetInstance()->Print( + wxString("[") << gauge->GetValue() << "/" << done + << "-" << willdo << "]", CS_DEBUG);*/ + } + wxTheApp->Yield(true); + } + + gauge->SetValue(0); + + delete dt; + WaitForEnd("unmark *\n"); SetStatus(choosing); wxTreeItemId root = tree->AddRoot(clientChoice->GetStringSelection(), -1, -1, new wxbTreeItemData("/", clientChoice->GetStringSelection(), 0)); @@ -1315,6 +1393,7 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { tree->Enable(true); list->Enable(true); working = false; + SetCursor(*wxSTANDARD_CURSOR); break; case configuring: start->Enable(false); @@ -1341,6 +1420,7 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { jobChoice->Enable(false); tree->Enable(false); list->Enable(false); + SetCursor(*wxHOURGLASS_CURSOR); working = true; break; } @@ -1368,6 +1448,7 @@ void wxbRestorePanel::OnClientChoiceChanged(wxCommandEvent& event) { if (working) { return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; clientChoice->Enable(false); jobChoice->Enable(false); @@ -1376,15 +1457,18 @@ void wxbRestorePanel::OnClientChoiceChanged(wxCommandEvent& event) { jobChoice->Enable(true); jobChoice->Refresh(); working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnStart(wxEvent& WXUNUSED(event)) { if (working) { return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; CmdStart(); working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnTreeChanging(wxTreeEvent& event) { @@ -1410,10 +1494,11 @@ void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) { if (working) { return; } - + SetCursor(*wxHOURGLASS_CURSOR); working = true; CmdList(event.GetItem()); working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) { @@ -1421,11 +1506,13 @@ void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) { //event.Skip(); return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; CmdMark(event.GetItem(), -1); //event.Skip(); tree->Refresh(); working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) { @@ -1433,6 +1520,7 @@ void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) { //event.Skip(); return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; //long item = event.GetId(); long item = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED); @@ -1440,6 +1528,7 @@ void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) { event.Skip(); tree->Refresh(); working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnListActivated(wxListEvent& event) { @@ -1447,6 +1536,7 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { //event.Skip(); return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; long item = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED); if (item > -1) { @@ -1466,6 +1556,7 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { if (name2 == name) { //tree->UnselectAll(); working = false; + SetCursor(*wxSTANDARD_CURSOR); tree->Expand(currentTreeItem); tree->SelectItem(currentChild); //tree->Refresh(); @@ -1476,6 +1567,7 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { } } working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnConfigUpdated(wxCommandEvent& event) { @@ -1490,9 +1582,11 @@ void wxbRestorePanel::OnConfigOk(wxEvent& WXUNUSED(event)) { if (working) { return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; CmdStart(); working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnConfigApply(wxEvent& WXUNUSED(event)) { @@ -1500,6 +1594,7 @@ void wxbRestorePanel::OnConfigApply(wxEvent& WXUNUSED(event)) { if (working) { return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; CmdConfigApply(); if (cfgUpdated == 0) { @@ -1507,6 +1602,7 @@ void wxbRestorePanel::OnConfigApply(wxEvent& WXUNUSED(event)) { cfgOk->Enable(true); } working = false; + SetCursor(*wxSTANDARD_CURSOR); } void wxbRestorePanel::OnConfigCancel(wxEvent& WXUNUSED(event)) { @@ -1514,9 +1610,11 @@ void wxbRestorePanel::OnConfigCancel(wxEvent& WXUNUSED(event)) { if (working) { return; } + SetCursor(*wxHOURGLASS_CURSOR); working = true; CmdConfigCancel(); working = false; + SetCursor(*wxSTANDARD_CURSOR); } /* TODO : correct that bad implementation of tree marked event forwarding */ -- 2.39.5