]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Merge from BR_imps_2013 14/01/2014
authorvsr <vsr@opencascade.com>
Wed, 15 Jan 2014 09:28:14 +0000 (09:28 +0000)
committervsr <vsr@opencascade.com>
Wed, 15 Jan 2014 09:28:14 +0000 (09:28 +0000)
src/genericgui/EditionContainer.cxx
src/genericgui/EditionScript.cxx
src/genericgui/EditionScript.hxx
src/genericgui/FormContainer.cxx
src/genericgui/FormContainer.hxx
src/hmi/commandsProc.cxx

index 1ac4754cf0ff3cc9b4a6da252148104c35079403..be134c58bf8e6808d2c0117ff52194ccf9de9356 100644 (file)
@@ -61,6 +61,7 @@ void EditionContainer::update(GuiEvent event, int type, Subject* son)
   switch (event)
     {
     case RENAME:
+    case UPDATE:
       _wContainer->le_name->setText((son->getName()).c_str());
       fillContainerPanel();
       break;
@@ -95,8 +96,6 @@ void EditionContainer::onApply()
 void EditionContainer::onCancel()
 {
   DEBTRACE("EditionContainer::onCancel");
-  SubjectContainer *scont = dynamic_cast<SubjectContainer*>(_subject);
-  YASSERT(scont);
-  _wContainer->FillPanel(scont->getContainer());
+  _wContainer->onCancel();
   ItemEdition::onCancel();
 }
index e165c36cd9bb6d5980dcc2edd60b4be6a8da5ddd..c616771bc67e730af4a3ec47c585d7af77acd097 100644 (file)
 #include "Resource.hxx"
 #include "Container.hxx"
 #include "InlineNode.hxx"
+#include "FormContainer.hxx"
+#include "Message.hxx"
 
 #if HAS_QSCI4>0
 #include <qsciscintilla.h>
 #include <qscilexerpython.h>
 #endif
 
-#include <QToolButton>
 #include <QSplitter>
 #include <QTemporaryFile>
 #include <QTextStream>
@@ -96,36 +97,6 @@ EditionScript::EditionScript(Subject* subject,
   _glayout->setMargin(1);
   splitter->addWidget(window);
 
-  //add an options section in ports layout for execution mode (local or remote)
-  QHBoxLayout* hboxLayout = new QHBoxLayout();
-  hboxLayout->setMargin(0);
-  QToolButton* tb_options = new QToolButton();
-  tb_options->setCheckable(true);
-  QIcon icon;
-  icon.addFile("icons:icon_down.png");
-  icon.addFile("icons:icon_up.png", QSize(), QIcon::Normal, QIcon::On);
-  tb_options->setIcon(icon);
-  hboxLayout->addWidget(tb_options);
-
-  QLabel* label = new QLabel("Execution Mode");
-  QFont font;
-  font.setBold(true);
-  font.setWeight(75);
-  label->setFont(font);
-  hboxLayout->addWidget(label);
-
-  _portslayout->addLayout(hboxLayout);
-
-  fr_options = new QFrame();
-  QHBoxLayout* hboxLayout1 = new QHBoxLayout(fr_options);
-  hboxLayout1->setMargin(0);
-  radiolocal= new QRadioButton("Local");
-  radioremote= new QRadioButton("Remote");
-  radiolocal->setChecked(true);
-  hboxLayout1->addWidget(radiolocal);
-  hboxLayout1->addWidget(radioremote);
-  hboxLayout->addWidget(fr_options);
-
   fr_container = new QFrame();
   QHBoxLayout* hboxLayout2 = new QHBoxLayout(fr_container);
   hboxLayout2->setMargin(0);
@@ -134,6 +105,10 @@ EditionScript::EditionScript(Subject* subject,
   cb_container = new ComboBox();
   hboxLayout2->addWidget(cb_container);
   _portslayout->addWidget(fr_container);
+
+  formcontainer = new FormContainer(this);
+  formcontainer->on_tb_container_toggled(false);
+  _portslayout->addWidget(formcontainer);
   //end of insertion of execution mode
 
   createTablePorts(_portslayout);
@@ -181,13 +156,11 @@ EditionScript::EditionScript(Subject* subject,
     }
   connect(_sci, SIGNAL(textChanged()), this, SLOT(onScriptModified()));
 
-  connect(tb_options, SIGNAL(toggled(bool)), this, SLOT(on_tb_options_toggled(bool)));
-  connect(radioremote, SIGNAL(toggled(bool)), this, SLOT(on_remote_toggled(bool)));
   connect(cb_container, SIGNAL(mousePressed()), this, SLOT(fillContainerPanel()));
   connect(cb_container, SIGNAL(activated(int)), this, SLOT(changeContainer(int)));
 
   update(UPDATE,0,0);
-  on_tb_options_toggled(false);
+  changeContainer(0);
 }
 
 EditionScript::~EditionScript()
@@ -253,7 +226,17 @@ void EditionScript::onApply()
         }
 #endif
     }
-  _isEdited = _isEdited || scriptEdited;
+
+  bool containerEdited = true;
+  if (formcontainer->onApply()) {
+    fillContainerPanel();
+    containerEdited = false;
+  } else {
+    Message mess(GuiContext::getCurrent()->_lastErrorMessage);
+    return;
+  }
+
+  _isEdited = _isEdited || scriptEdited || containerEdited;
 
   EditionElementaryNode::onApply();
 }
@@ -262,6 +245,7 @@ void EditionScript::onCancel()
 {
   if (_haveScript)
     _sci->setText(_subInlineNode->getScript().c_str());
+  formcontainer->onCancel();
   EditionElementaryNode::onCancel();
 }
 
@@ -303,47 +287,6 @@ void EditionScript::onEdit()
   onApply();
 }
 
-void EditionScript::on_tb_options_toggled(bool checked)
-{
-  DEBTRACE("EditionScript::on_tb_options_toggled " << checked);
-  _checked = checked;
-  if(_checked)
-    {
-      fr_options->show();
-      if(_remote)fr_container->show();
-    }
-  else
-    {
-      fr_options->hide();
-      fr_container->hide();
-    }
-}
-
-void EditionScript::on_remote_toggled(bool checked)
-{
-  DEBTRACE("EditionScript::on_remote_toggled " << checked);
-  _remote=checked;
-  YACS::ENGINE::InlineNode *pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(_subInlineNode->getNode());
-  std::string mode = pyNode->getExecutionMode();
-  DEBTRACE(mode);
-
-  if(checked)
-    {
-      //remote radio button is checked
-      if(mode != "remote")
-        _subInlineNode->setExecutionMode("remote");
-      fr_container->show();
-      fillContainerPanel();
-    }
-  else
-    {
-      //remote radio button is unchecked
-      if(mode != "local")
-        _subInlineNode->setExecutionMode("local");
-      fr_container->hide();
-    }
-}
-
 void EditionScript::fillContainerPanel()
 {
   DEBTRACE("EditionScript::fillContainerPanel ");
@@ -361,6 +304,7 @@ void EditionScript::fillContainerPanel()
     {
       int index = cb_container->findText(cont->getName().c_str());
       cb_container->setCurrentIndex(index);
+      formcontainer->FillPanel(cont);
     }
 }
 
@@ -385,6 +329,9 @@ void EditionScript::changeContainer(int index)
   SubjectContainer *scnt = GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer];
 
   _subInlineNode->setContainer(scnt);
+  
+  // show the selected container parameters
+  formcontainer->FillPanel(newContainer);
 }
 
 void EditionScript::update(GuiEvent event, int type, Subject* son)
@@ -394,22 +341,12 @@ void EditionScript::update(GuiEvent event, int type, Subject* son)
   if(event == ASSOCIATE)
     {
       fillContainerPanel();
+      SubjectContainer *scont = dynamic_cast<SubjectContainer*>(son);
+      YASSERT(scont);
+      formcontainer->FillPanel(scont->getContainer());
     }
   else if(event == UPDATE)
     {
-      YACS::ENGINE::InlineNode *pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(_subInlineNode->getNode());
-      std::string mode = pyNode->getExecutionMode();
-      if(mode == "remote")
-        {
-          _remote=true;
-          radioremote->setChecked(true);
-        }
-      else if(mode == "local")
-        {
-          _remote=false;
-          radiolocal->setChecked(true);
-        }
-
       fillContainerPanel();
     }
 }
index 1e6b3dbfec4d0712c40c6d4568a8a6b00db67e75..d5f0a77abec52f4025ab04c83d407a210e01a673 100644 (file)
@@ -23,7 +23,8 @@
 #include "yacsconfig.h"
 #include "EditionElementaryNode.hxx"
 #include "FormComponent.hxx"
-#include <QRadioButton>
+
+class FormContainer;
 
 #if HAS_QSCI4>0
 class QsciScintilla;
@@ -42,8 +43,6 @@ namespace YACS
       virtual void onCancel();
       virtual void onScriptModified();
       virtual void onEdit();
-      virtual void on_tb_options_toggled(bool checked);
-      virtual void on_remote_toggled(bool checked);
       virtual void fillContainerPanel();
       virtual void changeContainer(int);
       virtual void update(GuiEvent event, int type, Subject* son);
@@ -68,11 +67,9 @@ namespace YACS
       QPushButton* _editor;
       bool _checked;
       bool _remote;
-      QFrame *fr_options;
       QFrame *fr_container;
       ComboBox* cb_container;
-      QRadioButton* radiolocal;
-      QRadioButton* radioremote;
+      FormContainer* formcontainer;
     };
   }
 }
index 611cb98e80597af18eee62e9c58aabaadd9946d7..b01c70865b66956008096f4776f00f37c7e57030 100644 (file)
@@ -705,8 +705,16 @@ bool FormContainer::onApply()
   SubjectContainer *scont =
     QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container];
   YASSERT(scont);
-  bool ret = scont->setProperties(_properties);
+  bool ret = scont->setName(le_name->text().toStdString());
   DEBTRACE(ret);
-  if (ret) ret = scont->setName(le_name->text().toStdString());
+  if (ret) ret = scont->setProperties(_properties);
   return ret;
 }
+
+void FormContainer::onCancel()
+{
+  SubjectContainer *scont =
+    QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container];
+  YASSERT(scont);
+  FillPanel(scont->getContainer());
+}
index 27b97ebe9d795034139e32faf247c82f3990b29f..8c60b0f86de8d4b0695efd74bc9e6e1ca46529b3 100644 (file)
@@ -45,6 +45,7 @@ public:
   void FillPanel(YACS::ENGINE::Container *container);
   virtual void onModified();
   virtual bool onApply();
+  virtual void onCancel();
   void updateResource(const std::string &resource);
 
 public:
index 32c7a588c6cd36c44aa2ee0fe8fd7ee91e2642bc..c045d37f5e774345d33fd740e61af7a8ab99137e 100644 (file)
@@ -3358,6 +3358,9 @@ bool CommandSetContainerProperties::localExecute()
           YASSERT(ref);
           _oldProp = ref->getProperties();
           ref->setProperties(_properties);
+          SubjectContainer *scont = GuiContext::getCurrent()->_mapOfSubjectContainer[ref]; 
+          scont->update(UPDATE, 0, scont);
+          scont->notifyComponentsChange(ASSOCIATE, CONTAINER, scont);
           return true;
         }
       GuiContext::getCurrent()->_lastErrorMessage = "container not found: " + _container;