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