* Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
-
+
/**
- * Value of the title bar property.
- * It can be: study, knowledge.
+ * Value of the title bar property. It can be: study, knowledge.
*/
private String _titleProperty;
-
+
/**
- * Property that indicates whether the current open study is editable or not.
- * On the screen it looks like pen on the status icon, pop-up menu also can be called.
- * It is necessary for correct building the title bar.
+ * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
+ * menu also can be called. It is necessary for correct building the title bar.
*/
private String _editDisabledProperty = "false";
-
+
/**
- * Value of the tool bar property.
- * It can be: none, standard, study, back.
+ * Value of the tool bar property. It can be: none, standard, study, back.
*/
private String _toolProperty;
setMenuProperty("study");
setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ if ("true".equals(getWriteAccess())
+ && getUserRights().canCreateDocument()) {
setToolProperty("study");
} else {
setToolProperty("standard");
}
- initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
+ initializationScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty);
return SUCCESS;
}
setMenuProperty("study");
setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ if ("true".equals(getWriteAccess())
+ && getUserRights().canCreateDocument()) {
setToolProperty("study");
} else {
setToolProperty("standard");
}
- initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
+ initializationScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty);
try {
User user = getConnectedUser();
getScenarioService().removeKnowledgeElement(scene, kelm); // The knowledge element necessarily exists
mystudy.remove(kelm);
+ updateMenu();
+
+ return SUCCESS;
+ }
+
+ /**
+ * Promote a knowledge element from the current scenario.
+ *
+ * @return SUCCESS if no exceptions
+ */
+ public String doPromoteKnowledge() {
+ getKnowledgeElementService().promote(getKnowledgeElement()); // The knowledge element necessarily exists
+ updateMenu();
+ return SUCCESS;
+ }
+
+ /**
+ * Demote a knowledge element from the current scenario.
+ *
+ * @return SUCCESS if no exceptions
+ */
+ public String doDemoteKnowledge() {
+ getKnowledgeElementService().demote(getKnowledgeElement()); // The knowledge element necessarily exists
+ updateMenu();
+ return SUCCESS;
+ }
+
+ /**
+ * Get selected knowledge element.
+ *
+ * @return the selected knowledge element
+ */
+ private KnowledgeElement getKnowledgeElement() {
+ mystudy = getOpenStudy();
+ Step step = mystudy.getSelectedStep();
+ Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
+ return scene.getKnowledgeElement(Integer.valueOf(myindex));
+ }
+
+ /**
+ * Update current menu.
+ */
+ private void updateMenu() {
getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
setMenuProperty("study");
setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ if ("true".equals(getWriteAccess())
+ && getUserRights().canCreateDocument()) {
setToolProperty("study");
} else {
setToolProperty("standard");
}
- initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-
- return SUCCESS;
+ initializationScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty);
}
// ==============================================================================================================================
public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the _titleProperty.
+ *
* @return the _titleProperty
*/
public String getTitleProperty() {
/**
* Set the titleProperty.
- * @param titleProperty the titleProperty to set
+ *
+ * @param titleProperty
+ * the titleProperty to set
*/
public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
/**
* Get the editDisabledProperty.
+ *
* @return the editDisabledProperty
*/
public String getEditDisabledProperty() {
/**
* Set the editDisabledProperty.
- * @param editDisabledProperty the editDisabledProperty to set
+ *
+ * @param editDisabledProperty
+ * the editDisabledProperty to set
*/
public void setEditDisabledProperty(final String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
/**
* Get the toolProperty.
+ *
* @return the toolProperty
*/
public String getToolProperty() {
/**
* Set the toolProperty.
- * @param toolProperty the toolProperty to set
+ *
+ * @param toolProperty
+ * the toolProperty to set
*/
public void setToolProperty(final String toolProperty) {
_toolProperty = toolProperty;
}
-
-
}
\ No newline at end of file