import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
import org.splat.service.StudyService;
import org.splat.som.StepRights;
-import org.splat.dal.bo.som.Study;
+import org.splat.wapp.Constants;
import org.splat.wapp.PopupMenu;
import org.splat.wapp.SimpleMenu;
* @author Daniel Brunier-Coulin.
*
*/
-public class DisplayStudyStepAction extends DisplayBaseAction {
+public class DisplayStudyStepAction extends AbstractDisplayAction {
/**
* Serial version ID.
/**
* Presented study.
*/
- protected OpenStudy mystudy = null;
+ protected transient OpenStudy _openStudy = null;
/**
* Injected study service.
public String doOpen() {
Study study;
- mystudy = getOpenStudy();
- if (myindex != null)
+ String res = SUCCESS;
+ _openStudy = getOpenStudy();
+ if (_myindex == null) {
+ if (_selection == null) { // Opening a study just newed
+ _selection = _openStudy.getSelection(); // Default selection
+ study = _openStudy.getStudyObject();
+ } else { // Re-opening (refreshing) the currently open study
+ study = getStudyService().selectStudy(_openStudy.getIndex());
+ _openStudy = open(study); // Closes the previously open study
+ _openStudy.setSelection(_selection);
+ }
+ } else {
try { // Opening a study from the search result
- int index = Integer.valueOf(myindex);
- if (mystudy != null && mystudy.getStudyObject() != null
- && mystudy.getIndex() == index) { // - The selected study is currently open
- selection = mystudy.getSelection(); // Current selection
- study = mystudy.getStudyObject(); // Current Study object
+ int index = Integer.valueOf(_myindex);
+ if (_openStudy != null && _openStudy.getStudyObject() != null
+ && _openStudy.getIndex() == index) { // - The selected study is currently open
+ _selection = _openStudy.getSelection(); // Current selection
+ study = _openStudy.getStudyObject(); // Current Study object
// RKV:BEGIN: put in session if necessary
if (!getSession().containsKey("study.open")) {
open(study);
// RKV:END
} else { // - The selected study is new
study = getStudyService().selectStudy(index);
- mystudy = open(study);
- selection = mystudy.getSelection(); // Default selection
+ _openStudy = open(study);
+ _selection = _openStudy.getSelection(); // Default selection
}
} catch (Exception error) {
LOG.error("Reason:", error);
- return ERROR;
+ res = ERROR;
}
- else if (selection == null) { // Opening a study just newed
- selection = mystudy.getSelection(); // Default selection
- study = mystudy.getStudyObject();
- } else { // Re-opening (refreshing) the currently open study
- study = getStudyService().selectStudy(mystudy.getIndex());
- mystudy = open(study); // Closes the previously open study
- mystudy.setSelection(selection);
}
- // Initialization of menus
- ProjectElement owner = mystudy.getSelectedStep().getOwner();
- SimpleMenu menu = ApplicationSettings.getMenu("configuration");
- if (owner instanceof Scenario) {
- menu.enables("prop-scenario");
- menu.selects("prop-scenario");
- } else {
- menu.disables("prop-scenario");
- menu.selects("prop-general");
- }
- getSession().put("menu.study", mystudy.getMenu());
-
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
- } else {
- setToolProperty("standard");
+ if (!ERROR.equals(res)){
+ // Initialization of menus
+ ProjectElement owner = _openStudy.getSelectedStep().getOwner();
+ SimpleMenu menu = ApplicationSettings.getMenu("configuration");
+ if (owner instanceof Scenario) {
+ menu.enables(Constants.PROP_SCENARIO);
+ menu.selects(Constants.PROP_SCENARIO);
+ } else {
+ menu.disables(Constants.PROP_SCENARIO);
+ menu.selects("prop-general");
+ }
+ getSession().put("menu.study", _openStudy.getMenu());
+
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
+ } else {
+ setToolProperty(Constants.STANDARD_MENU);
+ }
+
+ setLeftMenuProperty(Constants.STUDY_MENU);
+
+ initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
}
-
- setLeftMenuProperty("study");
-
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
- return SUCCESS;
+ return res;
}
public String doSelectStep() {
- mystudy = getOpenStudy();
- if (selection == null) { // Switch back to the current study
- selection = mystudy.getSelection();
+ _openStudy = getOpenStudy();
+ if (_selection == null) { // Switch back to the current study
+ _selection = _openStudy.getSelection();
} else { // Selection of a step of current study
- mystudy.setSelection(selection);
+ _openStudy.setSelection(_selection);
}
// Re-initialization of the properties menu according to the selected step
- ProjectElement owner = mystudy.getSelectedStep().getOwner();
+ ProjectElement owner = _openStudy.getSelectedStep().getOwner();
SimpleMenu menu = ApplicationSettings.getMenu("configuration");
if (owner instanceof Scenario) {
- menu.enables("prop-scenario");
- menu.selects("prop-scenario");
+ menu.enables(Constants.PROP_SCENARIO);
+ menu.selects(Constants.PROP_SCENARIO);
} else {
- menu.disables("prop-scenario");
+ menu.disables(Constants.PROP_SCENARIO);
menu.selects("prop-general");
}
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("standard");
+ setToolProperty(Constants.STANDARD_MENU);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectDocument() {
- mystudy = getOpenStudy();
- Execute todo = Execute.valueOf(action);
- if (todo == Execute.develop)
- mystudy.developDocument(myindex);
- else if (todo == Execute.reduce)
- mystudy.reduceHistory(myindex);
- else if (todo == Execute.reduceall)
- mystudy.reduceDocument(myindex);
+ _openStudy = getOpenStudy();
+ Execute todo = Execute.valueOf(_action);
+ if (todo == Execute.develop) {
+ _openStudy.developDocument(_myindex);
+ } else if (todo == Execute.reduce) {
+ _openStudy.reduceHistory(_myindex);
+ } else if (todo == Execute.reduceall) {
+ _openStudy.reduceDocument(_myindex);
+ }
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("standard");
+ setToolProperty(Constants.STANDARD_MENU);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectKnowledge() {
- mystudy = getOpenStudy();
- Execute todo = Execute.valueOf(action);
- if (todo == Execute.develop)
- mystudy.developKnowledge(myindex);
- else if (todo == Execute.reduce)
- mystudy.reduceKnowledge(myindex);
+ _openStudy = getOpenStudy();
+ Execute todo = Execute.valueOf(_action);
+ if (todo == Execute.develop) {
+ _openStudy.developKnowledge(_myindex);
+ } else if (todo == Execute.reduce) {
+ _openStudy.reduceKnowledge(_myindex);
+ }
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("standard");
+ setToolProperty(Constants.STANDARD_MENU);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
// ==============================================================================================================================
public String getAction() {
- return action;
+ return _action;
}
public List<DocumentFacade> getDocuments() {
- return mystudy.getDisplayedDocuments();
+ return _openStudy.getDisplayedDocuments();
}
- public List<OpenObject.KnowledgeIterator> getKnowledges() {
- return mystudy.getDisplayedKnowledges();
+ public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
+ return _openStudy.getDisplayedKnowledges();
}
public List<SimulationContextFacade> getSimulationContexts() {
- return mystudy.getDisplayedSimulationContexts();
+ return _openStudy.getDisplayedSimulationContexts();
}
public PopupMenu getPopup() {
- return mystudy.getPopup();
+ return _openStudy.getPopup();
}
public int getStepNumber() {
- return mystudy.getSelectedStep().getNumber();
+ return _openStudy.getSelectedStep().getNumber();
}
public String getStepEnabled() {
- return String.valueOf(mystudy.isStepEnabled());
+ return String.valueOf(_openStudy.isStepEnabled());
}
public StepRights getUserRights() {
- return mystudy.getSelectedStepRights();
+ return _openStudy.getSelectedStepRights();
}
+ @Override
public String getWriteAccess() {
- return String.valueOf(mystudy.isOpenForWriting());
+ return String.valueOf(_openStudy.isOpenForWriting());
}
/**
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
*/
@Override
- public void setOpenStudy(OpenStudy study) {
+ public void setOpenStudy(final OpenStudy study) {
super.setOpenStudy(study);
- mystudy = study;
+ _openStudy = study;
}
/**
* Set the menuProperty.
* @param menuProperty the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
* Set the _titleProperty.
* @param _titleProperty the titleProperty to set
*/
- public void setTitleProperty(String titleProperty) {
+ public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
}
* Set the editDisabledProperty.
* @param editDisabledProperty the editDisabledProperty to set
*/
- public void setEditDisabledProperty(String editDisabledProperty) {
+ public void setEditDisabledProperty(final String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
}