Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.cxx
index 1432fffd6bdcf3d3d540ad8a1c3f89971b0b14fc..802d7d7b0fd5ea10fc7d4ff3161750f9ff73592f 100644 (file)
@@ -1,3 +1,21 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 // File:      SalomeApp_Application.cxx
 // Created:   10/22/2004 3:23:45 PM
 // Author:    Sergey LITONIN
 #include "SalomeApp_Application.h"
 
 #include "SalomeApp_Study.h"
-#include "SalomeApp_Module.h"
-#include "SalomeApp_OBFilter.h"
 #include "SalomeApp_DataModel.h"
 #include "SalomeApp_DataObject.h"
 #include "SalomeApp_EventFilter.h"
-#include "SalomeApp_WidgetContainer.h"
+#include "SalomeApp_VisualState.h"
+#include "SalomeApp_ExitDlg.h"
 
-#include "SalomeApp_AboutDlg.h"
-#include "SalomeApp_ModuleDlg.h"
-#include "SalomeApp_Preferences.h"
-#include "SalomeApp_PreferencesDlg.h"
 #include "SalomeApp_StudyPropertiesDlg.h"
-#include "SalomeApp_CheckFileDlg.h"
 
-#include "SalomeApp_GLSelector.h"
-#include "SalomeApp_OBSelector.h"
-#include "SalomeApp_OCCSelector.h"
-#include "SalomeApp_VTKSelector.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_Application.h"
+#include "LightApp_Preferences.h"
+#include "LightApp_WidgetContainer.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_NameDlg.h"
 
-#include <LogWindow.h>
-
-#include <GLViewer_Viewer.h>
-#include <GLViewer_ViewManager.h>
-
-#include <Plot2d_ViewManager.h>
-#include <SPlot2d_ViewModel.h>
-
-#include <OCCViewer_ViewManager.h>
-#include <SOCC_ViewModel.h>
-
-#include <SVTK_ViewModel.h>
-#include <SVTK_ViewManager.h>
-
-#include <STD_TabDesktop.h>
+#include "STD_LoadStudiesDlg.h"
 
 #include <SUIT_Tools.h>
 #include <SUIT_Session.h>
+#include <SUIT_MsgDlg.h>
 
-#include <QtxToolBar.h>
 #include <QtxMRUAction.h>
-#include <QtxDockAction.h>
-#include <QtxResourceEdit.h>
 
 #include <OB_Browser.h>
+#include <OB_ListItem.h>
 
 #include <PythonConsole_PyConsole.h>
 
 #include <SALOME_ModuleCatalog_impl.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
 
-#include <qmap.h>
-#include <qdir.h>
-#include <qlabel.h>
-#include <qimage.h>
 #include <qaction.h>
-#include <qmenubar.h>
 #include <qcombobox.h>
+#include <qlistbox.h>
+#include <qregexp.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
 #include <qmessagebox.h>
-#include <qapplication.h>
 
-#include "SALOMEDS_StudyManager.hxx"
+#include "SALOMEDSClient_ClientFactory.hxx"
+#include "SALOMEDSClient_IParameters.hxx"
 
 #include "SALOME_ListIteratorOfListIO.hxx"
 #include "SALOME_ListIO.hxx"
 
-#define OBJECT_BROWSER_WIDTH 300
-
-static const char* imageEmptyIcon[] = {
-"20 20 1 1",
-".     c None",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"...................."};
-
-extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
-{
-  return new SalomeApp_Application();
-}
+#include "ToolsGUI_CatalogGeneratorDlg.h"
+#include "ToolsGUI_RegWidget.h"
 
-SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0;
+#include <SALOMEDSClient_ClientFactory.hxx>
 
-/*
-  Class       : SalomeApp_Application
-  Description : Application containing SalomeApp module
-*/
-
-SalomeApp_Application::SalomeApp_Application()
-: CAM_Application( false ),
-myPrefs( 0 )
+#include <vector>
+/*!Internal class that updates object browser item properties */
+class SalomeApp_Updater : public OB_Updater
 {
-  STD_TabDesktop* desk = new STD_TabDesktop();
-
-  setDesktop( desk );
+public:
+  SalomeApp_Updater() : OB_Updater(){};
+  virtual ~SalomeApp_Updater(){};
+  virtual void update( SUIT_DataObject* theObj, OB_ListItem* theItem );
+};
 
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-  QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
-
-  desktop()->setIcon( aLogo );
-  desktop()->setDockableMenuBar( true );
-  desktop()->setDockableStatusBar( false );
-
-  clearViewManagers();
-
-  mySelMgr = new SalomeApp_SelectionMgr( this );
-
-  connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
-           this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
-
-  connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
-}
-
-SalomeApp_Application::~SalomeApp_Application()
+void SalomeApp_Updater::update( SUIT_DataObject* theObj, OB_ListItem* theItem )
 {
-  saveWindowsGeometry();
+  if( !theObj || !theItem )
+    return;
+
+  SalomeApp_DataObject* SAObj = dynamic_cast<SalomeApp_DataObject*>( theObj );
+  if( !SAObj )
+    return;
+  
+  _PTR(SObject) SObj = SAObj->object();
+  if( !SObj )
+    return;
+  _PTR( GenericAttribute ) anAttr;
 
-  if ( resourceMgr() )
+  // Selectable
+  if ( SObj->FindAttribute( anAttr, "AttributeSelectable" ) )
   {
-    if ( desktop() )
-      desktop()->saveGeometry( resourceMgr(), "desktop" );
-    resourceMgr()->save();
+    _PTR(AttributeSelectable) aAttrSel = anAttr;
+    theItem->setSelectable( aAttrSel->IsSelectable() );
   }
-
-  delete mySelMgr;
-
-  SalomeApp_EventFilter::Destroy();
+  // Expandable
+  if ( SObj->FindAttribute(anAttr, "AttributeExpandable") ) 
+  {
+    _PTR(AttributeExpandable) aAttrExpand = anAttr;
+    theItem->setExpandable( aAttrExpand->IsExpandable() );
+  }
+  // Opened
+  //this attribute is not supported in the version of SALOME 3.x
+  //if ( SObj->FindAttribute(anAttr, "AttributeOpened") ) 
+  //{
+  //  _PTR(AttributeOpened) aAttrOpen = anAttr;
+  //  theItem->setOpen( aAttrOpen->IsOpened() );
+  //}
 }
 
-void SalomeApp_Application::start()
+/*!Create new instance of SalomeApp_Application.*/
+extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
 {
-  if ( desktop() )
-    desktop()->loadGeometry( resourceMgr(), "desktop" );
-
-  CAM_Application::start();
-
-  QAction* a = action( ViewWindowsId );
-  if ( a && a->inherits( "QtxDockAction" ) )
-    ((QtxDockAction*)a)->setAutoPlace( true );
-
-  SalomeApp_EventFilter::Init();
-
-  updateWindows();
-  updateViewManagers();
-
-  putInfo( "" );
+  return new SalomeApp_Application();
 }
 
-QString SalomeApp_Application::applicationName() const
+/*!Constructor.*/
+SalomeApp_Application::SalomeApp_Application()
+: LightApp_Application()
 {
-  return tr( "APP_NAME" );
+  connect( desktop(), SIGNAL( message( const QString& ) ), 
+          this,      SLOT( onDesktopMessage( const QString& ) ) );
 }
 
-QString SalomeApp_Application::applicationVersion() const
+/*!Destructor.
+ *\li Destroy event filter.
+ */
+SalomeApp_Application::~SalomeApp_Application()
 {
-  static QString _app_version;
-
-  if ( _app_version.isEmpty() )
-  {
-    QString path( ::getenv( "GUI_ROOT_DIR" ) );
-    if ( !path.isEmpty() )
-      path += QDir::separator();
-    path += QString( "bin/salome/VERSION" );
+  // Do not destroy. It's a singleton !
+  //SalomeApp_EventFilter::Destroy();
+}
 
-    QFile vf( path );
-    if ( vf.open( IO_ReadOnly ) )
-    {
-      QString line;
-      vf.readLine( line, 1024 );
-      vf.close();
+/*!Start application.*/
+void SalomeApp_Application::start()
+{
+  LightApp_Application::start();
 
-      if ( !line.isEmpty() )
-      {
-       while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
-         line.remove( line.length() - 1, 1 );
+  SalomeApp_EventFilter::Init();
 
-       int idx = line.findRev( ":" );
-       if ( idx != -1 )
-         _app_version = line.mid( idx + 1 ).stripWhiteSpace();
+  static bool isFirst = true;
+  if ( isFirst ) {
+    isFirst = false;
+
+    QString hdffile;
+    QStringList pyfiles;
+
+    for (int i = 1; i < qApp->argc(); i++) {
+      QRegExp rxs ("--study-hdf=(.+)");
+      if ( rxs.search( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) {
+       QString file = rxs.capturedTexts()[1];
+        QFileInfo fi ( file );
+        QString extension = fi.extension( false ).lower();
+        if ( extension == "hdf" && fi.exists() )
+          hdffile = fi.absFilePath();
+      }
+      else {
+        QRegExp rxp ("--pyscript=(.+)");
+        if ( rxp.search( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) {
+          QStringList files = QStringList::split(",",rxp.capturedTexts()[1],false);
+          pyfiles += files;
+        }
       }
     }
-  }
 
-  return _app_version;
-}
+    if ( !hdffile.isEmpty() )       // open hdf file given as parameter
+      onOpenDoc( hdffile );
+    else if ( pyfiles.count() > 0 ) // create new study
+      onNewDoc();
 
-CAM_Module* SalomeApp_Application::loadModule( const QString& name )
-{
-  CAM_Module* mod = CAM_Application::loadModule( name );
-  if ( mod )
-  {
-    connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
-    connect( this, SIGNAL( studySaved() ),  mod, SLOT( onModelSaved() ) );
-    connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
+    // import/execute python scripts
+    if ( pyfiles.count() > 0 && activeStudy() ) {
+      SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+      if ( appStudy ) {
+       _PTR(Study) aStudy = appStudy->studyDS();
+       if ( !aStudy->GetProperties()->IsLocked() ) {
+          for (uint j = 0; j < pyfiles.count(); j++ ) {
+            QFileInfo fi ( pyfiles[j] );
+           PythonConsole* pyConsole = pythonConsole();
+           if ( pyConsole ) {
+              QString extension = fi.extension( false ).lower();
+              if ( fi.exists() ) {
+                // execute python script
+                QString command = QString( "execfile(\"%1\")" ).arg( fi.absFilePath() );
+                pyConsole->exec( command );
+              }
+              else {
+                // import python module
+                QString command = QString( "import %1" ).arg( pyfiles[j] );
+               if ( extension == "py" )
+                 command = QString( "import %1" ).arg( fi.baseName( true ) );
+                pyConsole->exec( command );
+              }
+            }
+          }
+       }
+      }
+    }
   }
-  return mod;
-}
-
-bool SalomeApp_Application::activateModule( const QString& modName )
-{
-  QString actName;
-  CAM_Module* prevMod = activeModule();
-
-  if ( prevMod )
-    actName = prevMod->moduleName();
-
-  if ( actName == modName )
-    return true;
-
-  saveWindowsGeometry();
-
-  bool status = CAM_Application::activateModule( modName );
-
-  updateModuleActions();
-
-  if ( !status )
-    return false;
-
-  updateWindows();
-  updateViewManagers();
-
-  return true;
-}
-
-SalomeApp_SelectionMgr* SalomeApp_Application::selectionMgr() const
-{
-  return mySelMgr;
 }
 
+/*!Create actions:*/
 void SalomeApp_Application::createActions()
 {
-  STD_Application::createActions();
+  LightApp_Application::createActions();
 
   SUIT_Desktop* desk = desktop();
-  SUIT_ResourceMgr* resMgr = resourceMgr();
   
-  // Dump study
+  //! Save GUI state
+  // "Save GUI State" command is moved to VISU module
+  //  createAction( SaveGUIStateId, tr( "TOT_DESK_FILE_SAVE_GUI_STATE" ), QIconSet(),
+  //           tr( "MEN_DESK_FILE_SAVE_GUI_STATE" ), tr( "PRP_DESK_FILE_SAVE_GUI_STATE" ),
+  //           0, desk, false, this, SLOT( onSaveGUIState() ) );
+  
+  //! Dump study
   createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
                tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
-               0, desk, false, this, SLOT( onDumpStudy() ) );
+               CTRL+Key_D, desk, false, this, SLOT( onDumpStudy() ) );
     
-  // Load script
+  //! Load script
   createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
                tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
-               0, desk, false, this, SLOT( onLoadScript() ) );
+               CTRL+Key_T, desk, false, this, SLOT( onLoadScript() ) );
 
-  // Properties
+  //! Properties
   createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
                tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
-               0, desk, false, this, SLOT( onProperties() ) );
-
-  // Preferences
-  createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
-               tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
-               CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
-
-  // MRU
-  QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
-  connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
-  registerAction( MRUId, mru );
-
-  // default icon for neutral point ('SALOME' module)
-  QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
-  if ( defIcon.isNull() )
-    defIcon = QPixmap( imageEmptyIcon );
-
-  // default icon for any module
-  QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ), false );
-  if ( modIcon.isNull() )
-    modIcon = QPixmap( imageEmptyIcon );
-
-  QToolBar* modTBar = new QtxToolBar( true, desk );
-  modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
-
-  QActionGroup* modGroup = new QActionGroup( this );
-  modGroup->setExclusive( true );
-  modGroup->setUsesDropDown( true );
-
-  QAction* a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
-                             tr( "PRP_APP_MODULE" ), 0, desk, true );
-  modGroup->add( a );
-  myActions.insert( QString(), a );
-
-  QMap<QString, QString> iconMap;
-  moduleIconNames( iconMap );
-
-  const int iconSize = 20;
-
-  modGroup->addTo( modTBar );
-  modTBar->addSeparator();
-
-  QStringList modList;
-  modules( modList, false );
-
-  for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
-  {
-    if ( (*it).isEmpty() )
-      continue;
-
-    QString iconName;
-    if ( iconMap.contains( *it ) )
-      iconName = iconMap[*it];
-
-    QString modName = moduleName( *it );
-
-    QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
-    if ( icon.isNull() )
-      icon = modIcon;
-
-    icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
-
-    QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
-    a->addTo( modTBar );
-    modGroup->add( a );
+               CTRL+Key_P, desk, false, this, SLOT( onProperties() ) );
 
-    myActions.insert( *it, a );
-  }
+  //! Catalog Generator
+  createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ),  QIconSet(),
+               tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ),
+               SHIFT+Key_G, desk, false, this, SLOT( onCatalogGen() ) );
 
-  SUIT_Tools::simplifySeparators( modTBar );
+  //! Registry Display
+  createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ),  QIconSet(),
+               tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
+               /*SHIFT+Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
 
-  // New window
+  //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" ),
+               CTRL+Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+  //SRN: BugID IPAL9021: End
 
-  int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
-  int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
-  createMenu( separator(), windowMenu, -1, 1 );
 
-  QMap<int, int> accelMap;
-  accelMap[NewGLViewId]  = ALT+Key_G;
-  accelMap[NewPlot2dId]  = ALT+Key_P;
-  accelMap[NewOCCViewId] = ALT+Key_O;
-  accelMap[NewVTKViewId] = ALT+Key_K;
+  int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
 
-  for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
-  {
-    QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
-                              tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
-                              tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
-                              accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
-    createMenu( a, newWinMenu, -1 );
-  }
-  connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
+  // "Save GUI State" command is renamed to "Save VISU State" and 
+  // creation of menu item is moved to VISU
+  //  createMenu( SaveGUIStateId, fileMenu, 10, -1 ); 
 
-  int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
+  createMenu( FileLoadId,   fileMenu, 0 );  //SRN: BugID IPAL9021, add a menu item "Load"
 
   createMenu( DumpStudyId, fileMenu, 10, -1 );
   createMenu( separator(), fileMenu, -1, 15, -1 );
@@ -381,177 +279,188 @@ void SalomeApp_Application::createActions()
   createMenu( separator(), fileMenu, -1, 15, -1 );
   createMenu( PropertiesId, fileMenu, 10, -1 );
   createMenu( separator(), fileMenu, -1, 15, -1 );
-  createMenu( PreferencesId, fileMenu, 15, -1 );
-  createMenu( separator(), fileMenu, -1, 15, -1 );
 
-  /*
-  createMenu( separator(), fileMenu, -1, 100, -1 );
-  createMenu( MRUId, fileMenu, 100, -1 );
-  createMenu( separator(), fileMenu, -1, 100, -1 );
-  */
+  int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, MenuToolsId, 50 );
+  createMenu( CatalogGenId, toolsMenu, 10, -1 );
+  createMenu( RegDisplayId, toolsMenu, 10, -1 );
+  createMenu( separator(), toolsMenu, -1, 15, -1 );
 }
 
-void SalomeApp_Application::onModuleActivation( QAction* a )
+/*! Purpose : SLOT. Open new document with \a aName.*/
+bool SalomeApp_Application::onOpenDoc( const QString& aName )
 {
-  if ( !a )
-    return;
-
-  QString modName = a->menuText();
-  if ( modName == tr( "APP_NAME" ) )
-    modName = QString::null;
-
-  // Force user to create/open a study before module activation
-  QMap<QString, QString> iconMap;
-  moduleIconNames( iconMap );
-  QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
-  if ( icon.isNull() )
-    icon = resourceMgr()->loadPixmap( "SalomeApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
-
-  bool cancelled = false;
-  while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
-    SalomeApp_ModuleDlg aDlg( desktop(), modName, icon );
-    int res = aDlg.exec();
-
-    switch ( res ){
-    case 1:
-      onNewDoc();
-      break;
-    case 2:
-      onOpenDoc();
-      break;
-    case 3:
-      //onLoadStudy();
-      //break;
-    case 0:
-    default:
-      putInfo( tr("INF_CANCELLED") );
-      myActions[QString()]->setOn( true );
-      cancelled = true;
+  bool res = false, toOpen = true, isAlreadyOpen = false;
+
+  // Look among opened studies
+  if (activeStudy()) { // at least one study is opened
+    SUIT_Session* aSession = SUIT_Session::session();
+    QPtrList<SUIT_Application> aAppList = aSession->applications();
+    QPtrListIterator<SUIT_Application> it (aAppList);
+    SUIT_Application* aApp = 0;
+    // iterate on all applications
+    for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
+      if (aApp->activeStudy()->studyName() == aName) {
+        isAlreadyOpen = true; // Already opened, ask user what to do
+
+        // The document ... is already open.
+        // Do you want to reload it?
+        int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
+                                             tr("QUE_DOC_ALREADYOPEN").arg(aName),
+                                             tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
+        if (aAnswer == 1) { // reload
+          if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
+            // Opened in THIS (active) application.
+            STD_Application* app1 = (STD_Application*)aAppList.at(0);
+            STD_Application* app2 = (STD_Application*)aAppList.at(1);
+            if (!app1 || !app2) {
+              // Error
+              return false;
+            }
+            if (app1->activeStudy()->studyName() == aName) {
+              // app1 is this application, we need another one
+              app1 = app2;
+            }
+            // Close document of this application. This application will be destroyed.
+            onCloseDoc(/*ask = */false);
+            // Open the file with another application, as this one will be destroyed.
+            return app1->onOpenDoc(aName);
+          } else {
+            // Opened in another application.
+            STD_Application* app = (STD_Application*)aApp;
+            if (app)
+              app->onCloseDoc(/*ask = */false);
+          }
+        } else { // do not reload
+          // OK, the study will not be reloaded, but we call
+          // CAM_Application::onOpenDoc( aName ) all the same.
+          // It will activate a desktop of the study <aName>.
+        }
+      }
     }
   }
 
-  if ( !cancelled )
-    activateModule( modName );
-}
-
-QString SalomeApp_Application::defaultModule() const
-{
-  QStringList aModuleNames;
-  modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
-  // If there's the one and only module --> activate it automatically
-  // TODO: Possible improvement - default module can be taken from preferences
-  return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
-}
+  // Look among unloaded studies
+  if (!isAlreadyOpen) {
+    std::vector<std::string> List = studyMgr()->GetOpenStudies();
+
+    QString studyName;
+    for (unsigned int ind = 0; ind < List.size() && !isAlreadyOpen; ind++) {
+      studyName = List[ind].c_str();
+      if (aName == studyName) {
+        // Already exists unloaded, ask user what to do
+        isAlreadyOpen = true;
+
+        // The document ... already exists in the study manager.
+        // Do you want to reload it?
+        int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
+                                             tr("QUE_DOC_ALREADYEXIST").arg(aName),
+                                             tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
+        if (aAnswer == 1) {
+          _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.latin1());
+          if (aStudy)
+            studyMgr()->Close(aStudy);
+        } else {
+          toOpen = false;
+        }
+      }
+    }
+  }
 
-void SalomeApp_Application::onNewWindow()
-{
-  const QObject* obj = sender();
-  if ( !obj || !obj->inherits( "QAction" ) )
-    return;
+  if (toOpen)
+    res = CAM_Application::onOpenDoc( aName );
 
-  QString type;
-  int id = actionId( (QAction*)obj );
-  switch ( id )
+  QAction* a = action( MRUId );
+  if ( a && a->inherits( "QtxMRUAction" ) )
   {
-  case NewGLViewId:
-    type = GLViewer_Viewer::Type();
-    break;
-  case NewPlot2dId:
-    type = Plot2d_Viewer::Type();
-    break;
-  case NewOCCViewId:
-    type = OCCViewer_Viewer::Type();
-    break;
-  case NewVTKViewId:
-    type = VTKViewer_Viewer::Type();
-    break;
+    QtxMRUAction* mru = (QtxMRUAction*)a;
+    if ( res )
+      mru->insert( aName );
+    else
+      mru->remove( aName );
   }
-
-  if ( !type.isEmpty() )
-    createViewManager( type );
+  return res;
 }
 
-//=======================================================================
-// name    : onNewDoc
-// Purpose : SLOT. Create new document
-//=======================================================================
-void SalomeApp_Application::onNewDoc()
+/*!SLOT. Load document.*/
+void SalomeApp_Application::onLoadDoc()
 {
-  SUIT_Study* study = activeStudy();
+  QString name, studyname, ext;
 
-  saveWindowsGeometry();
+  STD_LoadStudiesDlg aDlg( desktop(), TRUE);
 
-  CAM_Application::onNewDoc();
+  std::vector<std::string> List = studyMgr()->GetOpenStudies();
 
-  if ( !study ) // new study will be create in THIS application
-  {
-    updateWindows();
-    updateViewManagers();
+  SUIT_Session* aSession = SUIT_Session::session();
+  QPtrList<SUIT_Application> aAppList = aSession->applications();
+  SUIT_Application* aApp = 0;
+
+  for (unsigned int ind = 0; ind < List.size(); ind++) {
+     studyname = List[ind].c_str();
+     //Add to list only unloaded studies
+     bool isAlreadyOpen = false;
+     for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
+       {
+        aApp = it.current();
+        if(!aApp || !aApp->activeStudy()) continue;
+        if ( aApp->activeStudy()->studyName() == studyname ) isAlreadyOpen = true;
+       }
+
+     if ( !isAlreadyOpen ) aDlg.ListComponent->insertItem( studyname );
   }
-}
 
-//=======================================================================
-// name    : onOpenDoc
-// Purpose : SLOT. Open new document
-//=======================================================================
-void SalomeApp_Application::onOpenDoc()
-{
-  SUIT_Study* study = activeStudy();
-  saveWindowsGeometry();
+  int retVal = aDlg.exec();
+  studyname = aDlg.ListComponent->currentText();
 
-  CAM_Application::onOpenDoc();
+  if (retVal == QDialog::Rejected)
+    return;
 
-  if ( !study ) // new study will be create in THIS application
-  {
-    updateWindows();
-    updateViewManagers();
-  }
-}
+  if ( studyname.isNull() || studyname.isEmpty() )
+    return;
 
-bool SalomeApp_Application::onOpenDoc( const QString& aName )
-{
-  bool res = CAM_Application::onOpenDoc( aName );
+  name = studyname;
+#ifndef WNT
+  //this code replace marker of windows drive and path become invalid therefore 
+  // defines placed there
+  name.replace( QRegExp(":"), "/" );
+#endif
 
-  QAction* a = action( MRUId );
-  if ( a && a->inherits( "QtxMRUAction" ) )
+  if( LightApp_Application::onLoadDoc( name ) )
   {
-    QtxMRUAction* mru = (QtxMRUAction*)a;
-    if ( res )
-      mru->insert( aName );
-    else
-      mru->remove( aName );
+     updateWindows();
+     updateViewManagers();
+     updateObjectBrowser(true);
   }
-  return res;
 }
 
-bool SalomeApp_Application::onLoadDoc( const QString& aName )
+/*!
+  \brief Close application.
+*/
+void SalomeApp_Application::onExit()
 {
-  bool res = CAM_Application::onLoadDoc( aName );
+  bool killServers = false;
+  bool result = true;
 
-  /*jfa tmp:QAction* a = action( MRUId );
-  if ( a && a->inherits( "QtxMRUAction" ) )
-  {
-    QtxMRUAction* mru = (QtxMRUAction*)a;
-    if ( res )
-      mru->insert( aName );
-    else
-      mru->remove( aName );
-  }*/
-  return res;
+  if ( exitConfirmation() ) {
+    SalomeApp_ExitDlg dlg( desktop() );
+    result = dlg.exec() == QDialog::Accepted;
+    killServers = dlg.isServersShutdown();
+  }
+  
+  if ( result )
+    SUIT_Session::session()->closeSession( SUIT_Session::ASK, killServers );
 }
 
-void SalomeApp_Application::onSelection()
+/*!SLOT. Load document with \a aName.*/
+bool SalomeApp_Application::onLoadDoc( const QString& aName )
 {
-  onSelectionChanged();
-
-  if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
-    ((SalomeApp_Module*)activeModule())->selectionChanged();
+  return LightApp_Application::onLoadDoc( aName );
 }
 
-void SalomeApp_Application::onCopy() 
+/*!SLOT. Copy objects to study maneger from selection maneger..*/
+void SalomeApp_Application::onCopy()
 {
   SALOME_ListIO list;
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  LightApp_SelectionMgr* mgr = selectionMgr();
   mgr->selectedObjects(list);
   
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
@@ -560,7 +469,7 @@ void SalomeApp_Application::onCopy()
   _PTR(Study) stdDS = study->studyDS();
   if(!stdDS) return;
 
-  SALOME_ListIteratorOfListIO it( list ); 
+  SALOME_ListIteratorOfListIO it( list );
   if(it.More())
     {
       _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
@@ -573,77 +482,130 @@ void SalomeApp_Application::onCopy()
     }
 }
 
-void SalomeApp_Application::onPaste() 
+/*!SLOT. Paste objects to study maneger from selection manager.*/
+void SalomeApp_Application::onPaste()
 {
   SALOME_ListIO list;
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  LightApp_SelectionMgr* mgr = selectionMgr();
   mgr->selectedObjects(list);
-  
+
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
   if(study == NULL) return;
-  
+
   _PTR(Study) stdDS = study->studyDS();
   if(!stdDS) return;
-  
-  SALOME_ListIteratorOfListIO it( list ); 
+
+  if ( stdDS->GetProperties()->IsLocked() ) {
+    SUIT_MessageBox::warn1 ( desktop(),
+                            QObject::tr("WRN_WARNING"),
+                            QObject::tr("WRN_STUDY_LOCKED"),
+                            QObject::tr("BUT_OK") );
+    return;
+  }
+
+  SALOME_ListIteratorOfListIO it( list );
   if(it.More())
     {
       _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
       try {
        studyMgr()->Paste(so);
        updateObjectBrowser( true );
+       updateActions(); //SRN: BugID IPAL9377, case 3
       }
       catch(...) {
       }
     }
 }
 
+/*! Check if the study is locked */
+void SalomeApp_Application::onCloseDoc( bool ask )
+{
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+
+  if (study != NULL) {
+    _PTR(Study) stdDS = study->studyDS(); 
+    if(stdDS && stdDS->IsStudyLocked()) {
+      if ( SUIT_MessageBox::warn2( desktop(),
+                                  QObject::tr( "WRN_WARNING" ),
+                                  QObject::tr( "CLOSE_LOCKED_STUDY" ),
+                                  QObject::tr( "BUT_YES" ), 
+                                  QObject::tr( "BUT_NO" ),
+                                  SUIT_YES, 
+                                  SUIT_NO, 
+                                  SUIT_NO ) == SUIT_NO ) return;
+       
+    }
+  }
+
+  LightApp_Application::onCloseDoc( ask );
+}
+
+/*!Sets enable or disable some actions on selection changed.*/
 void SalomeApp_Application::onSelectionChanged()
 {
    SALOME_ListIO list;
-   SalomeApp_SelectionMgr* mgr = selectionMgr();
+   LightApp_SelectionMgr* mgr = selectionMgr();
    mgr->selectedObjects(list);
-   
+
+   bool canCopy  = false;
+   bool canPaste = false;
+
    SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
-   if(study == NULL) return;
-   
-   _PTR(Study) stdDS = study->studyDS();
-   if(!stdDS) return;
-   
-   QAction* qaction;  
-
-   SALOME_ListIteratorOfListIO it( list ); 
-   if(it.More() && list.Extent() == 1)
-   {
-      _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
+   if (study != NULL) {
+     _PTR(Study) stdDS = study->studyDS();
+
+     if (stdDS) {
+       SALOME_ListIteratorOfListIO it ( list );
 
-      qaction = action(EditCopyId); 
-      if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true);  
-      else qaction->setEnabled(false);         
-     
-      qaction = action(EditPasteId);
-      if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
-      else qaction->setEnabled(false);
-   } 
-   else {
-     qaction = action(EditCopyId); 
-     qaction->setEnabled(false); 
-     qaction = action(EditPasteId);
-     qaction->setEnabled(false);
+       if (it.More() && list.Extent() == 1) {
+         _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
+
+         if ( so ) {
+             canCopy = studyMgr()->CanCopy(so);
+             canPaste = studyMgr()->CanPaste(so);
+         }
+       }
+     }
    }
-}              
-void SalomeApp_Application::onRefresh()
+
+   action(EditCopyId)->setEnabled(canCopy);
+   action(EditPasteId)->setEnabled(canPaste);
+}
+
+/*!Delete references.*/
+void SalomeApp_Application::onDeleteInvalidReferences()
 {
-  updateObjectBrowser( true );
+  SALOME_ListIO aList;
+  LightApp_SelectionMgr* mgr = selectionMgr();
+  mgr->selectedObjects( aList, QString::null, false );
+
+  if( aList.IsEmpty() )
+    return;
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  _PTR(Study) aStudyDS = aStudy->studyDS();
+  _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
+  _PTR(SObject) anObj;
+
+  for( SALOME_ListIteratorOfListIO it( aList ); it.More(); 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() )
+        aStudyBuilder->RemoveReference( aSObject );
+    }
+  updateObjectBrowser();
 }
 
+/*!Private SLOT. */
 void SalomeApp_Application::onOpenWith()
 {
   QApplication::setOverrideCursor( Qt::waitCursor );
   SALOME_ListIO aList;
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  LightApp_SelectionMgr* mgr = selectionMgr();
   mgr->selectedObjects(aList);
   if (aList.Extent() != 1)
     {
@@ -657,29 +619,9 @@ void SalomeApp_Application::onOpenWith()
   QApplication::restoreOverrideCursor();
 }
 
-bool SalomeApp_Application::useStudy(const QString& theName)
-{
-  createEmptyStudy();
-  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
-  bool res = false;
-  if (aStudy)
-    res = aStudy->loadDocument( theName );
-  updateDesktopTitle();
-  updateCommandsStatus();
-  return res;
-}
-
-void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
-{
-  CAM_Application::setActiveStudy( study );
-
-  activateWindows();
-}
-
-//=======================================================================
-// name    : createNewStudy
-// Purpose : Create new study
-//=======================================================================
+/*!
+  Creates new study
+*/
 SUIT_Study* SalomeApp_Application::createNewStudy()
 {
   SalomeApp_Study* aStudy = new SalomeApp_Study( this );
@@ -693,20 +635,12 @@ SUIT_Study* SalomeApp_Application::createNewStudy()
   return aStudy;
 }
 
-//=======================================================================
-// name    : createNewStudy
-// Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu
-//=======================================================================
+/*!
+  Enable/Disable menu items and toolbar buttons. Rebuild menu
+*/
 void SalomeApp_Application::updateCommandsStatus()
 {
-  CAM_Application::updateCommandsStatus();
-
-  for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
-  {
-    QAction* a = action( id );
-    if ( a )
-      a->setEnabled( activeStudy() );
-  }
+  LightApp_Application::updateCommandsStatus();
 
   // Dump study menu
   QAction* a = action( DumpStudyId );
@@ -717,315 +651,104 @@ void SalomeApp_Application::updateCommandsStatus()
   a = action( LoadScriptId );
   if ( a )
     a->setEnabled( activeStudy() );
-  
+
+  // Properties menu
   a = action( PropertiesId );
   if( a )
     a->setEnabled( activeStudy() );
-    
-  a = action(EditCopyId);
-  a->setEnabled(false);              
-  a = action(EditPasteId);
-  a->setEnabled(false);      
-}
-
-//=======================================================================
-// name    : onHelpAbout
-// Purpose : SLOT. Display "About" message box
-//=======================================================================
-void SalomeApp_Application::onHelpAbout()
-{
-  SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
-  dlg->exec();
-  delete dlg;
-}
-
-QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
-{
-  QWidget* wid = 0;
 
-  int sId = studyId;
-  if ( sId < 0 )
-  {
-    if ( !activeStudy() )
-      return 0;
-    else
-      sId = activeStudy()->id();
-  }
-
-  if ( myWindows.contains( flag ) )
-    wid = myWindows[flag]->widget( sId );
+  // Save GUI state menu
+  a = action( SaveGUIStateId );
+  if( a )
+    a->setEnabled( activeStudy() );
 
-  return wid;
+  // update state of Copy/Paste menu items
+  onSelectionChanged();
 }
 
-void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
+/*!
+  \class DumpStudyFileDlg
+  Private class used in Dump Study operation.  Consists 2 check boxes: 
+  "Publish in study" and "Save GUI parameters"
+*/
+class DumpStudyFileDlg : public SUIT_FileDlg
 {
-  if ( !wid )
-    return;
-
-  int sId = studyId;
-  if ( sId < 0 )
+public:
+  DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true ) 
   {
-    if ( !activeStudy() )
-      return;
-    else
-      sId = activeStudy()->id();
+    QHBox* hB = new QHBox( this );
+    myPublishChk = new QCheckBox( tr("PUBLISH_IN_STUDY"), hB );
+    mySaveGUIChk = new QCheckBox( tr("SAVE_GUI_STATE"), hB );
+    QPushButton* pb = new QPushButton(this);      
+    addWidgets( new QLabel("", this), hB, pb );
+    pb->hide();    
   }
+  QCheckBox* myPublishChk;
+  QCheckBox* mySaveGUIChk;
+};
 
-  if ( !myWindows.contains( flag ) )
-  {
-    QMap<int, int> winMap;
-    currentWindows( winMap );
-
-    myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) );
-    if ( winMap.contains( flag ) )
-      desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
-
-    myWindows[flag]->setResizeEnabled( true );
-    myWindows[flag]->setCloseMode( QDockWindow::Always );
-    myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
-  }
+/*!Private SLOT. On dump study.*/
+void SalomeApp_Application::onDumpStudy( )
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if ( !appStudy ) return;
+  _PTR(Study) aStudy = appStudy->studyDS();
 
-  myWindows[flag]->insert( sId, wid );
+  QStringList aFilters;
+  aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
 
-  setWindowShown( flag, !myWindows[flag]->isEmpty() );
-}
-
-void SalomeApp_Application::removeWindow( const int flag, const int studyId )
-{
-  if ( !myWindows.contains( flag ) )
-    return;
-
-  int sId = studyId;
-  if ( sId < 0 )
-  {
-    if ( !activeStudy() )
-      return;
-    else
-      sId = activeStudy()->id();
-  }
-
-  QWidget* wid = myWindows[flag]->widget( sId );
-  myWindows[flag]->remove( sId );
-  delete wid;
-
-  setWindowShown( flag, !myWindows[flag]->isEmpty() );
-}
-
-QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId )
-{
-  QWidget* wid = window( flag, studyId );
-  if ( !wid )
-    addWindow( wid = createWindow( flag ), flag, studyId );
-
-  return wid;
-}
-
-bool SalomeApp_Application::isWindowVisible( const int type ) const
-{
-  bool res = false;
-  if ( myWindows.contains( type ) )
-  {
-    SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop();
-    res = desk && desk->appropriate( myWindows[type] );
-  }
-  return res;
-}
-
-void SalomeApp_Application::setWindowShown( const int type, const bool on )
-{
-  if ( !desktop() || !myWindows.contains( type ) )
-    return;
-
-  QDockWindow* dw = myWindows[type];
-  desktop()->setAppropriate( dw, on );
-  on ? dw->show() : dw->hide();
-}
-
-OB_Browser* SalomeApp_Application::objectBrowser()
-{
-  OB_Browser* ob = 0;
-  QWidget* wid = getWindow( WT_ObjectBrowser );
-  if ( wid->inherits( "OB_Browser" ) )
-    ob = (OB_Browser*)wid;
-  return ob;
-}
-
-LogWindow* SalomeApp_Application::logWindow()
-{
-  LogWindow* lw = 0;
-  QWidget* wid = getWindow( WT_LogWindow );
-  if ( wid->inherits( "LogWindow" ) )
-    lw = (LogWindow*)wid;
-  return lw;
-}
-
-PythonConsole* SalomeApp_Application::pythonConsole()
-{
-  PythonConsole* console = 0;
-  QWidget* wid = getWindow( WT_PyConsole );
-  if ( wid->inherits( "PythonConsole" ) )
-    console = (PythonConsole*)wid;
-  return console;
-}
-
-SalomeApp_Preferences* SalomeApp_Application::preferences() const
-{
-  return preferences( false );
-}
-
-SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create )
-{
-  SUIT_ViewManager* aVM = viewManager( vmType );
-  SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
-
-  if ( anActiveVM && anActiveVM->getType() == vmType )
-    aVM = anActiveVM;
-
-  if ( aVM && create )
-  {
-    if ( !aVM->getActiveView() )
-      aVM->createView();
-    else
-      aVM->getActiveView()->setFocus();
-  }
-  else if ( create )
-    aVM = createViewManager( vmType );
-
-  return aVM;
-}
-
-SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
-{
-  SUIT_ResourceMgr* resMgr = resourceMgr();
-
-  SUIT_ViewManager* viewMgr = 0;
-  if ( vmType == GLViewer_Viewer::Type() )
-  {
-    viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
-    new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
-  }
-  else if ( vmType == Plot2d_Viewer::Type() )
-  {
-    viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
-    viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
-  }
-  else if ( vmType == OCCViewer_Viewer::Type() )
-  {
-    viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
-    SOCC_Viewer* vm = new SOCC_Viewer();
-    vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
-    vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
-    int u( 1 ), v( 1 );
-    vm->isos( u, v );
-    u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
-    v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
-    //    vm->setIsos( u, v );
-    viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
-    new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
-  }
-  else if ( vmType == SVTK_Viewer::Type() )
-  {
-    viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
-    SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
-    vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
-    vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
-    new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
-  }
-
-  if ( !viewMgr )
-    return 0;
-
-  addViewManager( viewMgr );
-  SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
-
-  if ( viewWin && desktop() )
-    viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
-
-  connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
-           this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
-
-  return viewMgr;
-}
-
-void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM )
-{
-  removeViewManager( theVM );
-}
-
-void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy )
-{
-  SUIT_DataObject* aRoot = 0;
-  if ( theStudy && theStudy->root() )
-  {
-    aRoot = theStudy->root();
-    //aRoot->setName( tr( "DATA_MODELS" ) );
-  }
-  if ( objectBrowser() != 0 )
-    objectBrowser()->setRootObject( aRoot );
-
-  activateModule( defaultModule() );
-
-  activateWindows();
-}
-
-void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
-{
-  SUIT_DataObject* aRoot = 0;
-  if ( theStudy && theStudy->root() )
-  {
-    aRoot = theStudy->root();
-    //aRoot->dump();
-  }
-  if ( objectBrowser() != 0 ) {
-    objectBrowser()->setRootObject( aRoot );
-  }
-
-  activateModule( defaultModule() );
-
-  activateWindows();
-
-  emit studyOpened();
-}
-
-void SalomeApp_Application::onStudySaved( SUIT_Study* )
-{
-  emit studySaved();
-}
-
-void SalomeApp_Application::onStudyClosed( SUIT_Study* )
-{
-  emit studyClosed();
-
-  activateModule( "" );
-
-  saveWindowsGeometry();
-}
-
-void SalomeApp_Application::onDumpStudy( )
-{
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
-  if ( !appStudy ) return;
-  _PTR(Study) aStudy = appStudy->studyDS();
-
-  QStringList aFilters;
-  aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
-
-  SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
+  DumpStudyFileDlg* fd = new DumpStudyFileDlg( desktop() );
   fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
-  fd->setFilters( aFilters );  
-  fd->SetChecked(true);
-  fd->exec();
-  QString aFileName = fd->selectedFile();
-  bool toPublish = fd->IsChecked();
+  fd->setFilters( aFilters );
+  fd->myPublishChk->setChecked( true );
+  fd->mySaveGUIChk->setChecked( true );
+  QString aFileName;
+  while (1) {
+    fd->exec();
+    fd->raise();
+    aFileName = fd->selectedFile();
+    if (!aFileName.isEmpty()) {
+      if ( (aFileName.find('-', 0) == -1) && (aFileName.find('!', 0) == -1) && (aFileName.find('?', 0) == -1) &&
+          (aFileName.find('#', 0) == -1) && (aFileName.find('*', 0) == -1) && (aFileName.find('&', 0) == -1)) {
+       break;
+      }
+      else {
+      SUIT_MessageBox::warn1 ( desktop(),
+                              QObject::tr("WRN_WARNING"),
+                              tr("WRN_FILE_NAME_BAD"),
+                              QObject::tr("BUT_OK") );
+      }
+    }
+    else {
+      break;
+    }
+  }
+  bool toPublish = fd->myPublishChk->isChecked();
+  bool toSaveGUI = fd->mySaveGUIChk->isChecked();
   delete fd;
 
-  if(!aFileName.isEmpty()) {
+  if ( !aFileName.isEmpty() ) {
     QFileInfo aFileInfo(aFileName);
-    aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
+    int savePoint;
+    _PTR(AttributeParameter) ap;
+    _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+    if(ip->isDumpPython(appStudy->studyDS())) ip->setDumpPython(appStudy->studyDS()); //Unset DumpPython flag.
+    if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method
+      ip->setDumpPython(appStudy->studyDS());
+      savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point      
+    }
+    bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish);
+    if ( toSaveGUI ) 
+      appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point.
+    if ( !res )
+      SUIT_MessageBox::warn1 ( desktop(),
+                              QObject::tr("WRN_WARNING"),
+                              tr("WRN_DUMP_STUDY_FAILED"),
+                              QObject::tr("BUT_OK") );
   }
 }
 
+/*!Private SLOT. On load script.*/
 void SalomeApp_Application::onLoadScript( )
 {
   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
@@ -1057,294 +780,189 @@ void SalomeApp_Application::onLoadScript( )
   }
 }
 
-void SalomeApp_Application::onPreferences()
+/*!Private SLOT. On save GUI state.*/
+void SalomeApp_Application::onSaveGUIState()
 {
-  QApplication::setOverrideCursor( Qt::waitCursor );
-
-  SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop());
-
-  QApplication::restoreOverrideCursor();
-
-  if ( !prefDlg )
-    return;
-
-  prefDlg->exec();
-
-  delete prefDlg;
-}
-
-void SalomeApp_Application::onMRUActivated( QString aName )
-{
-  onOpenDoc( aName );
-}
-
-void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
-{
-  SalomeApp_Module* sMod = 0;
-  CAM_Module* mod = module( modName );
-  if ( mod && mod->inherits( "SalomeApp_Module" ) )
-    sMod = (SalomeApp_Module*)mod;
-
-  if ( sMod )
-    sMod->preferencesChanged( section, param );
-  else
-    preferencesChanged( section, param );
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if ( study ) {
+    SalomeApp_VisualState( this ).storeState();
+    updateSavePointDataObjects( study );
+    objectBrowser()->updateTree( study->root() );
+  }
+  updateActions();
 }
 
+/*!Gets file filter.
+ *\retval QString "(*.hdf)"
+ */
 QString SalomeApp_Application::getFileFilter() const
 {
   return "(*.hdf)";
 }
 
-void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s )
-{
-  CAM_Application::beforeCloseDoc( s );
-
-  for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
-    removeWindow( itr.key(), s->id() );
-}
-
-void SalomeApp_Application::updateActions()
-{
-  updateCommandsStatus();
-}
-
+/*!Create window.*/
 QWidget* SalomeApp_Application::createWindow( const int flag )
 {
   QWidget* wid = 0;
+  if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag);
 
   SUIT_ResourceMgr* resMgr = resourceMgr();
 
   if ( flag == WT_ObjectBrowser )
   {
-    OB_Browser* ob = new OB_Browser( desktop() );
-    ob->setAutoUpdate( true );
-    ob->setAutoOpenLevel( 1 );
-    ob->setCaption( tr( "OBJECT_BROWSER" ) );
-    ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
-    ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
-
-    ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
-
+    OB_Browser* ob = (OB_Browser*)wid;
+    ob->setUpdater( new SalomeApp_Updater() );
+    connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
+    bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
+         autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
     for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
     {
       ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
       ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
                                                    QString().sprintf( "visibility_column_%d", i ), true ) );
     }
-
-    // Create OBSelector
-    new SalomeApp_OBSelector( ob, mySelMgr );
-
-    wid = ob;
-
-    ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+    ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
+    ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
+    ob->resize( desktop()->width()/3, ob->height() );
   }
   else if ( flag == WT_PyConsole )
   {
     PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
     pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
     wid = pyCons;
-
-    //    pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
-  }
-  else if ( flag == WT_LogWindow )
-  {
-    LogWindow* logWin = new LogWindow( desktop() );
-    logWin->setCaption( tr( "LOG_WINDOW" ) );
-    wid = logWin;
-
-    logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+    pyCons->resize( pyCons->width(), desktop()->height()/4 );
+    //pyCons->connectPopupRequest(this, SLOT(onConnectPopupRequest(SUIT_PopupClient*, QContextMenuEvent*)));
   }
-
   return wid;
 }
 
-void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
-{
-  aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
-  aMap.insert( WT_PyConsole, Qt::DockBottom );
-  //  aMap.insert( WT_LogWindow, Qt::DockBottom );
-}
-
-void SalomeApp_Application::defaultViewManagers( QStringList& ) const
+/*!Create preferences.*/
+void SalomeApp_Application::createPreferences( LightApp_Preferences* pref )
 {
-}
+  LightApp_Application::createPreferences(pref);
 
-SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const
-{
-  if ( myPrefs )
-    return myPrefs;
-
-  SalomeApp_Application* that = (SalomeApp_Application*)this;
+  if ( !pref )
+    return;
 
-  if ( !_prefs_ && crt )
+  int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
+  int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
+  int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
+  for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
   {
-    _prefs_ = new SalomeApp_Preferences( resourceMgr() );
-    that->createPreferences( _prefs_ );
+    pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols,
+                         LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
   }
+  pref->setItemProperty( defCols, "columns", 1 );
 
-  that->myPrefs = _prefs_;
-
-  QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
-  for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
-  {
-    if ( !appIt.current()->inherits( "SalomeApp_Application" ) )
-      continue;
-
-    SalomeApp_Application* app = (SalomeApp_Application*)appIt.current();
-
-    QStringList modNameList;
-    app->modules( modNameList, false );
-    for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
-    {
-      int id = _prefs_->addPreference( *it );
-      _prefs_->setProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
-    }
+  // adding preference to LightApp_Application handled preferences..  a bit of hacking with resources..
+  int genTab = pref->addPreference( LightApp_Application::tr( "PREF_TAB_GENERAL" ), salomeCat );
+  int studyGroup = pref->addPreference( LightApp_Application::tr( "PREF_GROUP_STUDY" ), genTab );
+  pref->addPreference( tr( "PREF_STORE_VISUAL_STATE" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_visual_state" );
+}
 
-    ModuleList modList;
-    app->modules( modList );
-    for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
-    {
-      SalomeApp_Module* mod = 0;
-      if ( itr.current()->inherits( "SalomeApp_Module" ) )
-       mod = (SalomeApp_Module*)itr.current();
+/*!Update desktop title.*/
+void SalomeApp_Application::updateDesktopTitle() {
+  QString aTitle = applicationName();
+  QString aVer = applicationVersion();
+  if ( !aVer.isEmpty() )
+    aTitle += QString( " " ) + aVer;
 
-      if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
-       mod->createPreferences();
+  if ( activeStudy() )
+  {
+    QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
+    if ( !sName.isEmpty() ) {
+      SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+      if ( study ) {
+        _PTR(Study) stdDS = study->studyDS();
+        if(stdDS) {
+         if ( stdDS->GetProperties()->IsLocked() ) {
+           aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
+         } else {
+           aTitle += QString( " - [%1]" ).arg( sName );
+         }
+        }
+      }
     }
   }
 
-  connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
-           this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
-
-  return myPrefs;
+  desktop()->setCaption( aTitle );
 }
 
-void SalomeApp_Application::moduleAdded( CAM_Module* mod )
+/*!
+  \brief Show dialog box to propose possible user actions when study is closed.
+  \param docName study name
+  \return chosen action ID
+  \sa closeAction()
+*/
+int SalomeApp_Application::closeChoice( const QString& docName )
 {
-  CAM_Application::moduleAdded( mod );
-
-  SalomeApp_Module* salomeMod = 0;
-  if ( mod && mod->inherits( "SalomeApp_Module" ) )
-    salomeMod = (SalomeApp_Module*)mod;
+  SUIT_MsgDlg dlg( desktop(), tr( "APPCLOSE_CAPTION" ), tr ( "APPCLOSE_DESCRIPTION" ),
+                   QMessageBox::standardIcon( QMessageBox::Information ) );
+  dlg.addButton( tr ( "APPCLOSE_SAVE" ),   CloseSave );
+  dlg.addButton( tr ( "APPCLOSE_CLOSE" ),  CloseDiscard );
+  dlg.addButton( tr ( "APPCLOSE_UNLOAD" ), CloseUnload );
 
-  if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ))
-    salomeMod->createPreferences();
+  return dlg.exec();
 }
 
-void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
+/*!
+  \brief Process user actions selected from the dialog box when study is closed.
+  \param choice chosen action ID
+  \param closePermanently "forced study closing" flag
+  \return operation status
+  \sa closeChoice()
+*/
+bool SalomeApp_Application::closeAction( const int choice, bool& closePermanently )
 {
-  if ( !pref )
-    return;
-
-  int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
-
-  int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
-
-  int obGroup = pref->addPreference( tr( "PREF_GROUP_OBJBROWSER" ), genTab );
-  for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
+  bool res = true;
+  switch( choice )
   {
-    pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), obGroup,
-                         SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
+  case CloseSave:
+    if ( activeStudy()->isSaved() )
+      onSaveDoc();
+    else if ( !onSaveAsDoc() )
+      res = false;
+    break;
+  case CloseDiscard:
+    break;
+  case CloseUnload:
+    closePermanently = false;
+    break;
+  case CloseCancel:
+  default:
+    res = false;
   }
-  pref->setProperty( obGroup, "columns", 1 );
-
-  int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
-
-  int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
-
-  int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
-  pref->setProperty( occGroup, "columns", 1 );
-  pref->setProperty( vtkGroup, "columns", 1 );
-
-  int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
-                                  SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
-  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
-                      SalomeApp_Preferences::Color, "OCCViewer", "background" );
-
-  pref->setProperty( occTS, "min", 1 );
-  pref->setProperty( occTS, "max", 150 );
-
-  int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
-                                 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
-  int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
-                                 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
-
-  pref->setProperty( isoU, "min", 0 );
-  pref->setProperty( isoU, "max", 100000 );
-
-  pref->setProperty( isoV, "min", 0 );
-  pref->setProperty( isoV, "max", 100000 );
-
-  int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
-                                  SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
-  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
-                      SalomeApp_Preferences::Color, "VTKViewer", "background" );
-
-  pref->setProperty( vtkTS, "min", 1 );
-  pref->setProperty( vtkTS, "max", 150 );
+  return res;
 }
 
-void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
+/*!
+  \brief Get module activation actions
+  \return map <action_id><action_name> where
+  - action_id is unique non-zero action identifier
+  - action_name is action title
+  \sa moduleActionSelected()
+*/
+QMap<int, QString> SalomeApp_Application::activateModuleActions() const
 {
-  SUIT_ResourceMgr* resMgr = resourceMgr();
-  if ( !resMgr )
-    return;
-
-  if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
-  {
-    int sz = resMgr->integerValue( sec, param, -1 );
-    QPtrList<SUIT_ViewManager> lst;
-    viewManagers( OCCViewer_Viewer::Type(), lst );
-    for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
-    {
-      SUIT_ViewModel* vm = it.current()->getViewModel();
-      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
-       continue;
-
-      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
-      occVM->setTrihedronSize( sz );
-      occVM->getAISContext()->UpdateCurrentViewer();
-    }
-  }
-
-  if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
-  {
-    int sz = resMgr->integerValue( sec, param, -1 );
-    QPtrList<SUIT_ViewManager> lst;
-    viewManagers( SVTK_Viewer::Type(), lst );
-    for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
-    {
-      SUIT_ViewModel* vm = it.current()->getViewModel();
-      if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
-       continue;
-
-      SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm;
-      vtkVM->setTrihedronSize( sz );
-      vtkVM->Repaint();
-    }
-  }
-  /*
-  if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
-  {
-    QPtrList<SUIT_ViewManager> lst;
-    viewManagers( OCCViewer_Viewer::Type(), lst );
-    int u = resMgr->integerValue( sec, "iso_number_u" );
-    int v = resMgr->integerValue( sec, "iso_number_v" );
-    for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
-      ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
-  }
-  */
+  QMap<int, QString> opmap = LightApp_Application::activateModuleActions();
+  opmap.insert( LoadStudyId,  tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+  return opmap;
 }
 
-void SalomeApp_Application::afterCloseDoc()
+/*!
+  \brief Process module activation action.
+  \param id action identifier
+  \sa activateModuleActions()
+*/
+void SalomeApp_Application::moduleActionSelected( const int id )
 {
-  updateWindows();
-
-  CAM_Application::afterCloseDoc();
+  if ( id == LoadStudyId )
+    onLoadDoc();
+  else
+    LightApp_Application::moduleActionSelected( id );
 }
 
+/*!Gets CORBA::ORB_var*/
 CORBA::ORB_var SalomeApp_Application::orb()
 {
   ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
@@ -1352,252 +970,415 @@ CORBA::ORB_var SalomeApp_Application::orb()
   return _orb;
 }
 
+/*!Create and return SALOMEDS_StudyManager.*/
 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
 {
-  static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
-  return _sm;
+  static _PTR(StudyManager) _sm;
+  if(!_sm) _sm = ClientFactory::StudyManager();
+  return _sm.get();
 }
 
+/*!Create and return SALOME_NamingService.*/
 SALOME_NamingService* SalomeApp_Application::namingService()
 {
   static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
   return _ns;
 }
 
+/*!Create and return SALOME_LifeCycleCORBA.*/
 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
 {
   static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
   return _lcc;
 }
 
+/*!Return default engine IOR for light modules*/
 QString SalomeApp_Application::defaultEngineIOR()
 {
-  // Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
+  /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
   QString anIOR( "" );
   CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
   if ( !CORBA::is_nil( anEngine ) )
-    anIOR = orb()->object_to_string( anEngine );
+  {
+    CORBA::String_var objStr = orb()->object_to_string( anEngine );
+    anIOR = QString( objStr.in() );
+  }
   return anIOR;
 }
 
-void SalomeApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
+/*!Private SLOT. On preferences.*/
+void SalomeApp_Application::onProperties()
 {
-  iconMap.clear();
-
-  SUIT_ResourceMgr* resMgr = resourceMgr();
-  if ( !resMgr )
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if( !study )
     return;
 
-  QStringList modList;
-  modules( modList, false );
+  _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
+  SB->NewCommand();
 
-  for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
-  {
-    QString modName = *it;
-    QString modIntr = moduleName( modName );
-    QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
+  SalomeApp_StudyPropertiesDlg aDlg( desktop() );
+  int res = aDlg.exec();
+  if( res==QDialog::Accepted && aDlg.isChanged() )
+    SB->CommitCommand();
+  else
+    SB->AbortCommand();
 
-    if ( modIcon.isEmpty() )
-      continue;
+  //study->updateCaptions();
+  updateDesktopTitle();
+  updateActions();
+}
+
+/*!Insert items in popup, which necessary for current application*/
+void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
+{
+  LightApp_Application::contextMenuPopup( type, thePopup, title );
 
-    if ( SUIT_Tools::extension( modIcon ).isEmpty() )
-      modIcon += QString( ".png" );
+  OB_Browser* ob = objectBrowser();
+  if ( !ob || type != ob->popupClientType() )
+    return;
 
-    iconMap.insert( modName, modIcon );
+  // Get selected objects
+  SALOME_ListIO aList;
+  LightApp_SelectionMgr* mgr = selectionMgr();
+  mgr->selectedObjects( aList, QString::null, false );
+
+  // add GUI state commands: restore, rename
+  if ( aList.Extent() == 1 && aList.First()->hasEntry() && 
+       QString( aList.First()->getEntry() ).startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) {
+    thePopup->insertSeparator();
+    thePopup->insertItem( tr( "MEN_RESTORE_VS" ), this, SLOT( onRestoreGUIState() ) );
+    thePopup->insertItem( tr( "MEN_RENAME_VS" ),  this, SLOT( onRenameGUIState() ) );
+    thePopup->insertItem( tr( "MEN_DELETE_VS" ),  this, SLOT( onDeleteGUIState() ) );
   }
-}
 
-void SalomeApp_Application::updateModuleActions()
-{
-  QString modName;
-  if ( activeModule() )
-    modName = activeModule()->moduleName();
+  // "Delete reference" item should appear only for invalid references
 
-  if ( myActions.contains( modName ) )
-    myActions[modName]->setOn( true );
-}
+  // isInvalidRefs will be true, if at least one of selected objects is invalid reference
+  bool isInvalidRefs = false;
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  _PTR(Study) aStudyDS = aStudy->studyDS();
+  _PTR(SObject) anObj;
 
-void SalomeApp_Application::currentWindows( QMap<int, int>& winMap ) const
-{
-  winMap.clear();
-  if ( !activeStudy() )
-    return;
+  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 ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
-    ((SalomeApp_Module*)activeModule())->windows( winMap );
-  else
-    defaultWindows( winMap );
-}
+      if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
+       isInvalidRefs = true;
+    }
 
-void SalomeApp_Application::currentViewManagers( QStringList& lst ) const
-{
-  lst.clear();
-  if ( !activeStudy() )
+  // Add "Delete reference" item to popup
+  if ( isInvalidRefs )
+  {
+    thePopup->insertSeparator();
+    thePopup->insertItem( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
     return;
+  }
 
-  if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
-    ((SalomeApp_Module*)activeModule())->viewManagers( lst );
-  else
-    defaultViewManagers( lst );
+  aList.Clear();
+  mgr->selectedObjects( aList );
+
+  // "Activate module" item should appear only if it's necessary
+  if (aList.Extent() != 1)
+    return;
+  Handle(SALOME_InteractiveObject) aIObj = aList.First();
+  // 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" ) ) )
+    return;
+  QString aModuleName(aIObj->getComponentDataType());
+  QString aModuleTitle = moduleTitle(aModuleName);
+  CAM_Module* currentModule = activeModule();
+  if (currentModule && currentModule->moduleName() == aModuleTitle)
+    return;
+  if ( !aModuleTitle.isEmpty() )
+    thePopup->insertItem( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
 }
 
-void SalomeApp_Application::updateWindows()
+/*!Update obect browser:
+ 1.if 'updateModels' true, update existing data models;
+ 2. update "non-existing" (not loaded yet) data models;
+ 3. update object browser if it exists */
+void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
 {
-  QMap<int, int> winMap;
-  currentWindows( winMap );
+  // update "non-existing" (not loaded yet) data models
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  if ( study )
+  {
+    _PTR(Study) stdDS = study->studyDS();
+    if( stdDS )
+    {
+      for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() ) 
+      {
+       _PTR(SComponent) aComponent ( it->Value() );
+
+       if ( aComponent->ComponentDataType() == "Interface Applicative" )
+         continue; // skip the magic "Interface Applicative" component
 
-  for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
-    getWindow( it.key() );
+       OB_Browser* ob = static_cast<OB_Browser*>( getWindow( WT_ObjectBrowser ));
+       const bool isAutoUpdate = ob->isAutoUpdate();
+       ob->setAutoUpdate( false );
+       SalomeApp_DataModel::synchronize( aComponent, study );
+       ob->setAutoUpdate( isAutoUpdate );
+        //SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
+      }
+    }
+  }
 
-  loadWindowsGeometry();
+  // create data objects that correspond to GUI state save points
+  if ( study ) updateSavePointDataObjects( study );
 
-  for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
-    setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
+  // update existing data models (already loaded SComponents)
+  LightApp_Application::updateObjectBrowser( updateModels );
 }
 
-void SalomeApp_Application::updateViewManagers()
+/*!Display Catalog Genenerator dialog */
+void SalomeApp_Application::onCatalogGen()
 {
-  QStringList lst;
-  currentViewManagers( lst );
-
-  for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
-    getViewManager( *it, true );
+  ToolsGUI_CatalogGeneratorDlg aDlg( desktop() );
+  aDlg.exec();
 }
 
-void SalomeApp_Application::loadWindowsGeometry()
+/*!Display Registry Display dialog */
+void SalomeApp_Application::onRegDisplay()
 {
-  QtxDockAction* dockMgr = 0;
-
-  QAction* a = action( ViewWindowsId );
-  if ( a && a->inherits( "QtxDockAction" ) )
-    dockMgr = (QtxDockAction*)a;
+  CORBA::ORB_var anOrb = orb();
+  ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop(), "Registry" );
+  regWnd->show();
+  regWnd->raise();
+  regWnd->setActiveWindow();
+}
 
-  if ( !dockMgr )
-    return;
+/*!find original object by double click on item */
+void SalomeApp_Application::onDblClick( QListViewItem* it )
+{
+  OB_ListItem* item = dynamic_cast<OB_ListItem*>( it );
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
 
-  QString modName;
-  if ( activeModule() )
-    modName = moduleLibrary( activeModule()->moduleName(), false );
+  if( study && item )
+  {
+    SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
+    if( !obj )
+      return;
 
-  QString section = QString( "windows_geometry" );
-  if ( !modName.isEmpty() )
-    section += QString( "." ) + modName;
+    QString entry = obj->entry();
+    _PTR(SObject) sobj = study->studyDS()->FindObjectID( entry.latin1() ), ref;
 
-  dockMgr->loadGeometry( resourceMgr(), section, false );
-  dockMgr->restoreGeometry();
+    if( sobj && sobj->ReferencedObject( ref ) )
+    {
+      entry = ref->GetID().c_str();
+      QListViewItemIterator anIt( item->listView() );
+      for( ; anIt.current(); anIt++ )
+      {
+       OB_ListItem* item = dynamic_cast<OB_ListItem*>( anIt.current() );
+       if( !item )
+         continue;
+
+       SalomeApp_DataObject* original = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
+       if( original->entry()!=entry )
+         continue;
+
+       OB_Browser* br = objectBrowser();
+       br->setSelected( original );
+       SUIT_DataObject* p = original->parent();
+       while( p )
+       {
+         br->setOpen( p );
+         p = p->parent();
+       }
+       break;
+      }
+    }
+  }
 }
 
-void SalomeApp_Application::saveWindowsGeometry()
+/*!
+  Creates new view manager
+  \param type - type of view manager
+*/
+SUIT_ViewManager* SalomeApp_Application::newViewManager(const QString& type)
 {
-  QtxDockAction* dockMgr = 0;
-
-  QAction* a = action( ViewWindowsId );
-  if ( a && a->inherits( "QtxDockAction" ) )
-    dockMgr = (QtxDockAction*)a;
-
-  if ( !dockMgr )
-    return;
-
-  QString modName;
-  if ( activeModule() )
-    modName = moduleLibrary( activeModule()->moduleName(), false );
+  return createViewManager(type);
+}
 
-  QString section = QString( "windows_geometry" );
-  if ( !modName.isEmpty() )
-    section += QString( "." ) + modName;
 
-  dockMgr->storeGeometry();
-  dockMgr->saveGeometry( resourceMgr(), section, false );
+/*!Global utility funciton, returns selected GUI Save point object's ID */
+int getSelectedSavePoint( const LightApp_SelectionMgr* selMgr )
+{
+  SALOME_ListIO aList;
+  selMgr->selectedObjects( aList );
+  Handle(SALOME_InteractiveObject) aIObj = aList.First();
+  QString entry( aIObj->getEntry() );
+  QString startStr = QObject::tr( "SAVE_POINT_DEF_NAME" );
+  if ( !entry.startsWith( startStr ) ) // it's a "GUI state" object
+    return -1;
+  bool ok; // conversion to integer is ok?
+  int savePoint = entry.right( entry.length() - startStr.length() ).toInt( &ok );
+  return ok ? savePoint : -1;
 }
 
-void SalomeApp_Application::activateWindows()
+/*!Called on Restore GUI State popup command*/
+void SalomeApp_Application::onRestoreGUIState()
 {
-  if ( activeStudy() )
-  {
-    for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
-      itr.data()->activate( activeStudy()->id() );
-  }
+  int savePoint = ::getSelectedSavePoint( selectionMgr() );
+  if ( savePoint == -1 ) 
+    return;  
+  SalomeApp_VisualState( this ).restoreState( savePoint );
 }
 
-void SalomeApp_Application::onProperties()
+/*!Called on Rename GUI State popup command*/
+void SalomeApp_Application::onRenameGUIState()
 {
+  int savePoint = ::getSelectedSavePoint( selectionMgr() );
+  if ( savePoint == -1 ) 
+    return;  
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
-  if( !study )
+  if ( !study ) 
     return;
 
-  _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
-  SB->NewCommand();
+  QString newName = LightApp_NameDlg::getName( desktop(), study->getNameOfSavePoint( savePoint ) );
+  if ( !newName.isNull() && !newName.isEmpty() ) {
+    study->setNameOfSavePoint( savePoint, newName );
+    updateSavePointDataObjects( study );
+    objectBrowser()->updateTree( study->root() );
+  }
+}
 
-  SalomeApp_StudyPropertiesDlg aDlg( desktop() );
-  int res = aDlg.exec();
-  if( res==QDialog::Accepted && aDlg.isChanged() )
-    SB->CommitCommand();
-  else
-    SB->AbortCommand();
 
-  //study->updateCaptions();
+/*!Called on Delete GUI State popup command*/
+void SalomeApp_Application::onDeleteGUIState()
+{
+  int savePoint = ::getSelectedSavePoint( selectionMgr() );
+  if ( savePoint == -1 ) 
+    return;  
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if ( !study ) 
+    return;
+  
+  study->removeSavePoint( savePoint );
+  updateSavePointDataObjects( study );
 }
 
-QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters, 
-                                           const QString& caption, QWidget* parent )
+/*!Called on Save study operation*/
+void SalomeApp_Application::onStudySaved( SUIT_Study* study )
 {
-  if ( !parent )
-    parent = desktop();
-  QStringList fls = QStringList::split( ";;", filters, false );
-  return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
+  LightApp_Application::onStudySaved( study );
+
+  if ( objectBrowser() ) {
+    updateSavePointDataObjects( dynamic_cast<SalomeApp_Study*>( study ) );
+    objectBrowser()->updateTree( study->root() );
+  }
 }
 
-QString SalomeApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
+/*!Called on Open study operation*/
+void SalomeApp_Application::onStudyOpened( SUIT_Study* study )
 {
-  if ( !parent )
-    parent = desktop();
-  return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
+  LightApp_Application::onStudyOpened( study );
+
+  if ( objectBrowser() ) {
+    updateSavePointDataObjects( dynamic_cast<SalomeApp_Study*>( study ) );
+    objectBrowser()->updateTree( study->root() );
+  }
 }
 
-QStringList SalomeApp_Application::getOpenFileNames( const QString& initial, const QString& filters, 
-                                                    const QString& caption, QWidget* parent )
+/*! utility function.  returns true if list view item that correspond to given SUIT_DataObject is open.
+ only first level items are traversed */
+bool isListViewItemOpen( QListView* lv, const SUIT_DataObject* dobj )
 {
-  if ( !parent )
-    parent = desktop();
-  QStringList fls = QStringList::split( ";;", filters, false );
-  return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
+  if ( !lv || !dobj )
+    return false;
+
+  QListViewItem* item = lv->firstChild();
+  while ( item ) {
+    OB_ListItem* ob_item = dynamic_cast<OB_ListItem*>( item );
+    if ( ob_item && ob_item->dataObject() == dobj )
+      return ob_item->isOpen();
+    item = item->nextSibling();
+  }
+  return false;
 }
 
-void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
+/*! updateSavePointDataObjects: syncronize data objects that correspond to save points (gui states)*/
+void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study )
 {
-  CAM_Application::contextMenuPopup( type, thePopup, title );
-  thePopup->insertSeparator();
-  thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
-  
-  // "Activate module" item should appear only if it's necessary
   OB_Browser* ob = objectBrowser();
-  if ( !ob || type != ob->popupClientType() )
+
+  if ( !study || !ob )
     return;
-  SALOME_ListIO aList;
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
-  mgr->selectedObjects(aList);
-  if (aList.Extent() != 1)
+
+  // find GUI states root object
+  SUIT_DataObject* guiRootObj = 0;
+  DataObjectList ch; 
+  study->root()->children( ch ); 
+  DataObjectList::const_iterator it = ch.begin(), last = ch.end();
+  for ( ; it != last ; ++it ) {
+    if ( dynamic_cast<SalomeApp_SavePointRootObject*>( *it ) ) {
+      guiRootObj = *it;
+      break;
+    }
+  }
+  std::vector<int> savePoints = study->getSavePoints();
+  // case 1: no more save points but they existed in study's tree
+  if ( savePoints.empty() && guiRootObj ) {
+    delete guiRootObj;
     return;
-  Handle(SALOME_InteractiveObject) aIObj = aList.First();
-  QString aModuleName(aIObj->getComponentDataType());
-  QString aModuleTitle = moduleTitle(aModuleName);
-  CAM_Module* currentModule = activeModule();
-  if (currentModule && currentModule->moduleName() == aModuleTitle)
+  }
+  // case 2: no more save points but root does not exist either
+  if ( savePoints.empty() && !guiRootObj )
     return;
-  thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
+  // case 3: save points but no root for them - create it
+  if ( !savePoints.empty() && !guiRootObj )
+    guiRootObj = new SalomeApp_SavePointRootObject( study->root() );
+  // case 4: everything already exists.. here may be a problem: we want "GUI states" root object
+  // to be always the last one in the tree.  Here we check - if it is not the last one - remove and
+  // re-create it.
+  if ( guiRootObj->nextBrother() ) {
+    study->root()->removeChild(guiRootObj);
+    study->root()->appendChild(guiRootObj);
+    //study->root()->dump();
+  }
+
+  // store data objects in a map id-to-DataObject
+  QMap<int,SalomeApp_SavePointObject*> mapDO;
+  ch.clear(); 
+  guiRootObj->children( ch ); 
+  for( it = ch.begin(), last = ch.end(); it != last ; ++it ) {
+    SalomeApp_SavePointObject* dobj = dynamic_cast<SalomeApp_SavePointObject*>( *it );
+    if ( dobj )
+      mapDO[dobj->getId()] = dobj;
+  }
+
+  // iterate new save points.  if DataObject with such ID not found in map - create DataObject
+  // if in the map - remove it from map.  
+  for ( int i = 0; i < savePoints.size(); i++ )
+    if ( !mapDO.contains( savePoints[i] ) )
+      new SalomeApp_SavePointObject( guiRootObj, savePoints[i], study );
+    else
+      mapDO.remove( savePoints[i] );
+
+  // delete DataObjects that are still in the map -- their IDs were not found in data model
+  for ( QMap<int,SalomeApp_SavePointObject*>::Iterator it = mapDO.begin(); it != mapDO.end(); ++it )
+    delete it.data();
 }
 
-void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
+/*! Check data object */
+bool SalomeApp_Application::checkDataObject(LightApp_DataObject* theObj)
 {
-  if ( updateModels ) 
-  {
-    for ( ModuleListIterator it = modules(); it.current(); ++it )
-    {    
-      CAM_DataModel* camDM = it.current()->dataModel();
-      if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
-        ((SalomeApp_DataModel*)camDM)->update();
-    }
-  }
-  if ( objectBrowser() )
-    objectBrowser()->updateTree();
+  if (theObj)
+    return true;
+
+  return false;
 }
+
+/*! Process standard messages from desktop */
+void SalomeApp_Application::onDesktopMessage( const QString& message )
+{
+  // update object browser
+  if ( message.lower() == "updateobjectbrowser" || 
+       message.lower() == "updateobjbrowser" )
+    updateObjectBrowser();
+}
+