[hg] main-silver: list of unsubmitted tasks in the task dashboar...

  • From: Ondrej Vrabec < >
  • To:
  • Subject: [hg] main-silver: list of unsubmitted tasks in the task dashboar...
  • Date: Mon, 06 May 2013 15:43:15 -0700

changeset f59238318021 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/f59238318021
description:
        list of unsubmitted tasks in the task dashboard partially implemented
        - currently visble only on a switch: 
bugzilla.displayUnsubmittedQuery=true

diffstat:

 bugzilla/src/org/netbeans/modules/bugzilla/issue/BugzillaIssue.java          
 |   11 +
 bugzilla/src/org/netbeans/modules/bugzilla/issue/Bundle.properties           
 |    3 +
 bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form             
 |   20 +-
 bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java             
 |   52 ++++-
 bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java          
 |  103 +++++++++-
 
bugzilla/src/org/netbeans/modules/bugzilla/repository/BugzillaRepository.java 
|   25 ++
 bugzilla/src/org/netbeans/modules/bugzilla/util/BugzillaUtil.java            
 |    6 +
 7 files changed, 208 insertions(+), 12 deletions(-)

diffs (394 lines):

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
@@ -223,6 +223,17 @@
         support.firePropertyChange(IssueProvider.EVENT_ISSUE_REFRESHED, 
null, null);
     }
     
+    void deleteTask () {
+        synchronized (MODEL_LOCK) {
+            if (list != null) {
+                model.removeModelListener(list);
+                list = null;
+            }
+            model = null;
+        }
+        getRepository().deleteTask(task);
+    }
+    
     private void fireSeenChanged(boolean wasSeen, boolean seen) {
         support.firePropertyChange(IssueStatusProvider.EVENT_SEEN_CHANGED, 
wasSeen, seen);
     }
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
@@ -270,3 +270,6 @@
 MSG_LOG_FILE_DESC=IDE log
 IssuePanel.jButton1.TTtext=Save current changes made in the editor
 IssuePanel.btnSaveChanges.text=Save Changes
+IssuePanel.btnDeleteTask.text=Cancel Changes
+IssuePanel.btnDeleteTask.text=Delete Task
+IssuePanel.btnDeleteTask.TTtext=Delete the new task and forget all changes
diff --git a/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form 
b/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form
--- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.form
@@ -486,6 +486,8 @@
                                       <EmptySpace max="-2" attributes="0"/>
                                       <Component id="cancelButton" min="-2" 
max="-2" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="btnDeleteTask" min="-2" 
max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
                                       <Component id="attachLogCheckBox" 
min="-2" max="-2" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
                                       <Component id="viewLogButton" min="-2" 
max="-2" attributes="0"/>
@@ -664,14 +666,15 @@
                       <Component id="submitButton" alignment="3" min="-2" 
max="-2" attributes="0"/>
                       <Component id="cancelButton" alignment="3" min="-2" 
max="-2" attributes="0"/>
                       <Component id="btnSaveChanges" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                      <Component id="btnDeleteTask" alignment="3" min="-2" 
max="-2" attributes="0"/>
                   </Group>
               </Group>
               <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Component id="messagePanel" pref="2" max="32767" 
attributes="0"/>
+              <Component id="messagePanel" pref="3" max="32767" 
attributes="0"/>
               <EmptySpace min="-2" max="-2" attributes="0"/>
               <Component id="separator" min="-2" max="-2" attributes="0"/>
               <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Component id="dummyCommentsPanel" pref="38" max="32767" 
attributes="0"/>
+              <Component id="dummyCommentsPanel" pref="37" max="32767" 
attributes="0"/>
           </Group>
       </Group>
     </DimensionLayout>
@@ -1464,5 +1467,18 @@
         <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="btnSaveChangesActionPerformed"/>
       </Events>
     </Component>
+    <Component class="javax.swing.JButton" name="btnDeleteTask">
+      <Properties>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/netbeans/modules/bugzilla/issue/Bundle.properties" 
key="IssuePanel.btnDeleteTask.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/netbeans/modules/bugzilla/issue/Bundle.properties" 
key="IssuePanel.btnDeleteTask.TTtext" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="btnDeleteTaskActionPerformed"/>
+      </Events>
+    </Component>
   </SubComponents>
 </Form>
diff --git a/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/issue/IssuePanel.java
@@ -147,6 +147,7 @@
 import org.openide.util.Mutex;
 import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
+import org.openide.windows.TopComponent;
 import org.openide.windows.WindowManager;
 
 /**
@@ -502,16 +503,15 @@
         refreshButton.setVisible(!isNew);
         separatorLabel.setVisible(!isNew);
         cancelButton.setVisible(!isNew);
+        btnDeleteTask.setVisible(isNew);
         separatorLabel3.setVisible(!isNew);
+        addToCategoryButton.setVisible(!isNew);
+        separatorLabel2.setVisible(!isNew);
         showInBrowserButton.setVisible(!isNew);
+        if (!isNew) {
         Border sep2Border = BorderFactory.createLineBorder(Color.BLACK);
-        if (isNew) {
-            int gap = 
LayoutStyle.getInstance().getPreferredGap(separatorLabel2, reloadButton, 
LayoutStyle.ComponentPlacement.RELATED, SwingConstants.WEST, null);
-            sep2Border = BorderFactory.createCompoundBorder(
-                    BorderFactory.createEmptyBorder(0,0,0,gap),
-                    sep2Border);
-        }
         separatorLabel2.setBorder(sep2Border); // IssueProvider 180431
+        }
         assignedField.setEditable(issue.isNew() || issue.canReassign());
         assignedCombo.setEnabled(assignedField.isEditable());
         org.openide.awt.Mnemonics.setLocalizedText(submitButton, 
NbBundle.getMessage(IssuePanel.class, isNew ? 
"IssuePanel.submitButton.text.new" : "IssuePanel.submitButton.text")); // 
NOI18N
@@ -1558,6 +1558,7 @@
         attachLogCheckBox = new javax.swing.JCheckBox();
         viewLogButton = new 
org.netbeans.modules.bugtracking.util.LinkButton();
         btnSaveChanges = new javax.swing.JButton();
+        btnDeleteTask = new javax.swing.JButton();
 
         FormListener formListener = new FormListener();
 
@@ -1884,6 +1885,10 @@
         btnSaveChanges.setEnabled(false);
         btnSaveChanges.addActionListener(formListener);
 
+        org.openide.awt.Mnemonics.setLocalizedText(btnDeleteTask, 
org.openide.util.NbBundle.getMessage(IssuePanel.class, 
"IssuePanel.btnDeleteTask.text")); // NOI18N
+        
btnDeleteTask.setToolTipText(org.openide.util.NbBundle.getMessage(IssuePanel.class,
 "IssuePanel.btnDeleteTask.TTtext")); // NOI18N
+        btnDeleteTask.addActionListener(formListener);
+
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
         this.setLayout(layout);
         layout.setHorizontalGroup(
@@ -2040,6 +2045,8 @@
                                         
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                         .addComponent(cancelButton)
                                         
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                                        .addComponent(btnDeleteTask)
+                                        
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                         .addComponent(attachLogCheckBox)
                                         
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                         .addComponent(viewLogButton, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)))
@@ -2191,13 +2198,14 @@
                     
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                         .addComponent(submitButton)
                         .addComponent(cancelButton)
-                        .addComponent(btnSaveChanges)))
+                        .addComponent(btnSaveChanges)
+                        .addComponent(btnDeleteTask)))
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(messagePanel, 
javax.swing.GroupLayout.DEFAULT_SIZE, 2, Short.MAX_VALUE)
+                .addComponent(messagePanel, 
javax.swing.GroupLayout.DEFAULT_SIZE, 3, Short.MAX_VALUE)
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(separator, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(dummyCommentsPanel, 
javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE))
+                .addComponent(dummyCommentsPanel, 
javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE))
         );
 
         layout.linkSize(javax.swing.SwingConstants.VERTICAL, new 
java.awt.Component[] {refreshButton, reloadButton, separatorLabel, 
separatorLabel2, separatorLabel3, showInBrowserButton});
@@ -2316,6 +2324,9 @@
             else if (evt.getSource() == assignedCombo) {
                 IssuePanel.this.assignedComboActionPerformed(evt);
             }
+            else if (evt.getSource() == btnDeleteTask) {
+                IssuePanel.this.btnDeleteTaskActionPerformed(evt);
+            }
         }
 
         public void focusGained(java.awt.event.FocusEvent evt) {
@@ -2879,6 +2890,28 @@
         });
     }//GEN-LAST:event_btnSaveChangesActionPerformed
 
+    @NbBundle.Messages({
+        "LBL_IssuePanel.deleteTask.title=Delete New Task?",
+        "MSG_IssuePanel.deleteTask.message=Do you want to delete the new 
task permanently?"
+    })
+    private void btnDeleteTaskActionPerformed(java.awt.event.ActionEvent 
evt) {//GEN-FIRST:event_btnDeleteTaskActionPerformed
+        if (JOptionPane.YES_OPTION != 
JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(),
+                Bundle.MSG_IssuePanel_cancelChanges_message(),
+                Bundle.LBL_IssuePanel_cancelChanges_title(), 
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) {
+            return;
+        }
+        Container tc = SwingUtilities.getAncestorOfClass(TopComponent.class, 
this);
+        if (tc instanceof TopComponent) {
+            ((TopComponent) tc).close();
+        }        
+        RP.post(new Runnable() {
+            @Override
+            public void run() {
+                issue.deleteTask();
+            }
+        });
+    }//GEN-LAST:event_btnDeleteTaskActionPerformed
+
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JTextField actualField;
     private javax.swing.JLabel actualLabel;
@@ -2898,6 +2931,7 @@
     private javax.swing.JTextField blocksField;
     private javax.swing.JLabel blocksLabel;
     private javax.swing.JLabel blocksWarning;
+    private javax.swing.JButton btnDeleteTask;
     private javax.swing.JButton btnSaveChanges;
     private javax.swing.JButton cancelButton;
     private javax.swing.JTextField ccField;
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java
@@ -61,6 +61,7 @@
 import org.netbeans.modules.bugtracking.team.spi.OwnerInfo;
 import org.netbeans.modules.bugtracking.util.LogUtils;
 import org.netbeans.modules.bugzilla.util.BugzillaConstants;
+import org.netbeans.modules.bugzilla.util.BugzillaUtil;
 import org.netbeans.modules.mylyn.util.MylynSupport;
 import org.netbeans.modules.mylyn.util.SynchronizeQueryCommand;
 
@@ -127,7 +128,7 @@
         support.firePropertyChange(QueryProvider.EVENT_QUERY_REMOVED, null, 
null);
     }
 
-    private void fireQueryIssuesChanged() {
+    protected void fireQueryIssuesChanged() {
         support.firePropertyChange(QueryProvider.EVENT_QUERY_ISSUES_CHANGED, 
null, null);
     }  
     
@@ -489,4 +490,104 @@
         }
         return notifyListeners;
     }    
+    
+    public static class UnsubmittedTasksQuery extends BugzillaQuery 
implements ITaskListChangeListener {
+
+        private final Set<ITask> tasks = Collections.synchronizedSet(new 
LinkedHashSet<ITask>());
+        
+        public UnsubmittedTasksQuery (BugzillaRepository repository) {
+            super("Unsubmitted Changes", repository, null, true, false, 
false);
+            Bugzilla.getInstance().getRequestProcessor().post(new Runnable() 
{
+                @Override
+                public void run () {
+                    initialize();
 }
+            });
+        }
+
+        @Override
+        public void containersChanged (Set<TaskContainerDelta> deltas) {
+            // listen on changes on all tasks
+            boolean change = false;
+            for (TaskContainerDelta delta : deltas) {
+                if (delta.getElement() instanceof ITask) {
+                    ITask task = (ITask) delta.getElement();
+                    if (delta.getKind() == TaskContainerDelta.Kind.CONTENT) {
+                        if 
(getRepository().getTaskRepository().getRepositoryUrl().equals(task.getRepositoryUrl()))
 {
+                            // the task may change its status
+                            change |= BugzillaUtil.isOutgoing(task) ? 
tasks.add(task) : tasks.remove(task);
+                        }
+                    } else if (delta.getKind() == 
TaskContainerDelta.Kind.DELETED) {
+                        // the task was deleted permanently
+                        change |= tasks.remove(task);
+                    } else if (delta.getKind() == 
TaskContainerDelta.Kind.ADDED
+                            && task.getSynchronizationState() == 
ITask.SynchronizationState.OUTGOING_NEW) {
+                        // task may be added to the unsubmitted category
+                        try {
+                            change |= 
MylynSupport.getInstance().getUnsubmittedTasks(
+                                    
getRepository().getTaskRepository()).contains(task)
+                                    && tasks.add(task);                      
      
+                        } catch (CoreException ex) {
+                            Bugzilla.LOG.log(Level.INFO, null, ex);
+                        }
+                    }
+                }
+            }
+            if (change) {
+                fireQueryIssuesChanged();
+            }
+        }
+
+        @Override
+        int getSize () {
+            return tasks.size();
+        }
+
+        @Override
+        public boolean contains (String id) {
+            List<ITask> taskList = new ArrayList<ITask>(tasks);
+            for (ITask t : taskList) {
+                if (id.equals(t.getTaskId())) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    
+        @Override
+        public Collection<BugzillaIssue> 
getIssues(EnumSet<IssueCache.Status> includeStatus) {
+            List<ITask> taskList = new ArrayList<ITask>(tasks);
+
+            List<BugzillaIssue> ret = new ArrayList<BugzillaIssue>();
+            for (ITask task : taskList) {
+                ret.add(getRepository().getIssueForTask(task));
+            }
+            return ret;
+        }
+        
+        @Override
+        boolean refreshIntern (final boolean autoRefresh) {
+            // makes no senses
+            return false;
+        }
+
+        private void initialize () {
+            try {
+                MylynSupport supp = MylynSupport.getInstance();
+                
tasks.addAll(supp.getUnsubmittedTasks(getRepository().getTaskRepository()));
+                for (ITask task : 
supp.getTasks(getRepository().getTaskRepository())) {
+                    if (BugzillaUtil.isOutgoing(task)) {
+                        tasks.add(task);
+                    }
+                }
+                supp.addTaskListListener(this);
+                if (!tasks.isEmpty()) {
+                    fireQueryIssuesChanged();
+                }
+            } catch (CoreException ex) {
+                Bugzilla.LOG.log(Level.INFO, null, ex);
+            }
+        }
+        
+    }
+}
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/repository/BugzillaRepository.java
 
b/bugzilla/src/org/netbeans/modules/bugzilla/repository/BugzillaRepository.java
--- 
a/bugzilla/src/org/netbeans/modules/bugzilla/repository/BugzillaRepository.java
+++ 
b/bugzilla/src/org/netbeans/modules/bugzilla/repository/BugzillaRepository.java
@@ -239,6 +239,20 @@
         return issue;
     }
 
+    public void deleteTask (ITask task) {
+        assert task.getSynchronizationState() == 
ITask.SynchronizationState.OUTGOING_NEW
+                : "Only new local tasks can be deleted: " + 
task.getSynchronizationState();
+        if (task.getSynchronizationState() == 
ITask.SynchronizationState.OUTGOING_NEW) {
+            String id = BugzillaIssue.getID(task);
+            try {
+                MylynSupport.getInstance().deleteTask(task);
+            } catch (CoreException ex) {
+                Bugzilla.LOG.log(Level.INFO, null, ex);
+            }
+            getCache().removeIssue(id);
+        }
+    }
+
     protected Object[] getLookupObjects() {
         return new Object[] { getIssueCache() };
     }
@@ -452,6 +466,11 @@
                     Bugzilla.LOG.log(Level.WARNING, "Couldn''t find query 
with stored name {0}", queryName); // NOI18N
                 }
             }
+            if (Boolean.getBoolean("bugzilla.displayUnsubmittedQuery")) {
+                // TODO: should not be a query: this way it's listed in the 
Team dashboard
+                // either should go to SPI or somewhere in Bugtracking.utils
+                queries.add(new BugzillaQuery.UnsubmittedTasksQuery(this));
+            }
         }
         return queries;
     }
@@ -852,6 +871,12 @@
             }
             return Status.ISSUE_STATUS_UNKNOWN;
         }
+
+        private void removeIssue (String id) {
+            synchronized (CACHE_LOCK) {
+                issues.remove(id);
+            }
+        }
     }
 
     private class IssueAccessorImpl implements 
IssueCache.IssueAccessor<BugzillaIssue> {
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/util/BugzillaUtil.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/util/BugzillaUtil.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/util/BugzillaUtil.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/util/BugzillaUtil.java
@@ -192,4 +192,10 @@
         
Bugzilla.getInstance().getBugtrackingFactory().openQuery(getRepository(bugzillaQuery.getRepository()),
 bugzillaQuery);
     }
     
+    public static boolean isOutgoing (ITask task) {
+        return task.getSynchronizationState() == 
ITask.SynchronizationState.CONFLICT
+                || task.getSynchronizationState() == 
ITask.SynchronizationState.OUTGOING
+                || task.getSynchronizationState() == 
ITask.SynchronizationState.OUTGOING_NEW;
 }
+    
+}

[hg] main-silver: list of unsubmitted tasks in the task dashboar...

Ondrej Vrabec 05/06/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 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close