]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/Action.java
Salome HOME
Tool bar is improved.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / Action.java
index 74517cd57e92daf89ed2701c9d8610e74b355b66..dae6a9d5f84d54ad94082c5f53b3d75ce185144e 100644 (file)
@@ -14,11 +14,13 @@ import org.apache.struts2.interceptor.SessionAware;
 import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
 import org.splat.som.ApplicationRights;
+import org.splat.som.StudyRights;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.wapp.Menu;
+import org.splat.wapp.PopupMenu;
 
 
 /**
@@ -66,6 +68,11 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
         * TitleBarSettings bean.
         */
        private TitleBarSettings _titleBarSettings;
+       /**
+        * ToolBarSettings bean.
+        */
+       private ToolBarSettings _toolBarSettings;
+       
        /**
         * Injected application settings bean.
         */
@@ -174,6 +181,27 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
                getMenuBarSettings().setIsStudyNull(true);
        } else {
                getMenuBarSettings().setIsStudyNull(false);
+               
+               //for initialization ToolBarSettings.canUserEdit property
+               // and ToolBarSettings.isEnabledScript property.
+               
+               OpenStudy currentStudy = (OpenStudy)session.get("study.open");
+               PopupMenu    popup = currentStudy.getPopup();
+           StudyRights  user  = currentStudy.getStudyRights();
+           
+           if(user.canEditProperties()) {
+               getToolBarSettings().setCanUserEdit(true);
+           } else {
+               getToolBarSettings().setCanUserEdit(false);
+           }
+           
+           if (popup == null) {
+               getToolBarSettings().setIsEnabledScript(false);
+           } else if (popup.isEnabled("script")) {
+               getToolBarSettings().setIsEnabledScript(true);
+           } else {
+               getToolBarSettings().setIsEnabledScript(false);
+           }
        }
        
        if (session.get("knowledge.open") == null) {
@@ -212,7 +240,8 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
        
        getTitleBarSettings().setProgressState(entity.getProgressState().toString());
        getTitleBarSettings().setSelectionState(entity.getSelection());
-       getTitleBarSettings().setEntryType(entity.getType());
+       getTitleBarSettings().setEntryType(entity.getType().toLowerCase());
+       getTitleBarSettings().setEntryTypeTitle(entity.getType());
        getTitleBarSettings().setEntryTitle(entity.getTitle());
        getTitleBarSettings().setEditDisabledProperty(editDisabledProperty);
     }
@@ -229,7 +258,7 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
        }
        
        /**
-        * Initialization of the screen context for menu bar and tool bar.
+        * Initialization of the screen context for menu bar and title bar.
         * 
         * @param menuProperty - the property of the menu bar.
         * @param titleProperty - The title of the open study/knowledge.
@@ -241,6 +270,36 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
                initializationContext(titleProperty, editDisabledProperty);
                getMenuBarSettings().intializeMenuBar(menuProperty);
        }
+       
+       /**
+        * Initialization of the screen context for menu bar, title bar and tool bar.
+        * 
+        * @param menuProperty - the property of the menu bar.
+        * @param titleProperty - The title of the open study/knowledge.
+     * @param editDisabledProperty - Property that indicates whether the current open study is editable or not.
+     * @param toolProperty - the property of the tool bar.
+        */
+       public void initializationScreenContext(final String menuProperty, 
+                       final String titleProperty, final String editDisabledProperty,
+                       final String toolProperty) {
+               
+               initializationScreenContext(menuProperty, titleProperty, editDisabledProperty);
+               getToolBarSettings().intializeMenuBar(toolProperty);
+       }
+       
+       /**
+        * Initialization of the screen context for menu bar and tool bar.
+        * 
+        * @param menuProperty - the property of the menu bar.
+     * @param toolProperty - the property of the tool bar.
+        */
+       public void initializationScreenContext(final String menuProperty, 
+                       final String toolProperty) {
+               
+               initializationContext();
+               getMenuBarSettings().intializeMenuBar(menuProperty);
+               getToolBarSettings().intializeMenuBar(toolProperty);
+       }
 //  ==============================================================================================================================
 //  Getters and setters
 //  ==============================================================================================================================
@@ -297,6 +356,21 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
        public void setTitleBarSettings(TitleBarSettings titleBarSettings) {
                _titleBarSettings = titleBarSettings;
        }
+       /**
+        * Get the toolBarSettings.
+        * @return the toolBarSettings
+        */
+       public final ToolBarSettings getToolBarSettings() {
+               return _toolBarSettings;
+       }
+       /**
+        * Set the toolBarSettings.
+        * @param toolBarSettings the toolBarSettings to set
+        */
+       public final void setToolBarSettings(ToolBarSettings toolBarSettings) {
+               _toolBarSettings = toolBarSettings;
+       }
+       
        /**
         * Get the applicationSettings.
         * @return the applicationSettings