Salome HOME
Merge V8_4_BR branch.
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.cxx
index 95465cd4dc788db4b39384b56ba6fc96999931a8..95c0e878b0d6869688e76da003da25b1ef5a4c93 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #endif
 
 #ifndef DISABLE_PYCONSOLE
-  #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
-  #include <PyConsole_Console.h>
+  #include "SalomeApp_PyInterp.h"
   #include "SalomeApp_NoteBook.h"
+  #include "LightApp_PyEditor.h"
+  #include "PyConsole_Console.h"
 #endif
 #include "SalomeApp_Application.h"
 #include "SalomeApp_Study.h"
@@ -49,6 +50,7 @@
 #include "SalomeApp_ExitDlg.h"
 
 #include <LightApp_Application.h>
+#include <LightApp_FileValidator.h>
 #include <LightApp_Module.h>
 #include <LightApp_Preferences.h>
 #include <LightApp_SelectionMgr.h>
@@ -62,7 +64,6 @@
 #include <SUIT_Desktop.h>
 #include <SUIT_DataBrowser.h>
 #include <SUIT_FileDlg.h>
-#include <SUIT_FileValidator.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_TreeModel.h>
@@ -84,6 +85,7 @@
 #include <SALOME_LifeCycleCORBA.hxx>
 
 #include <QApplication>
+#include <QWidget>
 #include <QAction>
 #include <QRegExp>
 #include <QCheckBox>
@@ -161,8 +163,7 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
 
 /*!Constructor.*/
 SalomeApp_Application::SalomeApp_Application()
-  : LightApp_Application(), 
-    myIsSiman( false ),
+  : LightApp_Application(),
     myIsCloseFromExit( false )
 {
 }
@@ -176,6 +177,25 @@ SalomeApp_Application::~SalomeApp_Application()
   //SALOME_EventFilter::Destroy();
 }
 
+QStringList __getArgsList(QString argsString)
+{
+  // Special process if some items of 'args:' list are themselves lists
+  // Note that an item can be a list, but not a list of lists...
+  // So we can have something like this:
+  // myscript.py args:['file1','file2'],val1,"done",[1,2,3],[True,False],"ok"
+  // With such a call, argsString variable contains the string representing "[file1,file2]", "val1", "done", "[1,2,3]", "[True,False]", "ok"
+  // We have to split argsString to obtain: [[file1,file2],val1,done,[1,2,3],[True,False],ok]
+  argsString.replace("\\\"", "'"); // replace escaped double quotes by simple quotes
+  bool containsList = (QRegExp("(\\[[^\\]]*\\])").indexIn(argsString) >= 0);
+  if (containsList) {
+    QStringList sl = argsString.split("\"", QString::SkipEmptyParts);
+    sl.removeAll(", ");
+    return sl;
+  }
+  else
+    return argsString.split(",", QString::SkipEmptyParts);
+}
+
 /*!Start application.*/
 void SalomeApp_Application::start()
 {
@@ -188,9 +208,9 @@ void SalomeApp_Application::start()
     QStringList pyfiles;
     QString loadStudy;
 
-    for (int i = 1; i < qApp->argc(); i++) {
+    for (int i = 1; i < qApp->arguments().size(); i++) {
       QRegExp rxs ("--study-hdf=(.+)");
-      if ( rxs.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) {
+      if ( rxs.indexIn( qApp->arguments()[i] ) >= 0 && rxs.capturedTexts().count() > 1 ) {
         QString file = rxs.capturedTexts()[1];
         QFileInfo fi ( file );
         QString extension = fi.suffix().toLower();
@@ -199,9 +219,8 @@ void SalomeApp_Application::start()
       }
       else {
         QRegExp rxp ("--pyscript=\\[(.+)\\]");
-       QRegExp rxl ("--siman-study=(.+)");
-        if ( rxp.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) {
-         // pyscript
+        if ( rxp.indexIn( qApp->arguments()[i] ) >= 0 && rxp.capturedTexts().count() > 1 ) {
+          // pyscript
           QStringList dictList = rxp.capturedTexts()[1].split("},", QString::SkipEmptyParts);
           for (int k = 0; k < dictList.count(); ++k) {
             QRegExp rxd ("[\\s]*\\{?([^\\{\\}]+)\\}?[\\s]*");
@@ -212,13 +231,6 @@ void SalomeApp_Application::start()
             }
           }
         }
-#ifdef WITH_SIMANIO
-       if ( rxl.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxl.capturedTexts().count() > 1 ) {
-         // siman
-         loadStudy = rxl.capturedTexts()[1];
-         myIsSiman = true;
-       }
-#endif
       }
     }
     // Here pyfiles elements are: "script_name": [list_of_"arg"s]
@@ -227,6 +239,7 @@ void SalomeApp_Application::start()
     LightApp_Application::start();
     SALOME_EventFilter::Init();
 
+    setProperty("open_study_from_command_line", true);
     if ( !hdffile.isEmpty() )       // open hdf file given as parameter
       onOpenDoc( hdffile );
     else if ( pyfiles.count() > 0 ) // create new study
@@ -235,6 +248,7 @@ void SalomeApp_Application::start()
       if (onLoadDoc(loadStudy))
         updateObjectBrowser(true);
     }
+    setProperty("open_study_from_command_line", QVariant());
 
 #ifndef DISABLE_PYCONSOLE
     // import/execute python scripts
@@ -252,7 +266,7 @@ void SalomeApp_Application::start()
             if ( rxp.indexIn( pyfiles[j] ) >= 0 && rxp.capturedTexts().count() == 3 ) {
               QString script = rxp.capturedTexts()[1];
               QString args = "";
-              QStringList argList = rxp.capturedTexts()[2].split(",", QString::SkipEmptyParts);
+              QStringList argList = __getArgsList(rxp.capturedTexts()[2]);
               for (uint k = 0; k < argList.count(); k++ ) {
                 QString arg = argList[k].trimmed();
                 arg.remove( QRegExp("^[\"]") );
@@ -306,7 +320,7 @@ void SalomeApp_Application::createActions()
   //! Properties
   createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIcon(),
                 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
-                Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onProperties() ) );
+                0, desk, false, this, SLOT( onProperties() ) );
 
   //! Catalog Generator
   createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ),  QIcon(),
@@ -327,18 +341,6 @@ void SalomeApp_Application::createActions()
                 Qt::CTRL+Qt::Key_U, desk, false, this, SLOT( onUnloadDoc() ) );
 
 
-#ifdef WITH_SIMANIO
-  if (myIsSiman) {
-    // check-in operations for SIMAN study  
-    createAction( SimanCheckInId, tr( "TOT_SIMAN_CHECK_IN" ), QIcon(),
-                tr( "MEN_SIMAN_CHECK_IN" ), tr( "PRP_SIMAN_CHECK_IN" ),
-                0, desk, false, this, SLOT( onCheckIn() ) );
-    createAction( SimanLocalCheckInId, tr( "TOT_SIMAN_LOCAL_CHECK_IN" ), QIcon(),
-                tr( "MEN_SIMAN_LOCAL_CHECK_IN" ), tr( "PRP_SIMAN_LOCAL_CHECK_IN" ),
-                0, desk, false, this, SLOT( onLocalCheckIn() ) );
-  }
-#endif
-
   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
 
   // "Save GUI State" command is renamed to "Save VISU State" and
@@ -349,15 +351,6 @@ void SalomeApp_Application::createActions()
   createMenu( DisconnectId, fileMenu, 5 );
   createMenu( separator(),  fileMenu, -1, 5 );
 
-#ifdef WITH_SIMANIO
-  if (myIsSiman) {
-    // check-in operation for SIMAN study
-    // last argument "5" locates this just after "Save As" but certain constant is bad => insert after the separator
-    createMenu( SimanCheckInId, fileMenu, 5);
-    createMenu( SimanLocalCheckInId, fileMenu, 5);
-    createMenu( separator(), fileMenu, 5 );
-  }
-#endif
   createMenu( DumpStudyId, fileMenu, 10, -1 );
   createMenu( LoadScriptId, fileMenu, 10, -1 );
   createMenu( separator(), fileMenu, -1, 10, -1 );
@@ -416,7 +409,7 @@ 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,  
+  //      can be only one study. So if it is exists connect to them,
   //      overwise show warning message: "No active study on the server"
 
   /*
@@ -452,7 +445,7 @@ void SalomeApp_Application::onLoadDoc()
                               QObject::tr("WRN_NO_STUDY_ON SERV") );
     return;
   }
-  
+
   studyName = List[0].c_str();
 
 #ifndef WIN32
@@ -476,18 +469,18 @@ void SalomeApp_Application::onUnloadDoc( bool ask )
     if ( activeStudy()->isModified() ) {
       QString docName = activeStudy()->studyName().trimmed();
       int answer = SUIT_MessageBox::question( desktop(), tr( "DISCONNECT_CAPTION" ),
-                                           tr( "DISCONNECT_DESCRIPTION" ),
-                                           tr( "DISCONNECT_SAVE" ), 
-                                           tr( "DISCONNECT_WO_SAVE" ),
-                                           tr( "APPCLOSE_CANCEL" ), 0 );
+                                            tr( "DISCONNECT_DESCRIPTION" ),
+                                            tr( "DISCONNECT_SAVE" ),
+                                            tr( "DISCONNECT_WO_SAVE" ),
+                                            tr( "APPCLOSE_CANCEL" ), 0 );
       if ( answer == 0 ) { // save before unload
-       if ( activeStudy()->isSaved() )
-         onSaveDoc();
-       else if ( !onSaveAsDoc() )
-         return;
+        if ( activeStudy()->isSaved() )
+          onSaveDoc();
+        else if ( !onSaveAsDoc() )
+          return;
       }
       else if ( answer == 2 ) // Cancel
-       return;
+        return;
     }
   }
   closeActiveDoc( false );
@@ -562,17 +555,7 @@ bool SalomeApp_Application::onLoadDoc( const QString& aName )
 /*!SLOT. Parse message for desktop.*/
 void SalomeApp_Application::onDesktopMessage( const QString& message )
 {
-  if (message.indexOf("simanCheckoutDone ") == 0) {
-#ifdef WITH_SIMANIO
-    // Load document with a name, specified in aMessage.
-    onLoadDoc(message.section(' ', 1));
-#else
-    printf( "****************************************************************\n" );
-    printf( "*    Warning: SALOME is built without SIMAN support.\n" );
-    printf( "****************************************************************\n" );
-#endif
-  }
-  else if (message.indexOf("studyCreated:") == 0) {
+  if (message.indexOf("studyCreated:") == 0) {
     // Enable 'Connect' action
     updateCommandsStatus();
   }
@@ -801,10 +784,12 @@ void SalomeApp_Application::updateCommandsStatus()
   if ( a )
     a->setEnabled( activeStudy() );
 
+#ifndef DISABLE_PYCONSOLE
   // Load script menu
   a = action( LoadScriptId );
   if( a )
     a->setEnabled( pythonConsole() );
+#endif
 
   // Properties menu
   a = action( PropertiesId );
@@ -869,26 +854,6 @@ public:
   QCheckBox* mySaveGUIChk;
 };
 
-class DumpStudyFileValidator : public SUIT_FileValidator
-{
- public:
-  DumpStudyFileValidator( QWidget* parent) : SUIT_FileValidator ( parent ) {};
-  virtual ~DumpStudyFileValidator() {};
-  virtual bool canSave( const QString& file, bool permissions );
-};
-
-bool DumpStudyFileValidator::canSave(const QString& file, bool permissions)
-{
-  QFileInfo fi( file );
-  if ( !QRegExp( "[A-Za-z_][A-Za-z0-9_]*" ).exactMatch( fi.completeBaseName() ) ) {
-    SUIT_MessageBox::critical( parent(),
-                               QObject::tr("WRN_WARNING"),
-                               QObject::tr("WRN_FILE_NAME_BAD") );
-    return false;
-  }
-  return SUIT_FileValidator::canSave( file, permissions);
-}
-
 /*!Private SLOT. On dump study.*/
 void SalomeApp_Application::onDumpStudy( )
 {
@@ -910,9 +875,9 @@ void SalomeApp_Application::onDumpStudy( )
   }
 
   DumpStudyFileDlg fd( desktop() );
-  fd.setValidator( new DumpStudyFileValidator( &fd ) );
+  fd.setValidator( new LightApp_PyFileValidator( &fd ) );
   fd.setWindowTitle( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
-  fd.setFilters( aFilters );
+  fd.setNameFilters( aFilters );
   fd.myPublishChk->setChecked( anIsPublish );
   fd.myMultiFileChk->setChecked( anIsMultiFile );
   fd.mySaveGUIChk->setChecked( anIsSaveGUI );
@@ -964,17 +929,6 @@ void SalomeApp_Application::onLoadScript( )
   QString anInitialPath = "";
   if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
     anInitialPath = QDir::currentPath();
-  
-#ifdef WITH_SIMANIO
-  // MPV: if it is SIMAN study, make the initial path as the path to the Siman scripts storage
-  if (myIsSiman) {
-    SALOMEDSClient_StudyManager* aMgr = studyMgr();
-    aMgr->GetSimanStudy()->StudyId();
-    anInitialPath = QString(QDir::separator()) + "tmp" + QDir::separator() + "SimanSalome" + QDir::separator() + 
-      aMgr->GetSimanStudy()->StudyId().c_str() + QDir::separator() +
-      aMgr->GetSimanStudy()->ScenarioId().c_str() + QDir::separator() + aMgr->GetSimanStudy()->UserId().c_str();
-  }
-#endif
 
   QString aFile = SUIT_FileDlg::getFileName( desktop(), anInitialPath, filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
 
@@ -1003,40 +957,6 @@ void SalomeApp_Application::onSaveGUIState()
   updateActions();
 }
 
-/*!Public SLOT. On SIMAN check in operation.*/
-void SalomeApp_Application::onCheckIn()
-{
-#ifdef WITH_SIMANIO
-  setMenuShown(SimanCheckInId, false); // check in may be performed only once
-  setMenuShown(SimanLocalCheckInId, false);
-  SALOMEDSClient_StudyManager* aMgr = studyMgr();
-  aMgr->GetSimanStudy()->CheckIn("");
-#else
-  printf( "****************************************************************\n" );
-  printf( "*    Warning: SALOME is built without SIMAN support.\n" );
-  printf( "****************************************************************\n" );
-#endif
-}
-
-/*!Public SLOT. On SIMAN local check in operation.*/
-void SalomeApp_Application::onLocalCheckIn()
-{
-#ifdef WITH_SIMANIO
-  // get the active module
-  CAM_Module* aModule = activeModule();
-  if (!aModule) return; // there is no active module
-  
-  setMenuShown(SimanCheckInId, false); // check in may be performed only once
-  setMenuShown(SimanLocalCheckInId, false);
-  SALOMEDSClient_StudyManager* aMgr = studyMgr();
-  aMgr->GetSimanStudy()->CheckIn(aModule->name().toLatin1().data());
-#else
-  printf( "****************************************************************\n" );
-  printf( "*    Warning: SALOME is built without SIMAN support.\n" );
-  printf( "****************************************************************\n" );
-#endif
-}
-
 /*!Public SLOT. Performs some actions when dockable windows are triggered.*/
 void SalomeApp_Application::onDockWindowVisibilityChanged( bool theIsVisible )
 {
@@ -1049,14 +969,6 @@ void SalomeApp_Application::onDockWindowVisibilityChanged( bool theIsVisible )
     objectBrowserColumnsVisibility();
 }
 
-/*!Gets file filter.
- *\retval QString "(*.hdf)"
- */
-QString SalomeApp_Application::getFileFilter() const
-{
-  return "(*.hdf)";
-}
-
 /*!Create window.*/
 QWidget* SalomeApp_Application::createWindow( const int flag )
 {
@@ -1110,6 +1022,12 @@ QWidget* SalomeApp_Application::createWindow( const int flag )
       ob->setResizeOnExpandItem(resizeOnExpandItem);
       ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
 
+      for ( int i = SalomeApp_DataObject::EntryId; i < SalomeApp_DataObject::LastId; i++ )
+      {
+        bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i-1 ), true );
+        ob->treeView()->setColumnHidden( i, !shown );
+      }
+
       // temporary commented
       /*
       for ( int i = SalomeApp_DataObject::ValueIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ )
@@ -1131,15 +1049,14 @@ QWidget* SalomeApp_Application::createWindow( const int flag )
 #ifndef DISABLE_PYCONSOLE
   else if ( flag == WT_PyConsole )
   {
-    PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
+    PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
     pyCons->setObjectName( "pythonConsole" );
     pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
     pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
     pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
+    pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
     pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
     wid = pyCons;
-    //pyCons->resize( pyCons->width(), desktop()->height()/4 );
-    pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
   }
   else if ( flag == WT_NoteBook )
   {
@@ -1235,7 +1152,7 @@ int SalomeApp_Application::closeChoice( const QString& docName )
   choices.insert( idx++, CloseCancel );           // ...
 
   int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ),
-                                         tr( "APPCLOSE_DESCRIPTION" ), buttons, 0 );
+                                          tr( "APPCLOSE_DESCRIPTION" ), buttons, 0 );
   return choices[answer];
 }
 
@@ -1376,8 +1293,14 @@ void SalomeApp_Application::moduleActionSelected( const int id )
 /*!Gets CORBA::ORB_var*/
 CORBA::ORB_var SalomeApp_Application::orb()
 {
-  ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
-  static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
+  static CORBA::ORB_var _orb;
+
+  if ( CORBA::is_nil( _orb ) ) {
+    Qtx::CmdLineArgs args;
+    ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+    _orb = init( args.argc(), args.argv() );
+  }
+
   return _orb;
 }
 
@@ -1461,20 +1384,20 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop
   if ( aStudy ) {
     _PTR(Study) aStudyDS = aStudy->studyDS();
     _PTR(SObject) anObj;
-    
+
     for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
     {
       if( it.Value()->hasEntry() )
       {
-       _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
-       while( aRefObj && aRefObj->ReferencedObject( anObj ) )
-         aRefObj = anObj;
-       
-       if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
-         isInvalidRefs = true;
+        _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
+        while( aRefObj && aRefObj->ReferencedObject( anObj ) )
+          aRefObj = anObj;
+
+        if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
+          isInvalidRefs = true;
       }
     }
-    
+
     // Add "Delete reference" item to popup
     if ( isInvalidRefs )
     {
@@ -1487,41 +1410,41 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop
     if ( aList.Extent() == 1 ) {
       aList.Clear();
       mgr->selectedObjects( aList );
-      
+
       Handle(SALOME_InteractiveObject) aIObj = aList.First();
-      
+
       // add extra popup menu (defined in XML)
       if ( myExtActions.size() > 0 ) {
-       // Use only first selected object
-       SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
-       if ( study ) {
-         _PTR(Study) stdDS = study->studyDS();
-         if ( stdDS ) {
-           _PTR(SObject) aSO = stdDS->FindObjectID( aIObj->getEntry() );
-           if ( aSO ) {
-             _PTR( GenericAttribute ) anAttr;
-             std::string auid = "AttributeUserID";
-             auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
-             if ( aSO->FindAttribute( anAttr, auid ) ) {
-               _PTR(AttributeUserID) aAttrID = anAttr;
-               QString aId = aAttrID->Value().c_str();
-               if ( myExtActions.contains( aId ) ) {
-                 thePopup->addAction(myExtActions[aId]);
-               }
-             }
-           }
-         }
-       }
+        // Use only first selected object
+        SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+        if ( study ) {
+          _PTR(Study) stdDS = study->studyDS();
+          if ( stdDS ) {
+            _PTR(SObject) aSO = stdDS->FindObjectID( aIObj->getEntry() );
+            if ( aSO ) {
+              _PTR( GenericAttribute ) anAttr;
+              std::string auid = "AttributeUserID";
+              auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
+              if ( aSO->FindAttribute( anAttr, auid ) ) {
+                _PTR(AttributeUserID) aAttrID = anAttr;
+                QString aId = aAttrID->Value().c_str();
+                if ( myExtActions.contains( aId ) ) {
+                  thePopup->addAction(myExtActions[aId]);
+                }
+              }
+            }
+          }
+        }
       }
-      
+
       // check if item is a "GUI state" item (also a first level object)
       QString entry( aIObj->getEntry() );
       if ( !entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) {
-       QString aModuleName( aIObj->getComponentDataType() );
-       QString aModuleTitle = moduleTitle( aModuleName );
-       CAM_Module* currentModule = activeModule();
-       if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() )
-         thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
+        QString aModuleName( aIObj->getComponentDataType() );
+        QString aModuleTitle = moduleTitle( aModuleName );
+        CAM_Module* currentModule = activeModule();
+        if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() )
+          thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
       }
     }
   }
@@ -1605,6 +1528,7 @@ void SalomeApp_Application::onDblClick( SUIT_DataObject* theObj )
     if ( !aSelectedIndexes.isEmpty() )
       ob->treeView()->scrollTo( aSelectedIndexes.first() );
   }
+  emit objectDoubleClicked( theObj );
 }
 
 /*!
@@ -2096,7 +2020,8 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript,
   {
 #ifndef DISABLE_PYCONSOLE
     _PTR(Study) aStudyDS = newStudy->studyDS();
-    app->getNoteBook()->Init( aStudyDS );
+    if ( app->getNoteBook() )
+      app->getNoteBook()->Init( aStudyDS );
     newStudy->updateFromNotebook(theStudyName, theIsStudySaved);
     newStudy->Modified();
     updateDesktopTitle();
@@ -2137,7 +2062,7 @@ bool SalomeApp_Application::checkExistingDoc()
       std::vector<std::string> List = studyMgr()->GetOpenStudies();
       if( List.size() > 0 ) {
         SUIT_MessageBox::critical( desktop(), tr( "WRN_WARNING" ), tr( "ERR_ACTIVEDOC_LOAD" ));
-       result = false;
+        result = false;
       }
     }
   }
@@ -2149,7 +2074,7 @@ bool SalomeApp_Application::checkExistingDoc()
 
 PyConsole_Interp* SalomeApp_Application::createPyInterp()
 {
-  return new SalomeApp_PyInterp();
+  return new SalomeApp_PyInterp;
 }
 
 #endif // DISABLE_PYCONSOLE