]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Salome HOME
Tool bar 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          * Serial version ID.
48          */
49         private static final long serialVersionUID = 4964740932426016171L;
50
51         // ==============================================================================================================================
52         // Action methods
53         // ==============================================================================================================================
54
55         public String doInitialize() {
56                 // -----------------------------
57                 ResourceBundle label = ResourceBundle.getBundle("labels",
58                                 getApplicationSettings().getCurrentLocale());
59                 ResourceBundle custom = ResourceBundle.getBundle("som",
60                                 getApplicationSettings().getCurrentLocale());
61                 SimpleDateFormat datstring = new SimpleDateFormat(
62                                 custom.getString("date.format")); // Locale date display format
63                 Step step;
64
65                 mystudy = getOpenStudy();
66                 step = mystudy.getSelectedStep();
67                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
68                 lasdate = datstring.format(myscenario.getLastModificationDate());
69                 subject = label.getString("label.study") + " " + mystudy.getTitle();
70                 
71                 setMenuProperty("study");
72                 setTitleProperty("study");
73                 setEditDisabledProperty("true");
74                 setToolProperty("back");
75         initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
76
77                 return SUCCESS;
78         }
79
80         public String doCheckin() {
81                 Step step;
82
83                 mystudy = getOpenStudy();
84                 selection = mystudy.getSelection();
85                 step = mystudy.getSelectedStep();
86                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
87
88                 getScenarioService().checkin(myscenario);
89
90                 mystudy.getMenu().refreshGivenStepItem(
91                                 getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
92                 
93                 setMenuProperty("study");
94                 if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
95                         setToolProperty("study");
96                 } else {
97                         setToolProperty("standard");
98                 }
99                 initializationScreenContext(_menuProperty, _toolProperty);
100
101                 
102                 return SUCCESS;
103         }
104
105         // ==============================================================================================================================
106         // Getters
107         // ==============================================================================================================================
108
109         public User getAuthor() {
110                 // ------------------------
111                 if (myscenario.isCheckedout())
112                         return myscenario.getUser();
113                 else
114                         return myscenario.getAuthor();
115         }
116
117         public String getLastModificationDate() {
118                 // ----------------------------------------
119                 return lasdate;
120         }
121
122         public StepRights getSelectedStep() {
123                 // ------------------------------------
124                 return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
125         }
126
127         public String getSubject() {
128                 // ---------------------------
129                 return subject;
130         }
131
132         public String getTitle() {
133                 // -------------------------
134                 return myscenario.getTitle();
135         }
136
137         public boolean isCheckedout() {
138                 // ------------------------------
139                 return myscenario.isCheckedout();
140         }
141
142         /**
143          * Get the scenarioService.
144          * 
145          * @return the scenarioService
146          */
147         public ScenarioService getScenarioService() {
148                 return _scenarioService;
149         }
150
151         /**
152          * Set the scenarioService.
153          * 
154          * @param scenarioService
155          *            the scenarioService to set
156          */
157         public void setScenarioService(ScenarioService scenarioService) {
158                 _scenarioService = scenarioService;
159         }
160
161         /**
162          * Get the projectElementService.
163          * 
164          * @return the projectElementService
165          */
166         public ProjectElementService getProjectElementService() {
167                 return _projectElementService;
168         }
169
170         /**
171          * Set the projectElementService.
172          * 
173          * @param projectElementService
174          *            the projectElementService to set
175          */
176         public void setProjectElementService(
177                         ProjectElementService projectElementService) {
178                 _projectElementService = projectElementService;
179         }
180         
181         /**
182          * Get the menuProperty.
183          * @return the menuProperty
184          */
185         public String getMenuProperty() {
186                 return _menuProperty;
187         }
188
189         /**
190          * Set the menuProperty.
191          * @param menuProperty the menuProperty to set
192          */
193         public void setMenuProperty(String menuProperty) {
194                 this._menuProperty = menuProperty;
195         }
196         
197         /**
198          * Get the _titleProperty.
199          * @return the _titleProperty
200          */
201         public String getTitleProperty() {
202                 return _titleProperty;
203         }
204
205         /**
206          * Set the _titleProperty.
207          * @param _titleProperty the titleProperty to set
208          */
209         public void setTitleProperty(String titleProperty) {
210                 _titleProperty = titleProperty;
211         }
212
213         /**
214          * Get the editDisabledProperty.
215          * @return the editDisabledProperty
216          */
217         public final String getEditDisabledProperty() {
218                 return _editDisabledProperty;
219         }
220
221         /**
222          * Set the editDisabledProperty.
223          * @param editDisabledProperty the editDisabledProperty to set
224          */
225         public final void setEditDisabledProperty(String editDisabledProperty) {
226                 _editDisabledProperty = editDisabledProperty;
227         }
228
229         /**
230          * Get the toolProperty.
231          * @return the toolProperty
232          */
233         public String getToolProperty() {
234                 return _toolProperty;
235         }
236
237         /**
238          * Set the toolProperty.
239          * @param toolProperty the toolProperty to set
240          */
241         public void setToolProperty(final String toolProperty) {
242                 _toolProperty = toolProperty;
243         }
244 }