#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
+#include "SUIT_OverrideCursor.h"
#include "CAM_Module.h"
SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
- // Get file name
+ // Get file name(s)
QStringList aFilter;
aFilter.append( tr( "FLT_MED_FILES" ) );
aFilter.append( tr( "FLT_DISTRIBUTED_MED_FILES" ) );
bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false);
- SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
- fd->setCaption( tr( "IMPORT_FROM_FILE" ) );
- fd->setFilters( aFilter );
- fd->SetChecked( toUseBuildProgress );
+ SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
+ fd.setCaption( tr( "IMPORT_FROM_FILE" ) );
+ fd.setMode( SalomeApp_CheckFileDlg::ExistingFiles );
+ fd.setFilters( aFilter );
+ fd.SetChecked( toUseBuildProgress );
if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() )
- fd->setDir( QDir::currentDirPath() );
- fd->exec();
- QFileInfo aFileInfo( fd->selectedFile() );
- toUseBuildProgress = fd->IsChecked();
- delete fd;
-
- // Check the file name
- if ( !aFileInfo.exists() )
- return;
+ fd.setDir( QDir::currentDirPath() );
+
+ QStringList fileNames;
+ if ( !fd.exec() )
+ return; // cancelled, return
+
+ fileNames = fd.selectedFiles();
+ toUseBuildProgress = fd.IsChecked();
+
+ if ( fileNames.count() == 0 )
+ return; // nothing selected, return
+
+ SUIT_OverrideCursor wc;
+ QStringList errors;
+
+ for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) {
+ QFileInfo aFileInfo( *it );
- if ( !toUseBuildProgress )
- {
- bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true );
- bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true );
- bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true );
- bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false );
- bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false );
-
- QString anInfo("Importing From File " + aFileInfo.filePath() + "..." );
- application()->putInfo( anInfo );
-
- QApplication::setOverrideCursor(Qt::waitCursor);
- VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() );
-
- if (CORBA::is_nil(aResult.in())) {
- SUIT_MessageBox::warn1(GetDesktop(this),
- tr("WRN_VISU"),
- VisuGUI_BuildProgressDlg::tr("ERR_ERROR_IN_THE_FILE"),
- tr("BUT_OK"));
- QApplication::restoreOverrideCursor();
- }else{
- aResult->SetBuildFields( toBuildFields, toBuildMinMax );
- aResult->SetBuildGroups( toBuildGroups );
- aResult->Build( toBuildAll, toBuildAtOnce );
-
- UpdateObjBrowser(this);
- application()->putInfo( anInfo + tr("INF_DONE"));
- QApplication::restoreOverrideCursor();
- }
- }
- else
- {
- VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
- aBuildProgressDlg->setFileName( aFileInfo.filePath() );
- aBuildProgressDlg->setGenerator( GetVisuGen(this) );
- aBuildProgressDlg->show();
+ if ( !aFileInfo.exists() ) {
+ // file not exist
+ errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+ arg( tr( "ERR_FILE_NOT_EXISTS" ) ) );
}
+ else {
+ try {
+ if ( !toUseBuildProgress ) {
+ // build progress is not used, use build flags from settings
+ bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true );
+ bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true );
+ bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true );
+ bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false );
+ bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false );
+
+ QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " );
+ application()->putInfo( anInfo );
+
+ VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath() );
+
+ if ( CORBA::is_nil( aResult.in() ) ) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+ arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
+ }
+ else {
+ aResult->SetBuildFields( toBuildFields, toBuildMinMax );
+ aResult->SetBuildGroups( toBuildGroups );
+ aResult->Build( toBuildAll, toBuildAtOnce );
+ application()->putInfo( anInfo + tr("INF_DONE") );
+ }
+ } // if ( !toUseBuildProgress )
+ else {
+ // use build progress
+ wc.suspend();
+ VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
+ aBuildProgressDlg->setFileName( aFileInfo.filePath() );
+ aBuildProgressDlg->setGenerator( GetVisuGen(this) );
+ aBuildProgressDlg->exec();
+ wc.resume();
+ }
+ } // try
+ catch(...) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
+ }
+ } // else // if ( !aFileInfo.exists() )
+ } // for (...)
+
+ if ( errors.count() > 0 ) {
+ SUIT_MessageBox::error1( GetDesktop(this),
+ tr("ERR_ERROR"),
+ tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
+ tr("BUT_OK") );
+ }
+ else {
+ UpdateObjBrowser(this);
+ }
}
void
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
anInitialPath = QDir::currentDirPath();
- QFileInfo aFileInfo =
- SUIT_FileDlg::getFileName(GetDesktop(this),
- anInitialPath,
- aFilter,
- tr("MEN_IMPORT_TABLE"),
- true);
- if (aFileInfo.exists()) {
- application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
+ QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this),
+ anInitialPath,
+ aFilter,
+ tr("TLT_IMPORT_TABLE"));
+ if ( aFiles.count() == 0 )
+ return; // nothing selected
- CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
+ QStringList errors;
+ for ( QStringList::ConstIterator it = aFiles.begin(); it != aFiles.end(); ++it ) {
+ QFileInfo aFileInfo( *it );
- if (CORBA::is_nil(anObject.in())) {
- SUIT_MessageBox::warn1(GetDesktop(this),
- tr("WRN_VISU"),
- tr("ERR_ERROR_IN_THE_FILE"),
- tr("BUT_OK"));
- } else {
- application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
- UpdateObjBrowser(this);
+ if ( !aFileInfo.exists() ) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+ arg( tr( "ERR_FILE_NOT_EXISTS" ) ) );
}
+ else {
+ try {
+ QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
+ application()->putInfo( anInfo );
+
+ CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
+
+ if (CORBA::is_nil(anObject.in())) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+ arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
+ }
+ else {
+ application()->putInfo( anInfo + tr("INF_DONE") );
+ }
+ }
+ catch(...) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
+ }
+ }
+ }
+
+ if ( errors.count() > 0 ) {
+ SUIT_MessageBox::error1( GetDesktop(this),
+ tr("ERR_ERROR"),
+ tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
+ tr("BUT_OK") );
+ }
+ else {
+ UpdateObjBrowser(this);
}
}