Salome HOME
Study validation cycle operations are implemented according to the specification.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ApplicationSettings.java
index 6fb1c238eb52d1491f7ab0d385370184facfbb9d..b1772117fd199adda2e85015795f1e3a24b3a88c 100644 (file)
@@ -148,6 +148,15 @@ public class ApplicationSettings {
         * Delete icon file name.
         */
        private static final String IMG_DELETE = "icon.delete.png";
+       /**
+        * Promote icon file name.
+        */
+       private static final String IMG_PROMOTE = "image.publish.png";
+       /**
+        * Demote icon file name.
+        */
+       private static final String IMG_DEMOTE = "image.demote.png";
+       
        /**
         * Attach menu item name.
         */
@@ -269,7 +278,11 @@ public class ApplicationSettings {
         * Remove as reference action name.
         */
        private static final String ACT_REMOVE_AS_REFERENCE = "removeasref-study";
-
+       /**
+        * Promote the study action name.
+        */
+       private static final String ACT_PROMOTE_STUDY = "edit-study?action=promote";
+       
        /**
         * Siman application server name.
         */
@@ -505,51 +518,18 @@ public class ApplicationSettings {
 
        // Resources relative to studies
        /**
-        * Study popup menu.
+        * Base study popup menu.
         */
-       private static class EditableMarkedStudyPopup extends PopupMenu {
+       private static class StudyPopup extends PopupMenu {
                /**
                 * User rights for the selected study.
                 */
-               private transient StudyRights _user = null;
+               protected transient StudyRights _user = null;
 
                /**
-                * Study popup menu constructor.
-                * 
-                * @param isPublic
-                *            public study flag
-                * @param isMarked
-                *            "marked as reference" study flag
+                * Add items which are common for all study popup menus.
                 */
-               private EditableMarkedStudyPopup(final boolean isPublic,
-                               final boolean isMarked) {
-                       super();
-
-                       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"));
-                       }
-
-                       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")); */
+               protected void addCommonItems() {
                        addSeparator();
                        addItem(MNU_EDIT, new PopupItem("menu.properties").icon(
                                        "icon.ed.png").action(
@@ -599,9 +579,15 @@ public class ApplicationSettings {
                                        case remove:
                                                res = _user.canRemove();
                                                break;
-                                       /*
-                                        * case purge: res = _user.canPurge(); break;
-                                        */
+                                       case promote:
+                                               res = _user.canPromote();
+                                               break;
+                                       case demote:
+                                               res = _user.canDemote();
+                                               break;
+                                       case approve:
+                                               res = _user.canApprove();
+                                               break;
                                        case markasreference:
                                                if (_user.getOperand().getMarkreference() == 0) {
                                                        res = _user.canMarkStudyAsReference();
@@ -636,6 +622,116 @@ public class ApplicationSettings {
                }
        }
 
+       /**
+        * Approved study popup menu.
+        */
+       private static class EditableMarkedStudyPopup extends StudyPopup {
+
+               /**
+                * Study popup menu constructor.
+                * 
+                * @param isPublic
+                *            public study flag
+                * @param isMarked
+                *            "marked as reference" study flag
+                */
+               private EditableMarkedStudyPopup(final boolean isPublic,
+                               final boolean isMarked) {
+                       super();
+
+                       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"));
+                       }
+
+                       if (isPublic) {
+                               addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PROTECT).icon(
+                                               IMG_PROMOTE)
+                                               .action("edit-study?action=protect").confirmation(
+                                                               "message.protect.study"));
+                       } else {
+                               addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
+                                               IMG_PROMOTE)
+                                               .action("edit-study?action=publish").confirmation(
+                                                               "message.publish.study"));
+                       }
+
+                       addCommonItems();
+               }
+
+       }
+
+       /**
+        * In-Work study popup menu.
+        */
+       private static class EditableStudyPopup extends StudyPopup {
+               /**
+                * Study popup menu constructor.
+                */
+               private EditableStudyPopup() {
+                       super();
+
+                       addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
+                                       IMG_PROMOTE).action(ACT_PROMOTE_STUDY)
+                                       .confirmation("message.promote.study"));
+
+                       addCommonItems();
+               }
+       }
+
+       /**
+        * In-Work study popup menu.
+        */
+       private static class ReviewableStudyPopup extends StudyPopup {
+               /**
+                * Study popup menu constructor.
+                */
+               private ReviewableStudyPopup() {
+                       super();
+
+                       addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
+                                       IMG_DEMOTE).action("edit-study?action=demote")
+                                       .confirmation("message.demote.study"));
+                       addItem(MNU_PROMOTE, new PopupItem("menu.review").icon(
+                                       "image.review.png").action(ACT_PROMOTE_STUDY)
+                                       .confirmation("message.review.study"));
+
+                       addCommonItems();
+               }
+       }
+
+       /**
+        * In-Work study popup menu.
+        */
+       private static class ApprovableStudyPopup extends StudyPopup {
+               /**
+                * Study popup menu constructor.
+                */
+               private ApprovableStudyPopup() {
+                       super();
+
+                       addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
+                                       IMG_PROMOTE).action(ACT_PROMOTE_STUDY)
+                                       .confirmation("message.promote.study"));
+                       // Refuse
+                       addItem(MNU_DEMOTE, new PopupItem("menu.disapprove").icon(
+                                       IMG_DEMOTE).action("edit-study?action=demote")
+                                       .confirmation("message.disapprove.study"));
+                       addItem("approve", new PopupItem("menu.approve").icon(
+                                       "icon.APPROVED.png").action(ACT_PROMOTE_STUDY)
+                                       .confirmation("message.approve.study"));
+
+                       addCommonItems();
+               }
+       }
+
        // Resources relative to documents
        /**
         * Popup of a document.
@@ -735,7 +831,7 @@ public class ApplicationSettings {
                         * .confirmation("message.accept.document"));
                         */
                        addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
-                                       "image.publish.png").action("setDocument?action=promote")
+                                       IMG_PROMOTE).action("setDocument?action=promote")
                                        .confirmation("message.promote.document"));
                        addSeparator();
                        addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
@@ -768,7 +864,7 @@ public class ApplicationSettings {
                private ReviewableDocumentPopup() {
                        super();
                        addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
-                                       "image.demote.png").action("setDocument?action=demote")
+                                       IMG_DEMOTE).action("setDocument?action=demote")
                                        .confirmation("message.demote.document"));
                        addItem(MNU_PROMOTE, new PopupItem("menu.review").icon(
                                        "image.review.png").action("setDocument?action=review")
@@ -796,7 +892,7 @@ public class ApplicationSettings {
                private NotResultDocumentPopup() {
                        super();
                        addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
-                                       "image.demote.png").action("setDocument?action=demote")
+                                       IMG_DEMOTE).action("setDocument?action=demote")
                                        .confirmation("message.demote.document"));
                        addSeparator();
                        addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
@@ -828,7 +924,7 @@ public class ApplicationSettings {
                                        "setDocument?action=invalidate").confirmation(
                                        "message.demote.document"));
                        addItem(MNU_DEMOTE, new PopupItem("menu.disapprove").icon(
-                                       "image.demote.png").action("setDocument?action=disapprove")
+                                       IMG_DEMOTE).action("setDocument?action=disapprove")
                                        .confirmation("message.disapprove.document"));
                        addItem("approve", new PopupItem("menu.approve").icon(
                                        "icon.APPROVED.png").action("setDocument?action=approve")
@@ -1080,6 +1176,10 @@ public class ApplicationSettings {
                                false));
                _popups.put("steditableunmarkprivate", new EditableMarkedStudyPopup(
                                true, true));
+               _popups.put("steditable", new EditableStudyPopup());
+               _popups.put("streviewable", new ReviewableStudyPopup());
+               _popups.put("stapprovable", new ApprovableStudyPopup());
+
                _popups.put("editable", new EditableDocumentPopup());
                _popups.put("notresult", new NotResultDocumentPopup());
                _popups.put("reviewable", new ReviewableDocumentPopup());