]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Rename the scenario functionality is implemented
authormka <mka@opencascade.com>
Thu, 31 Jan 2013 14:35:35 +0000 (14:35 +0000)
committermka <mka@opencascade.com>
Thu, 31 Jan 2013 14:35:35 +0000 (14:35 +0000)
Workspace/Siman-Common/src/org/splat/service/ScenarioService.java
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman/WebContent/study/editScenarioProperties.jsp
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Workspace/Siman/src/struts.xml

index 939a0ef5c78d76c017a73c2e85daf3513c109b49..200d3a94d0106bd521df53a0ef65f967151f3435 100644 (file)
@@ -200,4 +200,10 @@ public interface ScenarioService {
         * @return true if removal succeeded
         */
        boolean removeKnowledgeElement(Scenario scenario, KnowledgeElement kelm);
+       
+       /**
+        * Rename the scenario.
+        * @param scenario - the scenario with a new title.
+        */
+       void renameScenario(final Scenario scenario);
 }
index 75bcac13a84901031f2dabeb37f93c5317cd5b65..ad4af9f41a415c722ff471419745a3479042cd0e 100644 (file)
@@ -958,6 +958,16 @@ public class ScenarioServiceImpl implements ScenarioService {
                }
                return isOk;
        }
+       
+       /**
+        * 
+        * {@inheritDoc}
+        * @see org.splat.service.ScenarioService#renameScenario(java.lang.String)
+        */
+       @Transactional
+       public void renameScenario(final Scenario scenario) {
+               getScenarioDAO().merge(scenario);
+       }
 
        /**
         * Get the knowledgeElementDAO.
index 35a2a639eb53f0c143266a9e78752c3dc0e6472b..0913a60e4b346519983688acf7455beee0c5e24f 100644 (file)
@@ -1,5 +1,8 @@
 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
 <%@ taglib prefix="s" uri="/struts-tags"%>
+
+<s:url id="rename_scenario" value="valid-rename.action" includeParams="none" escapeAmp="false" />
+
     <script language="JavaScript">
 
     function checkin (message) {
@@ -16,7 +19,7 @@
       <div id=article-box>
         <div id=section>
           <s:text name="title.prop.scenario">
-            <s:param><s:property value="%{title}"/></s:param>
+            <s:param><s:property value="%{selectedScenarioTitle}"/></s:param>
           </s:text>
         </div>
         <div id=article-body class=text>
 
 <!-- Scenario ckecked-in (editable)
   -->   <s:else>
-        <form name="property" action="valid-rename" method="post">
+        <s:form name="property" action="%{rename_scenario}" method="post">
           <table class="text">
             <tr>
               <td><s:text name="field.scenariotitle"/>*:&nbsp;</td>
               <td>
-                <input type=text size="25" name=title value="<s:property value="title"/>">
+                <input type=text" size="25" name="selectedScenarioTitle" value="<s:property value="selectedScenarioTitle"/>">
               </td>
               <td>
                 <input type="submit" name="save"   value="<s:text name="button.save"/>"/>
               </td>
             </tr>
           </table>
-        </form>
+        </s:form>
         </s:else>
 
         </div>
index e9e6fdb583be91a8b4dbb0ff5ba093f071153fc3..397dc825c0ef219e9fdbd07384eb624b16e63c4c 100644 (file)
@@ -491,7 +491,6 @@ public class ApplicationSettings {
                                                "message.markasreference.study"));
                        }
                        
-                       LOG.debug("MKA isPublic = " + isPublic);
                        if (isPublic) {
                                addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PROTECT).icon(
                                                "image.publish.png").action("edit-study?action=protect")
index e29124ff7fe621e1edaeebbdb5665a20aa0d15cc..c6ddf7dc6cacdf6731f279ffa4a4e8fb08fe45f9 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;
@@ -22,6 +25,11 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
        private transient Scenario _myscenario;
        private transient String _lasdate;
        private transient String _subject;
+       
+       /**
+        * Title of the selected scenario.
+        */
+       private String _selectedScenarioTitle;
 
        /**
         * The Scenario service.
@@ -51,6 +59,7 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                _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");
@@ -93,6 +102,25 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                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;
+       }
+       
        // ==============================================================================================================================
        // Getters
        // ==============================================================================================================================
@@ -124,13 +152,28 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                return _subject;
        }
 
-       public String getTitle() {
-               return _myscenario.getTitle();
-       }
 
        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;
+       }
 
        /**
         * Get the scenarioService.
index a313289ebeec2c616f7d1abf618dfc5502c9fe6b..5683d743e629fccd6691430aada15e585db209e7 100644 (file)
                </action>
                <action name="markasref-study" class="editStudyAction"
                        method="markAsReference">
+                       <interceptor-ref name="simanBasicStack" />
                        <result name="success" type="tiles">
                                page.displaystudy
                        </result>
                </action>
                <action name="removeasref-study" class="editStudyAction"
                        method="removeAsReference">
+                       <interceptor-ref name="simanBasicStack" />
                        <result name="success" type="tiles">
                                page.displaystudy
                        </result>
                </action>
                
+               <action name="valid-rename" class="editScenarioPropertiesAction"
+                       method="editScenarioTitle">
+                       <interceptor-ref name="simanBasicStack" />
+                       <result name="success" type="redirectAction">
+                               open-study
+                       </result>
+               </action>
+               
                <action name="add-scenario" class="newScenarioAction"
                        method="initialize">
                        <result name="success" type="tiles">