import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.Visibility;
import org.splat.manox.XDOM;
import org.splat.service.DocumentTypeService;
import org.splat.service.technical.ProjectSettingsService;
* Publish menu item name.
*/
private static final String MNU_NAME_PUBLISH = "menu.publish";
+ /**
+ * Protect menu item name.
+ */
+ private static final String MNU_NAME_PROTECT = "menu.protect";
/**
* Edit menu item name.
*/
private static class EditableMarkedStudyPopup extends PopupMenu {
private transient StudyRights _user = null;
- private EditableMarkedStudyPopup() {
+ private EditableMarkedStudyPopup(final boolean isPublic, final boolean isMarked) {
super();
- addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_NAME_MARK_AS_REFERENCE)
- .action(ACT_MARK_AS_REFERENCE).confirmation(
- "message.markasreference.study"));
- addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
- "image.publish.png").action("edit-study?action=publish")
- .confirmation("message.publish.study"));
+
+ if (isMarked) {
+ addItem(MNU_MARK_AS_REFERENCE, new PopupItem(
+ MNU_NAME_REMOVE_AS_REFERENCE).action(ACT_REMOVE_AS_REFERENCE)
+ .confirmation("message.removeasreference.study"));
+ } else {
+ addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_NAME_MARK_AS_REFERENCE)
+ .action(ACT_MARK_AS_REFERENCE).confirmation(
+ "message.markasreference.study"));
+ }
+
+ LOG.debug("MKA isPublic = " + isPublic);
+ if (isPublic) {
+ addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PROTECT).icon(
+ "image.publish.png").action("edit-study?action=protect")
+ .confirmation("message.protect.study"));
+ } else {
+ 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(
Item item = Item.valueOf(name);
switch (item) {
case publish:
- 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();
+ if (_user.getOperand().getVisibility() == Visibility.PRIVATE) {
+ res = _user.canPublish();
+ } else {
+ res = _user.canProtect();
+ }
break;
case edit:
res = _user.canEditProperties();
res = _user.canPurge();
break;
case markasreference:
- res = _user.canRemoveStudyAsReference();
+ if (_user.getOperand().getMarkreference() == 0) {
+ res = _user.canMarkStudyAsReference();
+ } else {
+ res = _user.canRemoveStudyAsReference();
+ }
break;
default:
res = false;
_menus.put(menu.getName(), menu);
_popups = new HashMap<String, PopupMenu>();
- _popups.put("steditablemark", new EditableMarkedStudyPopup());
- _popups.put("steditableunmark", new EditableUnmarkedStudyPopup());
+ _popups.put("steditablemarkpublic", new EditableMarkedStudyPopup(false, false));
+ _popups.put("steditableunmarkpublic", new EditableMarkedStudyPopup(false, true));
+ _popups.put("steditablemarkprivate", new EditableMarkedStudyPopup(true, false));
+ _popups.put("steditableunmarkprivate", new EditableMarkedStudyPopup(true, true));
_popups.put("editable", new EditableDocumentPopup());
_popups.put("notresult", new NotResultDocumentPopup());
_popups.put("reviewable", new ReviewableDocumentPopup());
// if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable");
// else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved");
/* else */
+
if (_mystudy.getProgressState() == ProgressState.TEMPLATE) {
- _popup = getApplicationSettings().getPopupMenu(
- "steditableunmark");
+ if (_mystudy.isPublic()) {
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditableunmarkprivate");
+ } else {
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditableunmarkpublic");
+ }
} else {
- _popup = getApplicationSettings().getPopupMenu(
- "steditablemark");
+
+ if (_mystudy.isPublic()) {
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditablemarkprivate");
+ } else {
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditablemarkpublic");
+ }
+
}
_popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
// Getters
// ==============================================================================================================================
+ @Override
public String getAuthorName() {
return _mystudy.getAuthor().toString();
}
+ @Override
public Long getIndex() {
return _mystudy.getIndex();
}
_menu = aMenu;
}
+ @Override
public ProgressState getProgressState() {
return _mystudy.getProgressState();
}
return getApplicationSettings().getModuleBar(getSelectedStep());
}
+ @Override
public String getReference() {
return _mystudy.getReference();
}
+ @Override
public Publication getSelectedDocument() {
return _selecdoc;
}
return _mystudy;
}
+ @Override
public String getTitle() {
return _mystudy.getTitle();
}
+ @Override
public String getType() {
/*
* RKV: return ResourceBundle.getBundle("labels", getApplicationSettings().getCurrentLocale()).getString( "label.study");
// Public services
// ==============================================================================================================================
+ @Override
public URL newTemplateBasedDocument(final String typename, final User author) {
String filename = typename + ".xml"; // Only XML templates are writeable
File template = new File(getRepositoryService().getTemplatePath()
_cuser = user;
_popup = null;
if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
- _popup = getApplicationSettings().getPopupMenu("steditablemark");
+ _popup = getApplicationSettings().getPopupMenu("steditablemarkpublic");
_popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
// ustep = getProjectElementService().getFirstStep(mystudy);