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 * Property that indicates whether the current open study is editable or not.
55 * On the screen it looks like pen on the status icon, pop-up menu also can be called.
56 * It is necessary for correct building the title bar.
58 private String _editDisabledProperty = "false";
60 // ==============================================================================================================================
62 // ==============================================================================================================================
64 public String doOpen() {
66 mystudy = getOpenStudy();
68 try { // Opening a study from the search result
69 int index = Integer.valueOf(myindex);
70 if (mystudy != null && mystudy.getStudyObject() != null
71 && mystudy.getIndex() == index) { // - The selected study is currently open
72 selection = mystudy.getSelection(); // Current selection
73 study = mystudy.getStudyObject(); // Current Study object
74 // RKV:BEGIN: put in session if necessary
75 if (!getSession().containsKey("study.open")) {
79 } else { // - The selected study is new
80 study = getStudyService().selectStudy(index);
81 mystudy = open(study);
82 selection = mystudy.getSelection(); // Default selection
84 } catch (Exception error) {
85 logger.error("Reason:", error);
88 else if (selection == null) { // Opening a study just newed
89 selection = mystudy.getSelection(); // Default selection
90 study = mystudy.getStudyObject();
91 } else { // Re-opening (refreshing) the currently open study
92 study = getStudyService().selectStudy(mystudy.getIndex());
93 mystudy = open(study); // Closes the previously open study
94 mystudy.setSelection(selection);
96 // Initialization of menus
97 ProjectElement owner = mystudy.getSelectedStep().getOwner();
98 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
99 if (owner instanceof Scenario) {
100 menu.enables("prop-scenario");
101 menu.selects("prop-scenario");
103 menu.disables("prop-scenario");
104 menu.selects("prop-general");
106 getSession().put("menu.study", mystudy.getMenu());
108 setMenuProperty("study");
109 setTitleProperty("study");
110 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
111 setToolProperty("study");
113 setToolProperty("standard");
116 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
121 public String doSelectStep() {
123 mystudy = getOpenStudy();
124 if (selection == null) { // Switch back to the current study
125 selection = mystudy.getSelection();
126 } else { // Selection of a step of current study
127 mystudy.setSelection(selection);
129 // Re-initialization of the properties menu according to the selected step
130 ProjectElement owner = mystudy.getSelectedStep().getOwner();
131 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
132 if (owner instanceof Scenario) {
133 menu.enables("prop-scenario");
134 menu.selects("prop-scenario");
136 menu.disables("prop-scenario");
137 menu.selects("prop-general");
140 setMenuProperty("study");
141 setTitleProperty("study");
142 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
143 setToolProperty("study");
145 setToolProperty("standard");
147 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
152 public String doSelectDocument() {
153 mystudy = getOpenStudy();
154 Execute todo = Execute.valueOf(action);
155 if (todo == Execute.develop)
156 mystudy.developDocument(myindex);
157 else if (todo == Execute.reduce)
158 mystudy.reduceHistory(myindex);
159 else if (todo == Execute.reduceall)
160 mystudy.reduceDocument(myindex);
162 setMenuProperty("study");
163 setTitleProperty("study");
164 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
165 setToolProperty("study");
167 setToolProperty("standard");
169 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
174 public String doSelectKnowledge() {
175 mystudy = getOpenStudy();
176 Execute todo = Execute.valueOf(action);
177 if (todo == Execute.develop)
178 mystudy.developKnowledge(myindex);
179 else if (todo == Execute.reduce)
180 mystudy.reduceKnowledge(myindex);
182 setMenuProperty("study");
183 setTitleProperty("study");
184 if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
185 setToolProperty("study");
187 setToolProperty("standard");
189 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
194 public String doClose() {
197 setMenuProperty("none");
198 initializationScreenContext(_menuProperty);
203 // ==============================================================================================================================
205 // ==============================================================================================================================
207 public String getAction() {
211 public List<DocumentFacade> getDocuments() {
212 return mystudy.getDisplayedDocuments();
215 public List<OpenObject.KnowledgeIterator> getKnowledges() {
216 return mystudy.getDisplayedKnowledges();
219 public List<SimulationContextFacade> getSimulationContexts() {
220 return mystudy.getDisplayedSimulationContexts();
223 public PopupMenu getPopup() {
224 return mystudy.getPopup();
227 public int getStepNumber() {
228 return mystudy.getSelectedStep().getNumber();
231 public String getStepEnabled() {
232 return String.valueOf(mystudy.isStepEnabled());
235 public StepRights getUserRights() {
236 return mystudy.getSelectedStepRights();
239 public String getWriteAccess() {
240 return String.valueOf(mystudy.isOpenForWriting());
244 * Get the studyService.
246 * @return the studyService
248 public StudyService getStudyService() {
249 return _studyService;
253 * Set the studyService.
255 * @param studyService
256 * the studyService to set
258 public void setStudyService(StudyService studyService) {
259 _studyService = studyService;
265 * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
268 public void setOpenStudy(OpenStudy study) {
269 super.setOpenStudy(study);
274 * Get the menuProperty.
275 * @return the menuProperty
277 public String getMenuProperty() {
278 return _menuProperty;
282 * Set the menuProperty.
283 * @param menuProperty the menuProperty to set
285 public void setMenuProperty(String menuProperty) {
286 this._menuProperty = menuProperty;
290 * Get the _titleProperty.
291 * @return the _titleProperty
293 public String getTitleProperty() {
294 return _titleProperty;
298 * Set the _titleProperty.
299 * @param _titleProperty the titleProperty to set
301 public void setTitleProperty(String titleProperty) {
302 _titleProperty = titleProperty;
306 * Get the editDisabledProperty.
307 * @return the editDisabledProperty
309 public String getEditDisabledProperty() {
310 return _editDisabledProperty;
314 * Set the editDisabledProperty.
315 * @param editDisabledProperty the editDisabledProperty to set
317 public void setEditDisabledProperty(String editDisabledProperty) {
318 _editDisabledProperty = editDisabledProperty;
322 * Get the toolProperty.
323 * @return the toolProperty
325 public String getToolProperty() {
326 return _toolProperty;
330 * Set the toolProperty.
331 * @param toolProperty the toolProperty to set
333 public void setToolProperty(final String toolProperty) {
334 _toolProperty = toolProperty;