]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/SUPERVGUI/SUPERVGUI_Library.cxx
Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Library.cxx
index d9473ed0f2ec15d1b8b6f6169faa99a89daa536c..4af1b37b8e2a09ded89effeb1437cd38e240d44d 100644 (file)
@@ -30,8 +30,9 @@
 #include "SUPERVGUI_Main.h"
 #include "SUPERVGUI.h"
 
-#include "QAD_MessageBox.h"
-#include "QAD_Application.h"
+#include "SUIT_Application.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_Session.h"
 
 #include <qlistbox.h>
 #include <qlayout.h>
@@ -100,12 +101,12 @@ bool SUPERVGUI_Library::createLibFile() const {
       return true;
     }
     else {
-      QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB1" ), tr( "OK" ) );
+      SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB1" ), tr( "OK" ) );
       return false; // error opening library file for writing
     }
   }
   catch ( ... ) {
-    QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_IO" ), tr( "OK" ) );
+    SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_IO" ), tr( "OK" ) );
   }
   return false;
 }
@@ -135,7 +136,7 @@ void saveStrings( QDomDocument doc, QDomElement element, const char* theNameAtt,
 bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
   try {
     if ( CORBA::is_nil( theNode ) ) {
-      QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_NIL_NODE" ), tr( "OK" ) );
+      SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_NIL_NODE" ), tr( "OK" ) );
       return false; // null node
     }
 
@@ -158,8 +159,8 @@ bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
       xmlOk = ( !rootElement.isNull() );
     }
     if ( !xmlOk ) {
-      const int toRecreate = QAD_MessageBox::error2( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), 
-                                                   tr( "MSG_ERROR_LIB_IS_RECREATE" ), tr( "BUT_YES" ), tr( "BUT_NO" ), 1, 0, 0 );
+      const int toRecreate = SUIT_MessageBox::error2( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), 
+                                                     tr( "MSG_ERROR_LIB_IS_RECREATE" ), tr( "BUT_YES" ), tr( "BUT_NO" ), 1, 0, 0 );
       if ( toRecreate ) { // user selected to recreate a bad XML file
        libFile.close(); // in case it was opened by doc.setContent()
        if ( !createLibFile() )
@@ -179,7 +180,7 @@ bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
       SUPERV::GNode_var aTmpNode = SUPERV::GNode::_narrow( theNode );
       theNode = aTmpNode->Coupled();
       if ( CORBA::is_nil( theNode ) ) {
-       QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_NIL_COUPLED" ), tr( "OK" ) );
+       SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_NIL_COUPLED" ), tr( "OK" ) );
        return false; // null coupled node
       }
     }
@@ -210,12 +211,12 @@ bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
     if ( theNode->IsLoop() ) {
       SUPERV::LNode_var aLoopNode = SUPERV::LNode::_narrow( theNode );
       if ( CORBA::is_nil( aLoopNode ) ) {
-       QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_LOOP" ), tr( "OK" ) );
+       SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_LOOP" ), tr( "OK" ) );
        return false;
       } 
       SUPERV::INode_var aEndLoopNode = aLoopNode->Coupled();
       if ( CORBA::is_nil( aEndLoopNode ) ) {
-       QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_LOOP" ), tr( "OK" ) );
+       SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_LOOP" ), tr( "OK" ) );
        return false;
       } 
       // save init, more, next, end-loop functions of the Loop node
@@ -229,12 +230,12 @@ bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
     if ( theNode->IsSwitch() ) {
       SUPERV::SNode_var aSwitchNode = SUPERV::SNode::_narrow( theNode );
       if ( CORBA::is_nil( aSwitchNode ) ) {
-       QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_SWITCH" ), tr( "OK" ) );
+       SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_SWITCH" ), tr( "OK" ) );
        return false;
       } 
       SUPERV::INode_var aEndSwitchNode = aSwitchNode->Coupled();
       if ( CORBA::is_nil( aEndSwitchNode ) ) {
-        QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_SWITCH" ), tr( "OK" ) );
+        SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_SWITCH" ), tr( "OK" ) );
         return false;
       } 
       // save EndSwitch function
@@ -263,7 +264,7 @@ bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
       return true;
     }
     else {  // error opening library file for final writing
-      QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_WRITE" ), tr( "OK" ) );
+      SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_LIB_WRITE" ), tr( "OK" ) );
       return false;
     }
   } // try
@@ -271,7 +272,7 @@ bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const {
   }
 
   // should get here only in case of exception
-  QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_EXPORT_EXCEPTION" ), tr( "OK" ) );
+  SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_EXPORT_EXCEPTION" ), tr( "OK" ) );
   return false;
 }
 
@@ -419,12 +420,12 @@ bool SUPERVGUI_Library::Import( SUPERV::Graph_var theDataflow,  SUPERV::INode_va
            return true;
          }
        default: // wrong kind of node error
-         QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_KIND_OF_NODE" ), tr( "OK" ) );
+         SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_KIND_OF_NODE" ), tr( "OK" ) );
          return false;
        } // switch ( kind_of_node )
       } // if ( index >= 0...)
       else {
-       QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_INDEX" ), tr( "OK" ) );
+       SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_INDEX" ), tr( "OK" ) );
       }
     } // if ( getNodes() )
     else {
@@ -436,7 +437,7 @@ bool SUPERVGUI_Library::Import( SUPERV::Graph_var theDataflow,  SUPERV::INode_va
 
   // Normally we get here ONLY if an exception occured.  All other paths of execution must return before.
   // But - who knows, maybe we can get here by some other means.. anyway, it's an error and we report it here
-  QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_EXCEPTION" ), tr( "OK" ) );
+  SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_EXCEPTION" ), tr( "OK" ) );
   return false;
 }
 
@@ -446,7 +447,7 @@ bool SUPERVGUI_Library::Import( SUPERV::Graph_var theDataflow,  SUPERV::INode_va
 bool SUPERVGUI_Library::getNodes( QDomDocument& doc, QDomNodeList& theNodes ) const {
   QFile libFile( GetLibraryFileName() );  // open existing library file
   if ( !libFile.exists() ) { 
-    QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_LIB_NO_XML" ), tr( "OK" ) );
+    SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_LIB_NO_XML" ), tr( "OK" ) );
     return false;
   }
 
@@ -458,7 +459,7 @@ bool SUPERVGUI_Library::getNodes( QDomDocument& doc, QDomNodeList& theNodes ) co
   if ( xmlOk )    
     xmlOk = ( doc.doctype().name() ==  DOCTYPE && doc.elementsByTagName( ROOT_ELEMENT ).length() == 1 ); 
   if ( !xmlOk ) {
-    QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_LIB_BAD_XML" ), tr( "OK" ) );
+    SUIT_MessageBox::error1( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_LIB_BAD_XML" ), tr( "OK" ) );
     return false;
   }
 
@@ -618,11 +619,16 @@ SUPERVGUI_LibDlg::~SUPERVGUI_LibDlg() {}
 void SUPERVGUI_LibDlg::add() {
   const int i = myLB->currentItem();
   if ( i >= 0 && i < myLB->count() ) {
-    SUPERV::Graph_var aDataflow = Supervision.getMain()->getDataflow();
+    SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+    if ( !aSupMod ) {
+      MESSAGE("NULL Supervision module!");
+      return;
+    }
+    SUPERV::Graph_var aDataflow = aSupMod->getMain()->getDataflow();
     SUPERV::INode_var aNode, aEndNode;
     if ( SUPERVGUI_Library::getLibrary()->Import( aDataflow, aNode, aEndNode, i ) ) {
       SUPERVGUI_Service::addNode( SUPERV::CNode::_narrow( aNode ), aEndNode, myX, myY );
-      Supervision.getMain()->sync();
+      aSupMod->getMain()->sync();
     }
     else { // all errors must be reported to user in Import(), MB shown, etc..
     }      // so we don't need to report errors if Import() returned false.