1 package org.splat.simer;
5 import org.splat.dal.bo.som.ProjectElement;
6 import org.splat.dal.bo.som.Scenario;
7 import org.splat.dal.bo.som.Study;
8 import org.splat.service.StudyService;
9 import org.splat.som.StepRights;
10 import org.splat.wapp.Constants;
11 import org.splat.wapp.PopupMenu;
12 import org.splat.wapp.SimpleMenu;
15 * Presents the current open study information.
17 * @author Daniel Brunier-Coulin.
20 public class DisplayStudyStepAction extends AbstractDisplayAction {
25 private static final long serialVersionUID = 6467920934724352021L;
30 protected transient OpenStudy _openStudy = null;
33 * Injected study service.
35 private StudyService _studyService;
38 * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
40 private String _menuProperty;
43 * Value of the title bar property. It can be: study, knowledge.
45 private String _titleProperty;
48 * Value of the tool bar property. It can be: none, standard, study, back.
50 private String _toolProperty;
53 * Value of the left menu property. It can be: open, study, knowledge, scenario.
55 private String _leftMenuProperty;
58 * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
59 * menu also can be called. It is necessary for correct building the title bar.
61 private String _editDisabledProperty = "false";
63 // ==============================================================================================================================
65 // ==============================================================================================================================
67 public String doOpen() {
70 _openStudy = getOpenStudy();
71 if (_myindex == null) {
72 if (_selection == null) { // Opening a study just newed
73 _selection = _openStudy.getSelection(); // Default selection
74 study = _openStudy.getStudyObject();
75 } else { // Re-opening (refreshing) the currently open study
76 study = getStudyService().selectStudy(_openStudy.getIndex());
77 _openStudy = open(study); // Closes the previously open study
78 _openStudy.setSelection(_selection);
81 try { // Opening a study from the search result
82 int index = Integer.valueOf(_myindex);
83 if (_openStudy != null && _openStudy.getStudyObject() != null
84 && _openStudy.getIndex() == index) { // - The selected study is currently open
85 _selection = _openStudy.getSelection(); // Current selection
86 study = _openStudy.getStudyObject(); // Current Study object
87 // RKV:BEGIN: put in session if necessary
88 if (!getSession().containsKey("study.open")) {
92 } else { // - The selected study is new
93 study = getStudyService().selectStudy(index);
94 _openStudy = open(study);
95 _selection = _openStudy.getSelection(); // Default selection
97 } catch (Exception error) {
98 LOG.error("Reason:", error);
102 if (!ERROR.equals(res)) {
103 // Initialization of menus
104 ProjectElement owner = _openStudy.getSelectedStep().getOwner();
105 SimpleMenu menu = getApplicationSettings().getMenu("configuration");
106 if (owner instanceof Scenario) {
107 menu.enables(Constants.PROP_SCENARIO);
108 menu.selects(Constants.PROP_SCENARIO);
110 menu.disables(Constants.PROP_SCENARIO);
111 menu.selects("prop-general");
113 getSession().put("menu.study", _openStudy.getMenu());
115 setMenuProperty(Constants.STUDY_MENU);
116 setTitleProperty(Constants.STUDY_MENU);
117 if (Constants.TRUE.equals(getWriteAccess())
118 && getUserRights().canCreateDocument()) {
119 setToolProperty(Constants.STUDY_MENU);
121 setToolProperty(Constants.STANDARD_MENU);
124 setLeftMenuProperty(Constants.STUDY_MENU);
126 initializationFullScreenContext(_menuProperty, _titleProperty,
127 _editDisabledProperty, _toolProperty, _leftMenuProperty);
132 public String doSelectStep() {
134 _openStudy = getOpenStudy();
135 if (_selection == null) { // Switch back to the current study
136 _selection = _openStudy.getSelection();
137 } else { // Selection of a step of current study
138 _openStudy.setSelection(_selection);
140 // Re-initialization of the properties menu according to the selected step
141 ProjectElement owner = _openStudy.getSelectedStep().getOwner();
142 SimpleMenu menu = getApplicationSettings().getMenu("configuration");
143 if (owner instanceof Scenario) {
144 menu.enables(Constants.PROP_SCENARIO);
145 menu.selects(Constants.PROP_SCENARIO);
147 menu.disables(Constants.PROP_SCENARIO);
148 menu.selects("prop-general");
151 setMenuProperty(Constants.STUDY_MENU);
152 setTitleProperty(Constants.STUDY_MENU);
153 if (Constants.TRUE.equals(getWriteAccess())
154 && getUserRights().canCreateDocument()) {
155 setToolProperty(Constants.STUDY_MENU);
157 setToolProperty(Constants.STANDARD_MENU);
160 setLeftMenuProperty(Constants.STUDY_MENU);
161 initializationFullScreenContext(_menuProperty, _titleProperty,
162 _editDisabledProperty, _toolProperty, _leftMenuProperty);
167 public String doSelectDocument() {
168 _openStudy = getOpenStudy();
169 Execute todo = Execute.valueOf(_action);
170 if (todo == Execute.develop) {
171 _openStudy.developDocument(_myindex);
172 } else if (todo == Execute.reduce) {
173 _openStudy.reduceHistory(_myindex);
174 } else if (todo == Execute.reduceall) {
175 _openStudy.reduceDocument(_myindex);
178 setMenuProperty(Constants.STUDY_MENU);
179 setTitleProperty(Constants.STUDY_MENU);
180 if (Constants.TRUE.equals(getWriteAccess())
181 && getUserRights().canCreateDocument()) {
182 setToolProperty(Constants.STUDY_MENU);
184 setToolProperty(Constants.STANDARD_MENU);
186 setLeftMenuProperty(Constants.STUDY_MENU);
187 initializationFullScreenContext(_menuProperty, _titleProperty,
188 _editDisabledProperty, _toolProperty, _leftMenuProperty);
193 public String doSelectKnowledge() {
194 _openStudy = getOpenStudy();
195 Execute todo = Execute.valueOf(_action);
196 if (todo == Execute.develop) {
197 _openStudy.developKnowledge(_myindex);
198 } else if (todo == Execute.reduce) {
199 _openStudy.reduceKnowledge(_myindex);
202 setMenuProperty(Constants.STUDY_MENU);
203 setTitleProperty(Constants.STUDY_MENU);
204 if (Constants.TRUE.equals(getWriteAccess())
205 && getUserRights().canCreateDocument()) {
206 setToolProperty(Constants.STUDY_MENU);
208 setToolProperty(Constants.STANDARD_MENU);
210 setLeftMenuProperty(Constants.STUDY_MENU);
211 initializationFullScreenContext(_menuProperty, _titleProperty,
212 _editDisabledProperty, _toolProperty, _leftMenuProperty);
217 public String doClose() {
220 setMenuProperty("none");
221 initializationScreenContext(_menuProperty);
226 // ==============================================================================================================================
228 // ==============================================================================================================================
230 public String getAction() {
234 public List<DocumentFacade> getDocuments() {
235 return _openStudy.getDisplayedDocuments();
238 public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
239 return _openStudy.getDisplayedKnowledges();
242 public List<SimulationContextFacade> getSimulationContexts() {
243 return _openStudy.getDisplayedSimulationContexts();
246 public PopupMenu getPopup() {
247 return _openStudy.getPopup();
250 public int getStepNumber() {
251 return _openStudy.getSelectedStep().getNumber();
254 public String getStepEnabled() {
255 return String.valueOf(_openStudy.isStepEnabled());
258 public StepRights getUserRights() {
259 return _openStudy.getSelectedStepRights();
263 public String getWriteAccess() {
264 return String.valueOf(_openStudy.isOpenForWriting());
268 * Get the studyService.
270 * @return the studyService
272 public StudyService getStudyService() {
273 return _studyService;
277 * Set the studyService.
279 * @param studyService
280 * the studyService to set
282 public void setStudyService(final StudyService studyService) {
283 _studyService = studyService;
289 * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
292 public void setOpenStudy(final OpenStudy study) {
293 super.setOpenStudy(study);
298 * Get the menuProperty.
300 * @return the menuProperty
302 public String getMenuProperty() {
303 return _menuProperty;
307 * Set the menuProperty.
309 * @param menuProperty
310 * the menuProperty to set
312 public void setMenuProperty(final String menuProperty) {
313 this._menuProperty = menuProperty;
317 * Get the _titleProperty.
319 * @return the _titleProperty
321 public String getTitleProperty() {
322 return _titleProperty;
326 * Set the _titleProperty.
328 * @param _titleProperty
329 * the titleProperty to set
331 public void setTitleProperty(final String titleProperty) {
332 _titleProperty = titleProperty;
336 * Get the editDisabledProperty.
338 * @return the editDisabledProperty
340 public String getEditDisabledProperty() {
341 return _editDisabledProperty;
345 * Set the editDisabledProperty.
347 * @param editDisabledProperty
348 * the editDisabledProperty to set
350 public void setEditDisabledProperty(final String editDisabledProperty) {
351 _editDisabledProperty = editDisabledProperty;
355 * Get the toolProperty.
357 * @return the toolProperty
359 public String getToolProperty() {
360 return _toolProperty;
364 * Set the toolProperty.
366 * @param toolProperty
367 * the toolProperty to set
369 public void setToolProperty(final String toolProperty) {
370 _toolProperty = toolProperty;
374 * Get the leftMenuProperty.
376 * @return the leftMenuProperty
378 public String getLeftMenuProperty() {
379 return _leftMenuProperty;
383 * Set the leftMenuProperty.
385 * @param leftMenuProperty
386 * the leftMenuProperty to set
388 public void setLeftMenuProperty(final String leftMenuProperty) {
389 _leftMenuProperty = leftMenuProperty;