]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
We can now remove resources
authorribes <ribes>
Thu, 21 Jan 2010 17:02:14 +0000 (17:02 +0000)
committerribes <ribes>
Thu, 21 Jan 2010 17:02:14 +0000 (17:02 +0000)
src/engine/BL_SALOMEServices.cxx
src/engine/BL_SALOMEServices.hxx
src/genericgui/JM_ResourceCatalog.cxx
src/genericgui/JM_ResourceCatalog.hxx

index f6604b55692ce5c6eee6c639adb12d4254744a9d..fc5cb9ab158488f4df1a440b582d221398e95a89 100644 (file)
@@ -80,7 +80,6 @@ BL::SALOMEServices::getResourceList()
     }
     delete resourceList;
   }
-
   return resource_list;
 }
 
@@ -151,6 +150,19 @@ BL::SALOMEServices::addResource(BL::ResourceDescr & new_resource)
   }
 }
 
+void 
+BL::SALOMEServices::removeResource(const std::string & name)
+{
+  try
+  {
+    _resources_manager->RemoveResource(name.c_str(), true, "");
+  }
+  catch (const SALOME::SALOME_Exception & ex)
+  {
+    DEBTRACE("SALOME Exception in removeResource ! " << ex.details.text.in());
+  }
+}
+
 std::string
 BL::SALOMEServices::create_job(BL::Job * job)
 {
index 6908379990cba919d7ae3b6097ec6d1cd581a01f..cce2c2b9aa7ba71b1379b5e7d00be30d230140e9 100644 (file)
@@ -63,6 +63,7 @@ namespace BL{
       std::list<std::string> getResourceList();
       BL::ResourceDescr getResourceDescr(const std::string& name);
       void addResource(BL::ResourceDescr & new_resource);
+      void removeResource(const std::string & name);
 
       std::string create_job(BL::Job * job);
       std::string start_job(BL::Job * job);
index 94e72edaffc25276346ca5cf735e76c8c036505b..134f3688521ee651e43f6c0677ee6f0492e288f6 100644 (file)
@@ -47,11 +47,14 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom
   _edit_button = new QPushButton("Edit");
   _edit_button->setEnabled(false);
   _add_button = new QPushButton("Add");
+  _remove_button = new QPushButton("Remove");
+  _remove_button->setEnabled(false);
 
   QHBoxLayout * button_layout = new QHBoxLayout(this);
   button_layout->addWidget(_show_button);
   button_layout->addWidget(_edit_button);
   button_layout->addWidget(_add_button);
+  button_layout->addWidget(_remove_button);
   QWidget * layout_widget = new QWidget(this);
   layout_widget->setLayout(button_layout);
 
@@ -66,6 +69,7 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom
   connect(_show_button, SIGNAL(clicked()), this, SLOT(show_button()));
   connect(_edit_button, SIGNAL(clicked()), this, SLOT(edit_button()));
   connect(_add_button, SIGNAL(clicked()), this, SLOT(add_button()));
+  connect(_remove_button, SIGNAL(clicked()), this, SLOT(remove_button()));
   // Double click on an item
   connect(_resource_files_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(item_choosed(QListWidgetItem*)));
   // Selection management
@@ -117,11 +121,13 @@ JM::ResourceCatalog::buttons_management()
   {
     _show_button->setEnabled(false);
     _edit_button->setEnabled(false);
+    _remove_button->setEnabled(false);
   }
   else
   {
     _show_button->setEnabled(true);
     _edit_button->setEnabled(true);
+    _remove_button->setEnabled(true);
   }
 }
 
@@ -139,6 +145,16 @@ JM::ResourceCatalog::add_button()
                                                                        _salome_services);
   resource_widget->exec();
   delete resource_widget;
+  refresh_resource_list();
+}
+
+void
+JM::ResourceCatalog::remove_button()
+{
+  QList<QListWidgetItem *> item_list = _resource_files_list->selectedItems();
+  QString item_name = item_list.at(0)->text();
+  _salome_services->removeResource(item_name.toStdString());
+  refresh_resource_list();
 }
 
 void
@@ -151,4 +167,5 @@ JM::ResourceCatalog::edit_button()
                                                                        item_name.toStdString());
   resource_widget->exec();
   delete resource_widget;
+  refresh_resource_list();
 }
index 2323b3688c9dbccd38949773c376a9f77f5b75d8..e05109750e4776117b044393ac0925d072a269b9 100644 (file)
@@ -48,6 +48,7 @@ namespace JM
       void show_button();
       void edit_button();
       void add_button();
+      void remove_button();
 
     protected:
       QWidget* _parent;
@@ -57,6 +58,7 @@ namespace JM
       QPushButton * _show_button;
       QPushButton * _edit_button;
       QPushButton * _add_button;
+      QPushButton * _remove_button;
       QListWidget * _resource_files_list;
   };
 }