Salome HOME
When reviewing a document, the first item of the document pop-up menu is "Demote...
authormka <mka@opencascade.com>
Thu, 11 Jul 2013 10:32:53 +0000 (10:32 +0000)
committermka <mka@opencascade.com>
Thu, 11 Jul 2013 10:32:53 +0000 (10:32 +0000)
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/DocumentFacade.java

index 001e781aaab2419f7090343a9c9c61e74e56a637..e489c5d57aa993150bdf32cc47bff30f71d509ad 100644 (file)
@@ -831,6 +831,70 @@ public class ApplicationSettings {
                                }
                        }
                }
+               
+               /**
+                * Add Actualize menu item.
+                */
+               protected void addActualize() {
+                       addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
+                       .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
+                       .confirmation("message.actualize.document"));
+               }
+               /**
+                * Add Review menu item.
+                */
+               protected void addReview() {
+                       addItem(MNU_PROMOTE, new PopupItem("menu.review").icon(
+                       "image.review.png").action("setDocument?action=review")
+                       .confirmation("message.review.document"));
+               }
+               /**
+                * Add Demote menu item.
+                * @param author
+                *                      indicates if the connected user is the author of the document.
+                */
+               protected void addDemote(final boolean author) {
+                       String itemName;
+                       if(author) {
+                               itemName = MNU_NAME_DEMOTE;
+                       } else {
+                               itemName = "menu.reject";
+                       }
+                       addItem(MNU_DEMOTE, new PopupItem(itemName).icon(
+                               IMG_DEMOTE).action("setDocument?action=demote")
+                               .confirmation("message.demote.document"));
+               }
+               /**
+                * Add Version menu item.
+                */
+               protected void addVersion() {
+                       addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+                                       IMG_VERSION).action(ACT_VERSION));
+               }
+               /**
+                * Add Attach menu item.
+                */
+               protected void addAttach() {
+                       addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
+                                       .action(ACT_ATTACH));
+               }
+               /**
+                * Add Remove menu item.
+                */
+               protected void addRemove() {
+                       addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE_VERSION).icon(
+                                       IMG_DELETE).action("remove-document").confirmation(
+                                       "message.delete.document"));
+               }
+               /**
+                * Add Approve menu item.
+                */
+               protected void addApprove() {
+                       addItem("approve", new PopupItem("menu.approve").icon(
+                       "icon.APPROVED.png").action("setDocument?action=approve")
+                       .confirmation("message.approve.document"));
+                       
+               }
        }
 
        /**
@@ -870,13 +934,13 @@ public class ApplicationSettings {
        }
 
        /**
-        * Popup of In-Draft documents.
+        * Popup of In-Draft documents when connected user is the author of the document.
         */
-       private static class ReviewableDocumentPopup extends DocumentPopup {
+       private static class ReviewableDocumentPopupAuthor extends DocumentPopup {
                /**
                 * Document popup menu constructor.
                 */
-               private ReviewableDocumentPopup() {
+               private ReviewableDocumentPopupAuthor() {
                        super();
                        addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
                                        .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
@@ -893,21 +957,41 @@ public class ApplicationSettings {
                        addSeparator();
                        addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
                                        IMG_VERSION).action(ACT_VERSION));
-                       addSeparator();
                        /*
+                        * addSeparator();
                         * addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action( ACT_NOT_YET_IMPLEMENTED).confirmation( "message.purge.document"));
                         */
                }
        }
+       
+       /**
+        * Popup of In-Draft documents when connected user is not the author of the document.
+        */
+       private static class ReviewableDocumentPopupNonAuthor extends DocumentPopup {
+               /**
+                * Default constructor.
+                */
+               private ReviewableDocumentPopupNonAuthor() {
+                       super();
+                       addActualize();
+                       addDemote(false);
+                       addReview();
+                       addSeparator();
+                       addAttach();
+                       addSeparator();
+                       addVersion();
+               }
+       }
 
        /**
-        * Popup menu for documents which are not results of a step.
+        * Popup menu for documents which are not results of a step
+        * when connected user is the author of the document.
         */
-       private static class NotResultDocumentPopup extends DocumentPopup {
+       private static class NotResultDocumentPopupAuthor extends DocumentPopup {
                /**
                 * Default constructor.
                 */
-               private NotResultDocumentPopup() {
+               private NotResultDocumentPopupAuthor() {
                        super();
                        addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
                                        .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
@@ -930,15 +1014,37 @@ public class ApplicationSettings {
                                        "message.delete.document"));
                }
        }
+       
+       /**
+        * Popup menu for documents which are not results of a step
+        * when connected user is not the author of the document.
+        */
+       private static class NotResultDocumentPopupNonAuthor extends DocumentPopup {
+               /**
+                * Default constructor.
+                */
+               private NotResultDocumentPopupNonAuthor() {
+                       super();
+                       addActualize();
+                       addDemote(false);
+                       addSeparator();
+                       addAttach();
+                       addSeparator();
+                       addVersion();
+                       addSeparator();
+                       addRemove();
+               }
+       }
 
        /**
-        * Popup of In-Check documents.
+        * Popup of In-Check documents
+        * when connected user is the author of the document.
         */
-       private static class ApprovableDocumentPopup extends DocumentPopup {
+       private static class ApprovableDocumentPopupAuthor extends DocumentPopup {
                /**
                 * Default constructor.
                 */
-               private ApprovableDocumentPopup() {
+               private ApprovableDocumentPopupAuthor() {
                        super();
                        addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
                                        .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
@@ -957,6 +1063,22 @@ public class ApplicationSettings {
                }
        }
 
+       /**
+        * Popup of In-Check documents
+        * when connected user is not the author of the document.
+        */
+       private static class ApprovableDocumentPopupNonAuthor extends DocumentPopup {
+               /**
+                * Default constructor.
+                */
+               private ApprovableDocumentPopupNonAuthor() {
+                       super();
+                       addActualize();
+                       addDemote(false);
+                       addApprove();
+               }
+       }
+
        /**
         * Popup of Approved documents.
         */
@@ -1209,9 +1331,12 @@ public class ApplicationSettings {
                _popups.put("stapprovable", new ApprovableStudyPopup());
 
                _popups.put("editable", new EditableDocumentPopup());
-               _popups.put("notresult", new NotResultDocumentPopup());
-               _popups.put("reviewable", new ReviewableDocumentPopup());
-               _popups.put("approvable", new ApprovableDocumentPopup());
+               _popups.put("notresult", new NotResultDocumentPopupAuthor());
+               _popups.put("reviewable", new ReviewableDocumentPopupAuthor());
+               _popups.put("approvable", new ApprovableDocumentPopupAuthor());
+               _popups.put("notresultNonAuthor", new NotResultDocumentPopupNonAuthor());
+               _popups.put("reviewableNonAuthor", new ReviewableDocumentPopupNonAuthor());
+               _popups.put("approvableNonAuthor", new ApprovableDocumentPopupNonAuthor());
                _popups.put("approved", new ApprovedPopup());
                _popups.put("extern", new ExternPopup());
                _popups.put("scontext", new ScontextPopup());
index accc56b79e994100c74df290d1a9a453e3d7acbf..8ad50a9ed67478bee6a72c5ed3e80128abf713e3 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 import java.util.ResourceBundle;
 
 import org.splat.dal.bo.kernel.Relation;
+import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ConvertsRelation;
 import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.DocumentType;
@@ -589,17 +590,28 @@ public class DocumentFacade implements HistoryFacade {
                        } else if (_state == ProgressState.inWORK) {
                                _popup = getApplicationSettings().getPopupMenu("editable");
                        } else if (_state == ProgressState.inDRAFT) {
-                               _popup = getApplicationSettings().getPopupMenu("reviewable");
+                               if(_owner.getUser().equals(_me.value().getAuthor())) { //connected usr is the author of the document
+                                       _popup = getApplicationSettings().getPopupMenu("reviewable");
+                               } else {
+                                       _popup = getApplicationSettings().getPopupMenu("reviewableNonAuthor");
+                               }
                        } else if (_state == ProgressState.APPROVED) {
                                _popup = getApplicationSettings().getPopupMenu("approved");
                        } else { // (state == ProgressState.inCHECK)
                                DocumentType aType = _me.value().getType(); // Only result documents need to be approved
                                Step aStep = getPublicationService().getInvolvedStep(_me);
                                if (aType.isResultOf(aStep.getStep())) {
-                                       _popup = getApplicationSettings()
-                                                       .getPopupMenu("approvable");
+                                       if(_owner.getUser().equals(_me.value().getAuthor())) {
+                                               _popup = getApplicationSettings().getPopupMenu("approvable");
+                                       } else {
+                                               _popup = getApplicationSettings().getPopupMenu("approvableNonAuthor");
+                                       }
                                } else {
-                                       _popup = getApplicationSettings().getPopupMenu("notresult");
+                                       if(_owner.getUser().equals(_me.value().getAuthor())) { //connected usr is the author of the document
+                                               _popup = getApplicationSettings().getPopupMenu("notresult");
+                                       } else {
+                                               _popup = getApplicationSettings().getPopupMenu("notresultNonAuthor");
+                                       }
                                }
                        }
                }