X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUPERVGUI%2FSUPERVGUI_Main.cxx;h=33e2a18d3523673749bc6813774d8b599052e14b;hb=ea7f29f75031ca13b9454f5e9ac73730f1f584eb;hp=d69ac8f54435c85d82906b33812430ca52d740de;hpb=ba259e92d52389c6acdca997e379785a15551ee0;p=modules%2Fsuperv.git diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index d69ac8f..33e2a18 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -332,31 +332,33 @@ void SUPERVGUI_Main::showCanvas() { } void SUPERVGUI_Main::insertFile() { - Trace("SUPERVGUI_Main::insertFile"); - if ((SUPERV_isNull(dataflow))) return; + Trace("SUPERVGUI_Main::insertFile"); + + if ( !ReadyToModify() ) // null dataflow or executing, .. + return; - QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - "", - "*.xml", - tr("MSG_GRAPH_INSERT"), - true); - if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name + QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("MSG_GRAPH_INSERT"), + true); + if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name - Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960 + Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960 - if (dataflow->Import(f.latin1())) { - if (myCurrentView == CANVASTABLE) { - myArray->destroy(); - myArray->create(); - } - else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { - myCanvas->merge(); - } - sync(); - } else { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + if (dataflow->Import(f.latin1())) { + if (myCurrentView == CANVASTABLE) { + myArray->destroy(); + myArray->create(); + } + else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { + myCanvas->merge(); } + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); } + } } void SUPERVGUI_Main::copy() { @@ -595,18 +597,9 @@ void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le */ void SUPERVGUI_Main::addNode() { Trace("SUPERVGUI_Main::addNode"); - bool error = SUPERV_isNull( dataflow ); - if ( error ) + + if ( !ReadyToModify() ) // null dataflow or executing, .. return; - - if ( dataflow->IsExecuting() ) { - error = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No - tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_NO" ), 0, 1, 0 ); - if ( error ) // user selected NOT to kill dataflow and NOT to add new node - return; - else // user selected to kill the dataflow and add new node after that - kill(); - } //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960 Supervision.getBrowser()->choose(); @@ -1199,6 +1192,25 @@ void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode) } } +/** + * ReadyToModify() must be called before any modification + * operation - asks to kill execution of dataflow. If returns false - + * modification (==Editing() ) is not allowed. + */ +bool SUPERVGUI_Main::ReadyToModify() { + if ( CORBA::is_nil( dataflow ) ) + return false; + if ( dataflow->IsExecuting() ) { + bool quit = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No + tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 ); + if ( quit ) // user selected NOT to kill dataflow and NOT to add new node + return false; + else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that + kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up + } + return true; +} + /******************************* SUPERVGUI_Thread class ****************************************/ SUPERVGUI_Thread::SUPERVGUI_Thread() :QThread()