Salome HOME
755ba3faef571bf7a0600e27b80d1413479d5915
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditStudyAction.java
1 package org.splat.simer;
2
3 import org.splat.dal.bo.som.Study;
4 import org.splat.service.StudyService;
5
6
7 public class EditStudyAction extends DisplayStudyStepAction {
8     
9         /**
10          * Serial version ID.
11          */
12     private static final long serialVersionUID = -4865668290514118396L;
13
14         private enum Execute { publish, promote }
15
16         private StudyService _studyService;
17         
18         /**
19          * Value of the menu property. 
20          * It can be: none, create, open, study, knowledge, sysadmin, help.
21          */
22         private String _menuProperty;
23         
24         /**
25          * Value of the title bar property. 
26          * It can be: study, knowledge.
27          */
28         private String _titleProperty;
29         
30         /**
31          * Value of the tool bar property. 
32          * It can be: none, standard, study, back.
33          */
34         private String _toolProperty;
35         
36         /**
37          * Value of the left menu property. 
38          * It can be: open, study, knowledge, scenario.
39          */
40         private String _leftMenuProperty;
41         
42         /**
43          * Property that indicates whether the current open study is editable or not.
44          * On the screen it looks like pen on the status icon, pop-up menu also can be called.
45          * It is necessary for correct building the title bar.
46          */
47         private String _editDisabledProperty = "false";
48
49 //  ==============================================================================================================================
50 //  Action methods
51 //  ==============================================================================================================================
52
53     public String doEdition () {
54           try {
55         _openStudy = getOpenStudy();
56
57         Execute  todo   = Execute.valueOf(_action);
58         Study    study  = _openStudy.getStudyObject();
59         
60         if      (todo == Execute.publish) getStudyService().moveToPublic(study);
61         else if (todo == Execute.promote) getStudyService().moveToReference(study);
62         _openStudy.getPopup().setContext("study", _openStudy.getStudyRights());   // The context has changed
63         
64         setMenuProperty("study");
65         setTitleProperty("study");
66         if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
67                         setToolProperty("study");
68                 } else {
69                         setToolProperty("standard");
70                 }
71         setLeftMenuProperty("study");
72                 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
73
74         return SUCCESS;
75           }
76       catch (RuntimeException saverror) {
77         LOG.error("Reason:", saverror);
78         return ERROR;
79       }
80     }
81         /**
82          * Get the studyService.
83          * 
84          * @return the studyService
85          */
86         public StudyService getStudyService() {
87                 return _studyService;
88         }
89
90         /**
91          * Set the studyService.
92          * 
93          * @param studyService
94          *            the studyService to set
95          */
96         public void setStudyService(StudyService studyService) {
97                 _studyService = studyService;
98         }
99         
100         /**
101          * Get the menuProperty.
102          * @return the menuProperty
103          */
104         public String getMenuProperty() {
105                 return _menuProperty;
106         }
107
108         /**
109          * Set the menuProperty.
110          * @param menuProperty the menuProperty to set
111          */
112         public void setMenuProperty(String menuProperty) {
113                 this._menuProperty = menuProperty;
114         }
115         
116         /**
117          * Get the _titleProperty.
118          * @return the _titleProperty
119          */
120         public String getTitleProperty() {
121                 return _titleProperty;
122         }
123
124         /**
125          * Set the _titleProperty.
126          * @param _titleProperty the titleProperty to set
127          */
128         public void setTitleProperty(String titleProperty) {
129                 _titleProperty = titleProperty;
130         }
131         /**
132          * Get the editDisabledProperty.
133          * @return the editDisabledProperty
134          */
135         public final String getEditDisabledProperty() {
136                 return _editDisabledProperty;
137         }
138         /**
139          * Set the editDisabledProperty.
140          * @param editDisabledProperty the editDisabledProperty to set
141          */
142         public final void setEditDisabledProperty(String editDisabledProperty) {
143                 _editDisabledProperty = editDisabledProperty;
144         }
145         
146         /**
147          * Get the toolProperty.
148          * @return the toolProperty
149          */
150         public String getToolProperty() {
151                 return _toolProperty;
152         }
153
154         /**
155          * Set the toolProperty.
156          * @param toolProperty the toolProperty to set
157          */
158         public void setToolProperty(final String toolProperty) {
159                 _toolProperty = toolProperty;
160         }
161         
162         /**
163          * Get the leftMenuProperty.
164          * @return the leftMenuProperty
165          */
166         public String getLeftMenuProperty() {
167                 return _leftMenuProperty;
168         }
169
170         /**
171          * Set the leftMenuProperty.
172          * @param leftMenuProperty the leftMenuProperty to set
173          */
174         public void setLeftMenuProperty(final String leftMenuProperty) {
175                 _leftMenuProperty = leftMenuProperty;
176         }
177
178 }