]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUIScriptingInterface.cxx
Created 2 applis :
[bbtk.git] / kernel / src / bbtkWxGUIScriptingInterface.cxx
index 5678db43262b431f5e35ea8c09003f4996e12234..9b5165cf49d1b02cc5a1d2c6604c53e59122491e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/10/06 10:30:10 $
-  Version:   $Revision: 1.21 $
+  Date:      $Date: 2008/10/08 10:56:27 $
+  Version:   $Revision: 1.22 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -54,7 +54,9 @@ namespace bbtk
       ID_Menu_CreatePackage,
       ID_Menu_CreateBlackBox,
       ID_Menu_ShowImageGraph,
-      ID_Menu_CreateIndex,
+      ID_Menu_RegeneratePackageDoc,
+      ID_Menu_RegenerateBoxesLists,
+      ID_Menu_RegenerateAll,
       ID_Menu_Windows_Files,
       ID_Menu_Windows_Help,
       ID_Menu_Windows_Messages,
@@ -93,7 +95,11 @@ namespace bbtk
     menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
     menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &black box") );
     menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last image graph") );
-    menuTools->Append( ID_Menu_CreateIndex, _T("&Generate index") );
+    menuTools->AppendSeparator();
+    menuTools->Append( ID_Menu_RegeneratePackageDoc,_T("&Regenerate package doc") );
+    menuTools->Append( ID_Menu_RegenerateBoxesLists,_T("&Regenerate boxes lists") );
+    menuTools->Append( ID_Menu_RegenerateAll,_T("&Regenerate all") );
+
 
     wxMenu *menuWindows = new wxMenu;
     menuWindows->AppendCheckItem(ID_Menu_Windows_Files,
@@ -430,37 +436,79 @@ namespace bbtk
   }
   //================================================================
 
+  //================================================================
+  void WxGUIScriptingInterface::OnMenuRegeneratePackageDoc(wxCommandEvent& WXUNUSED(event))
+  {
+    wxString name = wxGetTextFromUser(_T("Enter package name (* for all)"),
+                            _T("Regenerate package doc"),
+                            _T(""));
+       if (name.IsEmpty()) return;
+       std::string pack = bbtk::wx2std(name);
+
+       std::string command("cd \"");
+       command += ConfigurationFile::GetInstance().Get_bin_path();
+    command += "\" && bbRegeneratePackageDoc " + pack;
+       bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
+       
+       if ( ! system ( command.c_str() ) )
+    {
+       wxMessageBox(_T("Done !"),_T("Regenerate package '")+name+_T("' doc"),
+                   wxOK | wxICON_INFORMATION);
+     }
+   else 
+     {
+       wxString err("An error occured while running '");
+       err +=  bbtk::std2wx(command) + _T("'");
+       wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);      
+     }
+  }
+  //================================================================
 
   //================================================================
-  void WxGUIScriptingInterface::OnMenuCreateIndex(wxCommandEvent& WXUNUSED(event))
+  void WxGUIScriptingInterface::OnMenuRegenerateBoxesLists(wxCommandEvent& WXUNUSED(event))
   {
-         /*
-    std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path();
-    std::string filepath = doc_path+"/bbdoc/make-index.bbs";
+       std::string command("cd \"");
+       command += ConfigurationFile::GetInstance().Get_bin_path();
+    command += "\" && bbRegenerateBoxesLists";
+       bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
 
-    Interpreter::Pointer I = Interpreter::New();    
+       if ( ! system ( command.c_str() ) )
+    {
+       wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
+                   wxOK | wxICON_INFORMATION);
+     }
+   else 
+     {
+       wxString err("An error occured while running '");
+       err +=  bbtk::std2wx(command) + _T("'");
+       wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);      
+     }
+  }
+  //================================================================
 
-    I->InterpretLine( "config");
-    I->InterpretLine( "message echo 2");
-    I->InterpretLine( "exec freeze");
-    I->InterpretLine( "include *");
-    I->InterpretLine( "help packages");
-    I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials");
-    I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages");
-    I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories");
-    I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors");
-    */
+  //================================================================
+  void WxGUIScriptingInterface::OnMenuRegenerateAll(wxCommandEvent& WXUNUSED(event))
+  {
        std::string command("cd \"");
-       command += ConfigurationFile::GetInstance().Get_doc_path();
-       command += ConfigurationFile::GetInstance().Get_file_separator() + "bbdoc\" && \"";
        command += ConfigurationFile::GetInstance().Get_bin_path();
-    command += ConfigurationFile::GetInstance().Get_file_separator() + "bbi\" -N -q .";
-    command += ConfigurationFile::GetInstance().Get_file_separator() + "make-index.bbs"; 
+    command += "\" && bbRegeneratePackageDoc * && bbRegenerateBoxesLists";
        bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
-       system(command.c_str());
+
+       if ( ! system ( command.c_str() ) )
+    {
+       wxMessageBox(_T("Done !"),_T("Regenerate all"),
+                   wxOK | wxICON_INFORMATION);
+     }
+   else 
+     {
+       wxString err("An error occured while running '");
+       err +=  bbtk::std2wx(command) + _T("'");
+       wxMessageBox(err,_T("Regenerate all"),wxOK | wxICON_ERROR);      
+     }
   }
   //================================================================
 
 
   //================================================================
   void WxGUIScriptingInterface::InterpreterUserViewHtmlPage(const std::string& page)
@@ -625,7 +673,9 @@ namespace bbtk
     EVT_MENU(ID_Menu_CreatePackage, WxGUIScriptingInterface::OnMenuCreatePackage)
     EVT_MENU(ID_Menu_CreateBlackBox, WxGUIScriptingInterface::OnMenuCreateBlackBox)
     EVT_MENU(ID_Menu_ShowImageGraph, WxGUIScriptingInterface::OnMenuShowImageGraph)
-    EVT_MENU(ID_Menu_CreateIndex, WxGUIScriptingInterface::OnMenuCreateIndex)
+    EVT_MENU(ID_Menu_RegeneratePackageDoc, WxGUIScriptingInterface::OnMenuRegeneratePackageDoc)
+    EVT_MENU(ID_Menu_RegenerateBoxesLists, WxGUIScriptingInterface::OnMenuRegenerateBoxesLists)
+    EVT_MENU(ID_Menu_RegenerateAll, WxGUIScriptingInterface::OnMenuRegenerateAll)
     EVT_MENU(ID_Menu_Windows_Files, WxGUIScriptingInterface::OnMenuWindowsFiles)
     EVT_MENU(ID_Menu_Windows_Help, WxGUIScriptingInterface::OnMenuWindowsHelp)
     EVT_MENU(ID_Menu_Windows_Messages, WxGUIScriptingInterface::OnMenuWindowsMessages)