1 // File: SalomeApp_Application.cxx
2 // Created: 10/22/2004 3:23:45 PM
3 // Author: Sergey LITONIN
4 // Copyright (C) CEA 2004
6 #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
8 #include "SalomeApp_Application.h"
10 #include "SalomeApp_Study.h"
11 #include "SalomeApp_DataModel.h"
12 #include "SalomeApp_DataObject.h"
13 #include "SalomeApp_EventFilter.h"
15 #include "SalomeApp_StudyPropertiesDlg.h"
17 #include "SalomeApp_CheckFileDlg.h"
19 #include "LightApp_Application.h"
20 #include "LightApp_Preferences.h"
21 #include "LightApp_WidgetContainer.h"
22 #include "LightApp_SelectionMgr.h"
24 #include "STD_LoadStudiesDlg.h"
26 #include <SUIT_Tools.h>
27 #include <SUIT_Session.h>
29 #include <QtxMRUAction.h>
31 #include <OB_Browser.h>
32 #include <OB_ListItem.h>
34 #include <PythonConsole_PyConsole.h>
36 #include <SUIT_FileDlg.h>
37 #include <SUIT_MessageBox.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_ActionOperation.h>
41 #include <Utils_ORB_INIT.hxx>
42 #include <Utils_SINGLETON.hxx>
43 #include <SALOME_ModuleCatalog_impl.hxx>
44 #include <SALOME_LifeCycleCORBA.hxx>
48 #include <qcombobox.h>
52 #include "SALOMEDS_StudyManager.hxx"
53 #include "SALOMEDS_SObject.hxx"
55 #include "SALOME_ListIteratorOfListIO.hxx"
56 #include "SALOME_ListIO.hxx"
58 #include "ToolsGUI_CatalogGeneratorDlg.h"
59 #include "ToolsGUI_RegWidget.h"
61 /*!Create new instance of SalomeApp_Application.*/
62 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
64 return new SalomeApp_Application();
68 Class : SalomeApp_Application
69 Description : Application containing SalomeApp module or LightApp module
73 SalomeApp_Application::SalomeApp_Application()
74 : LightApp_Application()
79 *\li Destroy event filter.
81 SalomeApp_Application::~SalomeApp_Application()
83 // Do not destroy. It's a singleton !
84 //SalomeApp_EventFilter::Destroy();
87 /*!Start application.*/
88 void SalomeApp_Application::start()
90 LightApp_Application::start();
92 SalomeApp_EventFilter::Init();
96 void SalomeApp_Application::createActions()
98 LightApp_Application::createActions();
100 SUIT_Desktop* desk = desktop();
103 createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
104 tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
105 CTRL+Key_D, desk, false, this, SLOT( onDumpStudy() ) );
108 createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
109 tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
110 CTRL+Key_T, desk, false, this, SLOT( onLoadScript() ) );
113 createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
114 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
115 CTRL+Key_P, desk, false, this, SLOT( onProperties() ) );
117 //! Catalog Generator
118 createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIconSet(),
119 tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ),
120 SHIFT+Key_G, desk, false, this, SLOT( onCatalogGen() ) );
123 createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIconSet(),
124 tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
125 /*SHIFT+Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
127 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
129 createMenu( DumpStudyId, fileMenu, 10, -1 );
130 createMenu( separator(), fileMenu, -1, 15, -1 );
131 createMenu( LoadScriptId, fileMenu, 10, -1 );
132 createMenu( separator(), fileMenu, -1, 15, -1 );
133 createMenu( PropertiesId, fileMenu, 10, -1 );
134 createMenu( separator(), fileMenu, -1, 15, -1 );
136 int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 50 );
137 createMenu( CatalogGenId, toolsMenu, 10, -1 );
138 createMenu( RegDisplayId, toolsMenu, 10, -1 );
139 createMenu( separator(), toolsMenu, -1, 15, -1 );
142 /*! Purpose : SLOT. Open new document with \a aName.*/
143 bool SalomeApp_Application::onOpenDoc( const QString& aName )
145 bool res = false, toOpen = true, isAlreadyOpen = false;
147 // Look among opened studies
148 if (activeStudy()) { // at least one study is opened
149 SUIT_Session* aSession = SUIT_Session::session();
150 QPtrList<SUIT_Application> aAppList = aSession->applications();
151 QPtrListIterator<SUIT_Application> it (aAppList);
152 SUIT_Application* aApp = 0;
153 // iterate on all applications
154 for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
155 if (aApp->activeStudy()->studyName() == aName) {
156 isAlreadyOpen = true; // Already opened, ask user what to do
158 // The document ... is already open.
159 // Do you want to reload it?
160 int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
161 tr("QUE_DOC_ALREADYOPEN").arg(aName),
162 tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
163 if (aAnswer == 1) { // reload
164 if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
165 // Opened in THIS (active) application.
166 STD_Application* app1 = (STD_Application*)aAppList.at(0);
167 STD_Application* app2 = (STD_Application*)aAppList.at(1);
168 if (!app1 || !app2) {
172 if (app1->activeStudy()->studyName() == aName) {
173 // app1 is this application, we need another one
176 // Close document of this application. This application will be destroyed.
177 onCloseDoc(/*ask = */false);
178 // Open the file with another application, as this one will be destroyed.
179 return app1->onOpenDoc(aName);
181 // Opened in another application.
182 STD_Application* app = (STD_Application*)aApp;
184 app->onCloseDoc(/*ask = */false);
186 } else { // do not reload
187 // OK, the study will not be reloaded, but we call
188 // CAM_Application::onOpenDoc( aName ) all the same.
189 // It will activate a desktop of the study <aName>.
195 // Look among unloaded studies
196 if (!isAlreadyOpen) {
197 std::vector<std::string> List = studyMgr()->GetOpenStudies();
200 for (unsigned int ind = 0; ind < List.size() && !isAlreadyOpen; ind++) {
201 studyName = List[ind].c_str();
202 if (aName == studyName) {
203 // Already exists unloaded, ask user what to do
204 isAlreadyOpen = true;
206 // The document ... already exists in the study manager.
207 // Do you want to reload it?
208 int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
209 tr("QUE_DOC_ALREADYEXIST").arg(aName),
210 tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
212 _PTR(Study) aStudy = studyMgr()->GetStudyByName(aName.latin1());
214 studyMgr()->Close(aStudy);
223 res = CAM_Application::onOpenDoc( aName );
225 QAction* a = action( MRUId );
226 if ( a && a->inherits( "QtxMRUAction" ) )
228 QtxMRUAction* mru = (QtxMRUAction*)a;
230 mru->insert( aName );
232 mru->remove( aName );
237 /*!SLOT. Load document.*/
238 void SalomeApp_Application::onLoadDoc()
240 QString name, studyname, ext;
242 STD_LoadStudiesDlg aDlg( desktop(), TRUE);
244 std::vector<std::string> List = studyMgr()->GetOpenStudies();
246 SUIT_Session* aSession = SUIT_Session::session();
247 QPtrList<SUIT_Application> aAppList = aSession->applications();
248 SUIT_Application* aApp = 0;
250 for (unsigned int ind = 0; ind < List.size(); ind++) {
251 studyname = List[ind].c_str();
252 //Add to list only unloaded studies
253 bool isAlreadyOpen = false;
254 for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
257 if(!aApp || !aApp->activeStudy()) continue;
258 if ( aApp->activeStudy()->studyName() == studyname ) isAlreadyOpen = true;
261 if ( !isAlreadyOpen ) aDlg.ListComponent->insertItem( studyname );
264 int retVal = aDlg.exec();
265 studyname = aDlg.ListComponent->currentText();
267 if (retVal == QDialog::Rejected)
270 if ( studyname.isNull() || studyname.isEmpty() )
274 name.replace( QRegExp(":"), "/" );
276 if( LightApp_Application::onLoadDoc( name ) )
279 updateViewManagers();
280 updateObjectBrowser(true);
285 /*!SLOT. Load document with \a aName.*/
286 bool SalomeApp_Application::onLoadDoc( const QString& aName )
288 return LightApp_Application::onLoadDoc( aName );
291 /*!SLOT. Copy objects to study maneger from selection maneger..*/
292 void SalomeApp_Application::onCopy()
295 LightApp_SelectionMgr* mgr = selectionMgr();
296 mgr->selectedObjects(list);
298 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
299 if(study == NULL) return;
301 _PTR(Study) stdDS = study->studyDS();
304 SALOME_ListIteratorOfListIO it( list );
307 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
309 studyMgr()->Copy(so);
310 onSelectionChanged();
317 /*!SLOT. Paste objects to study maneger from selection manager.*/
318 void SalomeApp_Application::onPaste()
321 LightApp_SelectionMgr* mgr = selectionMgr();
322 mgr->selectedObjects(list);
324 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
325 if(study == NULL) return;
327 _PTR(Study) stdDS = study->studyDS();
330 SALOME_ListIteratorOfListIO it( list );
333 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
335 studyMgr()->Paste(so);
336 updateObjectBrowser( true );
337 updateActions(); //SRN: BugID IPAL9377, case 3
344 /*!Sets enable or disable some actions on selection changed.*/
345 void SalomeApp_Application::onSelectionChanged()
348 LightApp_SelectionMgr* mgr = selectionMgr();
349 mgr->selectedObjects(list);
351 bool canCopy = false;
352 bool canPaste = false;
354 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
356 _PTR(Study) stdDS = study->studyDS();
359 SALOME_ListIteratorOfListIO it ( list );
361 if (it.More() && list.Extent() == 1) {
362 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
365 SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
368 canCopy = studyMgr()->CanCopy(so);
369 canPaste = studyMgr()->CanPaste(so);
376 action(EditCopyId)->setEnabled(canCopy);
377 action(EditPasteId)->setEnabled(canPaste);
380 /*!Delete references.*/
381 void SalomeApp_Application::onDeleteInvalidReferences()
384 LightApp_SelectionMgr* mgr = selectionMgr();
385 mgr->selectedObjects( aList, QString::null, false );
387 if( aList.IsEmpty() )
390 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
391 _PTR(Study) aStudyDS = aStudy->studyDS();
392 _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
395 for( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
396 if ( it.Value()->hasEntry() )
398 _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
399 while( aRefObj && aRefObj->ReferencedObject( anObj ) )
402 if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
403 aStudyBuilder->RemoveReference( aSObject );
405 updateObjectBrowser();
409 void SalomeApp_Application::onOpenWith()
411 QApplication::setOverrideCursor( Qt::waitCursor );
413 LightApp_SelectionMgr* mgr = selectionMgr();
414 mgr->selectedObjects(aList);
415 if (aList.Extent() != 1)
417 QApplication::restoreOverrideCursor();
420 Handle(SALOME_InteractiveObject) aIObj = aList.First();
421 QString aModuleName(aIObj->getComponentDataType());
422 QString aModuleTitle = moduleTitle(aModuleName);
423 activateModule(aModuleTitle);
424 QApplication::restoreOverrideCursor();
427 //=======================================================================
428 // name : createNewStudy
429 /*! Purpose : Create new study*/
430 //=======================================================================
431 SUIT_Study* SalomeApp_Application::createNewStudy()
433 SalomeApp_Study* aStudy = new SalomeApp_Study( this );
435 // Set up processing of major study-related events
436 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
437 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
438 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
439 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
444 //=======================================================================
445 // name : updateCommandsStatus
446 /*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
447 //=======================================================================
448 void SalomeApp_Application::updateCommandsStatus()
450 LightApp_Application::updateCommandsStatus();
453 QAction* a = action( DumpStudyId );
455 a->setEnabled( activeStudy() );
458 a = action( LoadScriptId );
460 a->setEnabled( activeStudy() );
462 a = action( PropertiesId );
464 a->setEnabled( activeStudy() );
466 // update state of Copy/Paste menu items
467 onSelectionChanged();
470 /*!Private SLOT. On dump study.*/
471 void SalomeApp_Application::onDumpStudy( )
473 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
474 if ( !appStudy ) return;
475 _PTR(Study) aStudy = appStudy->studyDS();
477 QStringList aFilters;
478 aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
480 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
481 fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
482 fd->setFilters( aFilters );
483 fd->SetChecked(true);
485 QString aFileName = fd->selectedFile();
486 bool toPublish = fd->IsChecked();
489 if(!aFileName.isEmpty()) {
490 QFileInfo aFileInfo(aFileName);
491 bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
493 SUIT_MessageBox::warn1 ( desktop(),
494 QObject::tr("WRN_WARNING"),
495 tr("WRN_DUMP_STUDY_FAILED"),
496 QObject::tr("BUT_OK") );
500 /*!Private SLOT. On load script.*/
501 void SalomeApp_Application::onLoadScript( )
503 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
504 if ( !appStudy ) return;
505 _PTR(Study) aStudy = appStudy->studyDS();
507 if ( aStudy->GetProperties()->IsLocked() ) {
508 SUIT_MessageBox::warn1 ( desktop(),
509 QObject::tr("WRN_WARNING"),
510 QObject::tr("WRN_STUDY_LOCKED"),
511 QObject::tr("BUT_OK") );
515 QStringList filtersList;
516 filtersList.append(tr("PYTHON_FILES_FILTER"));
517 filtersList.append(tr("ALL_FILES_FILTER"));
519 QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
521 if ( !aFile.isEmpty() )
523 QString command = QString("execfile(\"%1\")").arg(aFile);
525 PythonConsole* pyConsole = pythonConsole();
528 pyConsole->exec( command );
533 *\retval QString "(*.hdf)"
535 QString SalomeApp_Application::getFileFilter() const
541 QWidget* SalomeApp_Application::createWindow( const int flag )
544 if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag);
546 SUIT_ResourceMgr* resMgr = resourceMgr();
548 if ( flag == WT_ObjectBrowser )
550 OB_Browser* ob = (OB_Browser*)wid;
551 connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
552 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
553 autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
554 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
556 ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
557 ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
558 QString().sprintf( "visibility_column_%d", i ), true ) );
560 ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
561 ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
562 ob->resize( desktop()->width()/3, ob->height() );
564 else if ( flag == WT_PyConsole )
566 PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
567 pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
569 pyCons->resize( pyCons->width(), desktop()->height()/4 );
570 //pyCons->connectPopupRequest(this, SLOT(onConnectPopupRequest(SUIT_PopupClient*, QContextMenuEvent*)));
575 /*!Create preferences.*/
576 void SalomeApp_Application::createPreferences( LightApp_Preferences* pref )
578 LightApp_Application::createPreferences(pref);
583 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
584 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
585 int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
586 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
588 pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols,
589 LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
591 pref->setItemProperty( defCols, "columns", 1 );
594 /*!Update desktop title.*/
595 void SalomeApp_Application::updateDesktopTitle() {
596 QString aTitle = applicationName();
597 QString aVer = applicationVersion();
598 if ( !aVer.isEmpty() )
599 aTitle += QString( " " ) + aVer;
603 QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
604 if ( !sName.isEmpty() ) {
605 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
607 _PTR(Study) stdDS = study->studyDS();
609 if ( stdDS->GetProperties()->IsLocked() ) {
610 aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
612 aTitle += QString( " - [%1]" ).arg( sName );
619 desktop()->setCaption( aTitle );
622 /*!Gets CORBA::ORB_var*/
623 CORBA::ORB_var SalomeApp_Application::orb()
625 ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
626 static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
630 /*!Create and return SALOMEDS_StudyManager.*/
631 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
633 static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
637 /*!Create and return SALOME_NamingService.*/
638 SALOME_NamingService* SalomeApp_Application::namingService()
640 static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
644 /*!Create and return SALOME_LifeCycleCORBA.*/
645 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
647 static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
651 /*!Return default engine IOR for light modules*/
652 QString SalomeApp_Application::defaultEngineIOR()
654 /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
656 CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
657 if ( !CORBA::is_nil( anEngine ) )
658 anIOR = orb()->object_to_string( anEngine );
662 /*!Private SLOT. On preferences.*/
663 void SalomeApp_Application::onProperties()
665 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
669 _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
672 SalomeApp_StudyPropertiesDlg aDlg( desktop() );
673 int res = aDlg.exec();
674 if( res==QDialog::Accepted && aDlg.isChanged() )
679 //study->updateCaptions();
680 updateDesktopTitle();
684 /*!Insert items in popup, which necessary for current application*/
685 void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
687 LightApp_Application::contextMenuPopup( type, thePopup, title );
689 OB_Browser* ob = objectBrowser();
690 if ( !ob || type != ob->popupClientType() )
693 // Get selected objects
695 LightApp_SelectionMgr* mgr = selectionMgr();
696 mgr->selectedObjects( aList, QString::null, false );
698 // "Delete reference" item should appear only for invalid references
700 // isInvalidRefs will be true, if at least one of selected objects is invalid reference
701 bool isInvalidRefs = false;
702 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
703 _PTR(Study) aStudyDS = aStudy->studyDS();
706 for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
707 if( it.Value()->hasEntry() )
709 _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
710 while( aRefObj && aRefObj->ReferencedObject( anObj ) )
713 if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
714 isInvalidRefs = true;
717 // Add "Delete reference" item to popup
720 thePopup->insertSeparator();
721 thePopup->insertItem( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
726 mgr->selectedObjects( aList );
728 // "Activate module" item should appear only if it's necessary
729 if (aList.Extent() != 1)
731 Handle(SALOME_InteractiveObject) aIObj = aList.First();
732 QString aModuleName(aIObj->getComponentDataType());
733 QString aModuleTitle = moduleTitle(aModuleName);
734 CAM_Module* currentModule = activeModule();
735 if (currentModule && currentModule->moduleName() == aModuleTitle)
737 thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
740 /*!Update obect browser:
741 1.if 'updateModels' true, update existing data models;
742 2. update "non-existing" (not loaded yet) data models;
743 3. update object browser if it existing */
744 void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
746 // update "non-existing" (not loaded yet) data models
747 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
750 _PTR(Study) stdDS = study->studyDS();
753 for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
755 _PTR(SComponent) aComponent ( it->Value() );
757 if ( aComponent->ComponentDataType() == "Interface Applicative" )
758 continue; // skip the magic "Interface Applicative" component
760 OB_Browser* ob = static_cast<OB_Browser*>( getWindow( WT_ObjectBrowser ));
761 const bool isAutoUpdate = ob->isAutoUpdate();
762 ob->setAutoUpdate( false );
763 SalomeApp_DataModel::synchronize( aComponent, study );
764 ob->setAutoUpdate( isAutoUpdate );
765 //SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
770 // update existing data models (already loaded SComponents)
771 LightApp_Application::updateObjectBrowser( updateModels );
773 /* if ( objectBrowser() )
775 objectBrowser()->updateGeometry();
776 objectBrowser()->updateTree();
780 /*!Display Catalog Genenerator dialog */
781 void SalomeApp_Application::onCatalogGen()
783 ToolsGUI_CatalogGeneratorDlg aDlg( desktop() );
787 /*!Display Registry Display dialog */
788 void SalomeApp_Application::onRegDisplay()
790 CORBA::ORB_var anOrb = orb();
791 ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop(), "Registry" );
794 regWnd->setActiveWindow();
797 /*!find original object by double click on item */
798 void SalomeApp_Application::onDblClick( QListViewItem* it )
800 OB_ListItem* item = dynamic_cast<OB_ListItem*>( it );
801 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
805 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
809 QString entry = obj->entry();
810 _PTR(SObject) sobj = study->studyDS()->FindObjectID( entry.latin1() ), ref;
812 if( sobj && sobj->ReferencedObject( ref ) )
814 entry = ref->GetID().c_str();
815 QListViewItemIterator anIt( item->listView() );
816 for( ; anIt.current(); anIt++ )
818 OB_ListItem* item = dynamic_cast<OB_ListItem*>( anIt.current() );
822 SalomeApp_DataObject* original = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
823 if( original->entry()!=entry )
826 OB_Browser* br = objectBrowser();
827 br->setSelected( original );
828 SUIT_DataObject* p = original->parent();