[hg] main-silver: Issue #240003 - Task-Dashboard Actions need to...

  • From: Jan Peska < >
  • To:
  • Subject: [hg] main-silver: Issue #240003 - Task-Dashboard Actions need to...
  • Date: Mon, 06 Jan 2014 19:54:10 +0000

changeset e6ef34c2f542 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/e6ef34c2f542
description:
        Issue #240003 - Task-Dashboard Actions need to check for support
        Disable scheduling and markAsRead actions if they are not supported

diffstat:

 bugtracking/src/org/netbeans/modules/bugtracking/IssueImpl.java             
|   5 +
 bugtracking/src/org/netbeans/modules/bugtracking/tasks/actions/Actions.java 
|  82 +++++++--
 2 files changed, 65 insertions(+), 22 deletions(-)

diffs (181 lines):

diff --git a/bugtracking/src/org/netbeans/modules/bugtracking/IssueImpl.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/IssueImpl.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/IssueImpl.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/IssueImpl.java
@@ -215,6 +215,11 @@
         return data == obj;
     }
 
+    public boolean hasStatus() {
+        IssueStatusProvider<R, I> sp = repo.getStatusProvider();
+        return sp != null;
+    }
+    
     public IssueStatusProvider.Status getStatus() {
         IssueStatusProvider<R, I> sp = repo.getStatusProvider();
         if(sp == null) {
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/actions/Actions.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/actions/Actions.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/actions/Actions.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/actions/Actions.java
@@ -175,6 +175,15 @@
             });
         }
 
+        /**
+         * Create MarkSeenAction for supplied nodes.
+         *
+         * <p>
+         * If one of the nodes does not support Status Handling, the action 
is disabled!</p>
+         *
+         * @param nodes
+         * @return
+         */
         static MarkSeenAction createAction(TreeListNode... nodes) {
             List<IssueImpl> tasks = new ArrayList<IssueImpl>();
             for (TreeListNode n : nodes) {
@@ -184,13 +193,19 @@
                     return null;
                 }
             }
+            boolean statusSupported = true;
             boolean setAsSeen = false;
             for (IssueImpl issue : tasks) {
+                if (!issue.hasStatus()) {
+                    statusSupported = false;
+                }
                 if 
(!issue.getStatus().equals(IssueStatusProvider.Status.SEEN)) {
                     setAsSeen = true;
                 }
             }
-            return new MarkSeenAction(setAsSeen, tasks);
+            MarkSeenAction markSeenAction = new MarkSeenAction(setAsSeen, 
tasks);
+            markSeenAction.setEnabled(statusSupported);
+            return markSeenAction;
         }
 
         private ProgressHandle getProgress() {
@@ -376,11 +391,11 @@
     public static List<Action> getTaskPopupActions(TaskNode... taskNodes) {
         List<Action> actions = new ArrayList<Action>();
         actions.add(new OpenTaskAction(taskNodes));
-        if (taskNodes.length == 1) {
-            AbstractAction action = 
DashboardViewer.getInstance().isTaskNodeActive(taskNodes[0]) ? new 
DeactivateTaskAction() : new ActivateTaskAction(taskNodes[0]);
-            action.setEnabled(false);
-            actions.add(action);
-        }
+        // uncomment ASA activation is ready
+//        if (taskNodes.length == 1) {
+//            AbstractAction action = 
DashboardViewer.getInstance().isTaskNodeActive(taskNodes[0]) ? new 
DeactivateTaskAction() : new ActivateTaskAction(taskNodes[0]);
+//            actions.add(action);
+//        }
         boolean enableSetCategory = true;
         boolean showRemoveTask = true;
         boolean showDeleteLocal = true;
@@ -471,7 +486,26 @@
         }
     }
 
+    /**
+     * Create action for changing scheduling info for supplied nodes.
+     *
+     * <p>
+     * If one of the nodes does not support schedule handling, the action is 
disabled!</p>
+     *
+     * @param nodes
+     * @return
+     */
     private static Action getScheduleAction(final TaskNode... taskNodes) {
+        // Check the selected nodes - if one of the selected nodes does not
+        // support scheduling - don't offer it in the menu
+        boolean hasSchedule = true;
+        for (TaskNode tn : taskNodes) {
+            if (!tn.getTask().hasSchedule()) {
+                hasSchedule = false;
+                break;
+            }
+        }
+
         IssueScheduleInfo schedule = null;
         if (taskNodes.length == 1) {
             schedule = taskNodes[0].getTask().getSchedule();
@@ -491,7 +525,9 @@
             }
         };
         scheduleMenu.addChangeListener(listener);
-        return scheduleMenu.getMenuAction();
+        Action menuAction = scheduleMenu.getMenuAction();
+        menuAction.setEnabled(hasSchedule);
+        return menuAction;
     }
 
     private static class SetCategoryAction extends TaskAction {
@@ -838,6 +874,7 @@
     public static List<Action> getQueryPopupActions(QueryNode... queryNodes) 
{
         boolean editPossible = true;
         boolean openPossible = true;
+        boolean deletePossible = true;
 
         for (QueryNode queryNode : queryNodes) {
             QueryImpl q = queryNode.getQuery();
@@ -847,14 +884,25 @@
             if (!q.providesMode(QueryController.QueryMode.VIEW)) {
                 openPossible = false;
             }
-            if (!editPossible && !openPossible) {
+            if (!q.canRemove()) {
+                deletePossible = false;
+            }
+            if (!editPossible && !openPossible && !deletePossible) {
                 break;
             }
         }
         List<Action> actions = new ArrayList<Action>();
-        actions.add(new EditQueryAction(queryNodes));
-        actions.add(new OpenQueryAction(queryNodes));
-        actions.add(new DeleteQueryAction(queryNodes));
+        EditQueryAction editQueryAction = new EditQueryAction(queryNodes);
+        editQueryAction.setEnabled(editPossible);
+        actions.add(editQueryAction);
+
+        OpenQueryAction openQueryAction = new OpenQueryAction(queryNodes);
+        openQueryAction.setEnabled(openPossible);
+        actions.add(openQueryAction);
+
+        DeleteQueryAction deleteQueryAction = new 
DeleteQueryAction(queryNodes);
+        deleteQueryAction.setEnabled(deletePossible);
+        actions.add(deleteQueryAction);
         //actions.add(new NotificationQueryAction(queryNodes));
         return actions;
     }
@@ -896,7 +944,7 @@
 
         @Override
         public boolean isEnabled() {
-            return false && 
!containsQueryFromLocalRepository(getQueryNodes());
+            return false;
         }
     }
 
@@ -912,11 +960,6 @@
                 queryNode.getQuery().open(QueryController.QueryMode.VIEW);
             }
         }
-
-        @Override
-        public boolean isEnabled() {
-            return !containsQueryFromLocalRepository(getQueryNodes());
-        }
     }
 
     public static class EditQueryAction extends QueryAction {
@@ -931,11 +974,6 @@
                 queryNode.getQuery().open(QueryController.QueryMode.EDIT);
             }
         }
-
-        @Override
-        public boolean isEnabled() {
-            return !containsQueryFromLocalRepository(getQueryNodes());
-        }
     }
     //</editor-fold>
 

[hg] main-silver: Issue #240003 - Task-Dashboard Actions need to...

Jan Peska 01/06/2014

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 65 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close