Salome HOME
Promote and demote knowledge element actions are added.
authorrkv <rkv@opencascade.com>
Wed, 31 Oct 2012 08:00:13 +0000 (08:00 +0000)
committerrkv <rkv@opencascade.com>
Wed, 31 Oct 2012 08:00:13 +0000 (08:00 +0000)
Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
Workspace/Siman/src/struts.xml

index 5e839d72c37943efa28907deeeedb7dec2dbd9c9..a69510412f5c075ddc929ec20af7436228cbfea0 100644 (file)
@@ -48,23 +48,20 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * 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;
-       
+
        /**
-        * 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";
-       
+
        /**
-        * 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;
 
@@ -82,12 +79,14 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
                setMenuProperty("study");
                setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+               if ("true".equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
                        setToolProperty("study");
                } else {
                        setToolProperty("standard");
                }
-               initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
+               initializationScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty);
 
                return SUCCESS;
        }
@@ -101,12 +100,14 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
                setMenuProperty("study");
                setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+               if ("true".equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
                        setToolProperty("study");
                } else {
                        setToolProperty("standard");
                }
-               initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
+               initializationScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty);
 
                try {
                        User user = getConnectedUser();
@@ -160,18 +161,61 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
                getScenarioService().removeKnowledgeElement(scene, kelm); // The knowledge element necessarily exists
 
                mystudy.remove(kelm);
+               updateMenu();
+
+               return SUCCESS;
+       }
+
+       /**
+        * Promote a knowledge element from the current scenario.
+        * 
+        * @return SUCCESS if no exceptions
+        */
+       public String doPromoteKnowledge() {
+               getKnowledgeElementService().promote(getKnowledgeElement()); // The knowledge element necessarily exists
+               updateMenu();
+               return SUCCESS;
+       }
+
+       /**
+        * Demote a knowledge element from the current scenario.
+        * 
+        * @return SUCCESS if no exceptions
+        */
+       public String doDemoteKnowledge() {
+               getKnowledgeElementService().demote(getKnowledgeElement()); // The knowledge element necessarily exists
+               updateMenu();
+               return SUCCESS;
+       }
+
+       /**
+        * Get selected knowledge element.
+        * 
+        * @return the selected knowledge element
+        */
+       private KnowledgeElement getKnowledgeElement() {
+               mystudy = getOpenStudy();
+               Step step = mystudy.getSelectedStep();
+               Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
+               return scene.getKnowledgeElement(Integer.valueOf(myindex));
+       }
+
+       /**
+        * Update current menu.
+        */
+       private void updateMenu() {
                getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
 
                setMenuProperty("study");
                setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+               if ("true".equals(getWriteAccess())
+                               && getUserRights().canCreateDocument()) {
                        setToolProperty("study");
                } else {
                        setToolProperty("standard");
                }
-               initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-
-               return SUCCESS;
+               initializationScreenContext(_menuProperty, _titleProperty,
+                               _editDisabledProperty, _toolProperty);
        }
 
        // ==============================================================================================================================
@@ -308,9 +352,10 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
        public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
-       
+
        /**
         * Get the _titleProperty.
+        * 
         * @return the _titleProperty
         */
        public String getTitleProperty() {
@@ -319,7 +364,9 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
        /**
         * Set the titleProperty.
-        * @param titleProperty the titleProperty to set
+        * 
+        * @param titleProperty
+        *            the titleProperty to set
         */
        public void setTitleProperty(final String titleProperty) {
                _titleProperty = titleProperty;
@@ -327,6 +374,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
        /**
         * Get the editDisabledProperty.
+        * 
         * @return the editDisabledProperty
         */
        public String getEditDisabledProperty() {
@@ -335,7 +383,9 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
        /**
         * Set the editDisabledProperty.
-        * @param editDisabledProperty the editDisabledProperty to set
+        * 
+        * @param editDisabledProperty
+        *            the editDisabledProperty to set
         */
        public void setEditDisabledProperty(final String editDisabledProperty) {
                _editDisabledProperty = editDisabledProperty;
@@ -343,6 +393,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
        /**
         * Get the toolProperty.
+        * 
         * @return the toolProperty
         */
        public String getToolProperty() {
@@ -351,11 +402,11 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
        /**
         * Set the toolProperty.
-        * @param toolProperty the toolProperty to set
+        * 
+        * @param toolProperty
+        *            the toolProperty to set
         */
        public void setToolProperty(final String toolProperty) {
                _toolProperty = toolProperty;
        }
-
-       
 }
\ No newline at end of file
index e4f843454d1fcb1f2066d19eb0667ef08fa8696b..e0447064fa79a0ceabe19e2872f6af9fca963b1b 100644 (file)
             <result name="success">/study/displayStudyStep.jsp</result>
             <result name="error">/study/displayStudyStep.jsp?error=removeKnowledge</result>
         </action>
+        <action name="promote-knowledge" class="editKnowledgeElementAction" method="promoteKnowledge">
+            <result name="success">/study/displayStudyStep.jsp</result>
+        </action>
+        <action name="demote-knowledge" class="editKnowledgeElementAction" method="demoteKnowledge">
+            <result name="success">/study/displayStudyStep.jsp</result>
+        </action>
 
     </package>