]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Implementation a mono-study approach in the GUI.
authorrnv <rnv@opencascade.com>
Wed, 7 May 2014 06:53:48 +0000 (10:53 +0400)
committerrnv <rnv@opencascade.com>
Wed, 7 May 2014 06:53:48 +0000 (10:53 +0400)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/resources/SalomeApp_msg_en.ts

index 976f9c8032f27411191db982a311f073f2048df1..2640effb99ec3c32e32fc75c8a33035a1a0491ee 100644 (file)
@@ -876,11 +876,12 @@ void LightApp_Application::onNewDoc()
   //asl: fix for 0020515
   if ( activeStudy() ) {
     saveDockWindowsState();
+  }
+  
 #ifdef SINGLE_DESKTOP
-    if ( !closeDoc() )
-      return;
+  if ( !checkExistingDoc() )
+    return;
 #endif
-  }
 
   CAM_Application::onNewDoc();
 }
@@ -892,15 +893,14 @@ void LightApp_Application::onOpenDoc()
 {
   SUIT_Study* study = activeStudy();
   saveDockWindowsState();
-  if (study) {
+  
 #ifdef SINGLE_DESKTOP
-    if ( !closeDoc() )
-      return;
+  if ( !checkExistingDoc() )
+    return;
 #endif
-  }
-
+  
   CAM_Application::onOpenDoc();
-
+  
   if ( !study ) // new study will be create in THIS application
   {
     updateWindows();
@@ -914,15 +914,13 @@ void LightApp_Application::onOpenDoc()
 */
 bool LightApp_Application::onOpenDoc( const QString& aName )
 {
-  if ( activeStudy() ) {
 #ifdef SINGLE_DESKTOP
-    if ( !closeDoc() )
-      return false;
+  if ( !checkExistingDoc() )
+    return false;
 #endif
-  }
   // We should take mru action first because this application instance can be deleted later.
   QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
-
+  
   bool res = CAM_Application::onOpenDoc( aName );
 
   if ( mru )
@@ -4425,3 +4423,11 @@ void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
       aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
   }
 }
+
+/*!
+  Check existing document.
+*/
+bool LightApp_Application::checkExistingDoc() {
+  return true;
+}
+
index 1fcef083d6aeeba8b3e0c667d3cd8e436b32d075..93b325c8a7e60d20989efbe6fedf476b371128bb 100644 (file)
@@ -179,6 +179,8 @@ public:
   void                                updateVisibilityState( DataObjectList& theList,
                                                              SUIT_ViewModel* theViewModel );  
 
+  virtual bool                        checkExistingDoc();
+
 signals:
   void                                studyOpened();
   void                                studySaved();
@@ -191,6 +193,7 @@ public slots:
   virtual void                        onHelpContextModule( const QString&, const QString&, const QString& = QString() );
   virtual void                        onNewDoc();
   virtual void                        onOpenDoc();
+
   virtual void                        onHelpAbout();
   virtual bool                        onOpenDoc( const QString& );
   virtual void                        onCopy();
index 6bab8edef41dccea24b5996745aa9f23cbd1a46d..4182bfcb145eb352d8fe696b0e722b86999e625a 100644 (file)
@@ -320,12 +320,13 @@ void SalomeApp_Application::createActions()
                 tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
                 /*Qt::SHIFT+Qt::Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
 
-  //SRN: BugID IPAL9021, add an action "Load"
-  createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
-                resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
-                tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
-                Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
-  //SRN: BugID IPAL9021: End
+  //rnv commented : implementation of the mono-study in GUI
+  //
+  //createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
+  //              resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
+  //              tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
+  //              Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+
 
 #ifdef WITH_SIMANIO
   if (myIsSiman) {
@@ -345,7 +346,7 @@ void SalomeApp_Application::createActions()
   // creation of menu item is moved to VISU
   //  createMenu( SaveGUIStateId, fileMenu, 10, -1 );
 
-  createMenu( FileLoadId,   fileMenu, 0 );  //SRN: BugID IPAL9021, add a menu item "Load"
+  // createMenu( FileLoadId,   fileMenu, 0 );
 
 #ifdef WITH_SIMANIO
   if (myIsSiman) {
@@ -423,6 +424,11 @@ void SalomeApp_Application::onLoadDoc()
 
   std::vector<std::string> List = studyMgr()->GetOpenStudies();
 
+  // rnv: According to the single-study approach on the server side
+  //      can be only one study. So if it is exists connect to them,  
+  //      overwise show warning message: "No active study on the server"
+
+  /*
   SUIT_Session* aSession = SUIT_Session::session();
   QList<SUIT_Application*> aAppList = aSession->applications();
 
@@ -444,10 +450,19 @@ void SalomeApp_Application::onLoadDoc()
      if ( !isAlreadyOpen )
        unloadedStudies << studyName;
   }
-
   studyName = SalomeApp_LoadStudiesDlg::selectStudy( desktop(), unloadedStudies );
   if ( studyName.isEmpty() )
     return;
+  */
+
+  if(List.size() <= 0) {
+    SUIT_MessageBox::warning( desktop(),
+                              QObject::tr("WRN_WARNING"),
+                              QObject::tr("WRN_NO_STUDY_ON SERV") );
+    return;
+  }
+  
+  studyName = List[0].c_str();
 
 #ifndef WIN32
   // this code replaces marker of windows drive and path become invalid therefore
@@ -1138,15 +1153,16 @@ int SalomeApp_Application::closeChoice( const QString& docName )
 {
   int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), tr( "APPCLOSE_DESCRIPTION" ).arg( docName ),
                                           tr ("APPCLOSE_SAVE"), tr ("APPCLOSE_CLOSE"),
-                                          tr ("APPCLOSE_UNLOAD"), tr ("APPCLOSE_CANCEL"), 0 );
+                                         //tr ("APPCLOSE_UNLOAD"), 
+                                         tr ("APPCLOSE_CANCEL"), 0 );
 
   int res = CloseCancel;
   if ( answer == 0 )
     res = CloseSave;
   else if ( answer == 1 )
     res = CloseDiscard;
-  else if ( answer == 2 )
-    res = CloseUnload;
+  // else if ( answer == 2 )
+  //   res = CloseUnload;
 
   return res;
 }
@@ -1249,7 +1265,10 @@ bool SalomeApp_Application::openAction( const int aChoice, const QString& aName
 QMap<int, QString> SalomeApp_Application::activateModuleActions() const
 {
   QMap<int, QString> opmap = LightApp_Application::activateModuleActions();
-  opmap.insert( LoadStudyId,     tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+
+  // rnv commented : implementation of the mono-study in GUI
+  // opmap.insert( LoadStudyId,     tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+
   opmap.insert( NewAndScriptId,  tr( "ACTIVATE_MODULE_OP_SCRIPT" ) );
   return opmap;
 }
@@ -1564,10 +1583,10 @@ void SalomeApp_Application::onStudyCreated( SUIT_Study* study )
 {
   LightApp_Application::onStudyCreated( study );
 
-#ifndef DISABLE_PYCONSOLE
-  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
-                               windowDock( getWindow( WT_ObjectBrowser ) ) );
-#endif
+//#ifndef DISABLE_PYCONSOLE
+//  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
+//                               windowDock( getWindow( WT_ObjectBrowser ) ) );
+//#endif
 
   loadDockWindowsState();
 
@@ -1579,10 +1598,10 @@ void SalomeApp_Application::onStudyOpened( SUIT_Study* study )
 {
   LightApp_Application::onStudyOpened( study );
 
-#ifndef DISABLE_PYCONSOLE
-  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
-                               windowDock( getWindow( WT_ObjectBrowser ) ) );
-#endif
+//#ifndef DISABLE_PYCONSOLE
+//  desktop()->tabifyDockWidget( windowDock( getWindow( WT_NoteBook ) ),
+//                               windowDock( getWindow( WT_ObjectBrowser ) ) );
+//#endif
 
   loadDockWindowsState();
 
@@ -2025,3 +2044,49 @@ void SalomeApp_Application::afterCloseDoc()
 #endif
   LightApp_Application::afterCloseDoc();
 }
+
+/*
+  Asks to close existing document.
+*/
+bool SalomeApp_Application::checkExistingDoc() {
+  bool result = true;
+  if( activeStudy() ) {
+    int answer = SUIT_MessageBox::question( desktop(), 
+                                           tr( "APPCLOSE_CAPTION" ), 
+                                           tr( "STUDYCLOSE_DESCRIPTION" ),
+                                           tr( "APPCLOSE_SAVE" ), 
+                                           tr( "APPCLOSE_CLOSE" ),
+                                           tr( "APPCLOSE_CANCEL" ), 0 );
+    if(answer == 0) {
+      if ( activeStudy()->isSaved() ) {
+       onSaveDoc();
+       closeDoc( false );
+      } else if ( onSaveAsDoc() ) {
+       if( !closeDoc( false ) ) {
+         result = false;
+       }
+      } else {
+       result = false;
+      }        
+    }
+    else if( answer == 1 ) {
+      closeDoc( false );
+    } else if( answer == 2 ) {
+      result = false;
+    }
+  } else {
+    SALOMEDSClient_StudyManager* aMgr = studyMgr();
+    if( aMgr ) {
+      std::vector<std::string> List = studyMgr()->GetOpenStudies();
+      if( List.size() > 0 ) {
+        int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_ACTIVEDOC_LOAD" ),
+                                                SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No );
+        if ( answer == SUIT_MessageBox::Yes ) {
+         onLoadDoc();
+       }
+       result = false;
+      }
+    }
+  }
+  return result;
+}
index c715722bb4287cdb1887ded5d7ef81995dfa1098..5d999d1a9135e8fb063d7929021e4e9880fe34c8 100644 (file)
@@ -96,6 +96,8 @@ public:
   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
 
   virtual void                        setDesktop( SUIT_Desktop* );
+  
+  virtual bool                        checkExistingDoc();
 
   static CORBA::ORB_var               orb();
   static SALOMEDSClient_StudyManager* studyMgr();
index d663c6ecb9e514d68e164b275ba383b08751f434..16e1ae5b53a3f6aa8348641c46e91874daaa5f64 100644 (file)
@@ -12,10 +12,26 @@ Python file must include only letters, digits and underscores and start from let
         <source>WRN_FILE_NOT_EXIST</source>
         <translation>The file %1 does not exist.</translation>
     </message>
+    <message>
+        <source>QUE_ACTIVEDOC_LOAD</source>
+        <translation>There is an active study in the session.
+Do you want to load it?
+</translation>
+    </message>
+    <message>
+        <source>STUDYCLOSE_DESCRIPTION</source>
+        <translation>You should close an existing study before.
+Do you want to close it?
+</translation>
+    </message>
     <message>
         <source>WRN_STUDY_LOCKED</source>
         <translation>Study is locked.</translation>
     </message>
+    <message>
+        <source>WRN_NO_STUDY_ON SERV</source>
+        <translation>No active study in this session.</translation>
+    </message>
     <message>
         <source>CLOSE_LOCKED_STUDY</source>
         <translation>Close locked study?</translation>
@@ -216,7 +232,7 @@ Do you want to reload it ?</translation>
     </message>
     <message>
         <source>APPCLOSE_DESCRIPTION</source>
-        <translation>Do you want to close or unload study before closing?</translation>
+        <translation>Do you want to save study before closing?</translation>
     </message>
     <message>
         <source>PRP_DESK_PROPERTIES</source>