]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
displayStudy.jsp is removed, markup is fixed. KnowledgeElement deleting is fixed.
authorrkv <rkv@opencascade.com>
Mon, 10 Dec 2012 13:07:30 +0000 (13:07 +0000)
committerrkv <rkv@opencascade.com>
Mon, 10 Dec 2012 13:07:30 +0000 (13:07 +0000)
14 files changed:
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml
Workspace/Siman/WebContent/jap/splat-launcher.jar
Workspace/Siman/WebContent/jap/splat-signedlauncher.jar
Workspace/Siman/WebContent/js/popup.js
Workspace/Siman/WebContent/jsp/editContext.jsp
Workspace/Siman/WebContent/jsp/readKnowledge.jsp
Workspace/Siman/WebContent/study/displayStudy.jsp [deleted file]
Workspace/Siman/WebContent/study/displayStudyStep.jsp
Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java
Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/struts.xml

index 0c250e97db02268927f888256b5140a20134df7f..fa1f31e41249a8e8145737f1a681db57d9de656d 100644 (file)
@@ -749,7 +749,8 @@ public class ScenarioServiceImpl implements ScenarioService {
                                aUser);
                if (res) {
                        if (aScenario.isCheckedout()
-                                       && (!aScenario.getUser().getUsername().equals(aUser.getUsername()))) {
+                                       && (!aScenario.getUser().getUsername().equals(
+                                                       aUser.getUsername()))) {
                                throw new NotApplicableException(MessageKeyEnum.SCN_000008
                                                .toString(), scenarioId, aScenario.getUser()
                                                .getUsername());
@@ -885,28 +886,27 @@ public class ScenarioServiceImpl implements ScenarioService {
         *            the knowledge element to remove
         * @return true if removal succeeded
         */
+       @Transactional
        public boolean removeKnowledgeElement(final Scenario scenario,
                        final KnowledgeElement kelm) {
                KnowledgeElement torem = scenario.getKnowledgeElement(kelm.getIndex());
-               if (torem == null) {
-                       return false;
-               }
-               boolean done = scenario.getKnowledgeElements().remove(torem);
-               if (done) {
-                       // Update of my transient data
-                       // RKV: These transient data are not used indeed.
-                       // RKV: List<KnowledgeElement> kelms = scenario.getKnowledgeByType().get(
-                       // RKV: kelm.getType().getIndex());
-                       // RKV: kelms.remove(torem);
-                       if (scenario.getKnowledgeElementsList() != null) {
-                               scenario.getKnowledgeElementsList().remove(torem);
+               boolean isOk = (torem != null);
+               if (isOk) {
+                       isOk =  scenario.getKnowledgeElements().remove(torem);
+                       if (isOk) {
+                               getScenarioDAO().merge(scenario);
+                               // Update of my transient data
+                               // RKV: These transient data are not used indeed.
+                               // RKV: List<KnowledgeElement> kelms = scenario.getKnowledgeByType().get(
+                               // RKV: kelm.getType().getIndex());
+                               // RKV: kelms.remove(torem);
+                               if (scenario.getKnowledgeElementsList() != null) {
+                                       scenario.getKnowledgeElementsList().remove(torem);
+                               }
+                               // TODO: If the owner study is not private, remove the knowledge from the Lucene index
                        }
-                       getScenarioDAO().update(scenario);
-                       // TODO: If the owner study is not private, remove the knowledge from the Lucene index
-                       return true;
-               } else {
-                       return false;
                }
+               return isOk;
        }
 
        /**
index 4d1b001433fb7116b344d7a06e72a6278d1b895e..878eceb9db0b6757a556949980814946867da37a 100644 (file)
 </definition>
 
 <definition name="page.displaystudy" extends="baseLayout">
-       <put-attribute name="presentation_pane"   value="/study/displayStudyStep.jsp"/>
+    <put-attribute name="presentation_pane"   value="/study/displayStudyStep.jsp"/>
 </definition>
+<!-- RKV: BEGIN: Simulation contexts -->
+<definition name="page.newcontext" extends="baseLayout">
+    <put-attribute name="presentation_pane"   value="/study/displayStudyStep.jsp?action=newContext"/>
+</definition>
+
+<definition name="page.selectcontext" extends="baseLayout">
+    <put-attribute name="presentation_pane"   value="/study/displayStudyStep.jsp?action=selectContext"/>
+</definition>
+
+<definition name="page.setcontext" extends="baseLayout">
+    <put-attribute name="presentation_pane"   value="/study/displayStudyStep.jsp?action=setContext"/>
+</definition>
+<!-- RKV: END: Simulation contexts -->
 
 <definition name="page.displaystudyproperties" extends="baseLayout">
        <put-attribute name="presentation_pane"   value="/study/displayStudyProperties.jsp"/>
index 587729240e237305d318b1125e646dffdfb5c6ed..8bb900a7675a03b441a569a5d38ec62b47d738e8 100644 (file)
Binary files a/Workspace/Siman/WebContent/jap/splat-launcher.jar and b/Workspace/Siman/WebContent/jap/splat-launcher.jar differ
index cbec878846f83b184b45ad46ee9fe0ba25663a7c..f2a64e4b07b596017c197d1460ad8a100cb32c9d 100644 (file)
Binary files a/Workspace/Siman/WebContent/jap/splat-signedlauncher.jar and b/Workspace/Siman/WebContent/jap/splat-signedlauncher.jar differ
index 7c3767de8f8c65a230f67dcfd473cfeee449a5a6..5acc0ea78899e38537d0e2d9993255af0d6dca06 100644 (file)
       }
       return true;
     }
-
-////  For making easier on the eyes and fingers
-//    function $(id) {
-////  --------------
-//      return document.getElementById(id);
-//    }
\ No newline at end of file
index 983161d3d072f036b7746d5591532facdfdea808..273d7b82fb4529ae43757242d8ae70f34ea7d349 100644 (file)
@@ -3,13 +3,11 @@
 %>
 <%@ taglib prefix="s" uri="/struts-tags"
 %>
-<s:set var="todo"><%=request.getParameter("action")%></s:set>
-<s:set var="type"><%=request.getParameter("type")%></s:set>
 <s:url id="undo" namespace="/study" action="step-study"></s:url>
 
 <!-- Selection of an existing type of simulation context
   -->
-<s:if test="%{#todo == 'selectContext'}">
+<s:if test="%{action == 'selectContext'}">
   <table cellpadding=0 cellspacing=0 border=0 class=text>
     <tr height=2><td></td></tr>
   <s:iterator value="simulationContexts">
@@ -82,7 +80,7 @@
 <!-- Input of a new type of simulation context
 -->
   <table cellpadding=0 cellspacing=0 border=0 class=text>
-    <s:if test="%{#todo == 'newContext'}">
+    <s:if test="%{action == 'newContext'}">
     <tr height=18>
       <td width=18 align=center>
         <s:a href="%{undo}"><img src="<s:url value="/skin/icon.undo.png"/>" border="none" title="<s:text name="tooltip.cancel"/>" /></s:a>
@@ -99,7 +97,7 @@
 
 <!-- Input of a value of the selected simulation context type
   -->
-    <s:elseif test="%{#todo == 'setContext'}">
+    <s:elseif test="%{action == 'setContext'}">
     <tr height=18>
       <td width=18 align=center>
         <s:a href="%{undo}"><img src="<s:url value="/skin/icon.undo.png"/>" border="none" title="<s:text name="tooltip.cancel"/>" /></s:a>
           </select>
         </td>
         <td id=enter style="display: none">
-          <input type=hidden name=contextType value="<s:property value="%{#type}"/>">
+          <input type=hidden name=contextType value="<s:property value="index"/>">
           <input type=text  name=contextValue>
         </td>
               <td>
       </s:if>
       <s:else>
         <td>
-          <input type=hidden name=contextType value="<s:property value="%{#type}"/>">
+          <input type=hidden name=contextType value="<s:property value="index"/>">
           <input type=hidden name=contextValue value="0">
           <input type=text   name=contextValue>
         </td>
index 0a74809928d1a3d673fd6c86cdfda462de37045d..a1d402d86f816618934b71f4bf2a360f38dc5972 100644 (file)
     <s:set var="knowledge"><%=type.getIndex().toString()%></s:set>
     <tr height=20 valign=bottom>
       <td>
-        <s:a href="%{addknowledge}?knowledgeType=%{#knowledge}">
+        <s:a href="%{addknowledge}?action=addKnowledge&index=%{#knowledge}">
           <img src="<s:url value="/skin/icon.add.png"/>" onMouseOver=this.src="<s:url value="/skin/icon.addhot.png"/>" onMouseOut=this.src="<s:url value="/skin/icon.add.png"/>" border="none" title="<s:text name="tooltip.addknowledge"/>" />
         </s:a>
       </td>
diff --git a/Workspace/Siman/WebContent/study/displayStudy.jsp b/Workspace/Siman/WebContent/study/displayStudy.jsp
deleted file mode 100644 (file)
index 753263b..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
-    pageEncoding="ISO-8859-1"
-%>
-<%@
-    taglib prefix="s" uri="/struts-tags"
-%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
-<!-- Initialization of the edit action, if any
-     =============================================================================================================================
-  -->
-<%  String              action = request.getParameter("action");   
-    String              type   = request.getParameter("index");
-    if (action == null) action = "display";
-%>
-<s:set var="todo"><%=action%></s:set>
-<html>
-
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-    <title><s:text name="name.module"/></title>
-    <link href="<s:url value="/skin/default.css"/>" rel="stylesheet" type="text/css">
-    <link href="<s:url value="/rtef/rte.css"/>" rel="stylesheet" type="text/css">
-    <script language="JavaScript" type="text/javascript" src="<s:url value="/rtef/lang/fr.js"/>"></script>
-    <script language="JavaScript" type="text/javascript" src="<s:url value="/rtef/richtext.js"/>"></script>
-    <script language="JavaScript" type="text/javascript" src="<s:url value="/rtef/xhtml.js"/>"></script>
-    <script language="JavaScript" type="text/javascript" src="<s:url value="/js/popup.js"/>"></script>
-    <script language="JavaScript" type="text/javascript" src="<s:url value="/js/action.js"/>"></script>
-
-    <script language="JavaScript">
-    
-    initTextEditor();
-
-    var substitutions = new Array (
-      new RegExp("[\r\n]",'g'),   " ",                // For removing carriage returns & line feeds
-      new RegExp("<p>&nbsp;"),    "<p>",              // For removing &nbsp; of the 1st paragraph
-      new RegExp("&nbsp;</p>"),   "</p>",             // For removing &nbsp; of the 1st paragraph
-      
-      new RegExp("&eacute;",'g'), "é",
-      new RegExp("&egrave;",'g'), "è",
-      new RegExp("&ecirc;",'g'),  "ê",
-      new RegExp("&euml;",'g'),   "ë",
-      new RegExp("&agrave;",'g'), "à",
-      new RegExp("&acirc;",'g'),  "â",
-      new RegExp("&icirc;",'g'),  "î",
-      new RegExp("&iuml;",'g'),   "ï",
-      new RegExp("&ocirc;",'g'),  "ô",
-      new RegExp("&ugrave;",'g'), "ù",
-      new RegExp("&ucirc;",'g'),  "û",
-      new RegExp("&uuml;",'g'),   "ü",
-      
-      new RegExp("&ccedil;",'g'), "ç"
-    );
-    
-    function initialize (action) {
-//  ----------------------------
-      if (action == "setContext") {
-         edit.elements[2].focus();
-      } else
-      if (action == "renameDocument") {
-        edoc.documentTitle.focus();
-      } else
-      if (action == "renameKnowledge") {
-        edit.knowledgeTitle.focus();
-      } else
-      if (action == "addKnowledge") {
-        edit.elements[1].focus();
-      } else
-      if (action != "display") {
-         edit.elements[0].focus();
-      }
-    }
-    function setValue () {
-//  -------------------
-      var select = edit.elements[0].value;  // contextValue select input
-      if (select == "0") {                  // Creation of a new context type
-        tds = document.getElementById("select");
-        tde = document.getElementById("enter");
-        tds.style.display = "none";         // Hides the select input
-        tde.style.display = "block";        // Displays the text input
-      }
-      edit.elements[2].focus();
-    }
-    function clean (html) {
-//  ---------------------     
-      html = trim(html);
-      for (i=0; i<substitutions.length; i = i+2) {
-        html = html.replace(substitutions[i], substitutions[i+1]);
-      }
-      return html;
-    }
-    function submitEdit () {
-//  ----------------------     
-      updateRTEs();   // Sets the value of knowledgeValue input    
-      edit.knowledgeValue.value = clean(edit.knowledgeValue.value);
-      edit.submit();
-    }
-    </script>
-  </head>
-
-  <body onLoad="initialize('<%=action%>')">
-<!-- Menu-bar
-     =============================================================================================================================
-  -->
-    <jsp:include page="/jsp/menubar.jsp" />
-
-<!-- Title-bar
-     =============================================================================================================================
-  -->
-    <jsp:include page="/jsp/titlebar.jsp" />
-
-<!-- Left pane
-     =============================================================================================================================
-  -->
-    <div id=left-pane>
-      <jsp:include page="/jsp/toolbar.jsp" />          
-      <div id=top-spacer></div>
-      <jsp:include page="/jsp/menuitem.jsp" />
-      <jsp:include page="/jsp/studyProperties.jsp" />
-    </div>
-
-    <div id=main-pane>
-
-<!-- Description and simulation context sections
-     =============================================================================================================================
-
-     Display of tabs
-  -->
-      <div id="tab-bar">
-      <div id="tab-description">
-          <span id="tab-front">&nbsp;&nbsp;<s:text name="title.description"/>&nbsp;&nbsp;</span>
-      </div>
-      <div id="tab-context">
-          <span id="tab-front">&nbsp;&nbsp;<s:text name="title.context"/>&nbsp;&nbsp;</span>
-      </div>
-      </div>
-
-<!-- Display of contents
-  -->
-      <div id="article-box">
-        <table width=100% border=0 cellspacing=0 cellpadding=0>
-          <tr valign=top>
-          <td width=38%>     <!-- Must conform to the width of above tab-description -->
-            <div id="top-spacer"></div>
-            <div id=article-body class=text>
-              <jsp:include page="/jsp/readDescription.jsp">
-                <jsp:param name="entity" value="study" />
-              </jsp:include>
-            </div>
-          </td>
-          <td width=1></td>    <!-- Trick for aligning the vertical separator with the tab -->
-          <td width=1 bgcolor=#AAAAAA></td>
-          <td>
-            <div id="top-spacer"></div>
-            <div id="article-body">
-              <s:if test="%{#todo == 'newContext' || #todo == 'selectContext' || #todo == 'setContext'}">
-                <form name="edit" action="<%=action%>?selection=<s:property value="selection"/>" method="post">
-                  <jsp:include page="/jsp/editContext.jsp">
-                    <jsp:param name="action" value="<%=action%>" />
-                    <jsp:param name="type"   value="<%=type%>" />
-                  </jsp:include>
-                </form>
-              </s:if>
-              <s:else>
-                <jsp:include page="/jsp/readContext.jsp" />
-              </s:else>
-            </div>
-          </td>
-          </tr>
-        </table>
-      </div>
-
-<!-- Knowledge elements section
-     =============================================================================================================================
-  -->
-      <s:if test="knowledges != null">
-      <div id=article-box>
-        <div id=section><s:text name="title.knowledge"/></div>
-        <div id=article-body class=text>
-          <s:if test="%{#todo == 'addKnowledge' || #todo == 'renameKnowledge' || #todo == 'editKnowledge'}">
-            <form name="edit" action="setKnowledge" method="post">
-            <jsp:include page="/jsp/editKnowledge.jsp">
-              <jsp:param name="action" value="<%=action%>" />
-              <jsp:param name="index"  value="<%=type%>" />
-            </jsp:include>
-            </form>
-          </s:if>
-          <s:else>
-            <jsp:include page="/jsp/readKnowledge.jsp">
-              <jsp:param name="entity" value="study" />
-            </jsp:include>
-          </s:else>
-        </div>
-      </div>
-      </s:if>
-
-<!-- Documents section
-     =============================================================================================================================
-  -->
-      <s:if test="documents != null">
-      <div id=article-box>
-        <div id=section><s:text name="title.document"/></div>
-        <div id=article-body class=text>
-          <s:if test="%{writeAccess == 'true' && stepEnabled == 'true'}">
-            <form name="edoc" action="setDocument" method="post">
-            <jsp:include page="/jsp/editContents.jsp">
-              <jsp:param name="action" value="<%=action%>" />
-              <jsp:param name="index"  value="<%=type%>" />
-            </jsp:include>
-            </form>
-          </s:if>
-          <s:else>
-            <jsp:include page="/jsp/readContents.jsp">
-              <jsp:param name="entity" value="study" />
-            </jsp:include>
-          </s:else>
-        </div>
-      </div>
-
-<!-- Comment section
-     =============================================================================================================================
-  -->
-      <s:if test="%{writeAccess == 'true' && stepEnabled == 'true'}">
-      <div id=article-box>
-        <div id=section><s:text name="title.comment"/></div>
-        <div id=article-body class=text>
-          <jsp:include page="/jsp/readComment.jsp"/>
-        </div>
-      </div>
-      </s:if>
-      </s:if>
-
-    </div>
-  </body>
-</html>
\ No newline at end of file
index 37d5b7943cb915a3c7755fcce3bad5d0413c96a3..8039f65f6d2a165cc4cd15ec51ed8c77ce591bad 100644 (file)
@@ -1,11 +1,6 @@
 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
-    pageEncoding="ISO-8859-1"
-%>
-<%@
-    taglib prefix="s" uri="/struts-tags"
-%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
+    pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="s" uri="/struts-tags"%>
 <!-- Initialization of the edit action, if any
      =============================================================================================================================
   -->
@@ -14,9 +9,8 @@
     if (action == null) action = "display";
 %>
 <s:set var="todo"><%=action%></s:set>
-<html>
-
        <link href=<s:url value="/skin/default.css"/> rel="stylesheet" type="text/css">
+    <link href="<s:url value="/rtef/rte.css"/>" rel="stylesheet" type="text/css">
 
     <script language="JavaScript" type="text/javascript" src="<s:url value="/rtef/lang/fr.js"/>"></script>
     <script language="JavaScript" type="text/javascript" src="<s:url value="/rtef/richtext.js"/>"></script>
       edit.knowledgeValue.value = clean(edit.knowledgeValue.value);
       edit.submit();
     }
+    $(document).ready(function (){
+        initialize('<%=action%>');
+    });
     </script>
 
-  <body onLoad="initialize('<%=action%>')">
-
 <!-- Description and simulation context sections
      =============================================================================================================================
 
             <div id="article-body">
               <s:if test="%{#todo == 'newContext' || #todo == 'selectContext' || #todo == 'setContext'}">
                 <form name="edit" action="<%=action%>?selection=<s:property value="selection"/>" method="post">
-                  <jsp:include page="/jsp/editContext.jsp">
-                    <jsp:param name="action" value="<%=action%>" />
-                    <jsp:param name="type"   value="<%=type%>" />
-                  </jsp:include>
+                  <jsp:include page="/jsp/editContext.jsp"/>
                 </form>
               </s:if>
               <s:else>
       </div>
       </s:if>
       </s:if>
-
-  </body>
-</html>
\ No newline at end of file
index 15e755987da41addd520289a124ad107f972fab8..e60f604c47dd37a08549da5c9deda96f37ae8900 100644 (file)
@@ -3,6 +3,11 @@ package org.splat.simer;
 
 public abstract class AbstractDisplayAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
+    private static final long serialVersionUID = 3003902258668626946L;
+
     /**
      * Index of the open object.
      */
@@ -11,13 +16,11 @@ public abstract class AbstractDisplayAction extends Action {
      * User activity selection.
      */
     protected  String           _selection = null;
+    /**
+     * Next action.
+     */
     protected  transient String _action    = null;
 
-       /**
-        * Serial version ID.
-        */
-    private static final long serialVersionUID = 3003902258668626946L;
-
        protected enum Execute { popup, develop, reduce, reduceall }
 
 //  ==============================================================================================================================
@@ -25,20 +28,23 @@ public abstract class AbstractDisplayAction extends Action {
 //  ==============================================================================================================================
 
     public String getSelection () {
-//  -----------------------------
       return _selection;   // Equals to myobject.getSelection()
     }
 
     public void setAction (final String action) {
-//  -------------------------------------
       this._action = action;
     }
     public void setIndex (final String index) {
-//  -----------------------------------
       this._myindex = index;
     }
+       /**
+        * Get the index.
+        * @return the index
+        */
+       public String getIndex() {
+               return _myindex;
+       }
     public void setSelection (final String step) {
-//  --------------------------------------
       this._selection = step;
     }    
 
index 76a15f5af42e5fcaddcb28c04b9a194da69e477e..cfcb2c5da289e630be51843265c7bb2945741c63 100644 (file)
@@ -1,6 +1,5 @@
 package org.splat.simer;
 
-import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.Scenario;
@@ -9,6 +8,7 @@ import org.splat.service.KnowledgeElementTypeService;
 import org.splat.service.ScenarioService;
 import org.splat.service.dto.KnowledgeElementDTO;
 import org.splat.som.Step;
+import org.splat.wapp.Constants;
 
 /**
  * Action for addition and modification of knowledge elements in the selected scenario.
@@ -23,15 +23,15 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
        /**
         * Edited knowledge element type.
         */
-       private String type = null; // Edited knowledge type
+       private String _knowledgeType = null; // Edited knowledge type
        /**
         * Edited knowledge element title.
         */
-       private String title = null;
+       private String _knowledgeTitle = null;
        /**
         * Edited knowledge element value.
         */
-       private String value = null;
+       private String _knowledgeValue = null;
        /**
         * Injected scenario service.
         */
@@ -83,15 +83,15 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
        public String doInitialize() {
                _openStudy = getOpenStudy();
 
-               setMenuProperty("study");
-               setTitleProperty("study");
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
                if ("true".equals(getWriteAccess())
                                && getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
                        setToolProperty("standard");
                }
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty,
                                _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
@@ -105,52 +105,52 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         */
        public String doSetKnowledge() {
 
-               setMenuProperty("study");
-               setTitleProperty("study");
+               String res = SUCCESS;
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
                if ("true".equals(getWriteAccess())
                                && getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
                        setToolProperty("standard");
                }
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty,
                                _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
                try {
-                       User user = getConnectedUser();
                        _openStudy = getOpenStudy();
 
-                       Step step = _openStudy.getSelectedStep();
-                       Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
-
-                       if ((title == null) || (value == null)) { 
+                       if ((_knowledgeTitle == null) || (_knowledgeValue == null)) {
                                KnowledgeElementDTO kelm = new KnowledgeElementDTO(Integer
-                                               .valueOf(type), title, value);
-                               if (value == null) { // Renaming of an existing Knowledge Element
-                                       getKnowledgeElementService().rename(kelm, title);
+                                               .valueOf(_knowledgeType), _knowledgeTitle,
+                                               _knowledgeValue);
+                               if (_knowledgeValue == null) { // Renaming of an existing Knowledge Element
+                                       getKnowledgeElementService().rename(kelm, _knowledgeTitle);
                                } else { // Edition of a knowledge
-                                       getKnowledgeElementService().update(kelm, value);
+                                       getKnowledgeElementService().update(kelm, _knowledgeValue);
                                }
                                _openStudy.update(kelm); // For updating the truncated value
                        } else { // Addition of a new Knowledge Element
                                KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
                                KnowledgeElementType ktype = getKnowledgeElementTypeService()
-                                               .selectType(Integer.valueOf(type));
-                               kprop.setType(ktype).setTitle(title).setValue(value).setAuthor(
-                                               user);
-                               _openStudy.add(getScenarioService().addKnowledgeElement(scene,
+                                               .selectType(Integer.valueOf(_knowledgeType));
+                               kprop.setType(ktype).setTitle(_knowledgeTitle).setValue(
+                                               _knowledgeValue).setAuthor(getConnectedUser());
+                               _openStudy.add(getScenarioService().addKnowledgeElement(
+                                               (Scenario) _openStudy.getSelectedStep().getOwner(),
                                                kprop));
-                               getMenu("study").selects(_openStudy.getSelection()); // Updates the menu icon, in case of first added document
+                               getMenu(Constants.STUDY_MENU)
+                                               .selects(_openStudy.getSelection()); // Updates the menu icon, in case of first added document
                        }
-                       return SUCCESS;
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
-                       return ERROR;
+                       res = ERROR;
                } catch (Exception error) {
                        LOG.error("Exception while saving a knowledge: ", error);
-                       return INPUT;
+                       res = INPUT;
                }
+               return res;
        }
 
        /**
@@ -211,17 +211,17 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * Update current menu.
         */
        private void updateMenu() {
-               getMenu("study").selects(_openStudy.getSelection()); // Updates the menu icon, in case of last removed document
+               getMenu(Constants.STUDY_MENU).selects(_openStudy.getSelection()); // Updates the menu icon, in case of last removed document
 
-               setMenuProperty("study");
-               setTitleProperty("study");
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
                if ("true".equals(getWriteAccess())
                                && getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
                        setToolProperty("standard");
                }
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty,
                                _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
@@ -237,8 +237,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * @return the knowledge type name
         */
        public String getKnowledgeType() {
-               // ---------------------------------
-               return type;
+               return _knowledgeType;
        }
 
        /**
@@ -247,7 +246,6 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * @return the knowledge element id
         */
        public String getSelectedKnowledge() {
-               // -------------------------------------
                return _myindex;
        }
 
@@ -258,8 +256,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         *            the knowledge type name
         */
        public void setKnowledgeType(final String type) {
-               // ------------------------------------------
-               this.type = type;
+               this._knowledgeType = type;
        }
 
        /**
@@ -269,8 +266,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         *            the new knowledge title
         */
        public void setKnowledgeTitle(final String title) {
-               // --------------------------------------------
-               this.title = title;
+               this._knowledgeTitle = title;
        }
 
        /**
@@ -280,8 +276,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         *            the knowledge value
         */
        public void setKnowledgeValue(final String value) {
-               // --------------------------------------------
-               this.value = value;
+               this._knowledgeValue = value;
        }
 
        /**
@@ -448,4 +443,22 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
                _leftMenuProperty = leftMenuProperty;
        }
 
+       /**
+        * Get the knowledgeValue.
+        * 
+        * @return the knowledgeValue
+        */
+       public String getKnowledgeValue() {
+               return _knowledgeValue;
+       }
+
+       /**
+        * Get the knowledgeTitle.
+        * 
+        * @return the knowledgeTitle
+        */
+       public String getKnowledgeTitle() {
+               return _knowledgeTitle;
+       }
+
 }
\ No newline at end of file
index 5ed1a7d23ead99480ab7fdc23d8175de37063f0a..036ea3abe5eebc65a2ce65cf3ae7e9f2e0161e72 100644 (file)
@@ -6,21 +6,48 @@ import java.util.List;
 import org.splat.dal.bo.som.ProjectElement;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.dal.bo.som.Study;
 import org.splat.service.SimulationContextService;
 import org.splat.service.SimulationContextTypeService;
 import org.splat.service.StepService;
 import org.splat.service.StudyService;
 import org.splat.som.Step;
-import org.splat.dal.bo.som.Study;
+import org.splat.wapp.Constants;
 
+/**
+ * Action for simulation context selection or input.
+ */
 public class EditSimulationContextAction extends DisplayStudyStepAction {
 
-       private List<SimulationContextType> contype = null;
-       private List<SimulationContext> contelm = null;
-       private String selectype = null; // Context type, if selected
-       private String newtype = null; // Context type, if newed
-       private SimulationContextType type = null; // Corresponding context type object
-       private String value = null; // Context value
+       /**
+        * Serialization version id.
+        */
+       private static final long serialVersionUID = -641719644024601042L;
+
+       /**
+        * List of involved context types.
+        */
+       private transient List<SimulationContextType> _contype = null;
+       /**
+        * List of simulation context values of the selected type.
+        */
+       private transient List<SimulationContext> _contelm = null;
+       /**
+        * Context type, if selected.
+        */
+       private transient String _selectype = null;
+       /**
+        * Context type, if newed.
+        */
+       private transient String _newtype = null;
+       /**
+        * Corresponding context type object.
+        */
+       private transient SimulationContextType _type = null;
+       /**
+        * Context value.
+        */
+       private transient String _value = null;
        /**
         * Injected study service.
         */
@@ -37,147 +64,186 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         * Injected simulation context type service.
         */
        private SimulationContextTypeService _simulationContextTypeService;
-       
+
        /**
-        * Value of the menu property. 
-        * It can be: none, create, open, study, knowledge, sysadmin, help.
+        * 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.
+        * Value of the title bar property. It can be: study, knowledge.
         */
        private String _titleProperty;
-       
+
        /**
-        * Value of the tool bar property. 
-        * It can be: none, standard, study, back.
+        * Value of the tool bar property. It can be: none, standard, study, back.
         */
        private String _toolProperty;
-       
+
        /**
-        * Value of the left menu property. 
-        * It can be: open, study, knowledge, scenario.
+        * Value of the left menu property. It can be: open, study, knowledge, scenario.
         */
        private String _leftMenuProperty;
-       
+
        /**
-        * 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.
+        * 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 static final long serialVersionUID = -641719644024601042L;
-
        // ==============================================================================================================================
        // Action methods
        // ==============================================================================================================================
 
+       /**
+        * Initialize context input/selection action.
+        * 
+        * @return "create" if there is no involved context types or "select" otherwise
+        */
        public String doInitialize() {
 
+               String res;
                _openStudy = getOpenStudy();
-               contype = getInvolvedContexts();
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+               _contype = getInvolvedContexts();
+
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               
-               setLeftMenuProperty("study");
-               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
-               if (contype.isEmpty())
-                       return "create";
-               else
-                       return "select";
+
+               setLeftMenuProperty(Constants.STUDY_MENU);
+               initializationFullScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+               if (_contype.isEmpty()) {
+                       res = "create";
+                       setAction("newContext");
+               } else {
+                       res = "select";
+                       setAction("selectContext");
+               }
+               return res;
        }
 
+       /**
+        * Select or create a simulation context. If a type has been selected then initialize the list of context values.
+        * 
+        * @return "set" if context type is selected or "create" otherwise
+        */
        public String doSelectContext() {
+               String res = "set";
                _openStudy = getOpenStudy();
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               setLeftMenuProperty("study");
-               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-               
-               int typid = Integer.valueOf(selectype);
-               if (typid == 0)
-                       return "create";
-
-               SimulationContext.Properties cprop = new SimulationContext.Properties();
-               type = getSimulationContextService().selectType(typid);
-               newtype = type.getName();
-               contype = getInvolvedContexts();
-               contelm = getSimulationContextService()
-                               .selectSimulationContextsWhere(cprop.setType(type));
-
-               return "set";
+               setLeftMenuProperty(Constants.STUDY_MENU);
+               initializationFullScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+               int typid = Integer.valueOf(_selectype);
+               if (typid == 0) {
+                       res = "create";
+                       setAction("newContext");
+               } else {
+
+                       SimulationContext.Properties cprop = new SimulationContext.Properties();
+                       _type = getSimulationContextService().selectType(typid);
+                       _newtype = _type.getName();
+                       _contype = getInvolvedContexts();
+                       _contelm = getSimulationContextService()
+                                       .selectSimulationContextsWhere(cprop.setType(_type));
+                       
+                       setAction("setContext");
+                       setIndex(String.valueOf(getContextType().getIndex()));
+               }
+
+               return res;
        }
 
+       /**
+        * Create new context. Add the created context to the step and reindex the study. <BR>
+        * If type or value are undefined then return INPUT.
+        * 
+        * @return SUCCESS if added or ERROR or INPUT if failed
+        */
        public String doCreateContext() {
-               // --------------------------------
+               String res = SUCCESS;
                try {
                        _openStudy = getOpenStudy();
-                       
-                       setMenuProperty("study");
-                       setTitleProperty("study");
-                       if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                               setToolProperty("study");
+
+                       setMenuProperty(Constants.STUDY_MENU);
+                       setTitleProperty(Constants.STUDY_MENU);
+                       if (Constants.TRUE.equals(getWriteAccess())
+                                       && getUserRights().canCreateDocument()) {
+                               setToolProperty(Constants.STUDY_MENU);
                        } else {
-                               setToolProperty("standard");
+                               setToolProperty(Constants.STANDARD_MENU);
                        }
-                       setLeftMenuProperty("study");
-                       initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-                       
-                       if (newtype.length() == 0 || value.length() == 0)
-                               return INPUT;
+                       setLeftMenuProperty(Constants.STUDY_MENU);
+                       initializationFullScreenContext(_menuProperty, _titleProperty,
+                                       _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
-                       Step step = _openStudy.getSelectedStep();
-                       ProjectElement owner = step.getOwner();
+                       if (_newtype.length() == 0 || _value.length() == 0) {
+                               res = INPUT;
+                       } else {
 
-                       SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       SimulationContext contex = null;
-                       type = getSimulationContextTypeService().createType(newtype,
-                                       step.getStep());
-                       cprop.setType(type).setValue(value);
-                       if (owner instanceof Study)
-                               contex = getStudyService().addProjectContext(((Study) owner),
-                                               cprop); // Re-indexes knowledges and the study
-                       else
-                               contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
+                               Step step = _openStudy.getSelectedStep();
+                               ProjectElement owner = step.getOwner();
 
-                       _openStudy.add(contex);
-                       return SUCCESS;
+                               SimulationContext.Properties cprop = new SimulationContext.Properties();
+                               SimulationContext contex = null;
+                               _type = getSimulationContextTypeService().createType(_newtype,
+                                               step.getStep());
+                               cprop.setType(_type).setValue(_value);
+                               if (owner instanceof Study) {
+                                       contex = getStudyService().addProjectContext(
+                                                       ((Study) owner), cprop); // Re-indexes knowledges and the study
+                               } else {
+                                       contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
+                               }
+
+                               _openStudy.add(contex);
+                       }
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
-                       return ERROR;
+                       res = ERROR;
                } catch (Exception error) {
-                       return INPUT;
+                       setAction("newContext");
+                       res = INPUT;
                }
+               return res;
        }
 
+       /**
+        * Remove the selected simulation context from the study step.
+        * 
+        * @return SUCCESS if removed or ERROR if failed
+        */
        public String doDeleteContext() {
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+
+               String res = SUCCESS;
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               setLeftMenuProperty("study");
-               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-               
+               setLeftMenuProperty(Constants.STUDY_MENU);
+               initializationFullScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
                try {
                        _openStudy = getOpenStudy();
 
@@ -185,36 +251,43 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        ProjectElement owner = step.getOwner();
                        SimulationContext context = step.getSimulationContext(Integer
                                        .valueOf(_myindex));
-                       if (owner instanceof Study)
+                       if (owner instanceof Study) {
                                getStudyService()
                                                .removeProjectContext(((Study) owner), context); // Re-indexes knowledges and the study
-                       else
+                       } else {
                                getStepService().removeSimulationContext(step, context); // Re-indexes knowledges only
+                       }
 
                        _openStudy.remove(context);
-                       return SUCCESS;
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
-                       return ERROR;
+                       res = ERROR;
                }
+               return res;
        }
 
+       /**
+        * Add the selected context to the study step and reindex the study. <BR>
+        * If type or value are undefined then return INPUT.
+        * 
+        * @return SUCCESS if added or ERROR or INPUT if failed
+        */
        public String doSetContext() {
-               // -----------------------------
-               String[] input = value.split(",");
-//             Session connex = Database.getCurSession();
-//             Transaction transax = connex.beginTransaction();
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+               String res = SUCCESS;
+               String[] input = _value.split(",");
+
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               setLeftMenuProperty("study");
-               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-               
+               setLeftMenuProperty(Constants.STUDY_MENU);
+               initializationFullScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
                try {
                        _openStudy = getOpenStudy();
 
@@ -228,86 +301,122 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                int valid = Integer.valueOf(input[0]);
                                contex = getSimulationContextService().selectSimulationContext(
                                                valid);
-                               if (owner instanceof Study)
+                               if (owner instanceof Study) {
                                        getStudyService()
                                                        .addProjectContext(((Study) owner), contex);
-                               else
+                               } else {
                                        getStepService().addSimulationContext(step, contex);
+                               }
                        } else {
                                // Setting a new simulation context value (input = 0,"new context value")
-                               int typid = Integer.valueOf(selectype);
+                               int typid = Integer.valueOf(_selectype);
                                SimulationContext.Properties cprop = new SimulationContext.Properties();
                                cprop.setType(getSimulationContextService().selectType(typid))
                                                .setValue(input[1].trim());
-                               if (owner instanceof Study)
+                               if (owner instanceof Study) {
                                        contex = getStudyService().addProjectContext(
                                                        ((Study) owner), cprop); // Re-indexes knowledges and the study
-                               else
+                               } else {
                                        contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
+                               }
                        }
                        _openStudy.add(contex);
-                       contype = getInvolvedContexts();
+                       _contype = getInvolvedContexts();
+                       
+                       setAction("setContext");
+                       setIndex(String.valueOf(getContextType().getIndex()));
 
-//                     transax.commit();
-                       return SUCCESS;
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
-                       return ERROR;
+                       res = ERROR;
                } catch (Exception error) {
-                       value = input[0];
-                       return INPUT;
+                       _value = input[0];
+                       setAction("setContext");
+                       res = INPUT;
                }
+               return res;
        }
 
        // ==============================================================================================================================
        // Getters and setters
        // ==============================================================================================================================
 
+       /**
+        * Get context type.
+        * 
+        * @return Corresponding context type object
+        */
        public SimulationContextType getContextType() {
-               // ----------------------------------------------
-               return type;
+               return _type;
        }
 
+       /**
+        * Get the new context type to be created.
+        * 
+        * @return Context type, if newed
+        */
        public String getContextName() {
-               // -------------------------------
-               return newtype;
+               return _newtype;
        }
 
-       // public List<SimulationContextFacade> getSimulationContexts () {
-       // -------------------------------------------------------
-       // return mystudy.getSelectedStep().getAllSimulationContexts();
-       // }
+       /**
+        * Get the list of involved context types.
+        * 
+        * @return List of involved context types
+        */
        public List<SimulationContextType> getSimulationContextTypes() {
-               // ---------------------------------------------------------------
-               return contype;
+               return _contype;
        }
 
+       /**
+        * Get the list of simulation context values of the selected type.
+        * 
+        * @return List of simulation context values of the selected type
+        */
        public List<SimulationContext> getSimulationContextValues() {
-               // ------------------------------------------------------------
-               return contelm;
+               return _contelm;
        }
 
-       public void setContextType(String type) {
-               // ----------------------------------------
-               this.selectype = type;
+       /**
+        * Get the selected context type.
+        * 
+        * @param type
+        *            Context type, if selected
+        */
+       public void setContextType(final String type) {
+               this._selectype = type;
        }
 
-       public void setContextValue(String value) {
-               // -----------------------------------------
-               this.value = value;
+       /**
+        * Set the context value.
+        * 
+        * @param value
+        *            context value
+        */
+       public void setContextValue(final String value) {
+               this._value = value;
        }
 
-       public void setNewType(String name) {
-               // ------------------------------------
-               this.newtype = name;
+       /**
+        * Set the new context type.
+        * 
+        * @param name
+        *            the new context type
+        */
+       public void setNewType(final String name) {
+               this._newtype = name;
        }
 
        // ==============================================================================================================================
        // Private service
        // ==============================================================================================================================
 
+       /**
+        * Get the list of context types involved in the current study step.
+        * 
+        * @return the list of context types
+        */
        private List<SimulationContextType> getInvolvedContexts() {
-               // ----------------------------------------------------------
                SimulationContextType.Properties sprop = new SimulationContextType.Properties()
                                .setStep(_openStudy.getSelectedStep().getStep());
                List<SimulationContextType> contype = getSimulationContextService()
@@ -323,16 +432,19 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        int to = 0;
                        while (to < types.length - 1) {
                                to += 1;
-                               if (types[to].isApproved() == state)
+                               if (types[to].isApproved() == state) {
                                        continue;
+                               }
 
-                               if (to > from + 1)
+                               if (to > from + 1) {
                                        Arrays.sort(types, from, to, compare);
-                               state = !state;
+                               }
+                               state ^= state;
                                from = to;
                        }
-                       if (to > from)
+                       if (to > from) {
                                Arrays.sort(types, from, to + 1, compare);
+                       }
                        contype = Arrays.asList(types);
                }
                return contype;
@@ -343,6 +455,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         * 
         * @return the studyService
         */
+       @Override
        public StudyService getStudyService() {
                return _studyService;
        }
@@ -353,7 +466,8 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         * @param studyService
         *            the studyService to set
         */
-       public void setStudyService(StudyService studyService) {
+       @Override
+       public void setStudyService(final StudyService studyService) {
                _studyService = studyService;
        }
 
@@ -373,12 +487,13 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         *            the simulationContextService to set
         */
        public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
+                       final SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
 
        /**
         * Get the simulationContextTypeService.
+        * 
         * @return the simulationContextTypeService
         */
        public SimulationContextTypeService getSimulationContextTypeService() {
@@ -387,13 +502,15 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
        /**
         * Set the simulationContextTypeService.
-        * @param simulationContextTypeService the simulationContextTypeService to set
+        * 
+        * @param simulationContextTypeService
+        *            the simulationContextTypeService to set
         */
        public void setSimulationContextTypeService(
-                       SimulationContextTypeService simulationContextTypeService) {
+                       final SimulationContextTypeService simulationContextTypeService) {
                _simulationContextTypeService = simulationContextTypeService;
        }
-       
+
        /**
         * Get the stepService.
         * 
@@ -409,86 +526,111 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         * @param stepService
         *            the stepService to set
         */
-       public void setStepService(StepService stepService) {
+       public void setStepService(final StepService stepService) {
                _stepService = stepService;
        }
-       
+
        /**
         * Get the menuProperty.
+        * 
         * @return the menuProperty
         */
+       @Override
        public String getMenuProperty() {
                return _menuProperty;
        }
 
        /**
         * Set the menuProperty.
-        * @param menuProperty the menuProperty to set
+        * 
+        * @param menuProperty
+        *            the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       @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
+        * Set the titleProperty.
+        * 
+        * @param titleProperty
+        *            the titleProperty to set
         */
-       public void setTitleProperty(String titleProperty) {
+       @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
+        * 
+        * @param editDisabledProperty
+        *            the editDisabledProperty to set
         */
-       public final void setEditDisabledProperty(String editDisabledProperty) {
+       @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
+        * 
+        * @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
+        * 
+        * @param leftMenuProperty
+        *            the leftMenuProperty to set
         */
+       @Override
        public void setLeftMenuProperty(final String leftMenuProperty) {
                _leftMenuProperty = leftMenuProperty;
        }
index 82dcc0efa6daa9bed44b5889b71acaa29405bfdf..1fef3115cc646acb4ac8688972acccf060d0c306 100644 (file)
@@ -97,8 +97,8 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        public OpenStudy open(final User user, final Study study) {
                ResourceBundle custom = ResourceBundle.getBundle("som",
                                getApplicationSettings().getCurrentLocale());
-               SimpleDateFormat datstring = new SimpleDateFormat(
-                               custom.getString("date.format"));
+               SimpleDateFormat datstring = new SimpleDateFormat(custom
+                               .getString("date.format"));
                Revision.Format verstring = new Revision.Format(getProjectSettings()
                                .getRevisionPattern());
 
@@ -257,8 +257,8 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
                        // Transfer to the document of all known properties
                        ResourceBundle locale = ResourceBundle.getBundle("som",
                                        getApplicationSettings().getCurrentLocale());
-                       SimpleDateFormat get = new SimpleDateFormat(
-                                       locale.getString("date.format"));
+                       SimpleDateFormat get = new SimpleDateFormat(locale
+                                       .getString("date.format"));
                        Writer tool = Toolbox.getWriter(credoc);
                        List<Step> slist = getInvolvedSteps();
                        for (Iterator<Step> i = slist.iterator(); i.hasNext();) {
@@ -267,15 +267,14 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
                                for (Iterator<SimulationContext> j = clist.iterator(); j
                                                .hasNext();) {
                                        SimulationContext context = j.next();
-                                       tool.updateProperty(context.getType().getName(),
-                                                       context.getValue());
+                                       tool.updateProperty(context.getType().getName(), context
+                                                       .getValue());
                                }
                        }
                        tool.updateProperty("reference", medoc.getReference());
                        tool.updateProperty("study", _mystudy.getTitle());
-                       tool.updateProperty("step",
-                                       locale.getString("folder.step." + step.getNumber())
-                                                       .replaceAll("''", "'"));
+                       tool.updateProperty("step", locale.getString(
+                                       "folder.step." + step.getNumber()).replaceAll("''", "'"));
                        tool.updateProperty("author", author.getUsername().toUpperCase());
                        tool.updateProperty("date", get.format(medoc.getCreationDate()));
                        tool.updateProperty("history", locale.getString("label.creation")
@@ -345,8 +344,8 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        }
 
        protected void add(final KnowledgeElement kelm) {
-               KnowledgeElementFacade facade = new KnowledgeElementFacade(
-                               BeanHelper.copyBean(kelm, KnowledgeElementDTO.class),
+               KnowledgeElementFacade facade = new KnowledgeElementFacade(BeanHelper
+                               .copyBean(kelm, KnowledgeElementDTO.class),
                                getApplicationSettings());
                // RKV KnowledgeIterator known = knowledge.get(kelm.getType().getIndex() - 2);
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
@@ -406,19 +405,30 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        }
 
        protected void remove(final KnowledgeElement kelm) {
-               KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
-                               .getIndex() - 2));
+               // RKV: KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
+               // RKV: .getIndex() - 2));
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
-               knowpres.remove(kelm.getIndex());
-               for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
-                               .hasNext();) {
-                       KnowledgeElementFacade facade = i.next();
-                       if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
-                                       KnowledgeElementDTO.class))) {
-                               continue;
+               // RKV:Begin: Find a knowledge iterator for appropriate knowledge type
+               KnowledgeIterator known = null;
+               for (KnowledgeIterator aKnowledgeSection : _knowledge) {
+                       if (aKnowledgeSection.getIndex().equals(
+                                       String.valueOf(kelm.getType().getIndex()))) {
+                               known = aKnowledgeSection;
+                               break;
+                       }
+               }
+               if (known != null) { // RKV:End
+                       knowpres.remove(kelm.getIndex());
+                       for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
+                                       .hasNext();) {
+                               KnowledgeElementFacade facade = i.next();
+                               if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
+                                               KnowledgeElementDTO.class))) {
+                                       continue;
+                               }
+                               i.remove();
+                               break;
                        }
-                       i.remove();
-                       break;
                }
        }
 
index b6cae402b89e22050aaeed46e146caffd332faf6..bc90fe82e5e54ef260427a2b0ff3259e81f7d34e 100644 (file)
         <!-- Edition of simulation contexts
           -->        
         <action name="add-context" class="editSimulationContextAction" method="initialize">
-            <result name="create">/study/displayStudy.jsp?action=newContext</result>
-            <result name="select">/study/displayStudy.jsp?action=selectContext</result>
+            <result name="create" type="tiles">page.newcontext</result>
+            <result name="select" type="tiles">page.selectcontext</result>
         </action>
         <action name="selectContext" class="editSimulationContextAction" method="selectContext">
-            <result name="create">/study/displayStudy.jsp?action=newContext</result>
-            <result name="set">/study/displayStudy.jsp?action=setContext&amp;index=%{contextType.index}</result>
+            <result name="create" type="tiles">page.newcontext</result>
+            <result name="set"    type="tiles">page.setcontext</result>
         </action>
         <action name="newContext" class="editSimulationContextAction" method="createContext">
             <result name="success" type="tiles">page.displaystudy</result>
-            <result name="input">/study/displayStudy.jsp?action=newContext</result>
+            <result name="input" type="tiles">page.newcontext</result>
             <result name="error" type="tiles">page.displaystudy</result>
         </action>
         <action name="setContext" class="editSimulationContextAction" method="setContext">
             <result name="success" type="tiles">page.displaystudy</result>
-            <result name="input">/study/displayStudy.jsp?action=setContext&amp;index=%{contextType.index}</result>
+            <result name="input" type="tiles">page.setcontext</result>
             <result name="error" type="tiles">page.displaystudy</result>
         </action>
         <action name="remove-context" class="editSimulationContextAction" method="deleteContext">
         <!-- Edition of knowledge elements
           -->        
         <action name="add-knowledge" class="editKnowledgeElementAction" method="initialize">
-                       <result name="success">/study/displayStudy.jsp?action=addKnowledge&amp;index=%{knowledgeType}</result>
+<!--             <result name="success">/study/displayStudy.jsp?action=addKnowledge&amp;index=%{knowledgeType}</result>-->
+            <result name="success" type="tiles">page.displaystudy</result>
         </action>
         <action name="edit-knowledge" class="editKnowledgeElementAction" method="initialize">
             <result name="success" type="tiles">page.displaystudy</result>