Salome HOME
Left menu is improved
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditScenarioPropertiesAction.java
1 package org.splat.simer;
2
3 import java.text.SimpleDateFormat;
4 import java.util.ResourceBundle;
5
6 import org.splat.dal.bo.kernel.User;
7 import org.splat.dal.bo.som.Scenario;
8 import org.splat.service.ProjectElementService;
9 import org.splat.service.ScenarioService;
10 import org.splat.som.Step;
11 import org.splat.som.StepRights;
12
13 public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
14
15         private Scenario myscenario;
16         private String lasdate;
17         private String subject;
18         private ScenarioService _scenarioService;
19         private ProjectElementService _projectElementService;
20         
21         /**
22          * Value of the menu property. 
23          * It can be: none, create, open, study, knowledge, sysadmin, help.
24          */
25         private String _menuProperty;
26         
27         /**
28          * Value of the title bar property. 
29          * It can be: study, knowledge.
30          */
31         private String _titleProperty;
32         
33         /**
34          * Property that indicates whether the current open study is editable or not.
35          * On the screen it looks like pen on the status icon, pop-up menu also can be called.
36          * It is necessary for correct building the title bar.
37          */
38         private String _editDisabledProperty = "false";
39         
40         /**
41          * Value of the tool bar property. 
42          * It can be: none, standard, study, back.
43          */
44         private String _toolProperty;
45         
46         /**
47          * Value of the left menu property. 
48          * It can be: open, study, knowledge, scenario.
49          */
50         private String _leftMenuProperty;
51
52         /**
53          * Serial version ID.
54          */
55         private static final long serialVersionUID = 4964740932426016171L;
56
57         // ==============================================================================================================================
58         // Action methods
59         // ==============================================================================================================================
60
61         public String doInitialize() {
62                 // -----------------------------
63                 ResourceBundle label = ResourceBundle.getBundle("labels",
64                                 getApplicationSettings().getCurrentLocale());
65                 ResourceBundle custom = ResourceBundle.getBundle("som",
66                                 getApplicationSettings().getCurrentLocale());
67                 SimpleDateFormat datstring = new SimpleDateFormat(
68                                 custom.getString("date.format")); // Locale date display format
69                 Step step;
70
71                 mystudy = getOpenStudy();
72                 step = mystudy.getSelectedStep();
73                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
74                 lasdate = datstring.format(myscenario.getLastModificationDate());
75                 subject = label.getString("label.study") + " " + mystudy.getTitle();
76                 
77                 setMenuProperty("study");
78                 setTitleProperty("study");
79                 setEditDisabledProperty("true");
80                 setToolProperty("back");
81                 setLeftMenuProperty("study");
82         initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
83
84                 return SUCCESS;
85         }
86
87         public String doCheckin() {
88                 Step step;
89
90                 mystudy = getOpenStudy();
91                 selection = mystudy.getSelection();
92                 step = mystudy.getSelectedStep();
93                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
94
95                 getScenarioService().checkin(myscenario);
96
97                 mystudy.getMenu().refreshGivenStepItem(
98                                 getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
99                 
100                 setMenuProperty("study");
101                 if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
102                         setToolProperty("study");
103                 } else {
104                         setToolProperty("standard");
105                 }
106                 setLeftMenuProperty("study");
107                 initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
108
109                 
110                 return SUCCESS;
111         }
112
113         // ==============================================================================================================================
114         // Getters
115         // ==============================================================================================================================
116
117         public User getAuthor() {
118                 // ------------------------
119                 if (myscenario.isCheckedout())
120                         return myscenario.getUser();
121                 else
122                         return myscenario.getAuthor();
123         }
124
125         public String getLastModificationDate() {
126                 // ----------------------------------------
127                 return lasdate;
128         }
129
130         public StepRights getSelectedStep() {
131                 // ------------------------------------
132                 return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
133         }
134
135         public String getSubject() {
136                 // ---------------------------
137                 return subject;
138         }
139
140         public String getTitle() {
141                 // -------------------------
142                 return myscenario.getTitle();
143         }
144
145         public boolean isCheckedout() {
146                 // ------------------------------
147                 return myscenario.isCheckedout();
148         }
149
150         /**
151          * Get the scenarioService.
152          * 
153          * @return the scenarioService
154          */
155         public ScenarioService getScenarioService() {
156                 return _scenarioService;
157         }
158
159         /**
160          * Set the scenarioService.
161          * 
162          * @param scenarioService
163          *            the scenarioService to set
164          */
165         public void setScenarioService(ScenarioService scenarioService) {
166                 _scenarioService = scenarioService;
167         }
168
169         /**
170          * Get the projectElementService.
171          * 
172          * @return the projectElementService
173          */
174         public ProjectElementService getProjectElementService() {
175                 return _projectElementService;
176         }
177
178         /**
179          * Set the projectElementService.
180          * 
181          * @param projectElementService
182          *            the projectElementService to set
183          */
184         public void setProjectElementService(
185                         ProjectElementService projectElementService) {
186                 _projectElementService = projectElementService;
187         }
188         
189         /**
190          * Get the menuProperty.
191          * @return the menuProperty
192          */
193         public String getMenuProperty() {
194                 return _menuProperty;
195         }
196
197         /**
198          * Set the menuProperty.
199          * @param menuProperty the menuProperty to set
200          */
201         public void setMenuProperty(String menuProperty) {
202                 this._menuProperty = menuProperty;
203         }
204         
205         /**
206          * Get the _titleProperty.
207          * @return the _titleProperty
208          */
209         public String getTitleProperty() {
210                 return _titleProperty;
211         }
212
213         /**
214          * Set the _titleProperty.
215          * @param _titleProperty the titleProperty to set
216          */
217         public void setTitleProperty(String titleProperty) {
218                 _titleProperty = titleProperty;
219         }
220
221         /**
222          * Get the editDisabledProperty.
223          * @return the editDisabledProperty
224          */
225         public final String getEditDisabledProperty() {
226                 return _editDisabledProperty;
227         }
228
229         /**
230          * Set the editDisabledProperty.
231          * @param editDisabledProperty the editDisabledProperty to set
232          */
233         public final void setEditDisabledProperty(String editDisabledProperty) {
234                 _editDisabledProperty = editDisabledProperty;
235         }
236
237         /**
238          * Get the toolProperty.
239          * @return the toolProperty
240          */
241         public String getToolProperty() {
242                 return _toolProperty;
243         }
244
245         /**
246          * Set the toolProperty.
247          * @param toolProperty the toolProperty to set
248          */
249         public void setToolProperty(final String toolProperty) {
250                 _toolProperty = toolProperty;
251         }
252         
253         /**
254          * Get the leftMenuProperty.
255          * @return the leftMenuProperty
256          */
257         public String getLeftMenuProperty() {
258                 return _leftMenuProperty;
259         }
260
261         /**
262          * Set the leftMenuProperty.
263          * @param leftMenuProperty the leftMenuProperty to set
264          */
265         public void setLeftMenuProperty(final String leftMenuProperty) {
266                 _leftMenuProperty = leftMenuProperty;
267         }
268 }