[hg] main-silver: Rewrite TaskNode to expand TaskContainerNode -...

  • From: Jan Peska < >
  • To:
  • Subject: [hg] main-silver: Rewrite TaskNode to expand TaskContainerNode -...
  • Date: Tue, 07 May 2013 18:45:41 -0700

changeset 03c5f610206c in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/03c5f610206c
description:
        Rewrite TaskNode to expand TaskContainerNode - prepare for subtask 
and enable "mark as ..." action on it.

diffstat:

 bugtracking/src/org/netbeans/modules/bugtracking/tasks/DashboardUtils.java   
            |  42 +++-
 bugtracking/src/org/netbeans/modules/bugtracking/tasks/actions/Actions.java  
            |  10 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/CategoryNode.java
       |   6 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/ClosedCategoryNode.java
 |   6 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/QueryNode.java
          |   6 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/RepositoryNode.java
     |   2 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskContainerNode.java
  |  22 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskNode.java
           |  82 ++++++---
 team.ui.util/manifest.mf                                                     
            |   2 +-
 
team.ui.util/src/org/netbeans/modules/team/ui/util/treelist/AsynchronousNode.java
        |   4 +-
 team.ui/src/org/netbeans/modules/team/ui/common/QueryNode.java               
            |   2 +-
 11 files changed, 113 insertions(+), 71 deletions(-)

diffs (426 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/DashboardUtils.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/DashboardUtils.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/DashboardUtils.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/DashboardUtils.java
@@ -110,13 +110,12 @@
         return displayName;
     }
 
-    public static String getTaskPlainDisplayText(IssueImpl issueImpl, 
JComponent component, int maxWidth) {
-        return computeFitText(component, maxWidth, issueImpl.getID() + " - " 
+ issueImpl.getSummary(), false);
+    public static String getTaskPlainDisplayText(IssueImpl task, JComponent 
component, int maxWidth) {
+        return computeFitText(component, maxWidth, getTaskDisplayName(task), 
false);
     }
 
-    public static String getTaskDisplayString(IssueImpl task, JComponent 
component, int maxWidth, boolean active, boolean hasFocus) {
-        String displayName;
-        String fitText = computeFitText(component, maxWidth, task.getID() + 
" - " + task.getSummary(), active); //NOI18N
+    public static String getTaskDisplayText(IssueImpl task, JComponent 
component, int maxWidth, boolean active, boolean hasFocus) {
+        String fitText = computeFitText(component, maxWidth, 
getTaskDisplayName(task), active); //NOI18N
 
         String activeText = active ? BOLD_START_SUBSTITUTE + fitText + 
BOLD_END_SUBSTITUTE : getFilterBoldText(fitText); //NOI18N
 
@@ -128,15 +127,7 @@
         if (task.isFinished()) {
             activeText = "<strike>" + activeText + "</strike>"; //NOI18N
         }
-        IssueStatusProvider.Status status = task.getStatus();
-        if (status == IssueStatusProvider.Status.NEW && !hasFocus) {
-            displayName = "<html><font color=\"green\">" + activeText + 
"</font></html>"; //NOI18N
-        } else if (status == IssueStatusProvider.Status.MODIFIED && 
!hasFocus) {
-            displayName = "<html><font color=\"blue\">" + activeText + 
"</font></html>"; //NOI18N
-        } else {
-            displayName = "<html>" + activeText + "</html>"; //NOI18N
-        }
-        return displayName;
+        return getTaskAnotatedText(activeText, task.getStatus(), hasFocus);
     }
 
     public static String computeFitText(JComponent component, int maxWidth, 
String text, boolean bold) {
@@ -174,6 +165,29 @@
         return text;
     }
 
+    public static String getTaskAnotatedText(IssueImpl task) {
+        return getTaskAnotatedText(getTaskDisplayName(task), 
task.getStatus(), false);
+    }
+
+    private static String getTaskAnotatedText(String text, 
IssueStatusProvider.Status status, boolean hasFocus) {
+        if (status == IssueStatusProvider.Status.NEW && !hasFocus) {
+            text = "<html><font color=\"green\">" + text + "</font></html>"; 
//NOI18N
+        } else if (status == IssueStatusProvider.Status.MODIFIED && 
!hasFocus) {
+            text = "<html><font color=\"blue\">" + text + "</font></html>"; 
//NOI18N
+        } else {
+            text = "<html>" + text + "</html>"; //NOI18N
+        }
+        return text;
+    }
+
+    private static String getTaskDisplayName(IssueImpl task) {
+        String displayName = task.getDisplayName();
+        if (displayName.startsWith("#")) {
+            displayName = displayName.replaceFirst("#", "");
+        }
+        return displayName;
+    }
+
     private static String getFilterBoldText(String fitText) {
         String filterText = 
DashboardTopComponent.findInstance().getFilterText();
         if (!filterText.equals("")) { //NOI18N
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
@@ -140,7 +140,7 @@
             List<IssueImpl> tasks = new ArrayList<IssueImpl>();
             for (TreeListNode n : nodes) {
                 if (n instanceof TaskContainerNode) {
-                    tasks.addAll(((TaskContainerNode) n).getTasks());
+                    tasks.addAll(((TaskContainerNode) n).getTasks(true));
                 } else {
                     return null;
                 }
@@ -173,8 +173,8 @@
             actions.add(new RemoveTaskAction(taskNodes));
         }
         actions.add(new SetCategoryAction(taskNodes));
-        actions.add(new ScheduleTaskAction(taskNodes));
-        actions.add(new NotificationTaskAction(taskNodes));
+        //actions.add(new ScheduleTaskAction(taskNodes));
+        //actions.add(new NotificationTaskAction(taskNodes));
         return actions;
     }
 
@@ -302,7 +302,7 @@
         List<Action> actions = new ArrayList<Action>();
         actions.add(new DeleteCategoryAction(categoryNodes));
         actions.add(new RenameCategoryAction(categoryNodes));
-        actions.add(new NotificationCategoryAction(categoryNodes));
+        //actions.add(new NotificationCategoryAction(categoryNodes));
         return actions;
     }
 
@@ -545,7 +545,7 @@
         List<Action> actions = new ArrayList<Action>();
         actions.add(new OpenQueryAction(queryNodes));
         actions.add(new DeleteQueryAction(queryNodes));
-        actions.add(new NotificationQueryAction(queryNodes));
+        //actions.add(new NotificationQueryAction(queryNodes));
         return actions;
     }
 
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/CategoryNode.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/CategoryNode.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/CategoryNode.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/CategoryNode.java
@@ -91,7 +91,7 @@
     }
 
     @Override
-    public List<IssueImpl> getTasks() {
+    public List<IssueImpl> getTasks(boolean includingNodeItself) {
         List<IssueImpl> tasks = Collections.emptyList();
         try {
             tasks = new ArrayList<IssueImpl>(category.getTasks());
@@ -118,8 +118,8 @@
     }
 
     @Override
-    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus) {
-        super.configure(component, foreground, background, isSelected, 
hasFocus);
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
+        super.configure(component, foreground, background, isSelected, 
hasFocus, rowWidth);
         if (panel != null) {
             if (DashboardViewer.getInstance().containsActiveTask(this)) {
                 lblName.setFont(lblName.getFont().deriveFont(Font.BOLD));
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/ClosedCategoryNode.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/ClosedCategoryNode.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/ClosedCategoryNode.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/ClosedCategoryNode.java
@@ -79,7 +79,7 @@
     }
 
     @Override
-    public List<IssueImpl> getTasks() {
+    public List<IssueImpl> getTasks(boolean includingNodeItself) {
         return Collections.emptyList();
     }
 
@@ -93,8 +93,8 @@
     }
 
     @Override
-    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus) {
-        super.configure(component, foreground, background, isSelected, 
hasFocus);
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
+        super.configure(component, foreground, background, isSelected, 
hasFocus, rowWidth);
         if (panel != null) {
             lblName.setText(DashboardUtils.getCategoryDisplayText(this));
         }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/QueryNode.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/QueryNode.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/QueryNode.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/QueryNode.java
@@ -109,7 +109,7 @@
     }
 
     @Override
-    public List<IssueImpl> getTasks() {
+    public List<IssueImpl> getTasks(boolean includingNodeItself) {
         List<IssueImpl> tasks = Collections.emptyList();
         try {
             tasks = new ArrayList<IssueImpl>(query.getIssues());
@@ -120,8 +120,8 @@
     }
 
     @Override
-    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus) {
-        super.configure(component, foreground, background, isSelected, 
hasFocus);
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
+        super.configure(component, foreground, background, isSelected, 
hasFocus, rowWidth);
         if (panel != null) {
             if (DashboardViewer.getInstance().containsActiveTask(this)) {
                 lblName.setFont(lblName.getFont().deriveFont(Font.BOLD));
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/RepositoryNode.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/RepositoryNode.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/RepositoryNode.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/RepositoryNode.java
@@ -113,7 +113,7 @@
     }
 
     @Override
-    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus) {
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
         lblName.setText(DashboardUtils.getRepositoryDisplayText(this));
         lblName.setForeground(foreground);
     }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskContainerNode.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskContainerNode.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskContainerNode.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskContainerNode.java
@@ -88,7 +88,7 @@
         initPaging();
     }
 
-    public abstract List<IssueImpl> getTasks();
+    public abstract List<IssueImpl> getTasks(boolean includingNodeItself);
 
     abstract void updateCounts();
 
@@ -106,7 +106,7 @@
             refreshTaskContainer();
             refresh = false;
         }
-        return getTasks();
+        return getTasks(false);
     }
 
     @Override
@@ -123,7 +123,7 @@
     }
 
     @Override
-    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus) {
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
         for (JLabel lbl : labels) {
             lbl.setForeground(foreground);
         }
@@ -207,10 +207,10 @@
     }
 
     final void updateNodes() {
-        updateNodes(getTasks());
+        updateNodes(getTasks(false));
     }
 
-    final void updateNodes(List<IssueImpl> issues) {
+    final void updateNodes(List<IssueImpl> tasks) {
         synchronized (LOCK) {
             DashboardViewer dashboard = DashboardViewer.getInstance();
             AppliedFilters appliedFilters = 
dashboard.getAppliedTaskFilters();
@@ -218,14 +218,14 @@
             if (taskListener == null) {
                 taskListener = new TaskListener();
             }
-            taskNodes = new ArrayList<TaskNode>(issues.size());
-            filteredTaskNodes = new ArrayList<TaskNode>(issues.size());
-            for (IssueImpl issue : issues) {
-                issue.addPropertyChangeListener(taskListener);
-                TaskNode taskNode = new TaskNode(issue, this);
+            taskNodes = new ArrayList<TaskNode>(tasks.size());
+            filteredTaskNodes = new ArrayList<TaskNode>(tasks.size());
+            for (IssueImpl task : tasks) {
+                task.addPropertyChangeListener(taskListener);
+                TaskNode taskNode = new TaskNode(task, this);
                 adjustTaskNode(taskNode);
                 taskNodes.add(taskNode);
-                if (appliedFilters.isInFilter(issue)) {
+                if (appliedFilters.isInFilter(task)) {
                     filteredTaskNodes.add(taskNode);
                 }
             }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskNode.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskNode.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskNode.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskNode.java
@@ -58,24 +58,24 @@
 import org.netbeans.modules.bugtracking.tasks.DashboardUtils;
 import org.netbeans.modules.team.ui.util.treelist.TreeLabel;
 import org.netbeans.modules.team.ui.util.treelist.TreeListNode;
-import org.openide.util.RequestProcessor;
 
 /**
  *
  * @author jpeska
  */
-public class TaskNode extends TreeListNode implements Comparable<TaskNode>, 
Refreshable{
+public class TaskNode extends TaskContainerNode implements 
Comparable<TaskNode> {
 
     private IssueImpl task;
     private JPanel panel;
     private TreeLabel lblName;
     private Category category;
     private final TaskListener taskListener;
+    private final Object LOCK = new Object();
 
     public TaskNode(IssueImpl task, TreeListNode parent) {
         // TODO subtasks, it is not in bugtracking API
         //super(task.hasSubtasks(), parent);
-        super(false, parent);
+        super(false, false, parent, 
DashboardUtils.getTaskAnotatedText(task));
         this.task = task;
         taskListener = new TaskListener();
     }
@@ -93,6 +93,57 @@
     }
 
     @Override
+    public List<IssueImpl> getTasks(boolean includingNodeItself) {
+        if (includingNodeItself) {
+            List<IssueImpl> l = new ArrayList<IssueImpl>(1);
+            l.add(task);
+            return l;
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    void updateCounts() {
+    }
+
+    @Override
+    boolean isTaskLimited() {
+        return false;
+    }
+
+    @Override
+    void refreshTaskContainer() {
+        task.refresh();
+    }
+
+    @Override
+    protected JComponent createComponent(List<IssueImpl> data) {
+        if (isError()) {
+            setError(false);
+            return null;
+        }
+        updateNodes(data);
+        panel = new JPanel(new GridBagLayout());
+        panel.setOpaque(false);
+        synchronized (LOCK) {
+            labels.clear();
+            buttons.clear();
+
+            lblName = new TreeLabel();
+            panel.add(lblName, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 
GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 
3), 0, 0));
+            lblName.setToolTipText(task.getTooltip());
+            labels.add(lblName);
+        }
+        return panel;
+    }
+
+    @Override
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
+        super.configure(component, foreground, background, isSelected, 
hasFocus, rowWidth);
+        lblName.setText(DashboardUtils.getTaskDisplayText(task, lblName, 
rowWidth, DashboardViewer.getInstance().isTaskNodeActive(this), isSelected || 
hasFocus));
+    }
+
+    @Override
     protected List<TreeListNode> createChildren() {
 //        if(!task.hasSubtasks()){
 //            return Collections.emptyList();
@@ -111,20 +162,6 @@
     }
 
     @Override
-    protected JComponent getComponent(Color foreground, Color background, 
boolean isSelected, boolean hasFocus, int rowWidth) {
-        if (panel == null) {
-            panel = new JPanel(new GridBagLayout());
-            panel.setOpaque(false);
-            lblName = new TreeLabel();
-            panel.add(lblName, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 
GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 
3), 0, 0));
-        }
-        lblName.setText(DashboardUtils.getTaskDisplayString(task, lblName, 
rowWidth, DashboardViewer.getInstance().isTaskNodeActive(this), isSelected || 
hasFocus));
-        lblName.setToolTipText(task.getTooltip());
-        lblName.setForeground(foreground);
-        return panel;
-    }
-
-    @Override
     protected Action getDefaultAction() {
         return new OpenTaskAction(this);
     }
@@ -279,17 +316,8 @@
         return compareNumericId(Integer.parseInt(suffix1), 
Integer.parseInt(suffix2));
     }
 
-    @Override
-    public void refreshContent() {
-        RequestProcessor.getDefault().post(new Runnable() {
-            @Override
-            public void run() {
-                task.refresh();
-            }
-        });
-    }
+    private class TaskListener implements PropertyChangeListener {
     
-    private class TaskListener implements PropertyChangeListener {
         @Override
         public void propertyChange(PropertyChangeEvent evt) {
             if 
(evt.getPropertyName().equals(IssueImpl.EVENT_ISSUE_REFRESHED)) {
diff --git a/team.ui.util/manifest.mf b/team.ui.util/manifest.mf
--- a/team.ui.util/manifest.mf
+++ b/team.ui.util/manifest.mf
@@ -2,5 +2,5 @@
 AutoUpdate-Show-In-Client: false
 OpenIDE-Module: org.netbeans.modules.team.ui.util
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/team/ui/util/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.0
+OpenIDE-Module-Specification-Version: 1.1
 
diff --git 
a/team.ui.util/src/org/netbeans/modules/team/ui/util/treelist/AsynchronousNode.java
 
b/team.ui.util/src/org/netbeans/modules/team/ui/util/treelist/AsynchronousNode.java
--- 
a/team.ui.util/src/org/netbeans/modules/team/ui/util/treelist/AsynchronousNode.java
+++ 
b/team.ui.util/src/org/netbeans/modules/team/ui/util/treelist/AsynchronousNode.java
@@ -115,7 +115,7 @@
     protected final JComponent getComponent(Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
         synchronized (LOCK) {
             if (null != inner) {
-                configure(inner, foreground, background, isSelected, 
hasFocus);
+                configure(inner, foreground, background, isSelected, 
hasFocus, rowWidth);
             } else {
                 if (!loaded) {
                     if (null == loader) {
@@ -145,7 +145,7 @@
      * @param isSelected
      * @param hasFocus
      */
-    protected abstract void configure(JComponent component, Color 
foreground, Color background, boolean isSelected, boolean hasFocus);
+    protected abstract void configure(JComponent component, Color 
foreground, Color background, boolean isSelected, boolean hasFocus, int 
rowWidth);
 
     /**
      * Creates node's renderer component. The method is always invoked from 
AWT
diff --git a/team.ui/src/org/netbeans/modules/team/ui/common/QueryNode.java 
b/team.ui/src/org/netbeans/modules/team/ui/common/QueryNode.java
--- a/team.ui/src/org/netbeans/modules/team/ui/common/QueryNode.java
+++ b/team.ui/src/org/netbeans/modules/team/ui/common/QueryNode.java
@@ -107,7 +107,7 @@
     }
 
     @Override
-    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus) {
+    protected void configure(JComponent component, Color foreground, Color 
background, boolean isSelected, boolean hasFocus, int rowWidth) {
         synchronized( LOCK ) {
             for( JLabel lbl : labels ) {
                 lbl.setForeground(foreground);

[hg] main-silver: Rewrite TaskNode to expand TaskContainerNode -...

Jan Peska 05/08/2013

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