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;
30 // ==============================================================================================================================
32 // ==============================================================================================================================
34 public String doOpen() {
36 mystudy = getOpenStudy();
38 try { // Opening a study from the search result
39 int index = Integer.valueOf(myindex);
40 if (mystudy != null && mystudy.getStudyObject() != null
41 && mystudy.getIndex() == index) { // - The selected study is currently open
42 selection = mystudy.getSelection(); // Current selection
43 study = mystudy.getStudyObject(); // Current Study object
44 // RKV:BEGIN: put in session if necessary
45 if (!getSession().containsKey("study.open")) {
49 } else { // - The selected study is new
50 study = getStudyService().selectStudy(index);
51 mystudy = open(study);
52 selection = mystudy.getSelection(); // Default selection
54 } catch (Exception error) {
55 logger.error("Reason:", error);
58 else if (selection == null) { // Opening a study just newed
59 selection = mystudy.getSelection(); // Default selection
60 study = mystudy.getStudyObject();
61 } else { // Re-opening (refreshing) the currently open study
62 study = getStudyService().selectStudy(mystudy.getIndex());
63 mystudy = open(study); // Closes the previously open study
64 mystudy.setSelection(selection);
66 // Initialization of menus
67 ProjectElement owner = mystudy.getSelectedStep().getOwner();
68 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
69 if (owner instanceof Scenario) {
70 menu.enables("prop-scenario");
71 menu.selects("prop-scenario");
73 menu.disables("prop-scenario");
74 menu.selects("prop-general");
76 getSession().put("menu.study", mystudy.getMenu());
81 public String doSelectStep() {
83 mystudy = getOpenStudy();
84 if (selection == null) { // Switch back to the current study
85 selection = mystudy.getSelection();
86 } else { // Selection of a step of current study
87 mystudy.setSelection(selection);
89 // Re-initialization of the properties menu according to the selected step
90 ProjectElement owner = mystudy.getSelectedStep().getOwner();
91 SimpleMenu menu = ApplicationSettings.getMenu("configuration");
92 if (owner instanceof Scenario) {
93 menu.enables("prop-scenario");
94 menu.selects("prop-scenario");
96 menu.disables("prop-scenario");
97 menu.selects("prop-general");
102 public String doSelectDocument() {
103 mystudy = getOpenStudy();
104 Execute todo = Execute.valueOf(action);
105 if (todo == Execute.develop)
106 mystudy.developDocument(myindex);
107 else if (todo == Execute.reduce)
108 mystudy.reduceHistory(myindex);
109 else if (todo == Execute.reduceall)
110 mystudy.reduceDocument(myindex);
114 public String doSelectKnowledge() {
115 mystudy = getOpenStudy();
116 Execute todo = Execute.valueOf(action);
117 if (todo == Execute.develop)
118 mystudy.developKnowledge(myindex);
119 else if (todo == Execute.reduce)
120 mystudy.reduceKnowledge(myindex);
124 public String doClose() {
129 // ==============================================================================================================================
131 // ==============================================================================================================================
133 public String getAction() {
137 public List<DocumentFacade> getDocuments() {
138 return mystudy.getDisplayedDocuments();
141 public List<OpenObject.KnowledgeIterator> getKnowledges() {
142 return mystudy.getDisplayedKnowledges();
145 public List<SimulationContextFacade> getSimulationContexts() {
146 return mystudy.getDisplayedSimulationContexts();
149 public PopupMenu getPopup() {
150 return mystudy.getPopup();
153 public int getStepNumber() {
154 return mystudy.getSelectedStep().getNumber();
157 public String getStepEnabled() {
158 return String.valueOf(mystudy.isStepEnabled());
161 public StepRights getUserRights() {
162 return mystudy.getSelectedStepRights();
165 public String getWriteAccess() {
166 return String.valueOf(mystudy.isOpenForWriting());
170 * Get the studyService.
172 * @return the studyService
174 public StudyService getStudyService() {
175 return _studyService;
179 * Set the studyService.
181 * @param studyService
182 * the studyService to set
184 public void setStudyService(StudyService studyService) {
185 _studyService = studyService;
191 * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
194 public void setOpenStudy(OpenStudy study) {
195 super.setOpenStudy(study);