]> SALOME platform Git repositories - tools/install.git/blobdiff - src/SALOME_InstallWizard.cxx
Salome HOME
Update copyright notes
[tools/install.git] / src / SALOME_InstallWizard.cxx
index 657acd66f952bc8d8849b9735533930bc1ae4c5b..acedde53dea629edc5e7c6a45d96c4280b13d75b 100644 (file)
@@ -1,9 +1,9 @@
 //  File      : SALOME_InstallWizard.cxx 
 //  Created   : Thu Dec 18 12:01:00 2002
-//  Author    : Vadim SANDLER
+//  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
 //  Project   : SALOME
 //  Module    : Installation Wizard
-//  Copyright : 2004-2005 CEA
+//  Copyright : 2002-2006 CEA
 
 #include "globals.h"
 
@@ -934,18 +934,29 @@ void SALOME_InstallWizard::setupReadmePage()
   pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
   readme->setPalette( pal );
   readme->setMinimumHeight( 10 );
-  // <Launch SALOME> button
-  runSalomeBtn = new QPushButton( tr( "Launch SALOME" ), readmePage );
-  QWhatsThis::add( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
-  QToolTip::add  ( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
-  QHBoxLayout* hLayout = new QHBoxLayout;
-  hLayout->addWidget( runSalomeBtn ); hLayout->addStretch();
-  // layouting
+
   pageLayout->addWidget( readme );
   pageLayout->setStretchFactor( readme, 5 );
-  pageLayout->addLayout( hLayout );
-  // connecting signals
-  connect( runSalomeBtn, SIGNAL( clicked() ), this, SLOT( onLaunchSalome() ) );
+
+  // Operation buttons
+  if ( buttons.count() > 0 ) {
+    QHBoxLayout* hLayout = new QHBoxLayout;
+    hLayout->setMargin( 0 ); hLayout->setSpacing( 6 );
+    ButtonList::Iterator it;
+    for ( it = buttons.begin(); it != buttons.end(); ++it ) {
+      QButton* b = new QPushButton( tr( (*it).label() ), readmePage );
+      if ( !(*it).tootip().isEmpty() ) {
+       QWhatsThis::add( b, tr( (*it).tootip() ) );
+       QToolTip::add  ( b, tr( (*it).tootip() ) );
+      }
+      hLayout->addWidget( b ); 
+      (*it).setButton( b );
+      connect( b, SIGNAL( clicked() ), this, SLOT( onFinishButton() ) );
+    }
+    hLayout->addStretch();
+    pageLayout->addLayout( hLayout );
+  }
+
   // loading README file
   QString readmeFile = QDir::currentDirPath() + "/README";
   QString text;
@@ -953,6 +964,7 @@ void SALOME_InstallWizard::setupReadmePage()
     readme->setText( text );
   else
     readme->setText( tr( "README file has not been found" ) );
+
   // adding page
   addPage( readmePage, tr( "Finish installation" ) );
 }
@@ -1133,15 +1145,56 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
                               QMessageBox::NoButton ) == QMessageBox::No ) {
       return false;
     }
-    QString binDir = "./Products/BINARIES";
-    if ( !myOS.isEmpty() )
-      binDir += "/" + myOS;
-    QFileInfo fib( QDir::cleanDirPath( binDir ) );
-    if ( !fib.exists() ) {
-      QMessageBox::warning( this, 
-                           tr( "Warning" ), 
-                           tr( "The directory %1 doesn't exist.\n"
-                               "This directory must contain binaries archives." ).arg( fib.absFilePath() ));
+    // check sources/binaries archives directories existance
+    int nbSources = 0, nbBinaries = 0; 
+    QCheckListItem* nitem = (QCheckListItem*)( productsView->firstChild() );
+    while( nitem ) {
+      if ( productsMap.contains( nitem ) ) {
+       if ( nitem->childCount() > 0 ) {
+         if ( productsView->isBinaries( nitem ) )
+           nbBinaries++;
+         else if ( productsView->isSources( nitem ) )
+           nbSources++;
+       }
+       else if ( nitem->isOn() ) {
+         nbBinaries++;
+         nbSources++;
+       }
+      }
+      nitem = (QCheckListItem*)( nitem->nextSibling() );
+    }
+
+    if ( nbBinaries > 0 ) {
+      QString binDir = "./Products/BINARIES";
+      if ( !myOS.isEmpty() )
+       binDir += "/" + myOS;
+      QFileInfo fib( QDir::cleanDirPath( binDir ) );
+      if ( !fib.exists() ) {
+       if ( QMessageBox::warning( this, 
+                                  tr( "Warning" ), 
+                                  tr( "The directory %1 doesn't exist.\n"
+                                      "This directory must contain binaries archives.\n"
+                                      "Continue?" ).arg( fib.absFilePath() ),
+                                  QMessageBox::Yes,
+                                  QMessageBox::No,
+                                  QMessageBox::NoButton ) == QMessageBox::No )
+         return false;
+      }
+    }
+    if ( nbSources > 0 ) {
+      QString srcDir = "./Products/SOURCES";
+      QFileInfo fis( QDir::cleanDirPath( srcDir ) );
+      if ( !fis.exists() ) {
+       if ( QMessageBox::warning( this, 
+                                  tr( "Warning" ), 
+                                  tr( "The directory %1 doesn't exist.\n"
+                                      "This directory must contain sources archives.\n"
+                                      "Continue?" ).arg( fis.absFilePath() ),
+                                  QMessageBox::Yes,
+                                  QMessageBox::No,
+                                  QMessageBox::NoButton ) == QMessageBox::No )
+         return false;
+      }
     }
     // run script that checks available disk space for installing of products    // returns 1 in case of error
     QString script = "./config_files/checkSize.sh '";
@@ -1513,7 +1566,7 @@ void SALOME_InstallWizard::launchScript()
     QCheckListItem* item = mapIter.key();
     Dependancies dep = mapIter.data();
     QString depproducts = QUOTE( DefineDependeces(productsMap) ); 
-    if ( dep.pickUpEnvironment() ) {
+    if ( !productsView->isNone( item ) && dep.pickUpEnvironment() ) {
       ___MESSAGE___( "... for " << dep.getName() );
       QString script;
       script += "cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
@@ -1578,46 +1631,36 @@ void SALOME_InstallWizard::onMoreBtn()
 }
 // ================================================================
 /*!
- *  SALOME_InstallWizard::onLaunchSalome
- *  <Launch Salome> button slot
+ *  SALOME_InstallWizard::onFinishButton
+ *  Operation buttons slot
  */
 // ================================================================
-void SALOME_InstallWizard::onLaunchSalome()
+void SALOME_InstallWizard::onFinishButton()
 {
-  QString msg = tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() );
-
-  QCheckListItem* item = findItem( "KERNEL-Bin" );
-  if ( item ) {
-    QFileInfo fi( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" );
-    QFileInfo fienv( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.sh" );
-    if ( fienv.exists() ) {
-      if ( fi.exists() ) {
-       QString script;
-       script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
-       script += "source salome.sh; ";
-       script += "cd bin/salome; ";
-       script += "runSalome > /dev/null";
-       script = "(bash -c '" + script + "')";
-       ___MESSAGE___( "script: " << script.latin1() );
-       if ( !system( script.latin1() ) )
-         return;
-       else
-         msg = tr( "Can't launch SALOME." );
+  const QObject* btn = sender();
+  ButtonList::Iterator it;
+  for ( it = buttons.begin(); it != buttons.end(); ++it ) {
+    if ( (*it).button() && (*it).button() == btn ) {
+      QString script;
+      script += "( cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
+      script +=  + (*it).script();
+      script += " execute ";
+      script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
+      script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
+      script += " > /dev/null )";
+      ___MESSAGE___( "script: " << script.latin1() );
+      if ( (*it).script().isEmpty() || system( script.latin1() ) ) {
+       QMessageBox::warning( this, 
+                             tr( "Error" ), 
+                             tr( "Can't perform action!"),
+                             QMessageBox::Ok, 
+                             QMessageBox::NoButton,
+                             QMessageBox::NoButton );
       }
-      else
-       msg = tr( "Can't launch SALOME." ) + "\n" + tr( "runSalome file can not be found." );
+      return;
     }
-    else
-      msg = tr( "Can't launch SALOME." ) + "\n" + tr( "Can't find environment file." );
-  }
-  QMessageBox::warning( this, 
-                       tr( "Error" ), 
-                       msg,
-                       QMessageBox::Ok, 
-                       QMessageBox::NoButton,
-                       QMessageBox::NoButton );
+  }
 }
-
 // ================================================================
 /*!
  *  SALOME_InstallWizard::onAbout
@@ -1785,10 +1828,20 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
     }
   }
   else if ( aPage == readmePage ) {
-    QCheckListItem* item = findItem( "KERNEL-Bin" );
-    runSalomeBtn->setEnabled( item &&
-                             QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" ).exists() &&
-                             QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" ).exists() );
+    ButtonList::Iterator it;
+    for ( it = buttons.begin(); it != buttons.end(); ++it ) {
+      if ( (*it).button() ) {
+       QString script;
+       script += "( cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
+       script +=  + (*it).script();
+       script += " check_enabled ";
+       script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
+       script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
+       script += " > /dev/null )";
+       ___MESSAGE___( "script: " << script.latin1() );
+       (*it).button()->setEnabled( !(*it).script().isEmpty() && !system( script.latin1() ) );
+      }
+    }
     finishButton()->setEnabled( true );
   }
   previousPage = aPage;
@@ -2229,6 +2282,19 @@ void SALOME_InstallWizard::setDependancies( QCheckListItem* item, Dependancies d
   productsMap[item] = dep;
 }
 // ================================================================
+/*!
+ *  SALOME_InstallWizard::addFinishButton
+ *  Add button for the <Finish> page
+ */
+// ================================================================
+void SALOME_InstallWizard::addFinishButton( const QString& label, 
+                                           const QString& tooltip, 
+                                           const QString& script)
+{
+  if ( !label.isEmpty() )
+    buttons.append( Button( label, tooltip, script ) );
+}
+// ================================================================
 /*!
  *  SALOME_InstallWizard::polish
  *  Polishing of the widget - to set right initial size