[hg] main-silver: Issue #234329 - Task tooltip in Tasks window i...

  • From: Jan Peska < >
  • To:
  • Subject: [hg] main-silver: Issue #234329 - Task tooltip in Tasks window i...
  • Date: Fri, 16 Aug 2013 08:56:37 -0700

changeset 6f87efa558f1 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/6f87efa558f1
description:
        Issue #234329 - Task tooltip in Tasks window is almost useless
        Enrich the Bugzilla Task tooltip

diffstat:

 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/TaskNode.java
 |    3 +
 bugzilla/src/org/netbeans/modules/bugzilla/BugzillaConfig.java               
  |   14 +
 bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java          
  |  110 +++++++++-
 bugzilla/src/org/netbeans/modules/bugzilla/issue/Bundle.properties           
  |    8 +
 4 files changed, 134 insertions(+), 1 deletions(-)

diffs (253 lines):

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
@@ -352,7 +352,10 @@
         public void propertyChange(PropertyChangeEvent evt) {
             if 
(evt.getPropertyName().equals(IssueImpl.EVENT_ISSUE_REFRESHED)) {
                 fireContentChanged();
+                if (lblName != null) {
+                    lblName.setToolTipText(task.getTooltip());
             }
         }
     }
 }
+}
diff --git a/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaConfig.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaConfig.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaConfig.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaConfig.java
@@ -42,6 +42,7 @@
 
 package org.netbeans.modules.bugzilla;
 
+import java.net.URL;
 import org.netbeans.modules.bugzilla.repository.BugzillaRepository;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -78,6 +79,7 @@
     public static final int DEFAULT_QUERY_REFRESH = 30;
     public static final int DEFAULT_ISSUE_REFRESH = 15;
     private Map<String, Icon> priorityIcons;
+    private Map<String, URL> priorityIconsURL;
 
     private BugzillaConfig() { }
 
@@ -211,6 +213,18 @@
         return priorityIcons.get(priority);
     }
 
+    public URL getPriorityIconURL(String priority) {
+        if(priorityIconsURL == null) {
+            priorityIconsURL = new HashMap<>();
+            priorityIconsURL.put("P1", 
BugzillaConfig.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/p1.png"));
 // NOI18N
+            priorityIconsURL.put("P2", 
BugzillaConfig.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/p2.png"));
 // NOI18N
+            priorityIconsURL.put("P3", 
BugzillaConfig.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/p3.png"));
 // NOI18N
+            priorityIconsURL.put("P4", 
BugzillaConfig.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/p4.png"));
 // NOI18N
+            priorityIconsURL.put("P5", 
BugzillaConfig.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/p5.png"));
 // NOI18N
+        }
+        return priorityIconsURL.get(priority);
+    }
+
     /**
      * Returns the path for the Bugzilla configuration directory.
      *
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java
@@ -50,6 +50,7 @@
 import java.io.OutputStream;
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
+import java.net.URL;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -85,6 +86,7 @@
 import org.netbeans.modules.bugtracking.util.AttachmentsPanel;
 import org.netbeans.modules.bugtracking.util.NBBugzillaUtils;
 import org.netbeans.modules.bugtracking.util.UIUtils;
+import org.netbeans.modules.bugzilla.BugzillaConfig;
 import org.netbeans.modules.bugzilla.commands.AddAttachmentCommand;
 import org.netbeans.modules.bugzilla.repository.BugzillaConfiguration;
 import org.netbeans.modules.bugzilla.repository.BugzillaRepository;
@@ -179,6 +181,7 @@
     private final PropertyChangeSupport support;
     private NbTask task;
     private String recentChanges = "";
+    private String tooltip = "";
     private NbTaskDataModel model;
     private static final Object MODEL_LOCK = new Object();
     private NbTaskDataModelListener list;
@@ -187,6 +190,10 @@
     private final TaskDataListenerImpl taskDataListener;
     private final TaskListenerImpl taskListener;
 
+    private static final URL ICON_REMOTE_PATH = 
IssuePanel.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/remote.png");
 //NOI18N
+    private static final URL ICON_CONFLICT_PATH = 
IssuePanel.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/conflict.png");
 //NOI18N
+    private static final URL ICON_UNSUBMITTED_PATH = 
IssuePanel.class.getClassLoader().getResource("org/netbeans/modules/bugzilla/resources/unsubmitted.png");
 //NOI18N
+
     public BugzillaIssue (NbTask task, BugzillaRepository repo) {
         this.task = task;
         this.repository = repo;
@@ -199,6 +206,7 @@
             }
         });
         updateRecentChanges();
+        updateTooltip();
         MylynSupport mylynSupp = MylynSupport.getInstance();
         taskDataListener = new TaskDataListenerImpl();
         
mylynSupp.addTaskDataListener(WeakListeners.create(TaskDataListener.class, 
taskDataListener, mylynSupp));
@@ -358,7 +366,7 @@
 //    }
 
     public String getTooltip() {
-        return getDisplayName();
+        return tooltip;
     }
 
     public static ColumnDescriptor[] getColumnDescriptors(BugzillaRepository 
repository) {
@@ -623,9 +631,17 @@
             if (taskDataState != null) {
                 td = taskDataState.getRepositoryData();
                 repositoryDataRef = new SoftReference<TaskData>(td);
+                EventQueue.invokeLater(new Runnable() {
+                    @Override
+                    public void run () {
                 if (node != null) {
                     node.fireDataChanged();
                 }
+                        if (updateTooltip()) {
+                            fireDataChanged();
+                        }
+                    }
+                });
             }
         } catch (CoreException ex) {
             Bugzilla.LOG.log(Level.WARNING, null, ex);
@@ -1284,6 +1300,94 @@
         }
     }
 
+    private boolean updateTooltip () {
+        String displayName = getDisplayName();
+        if (displayName.startsWith("#")) { //NOI18N
+            displayName = displayName.replaceFirst("#", ""); //NOI18N
+        }
+        String oldTooltip = tooltip;
+
+        SynchronizationState state = task.getSynchronizationState();
+        URL iconPath = getStateIcon(state);
+        String iconCode = "";
+        if (iconPath != null) {
+            iconCode = "<img src=\"" + iconPath + "\">&nbsp;"; //NOI18N
+        }
+        String stateName = getStateDisplayName(state);
+
+        String priorityLabel = NbBundle.getMessage(BugzillaIssue.class, 
"CTL_Issue_Priority_Title"); //NOI18N
+        String priority = getRepositoryFieldValue(IssueField.PRIORITY);
+        URL priorityIcon = 
BugzillaConfig.getInstance().getPriorityIconURL(priority);
+
+        boolean showIssueType = BugzillaUtil.showIssueType(repository);
+        String typeLabel = NbBundle.getMessage(BugzillaIssue.class, 
showIssueType ? "LBL_Type" : "CTL_Issue_Severity_Title"); //NOI18N
+        String type = showIssueType ? 
getRepositoryFieldValue(IssueField.ISSUE_TYPE) : 
getRepositoryFieldValue(IssueField.SEVERITY);
+
+        String productLabel = NbBundle.getMessage(BugzillaIssue.class, 
"CTL_Issue_Product_Title"); //NOI18N
+        String product = getRepositoryFieldValue(IssueField.PRODUCT);
+
+        String componentLabel = NbBundle.getMessage(BugzillaIssue.class, 
"CTL_Issue_Component_Title"); //NOI18N
+        String component = getRepositoryFieldValue(IssueField.COMPONENT);
+
+        String assigneeLabel = NbBundle.getMessage(BugzillaIssue.class, 
"LBL_Assigned"); //NOI18N
+        String assignee = getRepositoryFieldValue(IssueField.ASSIGNED_TO);
+
+        String statusLabel = NbBundle.getMessage(BugzillaIssue.class, 
"CTL_Issue_Status_Title"); //NOI18N
+        String status = getRepositoryFieldValue(IssueField.STATUS);
+        String resolution = getRepositoryFieldValue(IssueField.RESOLUTION);
+
+        if (resolution != null && !resolution.trim().isEmpty()) {
+            status += "/" + resolution;
+        }
+
+
+        String fieldTable = "<table>" //NOI18N
+            + "<tr><td><b>" + priorityLabel + ":</b></td><td><img src=\"" + 
priorityIcon + "\">&nbsp;" + priority + "</td><td 
style=\"padding-left:25px;\"><b>" + typeLabel + ":</b></td><td>" + type + 
"</td></tr>" //NOI18N
+            + "<tr><td><b>" + productLabel + ":</b></td><td>" + product + 
"</td><td style=\"padding-left:25px;\"><b>" + componentLabel + 
":</b></td><td>" + component + "</td></tr>" //NOI18N
+            + "<tr><td><b>" + assigneeLabel + ":</b></td><td colspan=\"3\">" 
+ assignee + "</td></tr>" //NOI18N
+            + "<tr><td><b>" + statusLabel + ":</b></td><td colspan=\"3\">" + 
status + "</td></tr>" //NOI18N
+            + "</table>"; //NOI18N
+
+        StringBuilder sb = new StringBuilder("<html>"); //NOI18N
+        sb.append("<b>").append(displayName).append("</b><br>"); //NOI18N
+        if (stateName != null && !stateName.isEmpty()) {
+            sb.append("<p 
style=\"padding:5px;\">").append(iconCode).append(stateName).append("</p><hr>");
 //NOI18N
+
+        }
+        sb.append(fieldTable);
+        sb.append("</html>"); //NOI18N
+        tooltip = sb.toString();
+        return !oldTooltip.equals(tooltip);
+    }
+
+    private URL getStateIcon(SynchronizationState state) {
+        URL iconPath = null;
+        if (state.equals(SynchronizationState.CONFLICT)) {
+            iconPath = ICON_CONFLICT_PATH;
+        } else if (state.equals(SynchronizationState.INCOMING) || 
state.equals(SynchronizationState.INCOMING_NEW)) {
+            iconPath = ICON_REMOTE_PATH;
+        } else if (state.equals(SynchronizationState.OUTGOING) || 
state.equals(SynchronizationState.OUTGOING_NEW)) {
+            iconPath = ICON_UNSUBMITTED_PATH;
+        }
+        return iconPath;
+    }
+
+    private String getStateDisplayName(SynchronizationState state) {
+        String displayName = "";
+        if (state.equals(SynchronizationState.CONFLICT)) {
+            displayName = NbBundle.getMessage(BugzillaIssue.class, 
"LBL_ConflictShort"); //NOI18N;
+        } else if (state.equals(SynchronizationState.INCOMING)) {
+            displayName = NbBundle.getMessage(BugzillaIssue.class, 
"LBL_RemoteShort"); //NOI18N;
+        } else if (state.equals(SynchronizationState.INCOMING_NEW)) {
+            displayName = NbBundle.getMessage(BugzillaIssue.class, 
"LBL_RemoteNewShort"); //NOI18N;
+        } else if (state.equals(SynchronizationState.OUTGOING)) {
+            displayName = NbBundle.getMessage(BugzillaIssue.class, 
"LBL_UnsubmittedShort"); //NOI18N;
+        } else if (state.equals(SynchronizationState.OUTGOING_NEW)) {
+            displayName = NbBundle.getMessage(BugzillaIssue.class, 
"LBL_UnsubmittedNewShort"); //NOI18N;
+        }
+        return displayName;
+    }
+    
     private boolean updateRecentChanges () {
         String oldChanges = recentChanges;
         recentChanges = "";
@@ -1448,6 +1552,7 @@
             }
         }
         updateRecentChanges();
+        updateTooltip();
         fireDataChanged();
     }
 
@@ -1663,6 +1768,9 @@
                             if (node != null) {
                                 node.fireDataChanged();
                             }
+                            if (updateTooltip()) {
+                                fireDataChanged();
+                            }
                             fireDataChanged();
                             refreshViewData(false);
                         }
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/issue/Bundle.properties 
b/bugzilla/src/org/netbeans/modules/bugzilla/issue/Bundle.properties
--- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/Bundle.properties
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/Bundle.properties
@@ -269,3 +269,11 @@
 IssuePanel.btnSaveChanges.TTtext=Save current changes made in the editor
 IssuePanel.btnDeleteTask.text=Dismiss Task
 IssuePanel.btnDeleteTask.TTtext=Dismiss the new task, delete it and forget 
all changes made to its fields
+
+LBL_Type=Type
+LBL_Assigned=Assignee
+LBL_ConflictShort=Conflict - your unsubmitted changes conflict with remote 
changes
+LBL_UnsubmittedShort=Unsubmitted - contains unsubmitted changes
+LBL_UnsubmittedNewShort=Unsubmitted New - newly created task, not yet 
submitted
+LBL_RemoteShort=Incoming - contains remote changes
+LBL_RemoteNewShort=Incoming New - new task created in repository

[hg] main-silver: Issue #234329 - Task tooltip in Tasks window i...

Jan Peska 08/16/2013

Project Features

About this Project

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