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;
13 public class DisplayStudyStepAction extends DisplayBaseAction {
18 private static final long serialVersionUID = 6467920934724352021L;
23 protected OpenStudy mystudy = null;
26 * Injected study service.
28 private StudyService _studyService;
31 * Value of the menu property.
32 * It can be: none, create, open, study, knowledge, sysadmin, help.
34 private String _menuProperty;
36 // ==============================================================================================================================
38 // ==============================================================================================================================
40 public String doOpen() {
42 mystudy = getOpenStudy();
44 try { // Opening a study from the search result
45 int index = Integer.valueOf(myindex);
46 if (mystudy != null && mystudy.getStudyObject() != null
47 && mystudy.getIndex() == index) { // - The selected study is currently open
48 selection = mystudy.getSelection(); // Current selection
49 study = mystudy.getStudyObject(); // Current Study object
50 // RKV:BEGIN: put in session if necessary
51 if (!getSession().containsKey("study.open")) {
55 } else { // - The selected study is new
56 study = getStudyService().selectStudy(index);
57 mystudy = open(study);
58 selection = mystudy.getSelection(); // Default selection
60 } catch (Exception error) {
61 logger.error("Reason:", error);
64 else if (selection == null) { // Opening a study just newed
65 selection = mystudy.getSelection(); // Default selection
66 study = mystudy.getStudyObject();
67 } else { // Re-opening (refreshing) the currently open study
68 study = getStudyService().selectStudy(mystudy.getIndex());
69 mystudy = open(study); // Closes the previously open study
70 mystudy.setSelection(selection);
72 // Initialization of menus
73 ProjectElement owner = mystudy.getSelectedStep().getOwner();
74 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
75 if (owner instanceof Scenario) {
76 menu.enables("prop-scenario");
77 menu.selects("prop-scenario");
79 menu.disables("prop-scenario");
80 menu.selects("prop-general");
82 getSession().put("menu.study", mystudy.getMenu());
84 setMenuProperty("study");
85 initializationScreenContext(_menuProperty);
90 public String doSelectStep() {
92 mystudy = getOpenStudy();
93 if (selection == null) { // Switch back to the current study
94 selection = mystudy.getSelection();
95 } else { // Selection of a step of current study
96 mystudy.setSelection(selection);
98 // Re-initialization of the properties menu according to the selected step
99 ProjectElement owner = mystudy.getSelectedStep().getOwner();
100 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
101 if (owner instanceof Scenario) {
102 menu.enables("prop-scenario");
103 menu.selects("prop-scenario");
105 menu.disables("prop-scenario");
106 menu.selects("prop-general");
109 setMenuProperty("study");
110 initializationScreenContext(_menuProperty);
115 public String doSelectDocument() {
116 mystudy = getOpenStudy();
117 Execute todo = Execute.valueOf(action);
118 if (todo == Execute.develop)
119 mystudy.developDocument(myindex);
120 else if (todo == Execute.reduce)
121 mystudy.reduceHistory(myindex);
122 else if (todo == Execute.reduceall)
123 mystudy.reduceDocument(myindex);
125 setMenuProperty("study");
126 initializationScreenContext(_menuProperty);
131 public String doSelectKnowledge() {
132 mystudy = getOpenStudy();
133 Execute todo = Execute.valueOf(action);
134 if (todo == Execute.develop)
135 mystudy.developKnowledge(myindex);
136 else if (todo == Execute.reduce)
137 mystudy.reduceKnowledge(myindex);
139 setMenuProperty("study");
140 initializationScreenContext(_menuProperty);
145 public String doClose() {
148 setMenuProperty("none");
149 initializationScreenContext(_menuProperty);
154 // ==============================================================================================================================
156 // ==============================================================================================================================
158 public String getAction() {
162 public List<DocumentFacade> getDocuments() {
163 return mystudy.getDisplayedDocuments();
166 public List<OpenObject.KnowledgeIterator> getKnowledges() {
167 return mystudy.getDisplayedKnowledges();
170 public List<SimulationContextFacade> getSimulationContexts() {
171 return mystudy.getDisplayedSimulationContexts();
174 public PopupMenu getPopup() {
175 return mystudy.getPopup();
178 public int getStepNumber() {
179 return mystudy.getSelectedStep().getNumber();
182 public String getStepEnabled() {
183 return String.valueOf(mystudy.isStepEnabled());
186 public StepRights getUserRights() {
187 return mystudy.getSelectedStepRights();
190 public String getWriteAccess() {
191 return String.valueOf(mystudy.isOpenForWriting());
195 * Get the studyService.
197 * @return the studyService
199 public StudyService getStudyService() {
200 return _studyService;
204 * Set the studyService.
206 * @param studyService
207 * the studyService to set
209 public void setStudyService(StudyService studyService) {
210 _studyService = studyService;
216 * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
219 public void setOpenStudy(OpenStudy study) {
220 super.setOpenStudy(study);
225 * Get the menuProperty.
226 * @return the menuProperty
228 public String getMenuProperty() {
229 return _menuProperty;
233 * Set the menuProperty.
234 * @param menuProperty the menuProperty to set
236 public void setMenuProperty(String menuProperty) {
237 this._menuProperty = menuProperty;