Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / src / SALOMEGUI / QAD_Desktop.cxx
index 3703c9d4c7ac496b65e01e3c6f61cee3dc443a0c..189665a8e367f45ae0dda69484e9b97d77557de6 100644 (file)
@@ -35,8 +35,6 @@ using namespace std;
 # include "Utils_SINGLETON.hxx"
 
 #define         INCLUDE_MENUITEM_DEF
-#define  DEFAULT_BROWSER "mozilla"
-
 
 #include "QAD.h"
 #include "QAD_Help.h"
@@ -59,7 +57,6 @@ using namespace std;
 #include "SALOMEGUI_OpenWith.h"
 #include "SALOMEGUI_StudyPropertiesDlg.h"
 #include "SALOMEGUI_TrihedronSizeDlg.h"
-#include "SALOMEGUI_ExternalBrowserDlg.h"
 #include "SALOMEGUI_LoadStudiesDlg.h"
 #include "SALOME_Selection.h"
 #include "SALOME_InteractiveObject.hxx"
@@ -69,7 +66,6 @@ using namespace std;
 #include "utilities.h"
 
 #include "SALOMEGUI_CloseDlg.h"
-#include "SALOMEGUI_ActivateComponentDlg.h"
 
 // QT Includes
 #include <qlabel.h>
@@ -91,7 +87,6 @@ using namespace std;
 #include <qfontdialog.h>
 #include <qlineedit.h>
 #include <qdatetime.h>
-#include <qthread.h>
 
 #if QT_VERSION > 300
   #include <qlistbox.h>
@@ -103,6 +98,8 @@ using namespace std;
 #include <OSD_Function.hxx>
 #include <TCollection_AsciiString.hxx>
 
+static const char* SEPARATOR    = ":";
+
 extern "C"
 {
 # include <string.h>
@@ -267,14 +264,27 @@ myQueryClose( true )
     /* find component icon */
     QString iconfile = strdup(list_composants[ind].moduleicone) ;
     QString modulename = strdup(list_composants[ind].modulename) ;
+    QString moduleusername = strdup(list_composants[ind].moduleusername) ;
+
+    //    MESSAGE ( " MODULE = " << modulename )
+    //    MESSAGE ( " MODULE icon = " << iconfile )
+    //    MESSAGE ( " MODULE username = " << moduleusername )
+
+    if ( mapComponentName.contains( moduleusername ) ) {
+      QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
+      continue;
+    }
+    mapComponentName.insert( moduleusername, modulename );
+      
     resDir = resMgr->findFile(iconfile,modulename) ;
     if (resDir)
       {
+       MESSAGE ( "resDir" << resDir )
        //resDir = QAD_Tools::addSlash(resDir) ;
        //QPixmap Icone(resDir+iconfile) ;
        QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
        QToolButton * toolb = 
-         new QToolButton( QIconSet( Icone ), modulename, QString::null, this, 
+         new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this, 
                           SLOT( onButtonActiveComponent () ),tbComponent );
        toolb->setToggleButton( true );
        myComponentButton.append(toolb);
@@ -287,7 +297,7 @@ myQueryClose( true )
       }
 
     if ( !QString(list_composants[ind].modulename).isEmpty() )
-      myCombo->insertItem( strdup(list_composants[ind].modulename) );
+      myCombo->insertItem( strdup(list_composants[ind].moduleusername) );
 
   }
 
@@ -354,17 +364,9 @@ const int IdSelectAll = 1004;
 */
 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
 {
-  if (e->type() == 2000   ) {
-    QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
-    return TRUE;
-  }
-  else if (e->type() == 2001 ) {
-    QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
-    return TRUE;
-  }
-    else if ( e->type() == QEvent::ContextMenu ) {
-      QContextMenuEvent* ce = (QContextMenuEvent*)e;
-      if ( o->inherits("QRenameEdit") ) {
+  if ( e->type() == QEvent::ContextMenu ) {
+    QContextMenuEvent* ce = (QContextMenuEvent*)e;
+    if ( o->inherits("QRenameEdit") ) {
       return TRUE;
     }
     else if ( o->inherits("QLineEdit") ) {
@@ -743,13 +745,6 @@ void QAD_Desktop::createActions()
 
     myPrefPopup.insertSeparator();
     
-    /* External Browser */
-    QActionP* externalBrowserAction = new QActionP( "", tr("MEN_DESK_PREF_EXTERNAL_BROWSER"), 0, this );
-    QAD_ASSERT(connect( externalBrowserAction, SIGNAL(activated()), this, SLOT(onExternalBrowser() )));
-    externalBrowserAction->addTo( &myPrefPopup );
-    myStdActions.insert( PrefExternalBrowserId, externalBrowserAction );
-        
-    myPrefPopup.insertSeparator();
     /* BrowserPopup */
     myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
     
@@ -876,24 +871,6 @@ void QAD_Desktop::createActions()
                        this, SLOT( onHelpContents() )));
     helpContentsAction->addTo( &myHelpPopup );
     myStdActions.insert( HelpContentsId , helpContentsAction );
-                               
-    id = myHelpPopup.insertSeparator();
-                                                  
-    /* GUI contents */
-    QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
-    helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
-    QAD_ASSERT(connect( helpContentsActionGUI, SIGNAL(activated()),
-                       this, SLOT( onHelpContentsGUI() )));
-    helpContentsActionGUI->addTo( &myHelpPopup );
-    myStdActions.insert( HelpContentsId , helpContentsActionGUI );
-
-    /* TUI contents */
-    QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
-    helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
-    QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
-                       this, SLOT( onHelpContentsTUI() )));
-    helpContentsActionTUI->addTo( &myHelpPopup );
-    myStdActions.insert( HelpContentsId , helpContentsActionTUI );                                                
 
     /* search */
 //    QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
@@ -1024,7 +1001,6 @@ void QAD_Desktop::updateCaption( UpdateCommand cmd )
     else
     {  /* default icon and title */
        setIcon( myDefaultIcon );
-       qApp->processEvents();
        setCaption( myDefaultTitle );
     }
 }
@@ -1188,6 +1164,23 @@ Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
   return eng._retn();
 }
 
+QString QAD_Desktop::getComponentName(const char *componentUserName)
+{
+  if ( mapComponentName.contains(componentUserName) )
+    return mapComponentName[ componentUserName ] ;
+  else
+    return "";
+}
+
+QString QAD_Desktop::getComponentUserName(const char *componentName)
+{
+  QMap<QString,QString>::Iterator it;
+  for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
+    if (it.data() == componentName )
+      return it.key();
+  return "";
+}
+
 /*!
   gets application Help Window (and creates if necessary)
 */
@@ -1195,6 +1188,37 @@ QAD_HelpWindow* QAD_Desktop::getHelpWindow()
 {
   if (!myHelpWindow) {
     myHelpWindow = new QAD_HelpWindow();  
+    
+    QMap<QString,QString>::Iterator it;
+    for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
+      QCString dir;
+      QString root;
+      
+      // look for index.html and set homeDir
+      // 1. $(MODULE_ROOT_DIR)/doc/index.html
+      // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
+      // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
+
+      if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
+       root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share")  + QAD_Tools::addSlash("salome")  + "doc" );
+       if ( QFileInfo( root + "index.html" ).exists() ) {
+         helpContext( root + "index.html", "" );
+       }
+       else {
+         root = QAD_Tools::addSlash( root + "html" );
+         if ( QFileInfo( root + "index.html" ).exists() ) {
+           helpContext( root + "index.html", "" );
+         }
+         else {
+           root = QAD_Tools::addSlash( root + "html" );
+           if ( QFileInfo( root + "index.html" ).exists() ) {
+             helpContext( root + "index.html", "" );
+           }
+         }
+       }
+      }
+    }
+    
     connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
   }
   return myHelpWindow;
@@ -1520,7 +1544,7 @@ void QAD_Desktop::onOpenStudy()
                                      tr("BUT_OK") );
            } else if (myActiveComp != "") {
              QApplication::setOverrideCursor( Qt::waitCursor );
-             loadComponentData(myActiveComp);
+             loadComponentData(mapComponentName[myActiveComp]);
              openStudy->updateObjBrowser(true);
              QApplication::restoreOverrideCursor();
            }
@@ -1541,14 +1565,14 @@ void QAD_Desktop::onOpenStudy()
 bool QAD_Desktop::loadComponentData( const QString& compName )
 {
   // Open component's data in active study if any
-  MESSAGE("loadComponentData(): Opening component data")
+  MESSAGE("loadComponentData(): Opening " << compName << " component data ")
   if (!myActiveStudy) {
     MESSAGE("loadComponentData(): No active study exists")
     return false;
   }
 
   Engines::Component_var comp ;
-  if ( compName.compare("Supervision") == 0 ) {
+  if ( compName.compare("SUPERV") == 0 ) {
     comp = getEngine( "SuperVisionContainer", compName) ;
   }
   else {
@@ -1561,7 +1585,7 @@ bool QAD_Desktop::loadComponentData( const QString& compName )
   }
 
   SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
-  SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject(compName));
+  SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
           
   if (!SCO->_is_nil()) {
     if (!CORBA::is_nil(comp)) {
@@ -1960,179 +1984,15 @@ void QAD_Desktop::onNewWindow3d()
   //NRI : SAL2214
 }
 
-// Helps to execute command
-class RunBrowser: public QThread {
-public:
-  
-  RunBrowser(QString theApp, QString theParams, QString theHelpFile): 
-    myApp(theApp), myParams(theParams), myHelpFile(theHelpFile), myStatus(0) {};
-  virtual void run()
-  {
-    QString aCommand;
-    
-    if ( !myApp.isEmpty())
-      {
-       aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
-       myStatus = system(aCommand);
-       if(myStatus != 0)
-         {
-           QCustomEvent* ce2000 = new QCustomEvent (2000);
-           postEvent (qApp, ce2000);
-         }
-      }
-    
-    if( myStatus != 0 || myApp.isEmpty())
-      {
-       myParams = "";
-       aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1()); 
-       myStatus = system(aCommand);
-       if(myStatus != 0)
-         {
-           QCustomEvent* ce2001 = new QCustomEvent (2001);
-           postEvent (qApp, ce2001);
-         }
-      }
-  }
-
-private:
-  QString myApp;
-  QString myParams;
-  QString myHelpFile;
-  int myStatus;
-  
-};
-
 /*!
     Called on 'help\contents'
 */
 void QAD_Desktop::onHelpContents()
 {
-
-  // look for main.html and set homeDir
-  // 1. $(SALOME_ROOT_DIR)/doc/main.html
-  // 2. $(SALOME_ROOT_DIR)/doc/html/main.html
-  // 3. $(SALOME_ROOT_DIR)/doc/html/html/main.html
-  // 4. /usr/local/doc/html/main.html
-  
-  QCString dir;
-  QString root;
-  QString homeDir;
-  
-  if ( (dir = getenv("SALOME_ROOT_DIR")) ) {
-    root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" );
-    if ( QFileInfo( root + "main.html" ).exists() ) {
-      homeDir = root;
-    }
-    else {
-      root = QAD_Tools::addSlash( root + "html" );
-      if ( QFileInfo( root + "main.html" ).exists() ) {
-       homeDir = root;
-      }
-      else {
-       root = QAD_Tools::addSlash( root + "html" );
-       if ( QFileInfo( root + "main.html" ).exists() ) {
-         homeDir = root;
-       }
-      }
-    }
-  }
-  if ( root.isEmpty() ) {
-    if ( QFileInfo( "/usr/local/doc/html/main.html" ).exists() ) {
-      homeDir = "/usr/local/doc/html/";
-    }
-  }
-  if ( root.isEmpty() ) 
-    root = "./doc/";
-  
-  QString helpFile = QFileInfo( homeDir + "main.html" ).absFilePath(); 
-  
-  QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
-  QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
-   
-  RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
-  rs->start();
-    
-}
-
-/*!
-    Called on 'help\GUI Reference'
-*/
-void QAD_Desktop::onHelpContentsGUI()
-{
-
-  // look for main.html and set homeDir
-  // 1. $(SALOME_ROOT_DIR)/doc/guihtml/guihtml/salomedoc.html
-  // 2. /usr/local/doc/guihtml/salomedoc.html
-  
-  QCString dir;
-  QString root;
-  QString homeDir;
-  
-  if ( (dir = getenv("SALOME_ROOT_DIR")) ) {
-    root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" );
-    root = QAD_Tools::addSlash( root + "guihtml" );
-    root = QAD_Tools::addSlash( root + "guihtml" );
-    if ( QFileInfo( root + "salomedoc.html" ).exists() ) {
-      homeDir = root;
-    }
-  }
-  if ( root.isEmpty() ) {
-    if ( QFileInfo( "/usr/local/doc/guihtml/salomedoc.html" ).exists() ) {
-      homeDir = "/usr/local/doc/guihtml/";
-    }
-  }
-  if ( root.isEmpty() ) 
-    root = "./doc/";
-  
-  QString helpFile = QFileInfo( homeDir + "salomedoc.html" ).absFilePath(); 
-  
-  QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
-  QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
-   
-  RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
-  rs->start();
-    
-}
-
-/*!
-    Called on 'help\TUI Reference'
-*/
-void QAD_Desktop::onHelpContentsTUI()
-{
-
-  // look for main.html and set homeDir
-  // 1. $(SALOME_ROOT_DIR)/doc/html/html/index.html
-  // 2. /usr/local/doc/html/index.html
-  
-  QCString dir;
-  QString root;
-  QString homeDir;
-  
-  if ( (dir = getenv("SALOME_ROOT_DIR")) ) {
-    root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" );
-    root = QAD_Tools::addSlash( root + "html" );
-    root = QAD_Tools::addSlash( root + "html" );
-    if ( QFileInfo( root + "index.html" ).exists() ) {
-      homeDir = root;
-    }
-  }
-  if ( root.isEmpty() ) {
-    if ( QFileInfo( "/usr/local/doc/html/index.html" ).exists() ) {
-      homeDir = "/usr/local/doc/html/";
-    }
-  }
-  if ( root.isEmpty() ) 
-    root = "./doc/";
-  
-  QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath(); 
-  
-  QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
-  QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
-   
-  RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
-  rs->start();
-    
+  if (myActiveApp)
+    myActiveApp->helpContents();
+  else
+    helpContents();
 }
 
 /*!
@@ -2381,7 +2241,7 @@ void QAD_Desktop::onOpenWith()
     if (SCO->FindAttribute(anAttr, "AttributeName")) {
       aName = SALOMEDS::AttributeName::_narrow(anAttr);
       name = aName->Value();
-      SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( name );
+      SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( mapComponentName[name] );
       if ( !Comp->_is_nil() ) {
        
        SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
@@ -2433,6 +2293,7 @@ void QAD_Desktop::onOpenWith()
 }
 
 typedef bool OneDim1(QAD_Desktop*);
+typedef bool OneDim2(QAD_Desktop*, char*);
 
 /*!
   Called to define settings of component.
@@ -2441,10 +2302,18 @@ void QAD_Desktop::setSettings()
 {
   if (!myActiveComp.isEmpty()) {
     OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
-    if ( osdF != NULL ) {
-      OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
-      (*f1)(this);
-    }
+    if ( osdF != NULL )
+      if (_islibso)
+       {
+         OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
+         (*f1)(this);
+       }
+      else
+       {
+         QString Component =mapComponentName[myActiveComp];
+         OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
+         (*f1)(this, (char*)Component.latin1());
+       }
   }
 }
 
@@ -2459,7 +2328,7 @@ bool QAD_Desktop::loadComponent(QString Component)
   QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
   if ( resMgr ) {
     QString msg;
-    if (!resMgr->loadResources( Component + "GUI", msg ))
+    if (!resMgr->loadResources( Component, msg ))
       {
        //NRI   QCString errMsg;
        //      errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
@@ -2473,14 +2342,14 @@ bool QAD_Desktop::loadComponent(QString Component)
   /* Parse xml file */
   myXmlHandler = new QAD_XmlHandler();
   myXmlHandler->setMainWindow(this);
-  if (!myXmlHandler->setComponent(resMgr->resources(Component + "GUI"))) return false;
+  if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
 
-  QString language = resMgr->language( Component + "GUI" );
+  QString language = resMgr->language( Component );
 
   QString ComponentXml = Component + "_" + language + ".xml";
   //ComponentXml = resMgr->resources(Component + "GUI") ;
   //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
-  ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component + "GUI" ) ) + ComponentXml;
+  ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
   QFile file( ComponentXml );
 
   if ( !file.exists() || !file.open( IO_ReadOnly ) )  {
@@ -2518,44 +2387,67 @@ bool QAD_Desktop::loadComponent(QString Component)
     nbToolbars = myActiveMenus->getToolBarList().count();
   /* Open Shared Library */
   mySharedLibrary = OSD_SharedLibrary();
+  _islibso = false;
 
   QString ComponentLib;
-  QCString dir;
+  QCString libs;
   QFileInfo fileInfo ;
-  bool found = false;
-  if ( dir = getenv("SALOME_SITE_DIR")) {
-    dir = QAD_Tools::addSlash(dir) ;
-    dir = dir + "lib" ;
-    dir = QAD_Tools::addSlash(dir) ;
+  QString fileString ;
+  QString dir;
+
+  if ( libs = getenv("LD_LIBRARY_PATH")) {
+    //    MESSAGE ( " LD_LIBRARY_PATH : " << libs );
+    QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
+    for ( int i = dirList.count()-1; i >= 0; i-- ) {
+      dir = dirList[ i ];
 #ifdef WNT
-    dir = dir + "lib" + Component.latin1() + "GUI.dll" ;
+      fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ;
 #else
-    dir = dir + "lib" + Component.latin1() + "GUI.so" ;
+      fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ;
 #endif
-    MESSAGE ( " GUI library = " << dir )
-    fileInfo.setFile(dir) ;
-    if (fileInfo.exists()) {
-      ComponentLib = fileInfo.fileName() ;
-      found = true;
+    
+      fileInfo.setFile(fileString) ;
+      if (fileInfo.exists()) {
+       //      MESSAGE ( " GUI library = " << fileString );
+       ComponentLib = fileInfo.fileName() ;
+       _islibso = true;
+       break;
+      }
     }
   }
-  
-  if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
-    dir = QAD_Tools::addSlash(dir) ;
-    dir = dir + "lib" ;
-    dir = QAD_Tools::addSlash(dir) ;
+
+  if (!_islibso) // component GUI could be in PyQt, use generic library
+    {
+      MESSAGE("GUI library not found, trying generic library for PyQt GUI");
+      bool found = false;
+      if (dir = getenv("KERNEL_ROOT_DIR"))
+       {
+         dir = QAD_Tools::addSlash(dir) ;
+         dir = dir + "lib" ;
+         dir = QAD_Tools::addSlash(dir) ;
+         dir = dir + "salome" ;
+         dir = QAD_Tools::addSlash(dir) ;
 #ifdef WNT
-    dir = dir + "lib" + Component.latin1() + "GUI.dll" ;
+         dir = dir + "libSalomePyQtcmodule.dll" ;
 #else
-    dir = dir + "lib" + Component.latin1() + "GUI.so" ;
+         dir = dir + "libSalomePyQtcmodule.so" ;
 #endif
-    MESSAGE ( " GUI library = " << dir )
-    fileInfo.setFile(dir) ;
-    if (fileInfo.exists()) {
-      ComponentLib = fileInfo.fileName() ;
-      found = true;
+         MESSAGE ( " GUI library = " << dir );
+         fileInfo.setFile(dir) ;
+         if (fileInfo.exists())
+           {
+             ComponentLib = fileInfo.fileName() ;
+             found = true;
+           }
+       }
+      if ( !found )
+       {
+         QMessageBox::critical( this,
+                                tr("ERR_ERROR"),
+                                tr("ERR_LIBGUI" ).arg(Component) );
+         return false;
+       }
     }
-  }
 
   mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
   ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY);
@@ -2569,10 +2461,19 @@ bool QAD_Desktop::loadComponent(QString Component)
 
   /* SETTINGS */
   OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
-  if ( osdF != NULL ) {
-    OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
-    (*f1)(this);
-  }
+  if ( osdF != NULL )
+    if (_islibso)
+      {
+       OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
+       (*f1)(this);
+      }
+    else
+      {
+       OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
+       (*f1)(this, (char*)Component.latin1());
+      }
+
+  
 
   /* COMPONENT INTERFACE */
   SALOME_ModuleCatalog::Acomponent_ptr aComponent =
@@ -2584,7 +2485,7 @@ bool QAD_Desktop::loadComponent(QString Component)
   }
 
   myActiveStudy->setMessage(QString("Component : ") +
-                           aComponent->componentname() + " created " );
+                           aComponent->componentusername() + " created " );
   myActiveStudy->setMessage(QString("Type : ") +
                            QString::number(aComponent->component_type()));
   myActiveStudy->setMessage(QString("Constraint : ") +
@@ -2676,6 +2577,8 @@ void QAD_Desktop::onDispatchTools(int id)
       dir = QAD_Tools::addSlash(dir) ;
       dir = dir + "lib" ;
       dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "salome" ;
+      dir = QAD_Tools::addSlash(dir) ;
 #ifdef WNT
       dir = dir + "libToolsGUI.dll" ;
 #else
@@ -2693,6 +2596,27 @@ void QAD_Desktop::onDispatchTools(int id)
       dir = QAD_Tools::addSlash(dir) ;
       dir = dir + "lib" ;
       dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "salome" ;
+      dir = QAD_Tools::addSlash(dir) ;
+#ifdef WNT
+      dir = dir + "libToolsGUI.dll" ;
+#else
+      dir = dir + "libToolsGUI.so" ;
+#endif
+      MESSAGE ( " GUI library = " << dir );
+      fileInfo.setFile(dir) ;
+      if (fileInfo.exists()) {
+       ToolsLib = fileInfo.fileName() ;
+       found = true;
+      }
+    }
+    
+    if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
+      dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "lib" ;
+      dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "salome" ;
+      dir = QAD_Tools::addSlash(dir) ;
 #ifdef WNT
       dir = dir + "libToolsGUI.dll" ;
 #else
@@ -2713,6 +2637,8 @@ void QAD_Desktop::onDispatchTools(int id)
       dir = QAD_Tools::addSlash(dir) ;
       dir = dir + "lib" ;
       dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "salome" ;
+      dir = QAD_Tools::addSlash(dir) ;
       dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
       MESSAGE ( " GUI library = " << dir );
       fileInfo.setFile(dir) ;
@@ -2726,6 +2652,23 @@ void QAD_Desktop::onDispatchTools(int id)
       dir = QAD_Tools::addSlash(dir) ;
       dir = dir + "lib" ;
       dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "salome" ;
+      dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
+      MESSAGE ( " GUI library = " << dir );
+      fileInfo.setFile(dir) ;
+      if (fileInfo.exists()) {
+       ToolsLib = fileInfo.fileName() ;
+       found = true;
+      }
+    }
+    
+    if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
+      dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "lib" ;
+      dir = QAD_Tools::addSlash(dir) ;
+      dir = dir + "salome" ;
+      dir = QAD_Tools::addSlash(dir) ;
       dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
       MESSAGE ( " GUI library = " << dir );
       fileInfo.setFile(dir) ;
@@ -2794,7 +2737,8 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad
       if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
       if ( myCombo->currentText() != component )
        myCombo->setCurrentText( component );
-      if (component.compare(QString("Salome"))!= 0) {
+      //NRI if (component.compare(QString("Salome"))!= 0) {
+      if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
 //     QApplication::setOverrideCursor( Qt::waitCursor );
        myActiveComp = component;
 
@@ -2808,7 +2752,7 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad
        }
 
        myActiveStudy->Selection( component );
-       if ( !loadComponent(component) ) {
+       if ( !loadComponent(mapComponentName[component]) ) {
          myCombo->setCurrentItem (0);
          for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
            aButton->setOn(false);
@@ -2829,7 +2773,7 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad
        }
 
        // Open new component's data in active study if any
-       if(isLoadData) loadComponentData(component);
+       if(isLoadData) loadComponentData(mapComponentName[component]);
 
        oldSel->Clear();
        myActiveStudy->updateObjBrowser(true);
@@ -2838,7 +2782,8 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad
 
       } else {  // component == "Salome"
        myActiveComp = "";
-       myActiveStudy->Selection( "Salome" );
+       //NRI   myActiveStudy->Selection( "Salome" );
+       myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
        SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
        Sel->ClearIObjects();
        for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
@@ -2851,35 +2796,15 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad
          aButton->setOn(true);
       }
     }
-  } else if (component.compare(QString("Salome"))!= 0) {
-  
-      SALOMEGUI_ActivateComponentDlg aDlg( this );
-      int res = aDlg.exec();
-      
-      switch ( res )
-       {
-       case 1:
-         onNewStudy();
-         onComboActiveComponent(component,true);                 
-         break;
-       case 2:
-          onOpenStudy();       
-         onComboActiveComponent(component,true);
-         break;
-       case 3:
-         onLoadStudy();
-         onComboActiveComponent(component,true);;
-         break;
-       case 0:
-       default:
-         putInfo( tr("INF_CANCELLED") );
-         myCombo->setCurrentItem (0);  
-         for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
-          aButton->setOn(false);
-          // return;
-         }
-       }
-      }
+  } else {
+    QMessageBox::critical( 0,
+                          tr( "ERR_ERROR" ),
+                          tr( "WRN_LOAD_COMPONENT" ) );
+    myCombo->setCurrentItem (0);       
+    for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
+      aButton->setOn(false);
+    }
+  }
 }
 
 /*!
@@ -3226,33 +3151,6 @@ void QAD_Desktop::onViewerTrihedron()
   }
 }
 
-void QAD_Desktop::onExternalBrowser()
-{
-  QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
-  QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
-   
-  SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
-  
-  if (!theApp.isEmpty())
-    {
-      QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
-      Dlg->setSettings(theApp, theParams);
-    }
-  int r = Dlg->exec();
-  QString theAppFromDialog = Dlg->getApp();
-  QString theParamsFromDialog = Dlg->getParams();
-  delete Dlg;
-  
-  if (r == QDialog::Accepted) 
-    {
-      QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
-      QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
-    }
-  
-}
-
-
 void QAD_Desktop::onDirList() 
 {
   // getting dir list from settings
@@ -3476,7 +3374,31 @@ void QAD_Desktop::helpSearch()
 /* Help Contents */
 void QAD_Desktop::helpContents()
 {
-  getHelpWindow()->contents();
+  if (myActiveComp == "")
+    myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
+
+  QCString dir;
+  QString root;
+  if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
+    root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share")  + QAD_Tools::addSlash("salome")  + "doc" );
+    if ( QFileInfo( root + "index.html" ).exists() ) {
+      helpContext( root + "index.html", "" );
+    }
+    else {
+      root = QAD_Tools::addSlash( root + "html" );
+      if ( QFileInfo( root + "index.html" ).exists() ) {
+       helpContext( root + "index.html", "" );
+      }
+      else {
+       root = QAD_Tools::addSlash( root + "html" );
+       if ( QFileInfo( root + "index.html" ).exists() ) {
+         helpContext( root + "index.html", "" );
+       }
+      }
+    }
+  }
+  
+  //NRI getHelpWindow()->contents();
   getHelpWindow()->show();
   getHelpWindow()->raise();
   getHelpWindow()->setActiveWindow();