Salome HOME
Left menu is improved
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditSimulationContextAction.java
index 20ea3c69c6e2f0639ae774f040cf967f5d900411..ff83ddfc03ec0d6879ee0041230494cae4728db1 100644 (file)
@@ -7,6 +7,7 @@ import org.splat.dal.bo.som.ProjectElement;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 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;
@@ -32,25 +33,41 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         * Injected simulation context service.
         */
        private SimulationContextService _simulationContextService;
-
        /**
-        * Get the stepService.
-        * 
-        * @return the stepService
+        * Injected simulation context type service.
         */
-       public StepService getStepService() {
-               return _stepService;
-       }
-
+       private SimulationContextTypeService _simulationContextTypeService;
+       
        /**
-        * Set the stepService.
-        * 
-        * @param stepService
-        *            the stepService to set
+        * Value of the menu property. 
+        * It can be: none, create, open, study, knowledge, sysadmin, help.
         */
-       public void setStepService(StepService stepService) {
-               _stepService = stepService;
-       }
+       private String _menuProperty;
+       
+       /**
+        * 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.
+        */
+       private String _toolProperty;
+       
+       /**
+        * 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.
+        */
+       private String _editDisabledProperty = "false";
 
        private static final long serialVersionUID = -641719644024601042L;
 
@@ -62,6 +79,17 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
                mystudy = getOpenStudy();
                contype = getInvolvedContexts();
+               
+               setMenuProperty("study");
+               setTitleProperty("study");
+               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty("study");
+               } else {
+                       setToolProperty("standard");
+               }
+               
+               setLeftMenuProperty("study");
+               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
                if (contype.isEmpty())
                        return "create";
@@ -71,6 +99,17 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
        public String doSelectContext() {
                mystudy = getOpenStudy();
+               
+               setMenuProperty("study");
+               setTitleProperty("study");
+               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty("study");
+               } else {
+                       setToolProperty("standard");
+               }
+               setLeftMenuProperty("study");
+               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+               
                int typid = Integer.valueOf(selectype);
                if (typid == 0)
                        return "create";
@@ -89,6 +128,17 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                // --------------------------------
                try {
                        mystudy = getOpenStudy();
+                       
+                       setMenuProperty("study");
+                       setTitleProperty("study");
+                       if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                               setToolProperty("study");
+                       } else {
+                               setToolProperty("standard");
+                       }
+                       setLeftMenuProperty("study");
+                       initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+                       
                        if (newtype.length() == 0 || value.length() == 0)
                                return INPUT;
 
@@ -97,7 +147,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
                        SimulationContext contex = null;
-                       type = getSimulationContextService().createType(newtype,
+                       type = getSimulationContextTypeService().createType(newtype,
                                        step.getStep());
                        cprop.setType(type).setValue(value);
                        if (owner instanceof Study)
@@ -117,6 +167,17 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        }
 
        public String doDeleteContext() {
+               
+               setMenuProperty("study");
+               setTitleProperty("study");
+               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty("study");
+               } else {
+                       setToolProperty("standard");
+               }
+               setLeftMenuProperty("study");
+               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+               
                try {
                        mystudy = getOpenStudy();
 
@@ -143,6 +204,17 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                String[] input = value.split(",");
 //             Session connex = Database.getCurSession();
 //             Transaction transax = connex.beginTransaction();
+               
+               setMenuProperty("study");
+               setTitleProperty("study");
+               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty("study");
+               } else {
+                       setToolProperty("standard");
+               }
+               setLeftMenuProperty("study");
+               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+               
                try {
                        mystudy = getOpenStudy();
 
@@ -304,4 +376,120 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
+
+       /**
+        * Get the simulationContextTypeService.
+        * @return the simulationContextTypeService
+        */
+       public SimulationContextTypeService getSimulationContextTypeService() {
+               return _simulationContextTypeService;
+       }
+
+       /**
+        * Set the simulationContextTypeService.
+        * @param simulationContextTypeService the simulationContextTypeService to set
+        */
+       public void setSimulationContextTypeService(
+                       SimulationContextTypeService simulationContextTypeService) {
+               _simulationContextTypeService = simulationContextTypeService;
+       }
+       
+       /**
+        * Get the stepService.
+        * 
+        * @return the stepService
+        */
+       public StepService getStepService() {
+               return _stepService;
+       }
+
+       /**
+        * Set the stepService.
+        * 
+        * @param stepService
+        *            the stepService to set
+        */
+       public void setStepService(StepService stepService) {
+               _stepService = stepService;
+       }
+       
+       /**
+        * Get the menuProperty.
+        * @return the menuProperty
+        */
+       public String getMenuProperty() {
+               return _menuProperty;
+       }
+
+       /**
+        * Set the menuProperty.
+        * @param menuProperty the menuProperty to set
+        */
+       public void setMenuProperty(String menuProperty) {
+               this._menuProperty = menuProperty;
+       }
+       
+       /**
+        * Get the _titleProperty.
+        * @return the _titleProperty
+        */
+       public String getTitleProperty() {
+               return _titleProperty;
+       }
+
+       /**
+        * Set the _titleProperty.
+        * @param _titleProperty the titleProperty to set
+        */
+       public void setTitleProperty(String titleProperty) {
+               _titleProperty = titleProperty;
+       }
+
+       /**
+        * Get the editDisabledProperty.
+        * @return the editDisabledProperty
+        */
+       public final String getEditDisabledProperty() {
+               return _editDisabledProperty;
+       }
+
+       /**
+        * Set the editDisabledProperty.
+        * @param editDisabledProperty the editDisabledProperty to set
+        */
+       public final void setEditDisabledProperty(String editDisabledProperty) {
+               _editDisabledProperty = editDisabledProperty;
+       }
+
+       /**
+        * Get the toolProperty.
+        * @return the toolProperty
+        */
+       public String getToolProperty() {
+               return _toolProperty;
+       }
+
+       /**
+        * Set the toolProperty.
+        * @param toolProperty the toolProperty to set
+        */
+       public void setToolProperty(final String toolProperty) {
+               _toolProperty = toolProperty;
+       }
+       
+       /**
+        * Get the leftMenuProperty.
+        * @return the leftMenuProperty
+        */
+       public String getLeftMenuProperty() {
+               return _leftMenuProperty;
+       }
+
+       /**
+        * Set the leftMenuProperty.
+        * @param leftMenuProperty the leftMenuProperty to set
+        */
+       public void setLeftMenuProperty(final String leftMenuProperty) {
+               _leftMenuProperty = leftMenuProperty;
+       }
 }
\ No newline at end of file