]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbRestorePanel : when the director is building tree, changes are made to the...
authorNicolas Boichat <nicolas@boichat.ch>
Sun, 25 Apr 2004 10:51:15 +0000 (10:51 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Sun, 25 Apr 2004 10:51:15 +0000 (10:51 +0000)
 - 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
bacula/src/wx-console/TODO
bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbmainframe.h
bacula/src/wx-console/wxbrestorepanel.cpp

index eaa4b0477afec398570482954ab3de37d37827ae..6bc40253031948606140ced21db9a3b59792f450 100644 (file)
@@ -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.
index eec0d6e172622735e7c03ee89ae6ebe1467dc92e..878344c7da07beaeb9b9546dab6ba2ed66e0fe10 100644 (file)
@@ -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
index be01d4f11bb897e0c8a4498f6565dbdaad758031..d3f25bd8e9e473a10db3e7476824db408d95d489 100644 (file)
@@ -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) << "<P>";
+      consoleCtrl->AppendText("<P>");
    }
+   
+   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;
index 9b6c06869937af12fc4aaeb0819f575b46d99adf..a22c8cd18bdd92775c7b405899d922a5416ef594 100644 (file)
@@ -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()
 };
index 2b209a47d634a9e33cbc7058ab7f59f264a98c92..ceff310329234da4fd05b4e71522707c7b01fe46 100644 (file)
@@ -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 */