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.service.StudyService;
8 import org.splat.som.StepRights;
9 import org.splat.dal.bo.som.Study;
10 import org.splat.wapp.PopupMenu;
11 import org.splat.wapp.SimpleMenu;
14 * Presents the current open study information.
15 * @author Daniel Brunier-Coulin.
18 public class DisplayStudyStepAction extends DisplayBaseAction {
23 private static final long serialVersionUID = 6467920934724352021L;
28 protected OpenStudy mystudy = null;
31 * Injected study service.
33 private StudyService _studyService;
36 * Value of the menu property.
37 * It can be: none, create, open, study, knowledge, sysadmin, help.
39 private String _menuProperty;
42 * Value of the title bar property.
43 * It can be: study, knowledge.
45 private String _titleProperty;
48 * Value of the tool bar property.
49 * It can be: none, standard, study, back.
51 private String _toolProperty;
54 * Value of the left menu property.
55 * It can be: open, study, knowledge, scenario.
57 private String _leftMenuProperty;
60 * Property that indicates whether the current open study is editable or not.
61 * On the screen it looks like pen on the status icon, pop-up menu also can be called.
62 * It is necessary for correct building the title bar.
64 private String _editDisabledProperty = "false";
66 // ==============================================================================================================================
68 // ==============================================================================================================================
70 public String doOpen() {
72 mystudy = getOpenStudy();
74 try { // Opening a study from the search result
75 int index = Integer.valueOf(myindex);
76 if (mystudy != null && mystudy.getStudyObject() != null
77 && mystudy.getIndex() == index) { // - The selected study is currently open
78 selection = mystudy.getSelection(); // Current selection
79 study = mystudy.getStudyObject(); // Current Study object
80 // RKV:BEGIN: put in session if necessary
81 if (!getSession().containsKey("study.open")) {
85 } else { // - The selected study is new
86 study = getStudyService().selectStudy(index);
87 mystudy = open(study);
88 selection = mystudy.getSelection(); // Default selection
90 } catch (Exception error) {
91 logger.error("Reason:", error);
94 else if (selection == null) { // Opening a study just newed
95 selection = mystudy.getSelection(); // Default selection
96 study = mystudy.getStudyObject();
97 } else { // Re-opening (refreshing) the currently open study
98 study = getStudyService().selectStudy(mystudy.getIndex());
99 mystudy = open(study); // Closes the previously open study
100 mystudy.setSelection(selection);
102 // Initialization of menus
103 ProjectElement owner = mystudy.getSelectedStep().getOwner();
104 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
105 if (owner instanceof Scenario) {
106 menu.enables("prop-scenario");
107 menu.selects("prop-scenario");
109 menu.disables("prop-scenario");
110 menu.selects("prop-general");
112 getSession().put("menu.study", mystudy.getMenu());
114 setMenuProperty("study");
115 setTitleProperty("study");
116 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
117 setToolProperty("study");
119 setToolProperty("standard");
122 setLeftMenuProperty("study");
124 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
129 public String doSelectStep() {
131 mystudy = getOpenStudy();
132 if (selection == null) { // Switch back to the current study
133 selection = mystudy.getSelection();
134 } else { // Selection of a step of current study
135 mystudy.setSelection(selection);
137 // Re-initialization of the properties menu according to the selected step
138 ProjectElement owner = mystudy.getSelectedStep().getOwner();
139 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
140 if (owner instanceof Scenario) {
141 menu.enables("prop-scenario");
142 menu.selects("prop-scenario");
144 menu.disables("prop-scenario");
145 menu.selects("prop-general");
148 setMenuProperty("study");
149 setTitleProperty("study");
150 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
151 setToolProperty("study");
153 setToolProperty("standard");
156 setLeftMenuProperty("study");
157 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
162 public String doSelectDocument() {
163 mystudy = getOpenStudy();
164 Execute todo = Execute.valueOf(action);
165 if (todo == Execute.develop)
166 mystudy.developDocument(myindex);
167 else if (todo == Execute.reduce)
168 mystudy.reduceHistory(myindex);
169 else if (todo == Execute.reduceall)
170 mystudy.reduceDocument(myindex);
172 setMenuProperty("study");
173 setTitleProperty("study");
174 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
175 setToolProperty("study");
177 setToolProperty("standard");
179 setLeftMenuProperty("study");
180 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
185 public String doSelectKnowledge() {
186 mystudy = getOpenStudy();
187 Execute todo = Execute.valueOf(action);
188 if (todo == Execute.develop)
189 mystudy.developKnowledge(myindex);
190 else if (todo == Execute.reduce)
191 mystudy.reduceKnowledge(myindex);
193 setMenuProperty("study");
194 setTitleProperty("study");
195 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
196 setToolProperty("study");
198 setToolProperty("standard");
200 setLeftMenuProperty("study");
201 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
206 public String doClose() {
209 setMenuProperty("none");
210 initializationScreenContext(_menuProperty);
215 // ==============================================================================================================================
217 // ==============================================================================================================================
219 public String getAction() {
223 public List<DocumentFacade> getDocuments() {
224 return mystudy.getDisplayedDocuments();
227 public List<OpenObject.KnowledgeIterator> getKnowledges() {
228 return mystudy.getDisplayedKnowledges();
231 public List<SimulationContextFacade> getSimulationContexts() {
232 return mystudy.getDisplayedSimulationContexts();
235 public PopupMenu getPopup() {
236 return mystudy.getPopup();
239 public int getStepNumber() {
240 return mystudy.getSelectedStep().getNumber();
243 public String getStepEnabled() {
244 return String.valueOf(mystudy.isStepEnabled());
247 public StepRights getUserRights() {
248 return mystudy.getSelectedStepRights();
251 public String getWriteAccess() {
252 return String.valueOf(mystudy.isOpenForWriting());
256 * Get the studyService.
258 * @return the studyService
260 public StudyService getStudyService() {
261 return _studyService;
265 * Set the studyService.
267 * @param studyService
268 * the studyService to set
270 public void setStudyService(StudyService studyService) {
271 _studyService = studyService;
277 * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
280 public void setOpenStudy(OpenStudy study) {
281 super.setOpenStudy(study);
286 * Get the menuProperty.
287 * @return the menuProperty
289 public String getMenuProperty() {
290 return _menuProperty;
294 * Set the menuProperty.
295 * @param menuProperty the menuProperty to set
297 public void setMenuProperty(String menuProperty) {
298 this._menuProperty = menuProperty;
302 * Get the _titleProperty.
303 * @return the _titleProperty
305 public String getTitleProperty() {
306 return _titleProperty;
310 * Set the _titleProperty.
311 * @param _titleProperty the titleProperty to set
313 public void setTitleProperty(String titleProperty) {
314 _titleProperty = titleProperty;
318 * Get the editDisabledProperty.
319 * @return the editDisabledProperty
321 public String getEditDisabledProperty() {
322 return _editDisabledProperty;
326 * Set the editDisabledProperty.
327 * @param editDisabledProperty the editDisabledProperty to set
329 public void setEditDisabledProperty(String editDisabledProperty) {
330 _editDisabledProperty = editDisabledProperty;
334 * Get the toolProperty.
335 * @return the toolProperty
337 public String getToolProperty() {
338 return _toolProperty;
342 * Set the toolProperty.
343 * @param toolProperty the toolProperty to set
345 public void setToolProperty(final String toolProperty) {
346 _toolProperty = toolProperty;
350 * Get the leftMenuProperty.
351 * @return the leftMenuProperty
353 public String getLeftMenuProperty() {
354 return _leftMenuProperty;
358 * Set the leftMenuProperty.
359 * @param leftMenuProperty the leftMenuProperty to set
361 public void setLeftMenuProperty(final String leftMenuProperty) {
362 _leftMenuProperty = leftMenuProperty;