matthiasblaesing / netbeans-mantis-integration

Integrate the Mantis bugtracker system into netbeans
22 stars 6 forks source link

Add Project Version Suppord #12

Closed wklaczynski closed 10 years ago

wklaczynski commented 11 years ago

Can not change target version in isue panel.

wklaczynski commented 11 years ago

in MantisIssueControler

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -6,6 +6,7 @@
 import biz.futureware.mantisconnect.IssueNoteData;
 import biz.futureware.mantisconnect.ObjectRef;
 import biz.futureware.mantisconnect.ProjectData;
+import biz.futureware.mantisconnect.ProjectVersionData;
 import biz.futureware.mantisconnect.RelationshipData;
 import eu.doppel_helix.netbeans.mantisintegration.data.FlattenedProjectData;
 import eu.doppel_helix.netbeans.mantisintegration.data.Permission;
@@ -63,13 +64,13 @@
     private ListBackedComboBoxModel<ObjectRef> resolutionsModel = new ListBackedComboBoxModel<ObjectRef>(ObjectRef.class);
     private ListBackedComboBoxModel<ObjectRef> statesModel = new ListBackedComboBoxModel<ObjectRef>(ObjectRef.class);
     private ListBackedComboBoxModel<ObjectRef> etasModel = new ListBackedComboBoxModel<ObjectRef>(ObjectRef.class);
+    private ListBackedComboBoxModel<String> versionModel = new ListBackedComboBoxModel<String>(String.class);
     private ListBackedComboBoxModel<ObjectRef> projectionsModel = new ListBackedComboBoxModel<ObjectRef>(ObjectRef.class);
     private ListBackedComboBoxModel<String> categoriesModel = new ListBackedComboBoxModel<String>(String.class);
     private ListBackedComboBoxModel<AccountData> assignedModel = new ListBackedComboBoxModel<AccountData>(AccountData.class);
     private MantisIssuePanel panel;
     private MantisIssue issue;
     private StateMonitor stateMonitor = new StateMonitor();
-
     private final SwingWorker updateModel = new SwingWorker() {
         List<FlattenedProjectData> projects;
         List<ObjectRef> viewStates;
@@ -90,7 +91,7 @@

                 projects = new ArrayList<FlattenedProjectData>();
                 projects.add(null);
-                for(ProjectData pd: mr.getProjects()) {
+                for (ProjectData pd : mr.getProjects()) {
                     projects.addAll(FlattenedProjectData.buildList(pd));
                 }

@@ -156,6 +157,7 @@
             panel.statusComboBox.setModel(statesModel);
             panel.projectionComboBox.setModel(projectionsModel);
             panel.etaComboBox.setModel(etasModel);
+            panel.versionComboBox.setModel(versionModel);
             panel.refreshLinkButton.addActionListener(this);
             panel.openIssueWebbrowserLinkButton.addActionListener(this);
             panel.projectComboBox.addActionListener(this);
@@ -191,7 +193,7 @@
             panel.addIssueButton.setVisible(true);
             panel.filler1.setVisible(true);
         } else {
-            if(issue.canUpdate()) {
+            if (issue.canUpdate()) {
                 panel.updateIssueButton.setVisible(true);
                 panel.statusComboBox.setEnabled(true);
                 panel.resolutionComboBox.setEnabled(true);
@@ -221,6 +223,7 @@
         panel.priorityComboBox.setEnabled(enabled);
         panel.projectionComboBox.setEnabled(enabled);
         panel.etaComboBox.setEnabled(enabled);
+        panel.versionComboBox.setEnabled(enabled);
         panel.platformTextField.setEditable(enabled);
         panel.osTextField.setEditable(enabled);
         panel.osVersionTextField.setEditable(enabled);
@@ -286,6 +289,9 @@
             if (property == null || "category".equals(property)) {
                 panel.categoryComboBox.setSelectedItem(issue.getCategory());
             }
+            if (property == null || "version".equals(property)) {
+                panel.versionComboBox.setSelectedItem(issue.getTarget_version());
+            }
             if (property == null || "view_state".equals(property)) {
                 panel.viewStatusComboBox.setSelectedItem(issue.getView_state());
             }
@@ -300,7 +306,7 @@
             }
             if (property == null || "handler".equals(property)) {
                 AccountData target = issue.getHandler();
-                if(! assignedModel.getBackingList().contains(target)) {
+                if (!assignedModel.getBackingList().contains(target)) {
                     assignedModel.addElement(target);
                 }
                 panel.assignedToComboBox.setSelectedItem(target);
@@ -461,6 +467,7 @@
         updateData.setSteps_to_reproduce(panel.stepsToReproduceEditorPane.getText());
         updateData.setSummary(panel.summaryTextField.getText());
         updateData.setView_state((ObjectRef) panel.viewStatusComboBox.getSelectedItem());
+        updateData.setTarget_version((String)panel.versionComboBox.getSelectedItem());
         // ToDo: the next two need exposure in GUI
         updateData.setTarget_version(issue.getTarget_version());
         updateData.setVersion(issue.getVersion());
@@ -501,7 +508,7 @@
                 }
             }
         } catch (Exception ex) {
-            if(ex instanceof RemoteException || ex instanceof ServiceException) {
+            if (ex instanceof RemoteException || ex instanceof ServiceException) {
                 NotifyDescriptor nd = new NotifyDescriptor.Exception(ex, 
                         "Failed to create/add issue");
                 DialogDisplayer.getDefault().notifyLater(nd);
@@ -559,6 +566,7 @@
             try {
                 List<String> categories = new ArrayList<String>();
                 List<AccountData> users = new ArrayList<AccountData>();
+                List<String> versions = new ArrayList<String>();
                 FlattenedProjectData fpd = (FlattenedProjectData) panel.projectComboBox.getSelectedItem();
                 if (fpd != null) {
                     MantisRepository mr = issue.getMantisRepository();
@@ -566,9 +574,14 @@
                     categories.addAll(Arrays.asList(mr.getCategories(fpd.getProjectData().getId())));
                     users.add(null);
                     users.addAll(Arrays.asList(mr.getUsers(fpd.getProjectData().getId())));
+                    versions.add(null);
+                    for (ProjectVersionData vdata : Arrays.asList(mr.getUnreleasedVersions(fpd.getProjectData().getId()))) {
+                        versions.add(vdata.getName());
                 }
+                }
                 categoriesModel.setBackingList(categories);
                 assignedModel.setBackingList(users);
+                versionModel.setBackingList(versions);
             } catch (Exception ex) {
                 if (ex instanceof RemoteException || ex instanceof ServiceException) {
                     NotifyDescriptor nd = new NotifyDescriptor.Exception(ex,
wklaczynski commented 11 years ago

In MantisIssue.java

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -140,6 +140,7 @@
         issueData.setNotes(id.getNotes());
         issueData.setCustom_fields(id.getCustom_fields());
         issueData.setTags(id.getTags());
+        issueData.setTarget_version(id.getTarget_version());
         Mutex.EVENT.writeAccess(new Runnable() {
             @Override
             public void run() {
wklaczynski commented 11 years ago

in MantisRepository.java

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -10,6 +10,7 @@
 import biz.futureware.mantisconnect.MantisConnectPortType;
 import biz.futureware.mantisconnect.ObjectRef;
 import biz.futureware.mantisconnect.ProjectData;
+import biz.futureware.mantisconnect.ProjectVersionData;
 import biz.futureware.mantisconnect.RelationshipData;
 import biz.futureware.mantisconnect.TagData;
 import biz.futureware.mantisconnect.UserData;
@@ -94,6 +95,7 @@
     private HashMap<BigInteger, TagData> tags;
     private HashMap<BigInteger, String[]> categories = new HashMap<BigInteger, String[]>();
     private HashMap<BigInteger, AccountData[]> users = new HashMap<BigInteger, AccountData[]>();
+    private HashMap<BigInteger, ProjectVersionData[]> unreleasedVersions = new HashMap<BigInteger, ProjectVersionData[]>();
     private HashMap<BigInteger, FilterData[]> filters = new HashMap<BigInteger, FilterData[]>();
     private UserData account = null;
     private MantisRepositoryQueryStore queryStore;
@@ -697,6 +699,27 @@
         return result;
     }

+    public ProjectVersionData[] getUnreleasedVersions(BigInteger projectID) throws ServiceException, RemoteException  {
+        if (unreleasedVersions.get(projectID) == null) {
+            MantisConnectPortType mcpt = getClient();
+            try {
+                ProjectVersionData[] projCategories = mcpt.mc_project_get_unreleased_versions(
+                        info.getUsername(),
+                        new String(info.getPassword()),
+                        projectID);
+                unreleasedVersions.put(projectID, projCategories);
+            } catch (RemoteException ex) {
+                logger.log(Level.INFO, "", ex);
+                unreleasedVersions.put(projectID, new ProjectVersionData[0]);
+            }
+        }
+        ProjectVersionData[] result = unreleasedVersions.get(projectID);
+        if(result == null) {
+            result = new ProjectVersionData[0];
+        }
+        return result;
+    }
+    
     public FilterData[] getFilters(BigInteger projectID) throws ServiceException, RemoteException  {
         if (filters.get(projectID) == null) {
             MantisConnectPortType mcpt = getClient();
wklaczynski commented 11 years ago

In MantisIssuePanel.java

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -158,6 +158,8 @@
         timetrackLabel = new javax.swing.JLabel();
         timetrackInput = new javax.swing.JFormattedTextField();
         filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767));
+        versionLabel = new javax.swing.JLabel();
+        versionComboBox = new javax.swing.JComboBox();

         setBackground(javax.swing.UIManager.getDefaults().getColor("TextArea.background"));

@@ -809,6 +811,7 @@
         gridBagConstraints.gridy = 1;
         gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
         addNotesPanel.add(timetrackLabel, gridBagConstraints);
+
         timetrackInput.setFormatterFactory(new TimeFormatterFactory());
         timetrackInput.setHorizontalAlignment(javax.swing.JTextField.CENTER);
         timetrackInput.setText(org.openide.util.NbBundle.getMessage(MantisIssuePanel.class, "MantisIssuePanel.timetrackInput.text")); // NOI18N
@@ -840,6 +843,27 @@
         gridBagConstraints.weighty = 1.0;
         innerPanel.add(filler1, gridBagConstraints);

+        versionLabel.setFont(versionLabel.getFont().deriveFont(versionLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+        org.openide.awt.Mnemonics.setLocalizedText(versionLabel, org.openide.util.NbBundle.getMessage(MantisIssuePanel.class, "MantisIssuePanel.versionLabel.text")); // NOI18N
+        versionLabel.setToolTipText(org.openide.util.NbBundle.getMessage(MantisIssuePanel.class, "MantisIssuePanel.versionLabel.toolTipText")); // NOI18N
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 4;
+        gridBagConstraints.gridy = 5;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING;
+        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+        innerPanel.add(versionLabel, gridBagConstraints);
+
+        versionComboBox.setPrototypeDisplayValue("XXXXXXXX");
+        versionComboBox.setRenderer(new ObjectRefListCellRenderer());
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 5;
+        gridBagConstraints.gridy = 5;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+        innerPanel.add(versionComboBox, gridBagConstraints);
+
         scrollablePane.setViewportView(innerPanel);

         scrollablePane.setBounds(0, 0, 584, 736);
@@ -921,6 +945,8 @@
     javax.swing.JButton updateIssueButton;
     javax.swing.JLabel updatedLabel;
     javax.swing.JLabel updatedValueLabel;
+    javax.swing.JComboBox versionComboBox;
+    javax.swing.JLabel versionLabel;
     javax.swing.JComboBox viewStatusComboBox;
     javax.swing.JLabel viewStatusLabel;
     // End of variables declaration                   
wklaczynski commented 11 years ago

In MantisIssuePanel.form

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -1363,7 +1363,7 @@
                     </Component>
                     <Component class="javax.swing.JFormattedTextField" name="timetrackInput">
                       <Properties>
-                        <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" preCode="try {" postCode="} catch (java.text.ParseException ex) {&#xa;ex.printStackTrace();&#xa;}">
+                        <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
                           <Connection code="new TimeFormatterFactory()" type="code"/>
                         </Property>
                         <Property name="horizontalAlignment" type="int" value="0"/>
@@ -1399,6 +1399,44 @@
                 </Constraint>
               </Constraints>
             </Component>
+            <Component class="javax.swing.JLabel" name="versionLabel">
+              <Properties>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
+                  <FontInfo relative="true">
+                    <Font bold="false" component="versionLabel" property="font" relativeSize="true" size="0"/>
+                  </FontInfo>
+                </Property>
+                <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+                  <ResourceString bundle="eu/doppel_helix/netbeans/mantisintegration/issue/Bundle.properties" key="MantisIssuePanel.versionLabel.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="eu/doppel_helix/netbeans/mantisintegration/issue/Bundle.properties" key="MantisIssuePanel.versionLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+                </Property>
+              </Properties>
+              <Constraints>
+                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+                  <GridBagConstraints gridX="4" gridY="5" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="512" weightX="0.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
+            <Component class="javax.swing.JComboBox" name="versionComboBox">
+              <Properties>
+                <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+                  <StringArray count="0"/>
+                </Property>
+                <Property name="prototypeDisplayValue" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                  <Connection code="&quot;XXXXXXXX&quot;" type="code"/>
+                </Property>
+                <Property name="renderer" type="javax.swing.ListCellRenderer" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                  <Connection code="new ObjectRefListCellRenderer()" type="code"/>
+                </Property>
+              </Properties>
+              <Constraints>
+                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+                  <GridBagConstraints gridX="5" gridY="5" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="512" weightX="1.0" weightY="0.0"/>
+                </Constraint>
+              </Constraints>
+            </Component>
           </SubComponents>
         </Container>
       </SubComponents>
wklaczynski commented 11 years ago

in Bundle.properties

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -58,3 +58,5 @@
 AddTagDialog.tagsLabel.text=New Tag(s):
 MantisIssuePanel.timetrackLabel.text=Time:
 MantisIssuePanel.timetrackInput.text=00:00
+MantisIssuePanel.versionLabel.text=Version:
+MantisIssuePanel.versionLabel.toolTipText=
matthiasblaesing commented 11 years ago

Hey, thanks for the patch. I did not apply your changes directly, but instead used them as a base to create a patch for all version fields of an issue. I build a test version for 7.3 and 7.3.1 - it would be good if you could give it a spin.

7.3: https://github.com/matthiasblaesing/netbeans-mantis-integration/wiki/MantisIntegration-0.7-SNAPSHOT.nbm 7.3.1: https://github.com/matthiasblaesing/netbeans-mantis-integration/wiki/MantisIntegration-0.7-SNAPSHOT-7.3.1.nbm

matthiasblaesing commented 10 years ago

I pushed the 0.7 release (last 7.3 build), I merge the netbeas 74 branch and try to cut a 0.8 release for 7.4