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 * Property that indicates whether the current open study is editable or not.
49 * On the screen it looks like pen on the status icon, pop-up menu also can be called.
50 * It is necessary for correct building the title bar.
52 private String _editDisabledProperty = "false";
54 // ==============================================================================================================================
56 // ==============================================================================================================================
58 public String doOpen() {
60 mystudy = getOpenStudy();
62 try { // Opening a study from the search result
63 int index = Integer.valueOf(myindex);
64 if (mystudy != null && mystudy.getStudyObject() != null
65 && mystudy.getIndex() == index) { // - The selected study is currently open
66 selection = mystudy.getSelection(); // Current selection
67 study = mystudy.getStudyObject(); // Current Study object
68 // RKV:BEGIN: put in session if necessary
69 if (!getSession().containsKey("study.open")) {
73 } else { // - The selected study is new
74 study = getStudyService().selectStudy(index);
75 mystudy = open(study);
76 selection = mystudy.getSelection(); // Default selection
78 } catch (Exception error) {
79 logger.error("Reason:", error);
82 else if (selection == null) { // Opening a study just newed
83 selection = mystudy.getSelection(); // Default selection
84 study = mystudy.getStudyObject();
85 } else { // Re-opening (refreshing) the currently open study
86 study = getStudyService().selectStudy(mystudy.getIndex());
87 mystudy = open(study); // Closes the previously open study
88 mystudy.setSelection(selection);
90 // Initialization of menus
91 ProjectElement owner = mystudy.getSelectedStep().getOwner();
92 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
93 if (owner instanceof Scenario) {
94 menu.enables("prop-scenario");
95 menu.selects("prop-scenario");
97 menu.disables("prop-scenario");
98 menu.selects("prop-general");
100 getSession().put("menu.study", mystudy.getMenu());
102 setMenuProperty("study");
103 setTitleProperty("study");
104 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
109 public String doSelectStep() {
111 mystudy = getOpenStudy();
112 if (selection == null) { // Switch back to the current study
113 selection = mystudy.getSelection();
114 } else { // Selection of a step of current study
115 mystudy.setSelection(selection);
117 // Re-initialization of the properties menu according to the selected step
118 ProjectElement owner = mystudy.getSelectedStep().getOwner();
119 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
120 if (owner instanceof Scenario) {
121 menu.enables("prop-scenario");
122 menu.selects("prop-scenario");
124 menu.disables("prop-scenario");
125 menu.selects("prop-general");
128 setMenuProperty("study");
129 setTitleProperty("study");
130 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
135 public String doSelectDocument() {
136 mystudy = getOpenStudy();
137 Execute todo = Execute.valueOf(action);
138 if (todo == Execute.develop)
139 mystudy.developDocument(myindex);
140 else if (todo == Execute.reduce)
141 mystudy.reduceHistory(myindex);
142 else if (todo == Execute.reduceall)
143 mystudy.reduceDocument(myindex);
145 setMenuProperty("study");
146 setTitleProperty("study");
147 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
152 public String doSelectKnowledge() {
153 mystudy = getOpenStudy();
154 Execute todo = Execute.valueOf(action);
155 if (todo == Execute.develop)
156 mystudy.developKnowledge(myindex);
157 else if (todo == Execute.reduce)
158 mystudy.reduceKnowledge(myindex);
160 setMenuProperty("study");
161 setTitleProperty("study");
162 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
167 public String doClose() {
170 setMenuProperty("none");
171 initializationScreenContext(_menuProperty);
176 // ==============================================================================================================================
178 // ==============================================================================================================================
180 public String getAction() {
184 public List<DocumentFacade> getDocuments() {
185 return mystudy.getDisplayedDocuments();
188 public List<OpenObject.KnowledgeIterator> getKnowledges() {
189 return mystudy.getDisplayedKnowledges();
192 public List<SimulationContextFacade> getSimulationContexts() {
193 return mystudy.getDisplayedSimulationContexts();
196 public PopupMenu getPopup() {
197 return mystudy.getPopup();
200 public int getStepNumber() {
201 return mystudy.getSelectedStep().getNumber();
204 public String getStepEnabled() {
205 return String.valueOf(mystudy.isStepEnabled());
208 public StepRights getUserRights() {
209 return mystudy.getSelectedStepRights();
212 public String getWriteAccess() {
213 return String.valueOf(mystudy.isOpenForWriting());
217 * Get the studyService.
219 * @return the studyService
221 public StudyService getStudyService() {
222 return _studyService;
226 * Set the studyService.
228 * @param studyService
229 * the studyService to set
231 public void setStudyService(StudyService studyService) {
232 _studyService = studyService;
238 * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
241 public void setOpenStudy(OpenStudy study) {
242 super.setOpenStudy(study);
247 * Get the menuProperty.
248 * @return the menuProperty
250 public String getMenuProperty() {
251 return _menuProperty;
255 * Set the menuProperty.
256 * @param menuProperty the menuProperty to set
258 public void setMenuProperty(String menuProperty) {
259 this._menuProperty = menuProperty;
263 * Get the _titleProperty.
264 * @return the _titleProperty
266 public String getTitleProperty() {
267 return _titleProperty;
271 * Set the _titleProperty.
272 * @param _titleProperty the titleProperty to set
274 public void setTitleProperty(String titleProperty) {
275 _titleProperty = titleProperty;
279 * Get the editDisabledProperty.
280 * @return the editDisabledProperty
282 public String getEditDisabledProperty() {
283 return _editDisabledProperty;
287 * Set the editDisabledProperty.
288 * @param editDisabledProperty the editDisabledProperty to set
290 public void setEditDisabledProperty(String editDisabledProperty) {
291 _editDisabledProperty = editDisabledProperty;