]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Salome HOME
Fix for mantis #0022093: To exclude the "In-Draft" state from drop-down list during...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditScenarioPropertiesAction.java
index e2094b9b6ea8e8c9650f46612e2024bf21a4f9ff..26a8d47a1299b9220a1753ce2aba3e0173acba73 100644 (file)
@@ -1,10 +1,13 @@
 package org.splat.simer;
 
 import java.text.SimpleDateFormat;
+import java.util.Iterator;
+import java.util.List;
 import java.util.ResourceBundle;
 
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.service.ProjectElementService;
 import org.splat.service.ScenarioService;
@@ -12,80 +15,58 @@ import org.splat.som.Step;
 import org.splat.som.StepRights;
 import org.splat.wapp.Constants;
 
+/**
+ * Action for scenario properties modification.
+ */
 public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
 
-       private Scenario myscenario;
-       private String lasdate;
-       private String subject;
-
-       /**
-        * The Scenario service.
-        */
-       private ScenarioService _scenarioService;
-
-       /**
-        * The PojectElement service.
-        */
-       private ProjectElementService _projectElementService;
-
-       /**
-        * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
-        */
-       private String _menuProperty;
-
        /**
-        * Value of the title bar property. It can be: study, knowledge.
+        * Serial version ID.
         */
-       private String _titleProperty;
+       private static final long serialVersionUID = 4964740932426016171L;
 
-       /**
-        * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
-        * menu also can be called. It is necessary for correct building the title bar.
-        */
-       private String _editDisabledProperty = "false";
+       private transient Scenario _myscenario;
+       private transient String _lasdate;
+       private transient String _subject;
 
        /**
-        * Value of the tool bar property. It can be: none, standard, study, back.
+        * Title of the selected scenario.
         */
-       private String _toolProperty;
+       private String _selectedScenarioTitle;
 
        /**
-        * Value of the left menu property. It can be: open, study, knowledge, scenario.
+        * The Scenario service.
         */
-       private String _leftMenuProperty;
+       private ScenarioService _scenarioService;
 
        /**
-        * Serial version ID.
+        * The PojectElement service.
         */
-       private static final long serialVersionUID = 4964740932426016171L;
+       private ProjectElementService _projectElementService;
 
        // ==============================================================================================================================
        // Action methods
        // ==============================================================================================================================
 
        public String doInitialize() {
-               // -----------------------------
                ResourceBundle label = ResourceBundle.getBundle("labels",
                                getApplicationSettings().getCurrentLocale());
                ResourceBundle custom = ResourceBundle.getBundle("som",
                                getApplicationSettings().getCurrentLocale());
                SimpleDateFormat datstring = new SimpleDateFormat(custom
-                               .getString("date.format")); // Locale date display format
+                               .getString("date.format"), getApplicationSettings()
+                               .getCurrentLocale()); // Locale date display format
                Step step;
 
                _openStudy = getOpenStudy();
                step = _openStudy.getSelectedStep();
-               myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
-               lasdate = datstring.format(myscenario.getLastModificationDate());
-               subject = label.getString("label.study") + " " + _openStudy.getTitle();
-
-               setMenuProperty(Constants.STUDY_MENU);
-               setTitleProperty(Constants.STUDY_MENU);
-               setEditDisabledProperty("true");
-               setToolProperty("back");
-               setLeftMenuProperty("open");
-               initializationFullScreenContext(_menuProperty, _titleProperty,
-                               _editDisabledProperty, _toolProperty, _leftMenuProperty);
+               _myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
+               _lasdate = datstring.format(_myscenario.getLastModificationDate());
+               _subject = label.getString("label.study") + " " + _openStudy.getTitle();
+               _selectedScenarioTitle = _myscenario.getTitle();
+
+               initializationFullScreenContext(Constants.STUDY_MENU,
+                               Constants.STUDY_MENU, "true", "back", "open");
 
                return SUCCESS;
        }
@@ -103,27 +84,46 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                _openStudy = getOpenStudy();
                _selection = _openStudy.getSelection();
                step = _openStudy.getSelectedStep();
-               myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
+               _myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
 
-               getScenarioService().checkin(myscenario.getIndex());
+               getScenarioService().checkin(_myscenario.getIndex());
                // TODO: Do it in the business service after moving to DTO instead of id parameter
                // or reread the scenario.
-               myscenario.setUser(null);
+               _myscenario.setUser(null);
 
                _openStudy.getMenu().refreshGivenStepItem(
-                               getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
+                               getProjectElementService().getFirstStep(_myscenario)); // For updating the scenario icon
 
-               setMenuProperty(Constants.STUDY_MENU);
                if ("true".equals(getWriteAccess())
                                && getUserRights().canCreateDocument()) {
                        setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               setLeftMenuProperty(Constants.STUDY_MENU);
-               initializationFullScreenContext(_menuProperty, _toolProperty,
-                               _leftMenuProperty);
+               initializationFullScreenContext(Constants.STUDY_MENU,
+                               getToolProperty(), Constants.STUDY_MENU);
+
+               return SUCCESS;
+       }
 
+       /**
+        * Rename the scenario functionality.
+        * 
+        * @return SUCCESS
+        */
+       public String doEditScenarioTitle() {
+               OpenStudy openStudy = getOpenStudy();
+               Study study = openStudy.getStudyObject();
+               List<Scenario> scenarios = study.getScenariiList();
+               Iterator<Scenario> iter = scenarios.iterator();
+               for (; iter.hasNext();) {
+                       Scenario scenario = iter.next();
+                       if (openStudy.getSelectedScenarioId().equals(
+                                       String.valueOf(scenario.getIndex()))) {
+                               scenario.setTitle(getSelectedScenarioTitle());
+                               _scenarioService.renameScenario(scenario);
+                       }
+               }
                return SUCCESS;
        }
 
@@ -138,16 +138,16 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
         */
        public User getAuthor() {
                User author;
-               if (myscenario.isCheckedout()) {
-                       author = myscenario.getUser();
+               if (_myscenario.isCheckedout()) {
+                       author = _myscenario.getUser();
                } else {
-                       author = myscenario.getAuthor();
+                       author = _myscenario.getAuthor();
                }
                return author;
        }
 
        public String getLastModificationDate() {
-               return lasdate;
+               return _lasdate;
        }
 
        public StepRights getSelectedStep() {
@@ -155,15 +155,30 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
        }
 
        public String getSubject() {
-               return subject;
+               return _subject;
        }
 
-       public String getTitle() {
-               return myscenario.getTitle();
+       public boolean isCheckedout() {
+               return _myscenario.isCheckedout();
        }
 
-       public boolean isCheckedout() {
-               return myscenario.isCheckedout();
+       /**
+        * Get the selectedScenarioTitle.
+        * 
+        * @return the selectedScenarioTitle
+        */
+       public String getSelectedScenarioTitle() {
+               return _selectedScenarioTitle;
+       }
+
+       /**
+        * Set the selectedScenarioTitle.
+        * 
+        * @param selectedScenarioTitle
+        *            the selectedScenarioTitle to set
+        */
+       public void setSelectedScenarioTitle(final String selectedScenarioTitle) {
+               _selectedScenarioTitle = selectedScenarioTitle;
        }
 
        /**
@@ -204,109 +219,4 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                        final ProjectElementService projectElementService) {
                _projectElementService = projectElementService;
        }
-
-       /**
-        * Get the menuProperty.
-        * 
-        * @return the menuProperty
-        */
-       @Override
-       public String getMenuProperty() {
-               return _menuProperty;
-       }
-
-       /**
-        * Set the menuProperty.
-        * 
-        * @param menuProperty
-        *            the menuProperty to set
-        */
-       @Override
-       public void setMenuProperty(final String menuProperty) {
-               this._menuProperty = menuProperty;
-       }
-
-       /**
-        * Get the _titleProperty.
-        * 
-        * @return the _titleProperty
-        */
-       @Override
-       public String getTitleProperty() {
-               return _titleProperty;
-       }
-
-       /**
-        * Set the _titleProperty.
-        * 
-        * @param _titleProperty
-        *            the titleProperty to set
-        */
-       @Override
-       public void setTitleProperty(final String titleProperty) {
-               _titleProperty = titleProperty;
-       }
-
-       /**
-        * Get the editDisabledProperty.
-        * 
-        * @return the editDisabledProperty
-        */
-       @Override
-       public final String getEditDisabledProperty() {
-               return _editDisabledProperty;
-       }
-
-       /**
-        * Set the editDisabledProperty.
-        * 
-        * @param editDisabledProperty
-        *            the editDisabledProperty to set
-        */
-       @Override
-       public final void setEditDisabledProperty(final String editDisabledProperty) {
-               _editDisabledProperty = editDisabledProperty;
-       }
-
-       /**
-        * Get the toolProperty.
-        * 
-        * @return the toolProperty
-        */
-       @Override
-       public String getToolProperty() {
-               return _toolProperty;
-       }
-
-       /**
-        * Set the toolProperty.
-        * 
-        * @param toolProperty
-        *            the toolProperty to set
-        */
-       @Override
-       public void setToolProperty(final String toolProperty) {
-               _toolProperty = toolProperty;
-       }
-
-       /**
-        * Get the leftMenuProperty.
-        * 
-        * @return the leftMenuProperty
-        */
-       @Override
-       public String getLeftMenuProperty() {
-               return _leftMenuProperty;
-       }
-
-       /**
-        * Set the leftMenuProperty.
-        * 
-        * @param leftMenuProperty
-        *            the leftMenuProperty to set
-        */
-       @Override
-       public void setLeftMenuProperty(final String leftMenuProperty) {
-               _leftMenuProperty = leftMenuProperty;
-       }
 }
\ No newline at end of file