- private static class NewMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private NewMenu ()
- {
- super("create");
- addItem("new-empty", "menu.new.empty", "image.empty.png", "select?menu=create&item=new-empty");
- addItem("new-copy", new MenuItem("menu.new.copy").icon("image.copy.png") );
- addItem("new-instance", new MenuItem("menu.new.instance").icon("image.hold.gif") );
- addItem("new-import", new MenuItem("menu.new.import").icon("icon.upload.png") );
- this.selects("new-empty");
- }
- }
- private static class SearchMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private SearchMenu ()
- {
- super("search");
- addItem("search-study", "menu.search.study", "image.study.png", "select?menu=search&item=search-study");
- addItem("search-knowledge", "menu.search.idea", "image.idea.png", "select?menu=search&item=search-knowledge");
- addItem("search-document", new MenuItem("menu.search.document").icon("icon.any.png") );
- this.selects("search-study");
- }
- }
- private static class PropertiesMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private PropertiesMenu ()
- {
- super("configuration");
- addItem("prop-general", "menu.prop.general", "image.hold.gif", "select?menu=properties&item=prop-general");
- addItem("prop-scenario", "menu.prop.scenario", "image.hold.gif", "select?menu=properties&item=prop-scenario");
- addItem("prop-timestamp", new MenuItem("menu.prop.timestamp").icon("image.stamp.png") );
- addItem("prop-comlog", new MenuItem("menu.prop.comlog").icon("image.hold.gif") );
- addItem("prop-version", new MenuItem("menu.prop.version").icon("image.dirclosed.png") );
- }
- }
- private static class DatadminMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private DatadminMenu ()
- {
- super("datadmin");
- addItem("admin-scontext", "menu.admin.context", "image.hold.gif", "select?menu=datadmin&item=admin-scontext");
- addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png", "select?menu=datadmin&item=admin-knowelm");
- addItem("admin-study", new MenuItem("menu.admin.study").icon("image.study.png") );
- }
- }
- private static class SysadminMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private SysadminMenu ()
- {
- super("sysadmin");
- addItem("admin-indexing", "menu.admin.indexing", "image.index.png", "select?menu=sysadmin&item=admin-indexing");
- addItem("admin-importuser", "menu.admin.importuser", "image.group.png", "select?menu=sysadmin&item=admin-importuser");
- }
- }
- private enum Item { publish, accept, approve, promote, demote, undo, rename, attach, edit, script, version, replace, export, remove, purge };
-// Resources relative to studies
- private static class EditableStudyPopup extends PopupMenu {
-// ----------------------------------------------------------------
- private StudyRights user = null;
-
- private EditableStudyPopup ()
- {
- addItem("publish", new PopupItem("menu.publish").icon("image.publish.png").action("edit-study?action=publish").confirmation("message.publish.study"));
- addItem("promote", new PopupItem("menu.archive"));
- addSeparator();
- addItem("edit", new PopupItem("menu.properties").icon("icon.ed.png").action("../select?menu=properties"));
- addSeparator();
- addItem("script", new PopupItem("menu.newscenario").action("add-scenario"));
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("notyetimplemented"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").confirmation("message.purge.study"));
- addItem("export", new PopupItem("menu.export").icon("image.export.png")); // For future needs
- addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("notyetimplemented").confirmation("message.delete.study"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.publish) return user.canPublish();
- if (item == Item.edit) return user.canEditProperties();
- if (item == Item.script) return user.canAddScenario();
- if (item == Item.version) return user.canVersion();
- if (item == Item.remove) return user.canRemove();
- if (item == Item.purge) return user.canPurge();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof StudyRights) {
- user = (StudyRights)context; // Just for optimizing
- boolean history = user.getOperand().isVersioned();
- PopupItem item = this.item("remove");
- if (history) item.rename("menu.remove.version");
- else item.rename("menu.remove.study");
- }
- }
- }
-// Resources relative to documents
- private static class EditableDocumentPopup extends PopupMenu { // Popup of In-Work documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private EditableDocumentPopup ()
- {
- addItem("accept", new PopupItem("menu.accept").icon("image.accept.png").action("setDocument?action=accept").confirmation("message.accept.document"));
- addItem("promote", new PopupItem("menu.promote").icon("image.publish.png").action("setDocument?action=promote").confirmation("message.promote.document"));
- addSeparator();
- addItem("rename", new PopupItem("menu.rename").action("edit-document?action=renameDocument"));
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- addItem("replace", new PopupItem("menu.replace").icon("image.replace.png").action("select-file?nextAction=replace"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
- addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.accept) return user.canAccept();
- if (item == Item.promote) return user.canPromote();
- if (item == Item.rename) return user.canRename();
- if (item == Item.attach) return user.canAttach();
- if (item == Item.version) return user.canVersion();
- if (item == Item.replace) return user.canReplace();
- if (item == Item.purge) return user.canPurge();
- if (item == Item.remove) return user.canRemove();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- Document downer = user.getOperand();
- PopupItem item = this.item("remove");
- if (downer.isVersioned()) item.rename("menu.remove.version");
- else item.rename("menu.remove.document");
- }
- }
- }
- private static class ReviewableDocumentPopup extends PopupMenu { // Popup of In-Draft documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private ReviewableDocumentPopup ()
- {
- addItem("demote", new PopupItem("menu.demote").icon("image.demote.png").action("setDocument?action=demote").confirmation("message.demote.document"));
- addItem("promote", new PopupItem("menu.review").icon("image.review.png").action("setDocument?action=review").confirmation("message.review.document"));
- addSeparator();
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.demote) return user.canDemote();
- if (item == Item.promote) return user.canReview();
- if (item == Item.attach) return user.canAttach();
- if (item == Item.version) return user.canVersion();
- if (item == Item.purge) return user.canPurge();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- }
- }
- }
- private static class NotResultDocumentPopup extends PopupMenu {
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private NotResultDocumentPopup ()
- {
- addItem("demote", new PopupItem("menu.demote").icon("image.demote.png").action("setDocument?action=demote").confirmation("message.demote.document"));
- addSeparator();
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
- addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
- }
- }
- private static class ApprovableDocumentPopup extends PopupMenu { // Popup of In-Check documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private ApprovableDocumentPopup ()
- {
- addItem("undo", new PopupItem("menu.demote").icon("image.invalidate.png").action("setDocument?action=invalidate").confirmation("message.demote.document"));
- addItem("demote", new PopupItem("menu.disapprove").icon("image.demote.png").action("setDocument?action=disapprove").confirmation("message.disapprove.document"));
- addItem("approve", new PopupItem("menu.approve").icon("icon.APPROVED.png").action("setDocument?action=approve").confirmation("message.approve.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.undo) return user.canInvalidate();
- if (item == Item.demote) return user.canDemote();
- if (item == Item.approve) return user.canApprove();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- }
- }
- }
- private static class ApprovedPopup extends PopupMenu { // Popup of Approved documents
-// ----------------------------------------------------------------
- private ApprovedPopup ()
- {
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- }
- }
- private static class ExternPopup extends PopupMenu { // Popup of Extern documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private ExternPopup ()
- {
- addItem("rename", new PopupItem("menu.rename").action("edit-document?action=renameDocument"));
- addItem("replace", new PopupItem("menu.replace").icon("image.replace.png").action("select-file?nextAction=replace"));
- addSeparator();
- addItem("remove", new PopupItem("menu.remove.document").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.rename) return user.canRename();
- if (item == Item.replace) return user.canReplace();
- if (item == Item.remove) return user.canRemove();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- }
- }
- }
-// Resources relative to simulation contexts
- private static class ScontextPopup extends PopupMenu {
-// --------------------------------------------------------
- private SimulationContextFacade owner = null;
-
- private ScontextPopup ()
- {
- addItem("rename", new PopupItem("menu.rename").action("edit-context?action=renameContext"));
- addItem("edit", new PopupItem("menu.edit").action("edit-context?action=editContext"));
- addSeparator();
- addItem("remove", new PopupItem("menu.remove").icon("icon.delete.png").action("remove-context").confirmation("message.delete.context"));
- }
- public boolean isEnabled (String name)
- {
- Item item = Item.valueOf(name);
-
- if (item == Item.rename) {
- return false;
- } else
- if (item == Item.edit) {
-// if (!owner.isEditable())
- return false;
- }
- return true;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof SimulationContextFacade) {
- owner = (SimulationContextFacade)context; // Just for optimizing
- }
- else {
- super.setContext(name, context);
- }
- }
- }
-// Resources relative to knowledge
- private static class FeedbexPopup extends PopupMenu {
-// --------------------------------------------------------
- private KnowledgeElement owner = null;
-
- private FeedbexPopup ()
- {
- addItem("promote", new PopupItem("menu.promote").icon("image.review.png").action("promote-knowledge").confirmation("message.promote.knowledge"));
- addItem("demote", new PopupItem("menu.demote").icon("image.invalidate.png").action("demote-knowledge").confirmation("message.demote.knowledge"));
- addSeparator();
- addItem("rename", new PopupItem("menu.rename").action("edit-knowledge?action=renameKnowledge"));
- addItem("edit", new PopupItem("menu.edit").action("edit-knowledge?action=editKnowledge"));
- addSeparator();
- addItem("remove", new PopupItem("menu.remove").icon("icon.delete.png").action("remove-knowledge").confirmation("message.delete.knowledge"));
- }
- public boolean isEnabled (String name)
- {
- Item item = Item.valueOf(name);
-
- if (item == Item.promote) {
- if (owner.getProgressState() != ProgressState.inDRAFT) return false;
- } else
- if (item == Item.demote) {
- if (owner.getProgressState() != ProgressState.inCHECK) return false;
- }
- return true;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof KnowledgeElement) owner = (KnowledgeElement)context; // Just for optimizing
- else {
- super.setContext(name, context);
- }
- }
- }
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
-
- public static ApplicationSettings getMe () {
-// ------------------------------------------
- return my; // The application is supposed being previously created below
- }
+ private static class NewMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private NewMenu() {
+ super("create");
+ addItem("new-empty", "menu.new.empty", "image.empty.png",
+ "select?menu=create&item=new-empty");
+ addItem("new-copy", new MenuItem("menu.new.copy")
+ .icon("image.copy.png"));
+ addItem("new-instance", new MenuItem("menu.new.instance")
+ .icon("image.hold.gif"));
+ addItem("new-import", new MenuItem("menu.new.import")
+ .icon("icon.upload.png"));
+ this.selects("new-empty");
+ }
+ }
+
+ private static class SearchMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private SearchMenu() {
+ super("search");
+ addItem("search-study", "menu.search.study", "image.study.png",
+ "select?menu=search&item=search-study");
+ addItem("search-knowledge", "menu.search.idea", "image.idea.png",
+ "select?menu=search&item=search-knowledge");
+ addItem("search-document", new MenuItem("menu.search.document")
+ .icon("icon.any.png"));
+ this.selects("search-study");
+ }
+ }
+
+ private static class PropertiesMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private PropertiesMenu() {
+ super("configuration");
+ addItem("prop-general", "menu.prop.general", "image.hold.gif",
+ "select?menu=properties&item=prop-general");
+ addItem("prop-scenario", "menu.prop.scenario", "image.hold.gif",
+ "select?menu=properties&item=prop-scenario");
+ addItem("prop-timestamp", new MenuItem("menu.prop.timestamp")
+ .icon("image.stamp.png"));
+ addItem("prop-comlog", new MenuItem("menu.prop.comlog")
+ .icon("image.hold.gif"));
+ addItem("prop-version", new MenuItem("menu.prop.version")
+ .icon("image.dirclosed.png"));
+ }
+ }
+
+ private static class DatadminMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private DatadminMenu() {
+ super("datadmin");
+ addItem("admin-scontext", "menu.admin.context", "image.hold.gif",
+ "select?menu=datadmin&item=admin-scontext");
+ addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png",
+ "select?menu=datadmin&item=admin-knowelm");
+ addItem("admin-study", new MenuItem("menu.admin.study")
+ .icon("image.study.png"));
+ }
+ }
+
+ private static class SysadminMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private SysadminMenu() {
+ super("sysadmin");
+ addItem("admin-indexing", "menu.admin.indexing", "image.index.png",
+ "select?menu=sysadmin&item=admin-indexing");
+ addItem("admin-importuser", "menu.admin.importuser",
+ "image.group.png",
+ "select?menu=sysadmin&item=admin-importuser");
+ }
+ }
+
+ private enum Item {
+ publish, accept, approve, promote, demote, undo, rename, attach, edit, script, version, replace, export, remove, purge
+ };
+
+ // Resources relative to studies
+ private static class EditableStudyPopup extends PopupMenu {
+ // ----------------------------------------------------------------
+ private StudyRights user = null;
+
+ private EditableStudyPopup() {
+ addItem("publish", new PopupItem("menu.publish").icon(
+ "image.publish.png").action("edit-study?action=publish")
+ .confirmation("message.publish.study"));
+ addItem("promote", new PopupItem("menu.archive"));
+ addSeparator();
+ addItem("edit", new PopupItem("menu.properties")
+ .icon("icon.ed.png").action("../select?menu=properties"));
+ addSeparator();
+ addItem("script", new PopupItem("menu.newscenario")
+ .action("add-scenario"));
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action("notyetimplemented"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge")
+ .confirmation("message.purge.study"));
+ addItem("export", new PopupItem("menu.export")
+ .icon("image.export.png")); // For future needs
+ addItem("remove", new PopupItem("menu.remove.version").icon(
+ "icon.delete.png").action("notyetimplemented")
+ .confirmation("message.delete.study"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.publish)
+ return user.canPublish();
+ if (item == Item.edit)
+ return user.canEditProperties();
+ if (item == Item.script)
+ return user.canAddScenario();
+ if (item == Item.version)
+ return user.canVersion();
+ if (item == Item.remove)
+ return user.canRemove();
+ if (item == Item.purge)
+ return user.canPurge();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof StudyRights) {
+ user = (StudyRights) context; // Just for optimizing
+ boolean history = user.getOperand().isVersioned();
+ PopupItem item = this.item("remove");
+ if (history)
+ item.rename("menu.remove.version");
+ else
+ item.rename("menu.remove.study");
+ }
+ }
+ }
+
+ // Resources relative to documents
+ private static class EditableDocumentPopup extends PopupMenu { // Popup of In-Work documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private EditableDocumentPopup() {
+ addItem("accept", new PopupItem("menu.accept").icon(
+ "image.accept.png").action("setDocument?action=accept")
+ .confirmation("message.accept.document"));
+ addItem("promote", new PopupItem("menu.promote").icon(
+ "image.publish.png").action("setDocument?action=promote")
+ .confirmation("message.promote.document"));
+ addSeparator();
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-document?action=renameDocument"));
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ addItem("replace", new PopupItem("menu.replace").icon(
+ "image.replace.png").action(
+ "select-file?nextAction=replace"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge").action(
+ "notyetimplemented").confirmation("message.purge.document"));
+ addItem("remove", new PopupItem("menu.remove.version").icon(
+ "icon.delete.png").action("remove-document").confirmation(
+ "message.delete.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.accept)
+ return user.canAccept();
+ if (item == Item.promote)
+ return user.canPromote();
+ if (item == Item.rename)
+ return user.canRename();
+ if (item == Item.attach)
+ return user.canAttach();
+ if (item == Item.version)
+ return user.canVersion();
+ if (item == Item.replace)
+ return user.canReplace();
+ if (item == Item.purge)
+ return user.canPurge();
+ if (item == Item.remove)
+ return user.canRemove();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ Document downer = user.getOperand();
+ PopupItem item = this.item("remove");
+ if (downer.isVersioned())
+ item.rename("menu.remove.version");
+ else
+ item.rename("menu.remove.document");
+ }
+ }
+ }
+
+ private static class ReviewableDocumentPopup extends PopupMenu { // Popup of In-Draft documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private ReviewableDocumentPopup() {
+ addItem("demote", new PopupItem("menu.demote").icon(
+ "image.demote.png").action("setDocument?action=demote")
+ .confirmation("message.demote.document"));
+ addItem("promote", new PopupItem("menu.review").icon(
+ "image.review.png").action("setDocument?action=review")
+ .confirmation("message.review.document"));
+ addSeparator();
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge").action(
+ "notyetimplemented").confirmation("message.purge.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.demote)
+ return user.canDemote();
+ if (item == Item.promote)
+ return user.canReview();
+ if (item == Item.attach)
+ return user.canAttach();
+ if (item == Item.version)
+ return user.canVersion();
+ if (item == Item.purge)
+ return user.canPurge();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ }
+ }
+ }
+
+ private static class NotResultDocumentPopup extends PopupMenu {
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private NotResultDocumentPopup() {
+ addItem("demote", new PopupItem("menu.demote").icon(
+ "image.demote.png").action("setDocument?action=demote")
+ .confirmation("message.demote.document"));
+ addSeparator();
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge").action(
+ "notyetimplemented").confirmation("message.purge.document"));
+ addItem("remove", new PopupItem("menu.remove.version").icon(
+ "icon.delete.png").action("remove-document").confirmation(
+ "message.delete.document"));
+ }
+ }
+
+ private static class ApprovableDocumentPopup extends PopupMenu { // Popup of In-Check documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private ApprovableDocumentPopup() {
+ addItem("undo", new PopupItem("menu.demote").icon(
+ "image.invalidate.png").action(
+ "setDocument?action=invalidate").confirmation(
+ "message.demote.document"));
+ addItem("demote", new PopupItem("menu.disapprove").icon(
+ "image.demote.png").action("setDocument?action=disapprove")
+ .confirmation("message.disapprove.document"));
+ addItem("approve", new PopupItem("menu.approve").icon(
+ "icon.APPROVED.png").action("setDocument?action=approve")
+ .confirmation("message.approve.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.undo)
+ return user.canInvalidate();
+ if (item == Item.demote)
+ return user.canDemote();
+ if (item == Item.approve)
+ return user.canApprove();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ }
+ }
+ }
+
+ private static class ApprovedPopup extends PopupMenu { // Popup of Approved documents
+ // ----------------------------------------------------------------
+ private ApprovedPopup() {
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ }
+ }
+
+ private static class ExternPopup extends PopupMenu { // Popup of Extern documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private ExternPopup() {
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-document?action=renameDocument"));
+ addItem("replace", new PopupItem("menu.replace").icon(
+ "image.replace.png").action(
+ "select-file?nextAction=replace"));
+ addSeparator();
+ addItem("remove", new PopupItem("menu.remove.document").icon(
+ "icon.delete.png").action("remove-document").confirmation(
+ "message.delete.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.rename)
+ return user.canRename();
+ if (item == Item.replace)
+ return user.canReplace();
+ if (item == Item.remove)
+ return user.canRemove();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ }
+ }
+ }
+
+ // Resources relative to simulation contexts
+ private static class ScontextPopup extends PopupMenu {
+ // --------------------------------------------------------
+ private SimulationContextFacade owner = null;
+
+ private ScontextPopup() {
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-context?action=renameContext"));
+ addItem("edit", new PopupItem("menu.edit")
+ .action("edit-context?action=editContext"));
+ addSeparator();
+ addItem("remove", new PopupItem("menu.remove").icon(
+ "icon.delete.png").action("remove-context").confirmation(
+ "message.delete.context"));
+ }
+
+ public boolean isEnabled(String name) {
+ Item item = Item.valueOf(name);
+
+ if (item == Item.rename) {
+ return false;
+ } else if (item == Item.edit) {
+ // if (!owner.isEditable())
+ return false;
+ }
+ return true;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof SimulationContextFacade) {
+ owner = (SimulationContextFacade) context; // Just for optimizing
+ } else {
+ super.setContext(name, context);
+ }
+ }
+ }
+
+ // Resources relative to knowledge
+ private static class FeedbexPopup extends PopupMenu {
+ // --------------------------------------------------------
+ private KnowledgeElement owner = null;
+
+ private FeedbexPopup() {
+ addItem("promote", new PopupItem("menu.promote").icon(
+ "image.review.png").action("promote-knowledge")
+ .confirmation("message.promote.knowledge"));
+ addItem("demote", new PopupItem("menu.demote").icon(
+ "image.invalidate.png").action("demote-knowledge")
+ .confirmation("message.demote.knowledge"));
+ addSeparator();
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-knowledge?action=renameKnowledge"));
+ addItem("edit", new PopupItem("menu.edit")
+ .action("edit-knowledge?action=editKnowledge"));
+ addSeparator();
+ addItem("remove", new PopupItem("menu.remove").icon(
+ "icon.delete.png").action("remove-knowledge").confirmation(
+ "message.delete.knowledge"));
+ }
+
+ public boolean isEnabled(String name) {
+ Item item = Item.valueOf(name);
+
+ if (item == Item.promote) {
+ if (owner.getProgressState() != ProgressState.inDRAFT)
+ return false;
+ } else if (item == Item.demote) {
+ if (owner.getProgressState() != ProgressState.inCHECK)
+ return false;
+ }
+ return true;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof KnowledgeElement)
+ owner = (KnowledgeElement) context; // Just for optimizing
+ else {
+ super.setContext(name, context);
+ }
+ }
+ }
+
+ // ==============================================================================================================================
+ // Construction
+ // ==============================================================================================================================
+
+ public static ApplicationSettings getMe() {
+ // ------------------------------------------
+ return my; // The application is supposed being previously created below
+ }
+