}
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() {
*/
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();
}
}
+/**
+ * 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()