- res = _user.canPublish();
- break;
- case edit:
- res = _user.canEditProperties();
- break;
- case script:
- res = _user.canAddScenario();
- break;
- case version:
- res = _user.canVersion();
- break;
- case remove:
- res = _user.canRemove();
- break;
- case purge:
- res = _user.canPurge();
- break;
- case markasreference:
- res = _user.canMarkStudyAsReference();
- break;
- default:
- res = false;
- }
- }
- return res;
- }
-
- @Override
- public void setContext(final String name, final Object context) {
- if (context instanceof StudyRights) {
- _user = (StudyRights) context; // Just for optimizing
- boolean history = _user.getOperand().isVersioned();
- PopupItem item = this.item(MNU_REMOVE);
- if (history) {
- item.rename(MNU_NAME_REMOVE);
- } else {
- item.rename("menu.remove.study");
- }
- }
- }
- }
-
- // Resources relative to studies
- private static class EditableUnmarkedStudyPopup extends PopupMenu {
- private transient StudyRights _user = null;
-
- private EditableUnmarkedStudyPopup() {
- super();
- addItem(MNU_MARK_AS_REFERENCE, new PopupItem(
- MNU_NAME_REMOVE_AS_REFERENCE).action(ACT_REMOVE_AS_REFERENCE)
- .confirmation("message.removeasreference.study"));
- addItem(MNU_PUBLISH,
- new PopupItem(MNU_NAME_PUBLISH).icon("image.publish.png")
- .action("edit-study?action=publish")
- .confirmation("message.publish.study"));
- /* addItem(MNU_PROMOTE, new PopupItem("menu.archive")); */
- addSeparator();
- addItem(MNU_EDIT,
- new PopupItem("menu.properties").icon("icon.ed.png")
- .action("../select?menu=properties"));
- addSeparator();
- addItem(MNU_SCRIPT,
- new PopupItem(MNU_NAME_SCRIPT).action("add-scenario"));
- /*
- * addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon( IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED));
- */
- addSeparator();
- /*
- * addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE) .confirmation("message.purge.study")); addItem("export", new
- * PopupItem("menu.export") .icon("image.export.png")); // For future needs
- */addItem(
- MNU_REMOVE,
- new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
- .action(ACT_NOT_YET_IMPLEMENTED)
- .confirmation("message.delete.study"));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.splat.wapp.ContextualMenu#isEnabled(java.lang.String)
- */
- @Override
- public boolean isEnabled(final String name) {
- boolean res = (_user != null);
- if (res) {
- Item item = Item.valueOf(name);
- switch (item) {
- case publish:
- res = _user.canPublish();