]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
IMP 001989: multi selection in "Import" dialog boxes V4_1_0_maintainance_20080703 V4_1_0_maintainance_20080704 V4_1_0_maintainance_20080707
authorvsr <vsr@opencascade.com>
Wed, 2 Jul 2008 08:42:55 +0000 (08:42 +0000)
committervsr <vsr@opencascade.com>
Wed, 2 Jul 2008 08:42:55 +0000 (08:42 +0000)
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx

index d91aef28f8af785e33569e8ee298a9c97d145735..1515c7160432491827fbce70ab220795573c1f37 100644 (file)
@@ -2495,3 +2495,18 @@ msgstr "File size (bytes)"
 
 msgid "VisuGUI_FileInfoDlg::MED_VERSION"
 msgstr "MED version"
+
+msgid "VisuGUI::ERR_ERROR_IN_THE_FILE"
+msgstr "Error in the file"
+
+msgid "VisuGUI::TLT_IMPORT_TABLE"
+msgstr "Import table"
+
+msgid "VisuGUI::ERR_FILE_NOT_EXISTS"
+msgstr "File does not exist"
+
+msgid "VisuGUI::UNKNOWN_IMPORT_ERROR"
+msgstr "Unknown error"
+
+msgid "VisuGUI::IMPORT_ERRORS"
+msgstr "Import operation has finished with errors:"
index bd362c51a5cfc31fb2db47028f1aa49b2736f9f3..709affe7ccc98e67157d942a5395a070fb506eeb 100644 (file)
@@ -53,6 +53,7 @@
 
 #include "SUIT_ViewWindow.h"
 #include "SUIT_ViewManager.h"
+#include "SUIT_OverrideCursor.h"
 
 #include "CAM_Module.h"
 
@@ -187,7 +188,7 @@ VisuGUI
   
   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" ) );
@@ -195,58 +196,86 @@ VisuGUI
   
   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
@@ -265,26 +294,50 @@ VisuGUI
   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);
   }
 }