Salome HOME
Tool bar is improved.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / admin / SimulationContextAction.java
index 232e52c9dc9b78b5908a53d4e37e6bcfcf85fc0b..4366eb204f056b706828120484cc6fb6bfa7a602 100644 (file)
@@ -24,6 +24,7 @@ import org.splat.service.SearchService;
 import org.splat.service.SimulationContextService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.dto.Proxy;
+import org.splat.service.dto.SimulationContextFacade;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
@@ -62,6 +63,18 @@ public class SimulationContextAction extends Action {
         * Injected simulation context service.
         */
        private SimulationContextService _simulationContextService;
+       
+       /**
+        * Value of the menu property. 
+        * It can be: none, create, open, study, knowledge, sysadmin, help.
+        */
+       private String _menuProperty;
+       
+       /**
+        * Value of the tool bar property. 
+        * It can be: none, standard, study, back.
+        */
+       private String _toolProperty;
 
        /**
         * Context name comparator.
@@ -118,27 +131,22 @@ public class SimulationContextAction extends Action {
        // Action methods
        // ==============================================================================================================================
 
+       /**
+        * Initialize the simulation context list.
+        * @return SUCCESS if succeeded, otherwise - ERROR
+        */
        public String doInitialize() {
-               // -----------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
-                       SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       List<SimulationContext> context = getSimulationContextService()
-                                       .selectSimulationContextsWhere(
-                                                       cprop.setState(ProgressState.inCHECK));
-
-                       tocheck = new Vector<SimulationContextFacade>(context.size());
-                       for (Iterator<SimulationContext> i = context.iterator(); i
-                                       .hasNext();) {
-                               tocheck.add(new SimulationContextFacade(i.next(),
-                                               getProjectSettings().getAllSteps()));
-                       }
+                       tocheck = getSimulationContextService()
+                                       .getSimulationContextsInState(ProgressState.inCHECK);
                        selection = 0;
                        edition = null;
                        owner = null;
+                       
+                       setMenuProperty("study");
+                       setToolProperty("none");
+               initializationScreenContext(_menuProperty, _toolProperty);
 
-                       transax.commit();
                        return SUCCESS;
                } catch (Exception error) {
                        logger.error("Reason:", error);
@@ -148,7 +156,12 @@ public class SimulationContextAction extends Action {
 
        public String doSelect() {
                // -------------------------
-               Session connex = Database.getSession();
+               
+               setMenuProperty("study");
+               setToolProperty("none");
+        initializationScreenContext(_menuProperty, _toolProperty);
+        
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
@@ -174,7 +187,8 @@ public class SimulationContextAction extends Action {
                                        kprop.setSimulationContexts(selected).setState(
                                                        ProgressState.inWORK));
 
-                       step = edition.getType().getAttachedStep();
+                       step = getSimulationContextService().getAttachedStep(
+                                       edition.getType());
                        owner = new HashSet<ProjectElementFacade>();
                        for (Iterator<Proxy> i = kelm.iterator(); i.hasNext();) {
                                KnowledgeElement next = getKnowledgeElementService()
@@ -190,7 +204,8 @@ public class SimulationContextAction extends Action {
                        }
                        SimulationContextType.Properties sprop = new SimulationContextType.Properties();
                        List<SimulationContextType> types = getSimulationContextService()
-                                       .selectTypesWhere(sprop.setState(ProgressState.APPROVED));
+                                       .selectTypesWhere(
+                                                       sprop.setProgressState(ProgressState.APPROVED));
                        Locale[] support = ApplicationSettings.getSupportedLocales();
 
                        // Sort localized type names
@@ -332,6 +347,7 @@ public class SimulationContextAction extends Action {
 
        /**
         * Get the searchService.
+        * 
         * @return the searchService
         */
        public SearchService getSearchService() {
@@ -340,9 +356,44 @@ public class SimulationContextAction extends Action {
 
        /**
         * Set the searchService.
-        * @param searchService the searchService to set
+        * 
+        * @param searchService
+        *            the searchService to set
         */
        public void setSearchService(SearchService searchService) {
                _searchService = searchService;
        }
+       
+       /**
+        * Get the menuProperty. 
+        * @return the menuProperty
+        */
+       public String getMenuProperty() {
+               return _menuProperty;
+       }
+
+       /**
+        * Set the menuProperty.
+        * @param menuProperty
+        *            the menuProperty to set
+        */
+       public void setMenuProperty(final String menuProperty) {
+               this._menuProperty = menuProperty;
+       }
+       
+       /**
+        * 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;
+       }
 }
\ No newline at end of file