Skip to content

Commit d6b214a

Browse files
committed
Add the feature for adding a milestone #10
1 parent abe95de commit d6b214a

9 files changed

Lines changed: 559 additions & 8 deletions

File tree

Binary file not shown.

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
<enabled>false</enabled>
5050
</snapshots>
5151
</repository>
52+
<repository>
53+
<id>unknown-jars-temp-repo</id>
54+
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
55+
<url>file:${project.basedir}/lib</url>
56+
</repository>
5257
</repositories>
5358
<dependencies>
5459
<dependency>
@@ -124,6 +129,11 @@
124129
<artifactId>org-netbeans-modules-options-api</artifactId>
125130
<version>RELEASE80</version>
126131
</dependency>
132+
<dependency>
133+
<groupId>unknown.binary</groupId>
134+
<artifactId>swingx-all-1.6.4</artifactId>
135+
<version>SNAPSHOT</version>
136+
</dependency>
127137
</dependencies>
128138
<properties>
129139
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/com/junichi11/netbeans/modules/github/issues/GitHubCache.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,21 @@ public List<User> getCollaborators() {
132132
* @return milestones
133133
*/
134134
public List<Milestone> getMilestones() {
135-
if (milestones == null) {
135+
return getMilestones(false);
136+
}
137+
138+
/**
139+
* Get milestones.
140+
*
141+
* @param force {@code true} if don't use cache data, otherwise
142+
* {@code false}
143+
* @return milestones
144+
*/
145+
public List<Milestone> getMilestones(boolean force) {
146+
if (milestones == null || force) {
147+
if (milestones != null) {
148+
milestones.clear();
149+
}
136150
Repository gHRepository = repository.getRepository();
137151
GitHubClient client = repository.createGitHubClient();
138152
if (client == null) {

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/GitHubIssuePanel.form

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<Group type="102" alignment="1" attributes="0">
4343
<Component id="headerErrorLabel" min="-2" max="-2" attributes="0"/>
4444
<EmptySpace max="32767" attributes="0"/>
45+
<Component id="newMilestoneButton" min="-2" max="-2" attributes="0"/>
46+
<EmptySpace max="-2" attributes="0"/>
4547
<Component id="addLabelButton" min="-2" max="-2" attributes="0"/>
4648
<EmptySpace max="-2" attributes="0"/>
4749
<Component id="headerSubmitButton" min="-2" max="-2" attributes="0"/>
@@ -103,6 +105,7 @@
103105
<Component id="headerSubmitButton" alignment="3" min="-2" max="-2" attributes="0"/>
104106
<Component id="headerErrorLabel" alignment="3" min="-2" max="-2" attributes="0"/>
105107
<Component id="addLabelButton" alignment="3" min="-2" max="-2" attributes="0"/>
108+
<Component id="newMilestoneButton" alignment="3" min="-2" max="-2" attributes="0"/>
106109
</Group>
107110
</Group>
108111
</Group>
@@ -214,6 +217,16 @@
214217
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addLabelButtonActionPerformed"/>
215218
</Events>
216219
</Component>
220+
<Component class="javax.swing.JButton" name="newMilestoneButton">
221+
<Properties>
222+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
223+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.newMilestoneButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
224+
</Property>
225+
</Properties>
226+
<Events>
227+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newMilestoneButtonActionPerformed"/>
228+
</Events>
229+
</Component>
217230
</SubComponents>
218231
</Container>
219232
<Container class="javax.swing.JScrollPane" name="mainScrollPane">

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/GitHubIssuePanel.java

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,7 @@ public void update() {
177177
if (isCollaborator) {
178178
GitHubCache cache = GitHubCache.create(repository);
179179
// milestone
180-
List<Milestone> milestones = cache.getMilestones();
181-
milestoneComboBoxModel.removeAllElements();
182-
milestoneComboBoxModel.addElement(null);
183-
for (Milestone milestone : milestones) {
184-
milestoneComboBoxModel.addElement(milestone);
185-
}
180+
updateMilestones(cache, false);
186181

187182
// assignee
188183
List<User> collaborators = cache.getCollaborators();
@@ -192,6 +187,7 @@ public void update() {
192187
assigneeComboBoxModel.addElement(collaborator);
193188
}
194189

190+
// label
195191
updateLables(cache, false);
196192
}
197193

@@ -262,6 +258,15 @@ public void update() {
262258
fireChange();
263259
}
264260

261+
private void updateMilestones(GitHubCache cache, boolean force) {
262+
List<Milestone> milestones = cache.getMilestones(force);
263+
milestoneComboBoxModel.removeAllElements();
264+
milestoneComboBoxModel.addElement(null);
265+
for (Milestone milestone : milestones) {
266+
milestoneComboBoxModel.addElement(milestone);
267+
}
268+
}
269+
265270
private void updateLables(GitHubCache cache, boolean force) {
266271
List<Label> labels = cache.getLabels(force);
267272
labelsListModel.removeAllElements();
@@ -291,6 +296,9 @@ private void setAssigneeSelected(User assignee) {
291296
}
292297

293298
private void setMilestoneSelected(Milestone milestone) {
299+
if (milestone == null) {
300+
return;
301+
}
294302
int size = milestoneComboBoxModel.getSize();
295303
for (int i = 0; i < size; i++) {
296304
Milestone m = milestoneComboBoxModel.getElementAt(i);
@@ -332,6 +340,7 @@ private void setCollaboratorsComponentsVisible(boolean isVisible) {
332340
assigneeLabel.setVisible(isVisible);
333341
assigneeComboBox.setVisible(isVisible);
334342
addLabelButton.setVisible(isVisible);
343+
newMilestoneButton.setVisible(isVisible);
335344
}
336345

337346
@NbBundle.Messages({
@@ -543,6 +552,7 @@ private void initComponents() {
543552
jSeparator1 = new javax.swing.JSeparator();
544553
refreshLinkButton = new org.netbeans.modules.bugtracking.commons.LinkButton();
545554
addLabelButton = new javax.swing.JButton();
555+
newMilestoneButton = new javax.swing.JButton();
546556
mainScrollPane = new javax.swing.JScrollPane();
547557
mainPanel = new javax.swing.JPanel();
548558
assigneeLabel = new javax.swing.JLabel();
@@ -606,6 +616,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
606616
}
607617
});
608618

619+
org.openide.awt.Mnemonics.setLocalizedText(newMilestoneButton, org.openide.util.NbBundle.getMessage(GitHubIssuePanel.class, "GitHubIssuePanel.newMilestoneButton.text")); // NOI18N
620+
newMilestoneButton.addActionListener(new java.awt.event.ActionListener() {
621+
public void actionPerformed(java.awt.event.ActionEvent evt) {
622+
newMilestoneButtonActionPerformed(evt);
623+
}
624+
});
625+
609626
javax.swing.GroupLayout headerPanelLayout = new javax.swing.GroupLayout(headerPanel);
610627
headerPanel.setLayout(headerPanelLayout);
611628
headerPanelLayout.setHorizontalGroup(
@@ -616,6 +633,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
616633
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, headerPanelLayout.createSequentialGroup()
617634
.addComponent(headerErrorLabel)
618635
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
636+
.addComponent(newMilestoneButton)
637+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
619638
.addComponent(addLabelButton)
620639
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
621640
.addComponent(headerSubmitButton))
@@ -667,7 +686,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
667686
.addGroup(headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
668687
.addComponent(headerSubmitButton)
669688
.addComponent(headerErrorLabel)
670-
.addComponent(addLabelButton)))
689+
.addComponent(addLabelButton)
690+
.addComponent(newMilestoneButton)))
671691
);
672692

673693
mainPanel.setAutoscrolls(true);
@@ -844,6 +864,32 @@ private void addLabelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE
844864
}
845865
}//GEN-LAST:event_addLabelButtonActionPerformed
846866

867+
@NbBundle.Messages({
868+
"GitHubIssuePanel.message.addMilestone.error=Can't add a milestone"
869+
})
870+
private void newMilestoneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newMilestoneButtonActionPerformed
871+
assert gitHubIssue != null;
872+
GitHubRepository repository = getRepository();
873+
if (repository == null) {
874+
return;
875+
}
876+
GitHubCache cache = GitHubCache.create(repository);
877+
Milestone milestone = MilestonePanel.showDialog(cache.getMilestones());
878+
if (milestone != null) {
879+
Milestone newMilestone = repository.addMilestone(milestone);
880+
if (newMilestone == null) {
881+
// show dialog
882+
UiUtils.showErrorDialog(Bundle.GitHubIssuePanel_message_addMilestone_error());
883+
return;
884+
}
885+
updateMilestones(cache, true);
886+
Issue issue = getIssue().getIssue();
887+
if (issue != null) {
888+
setMilestoneSelected(issue.getMilestone());
889+
}
890+
}
891+
}//GEN-LAST:event_newMilestoneButtonActionPerformed
892+
847893
// Variables declaration - do not modify//GEN-BEGIN:variables
848894
private javax.swing.JButton addLabelButton;
849895
private javax.swing.JComboBox<User> assigneeComboBox;
@@ -876,6 +922,7 @@ private void addLabelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE
876922
private javax.swing.JButton newCommentCloseReopenIssueButton;
877923
private javax.swing.JLabel newCommentLabel;
878924
private com.junichi11.netbeans.modules.github.issues.issue.ui.CommentTabbedPanel newCommentTabbedPanel;
925+
private javax.swing.JButton newMilestoneButton;
879926
private org.netbeans.modules.bugtracking.commons.LinkButton refreshLinkButton;
880927
private javax.swing.JLabel titleLabel;
881928
private javax.swing.JTextField titleTextField;
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4+
<AuxValues>
5+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
9+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
11+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14+
</AuxValues>
15+
16+
<Layout>
17+
<DimensionLayout dim="0">
18+
<Group type="103" groupAlignment="0" attributes="0">
19+
<Group type="102" alignment="0" attributes="0">
20+
<EmptySpace max="-2" attributes="0"/>
21+
<Group type="103" groupAlignment="0" attributes="0">
22+
<Component id="descriptionScrollPane" pref="400" max="32767" attributes="0"/>
23+
<Group type="102" alignment="1" attributes="0">
24+
<Group type="103" groupAlignment="0" attributes="0">
25+
<Component id="titleTextField" max="32767" attributes="0"/>
26+
<Group type="102" alignment="0" attributes="0">
27+
<Group type="103" groupAlignment="0" attributes="0">
28+
<Component id="descriptionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
29+
<Component id="titleLabel" min="-2" max="-2" attributes="0"/>
30+
</Group>
31+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
32+
</Group>
33+
</Group>
34+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
35+
<Group type="103" groupAlignment="0" attributes="0">
36+
<Component id="dueDateLabel" min="-2" max="-2" attributes="0"/>
37+
<Component id="dueDateDatePicker" min="-2" max="-2" attributes="0"/>
38+
</Group>
39+
</Group>
40+
<Group type="102" attributes="0">
41+
<Component id="errorLabel" min="-2" max="-2" attributes="0"/>
42+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
43+
</Group>
44+
</Group>
45+
<EmptySpace max="-2" attributes="0"/>
46+
</Group>
47+
</Group>
48+
</DimensionLayout>
49+
<DimensionLayout dim="1">
50+
<Group type="103" groupAlignment="0" attributes="0">
51+
<Group type="102" alignment="0" attributes="0">
52+
<EmptySpace min="-2" max="-2" attributes="0"/>
53+
<Group type="103" groupAlignment="3" attributes="0">
54+
<Component id="titleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
55+
<Component id="dueDateLabel" alignment="3" min="-2" max="-2" attributes="0"/>
56+
</Group>
57+
<EmptySpace min="-2" max="-2" attributes="0"/>
58+
<Group type="103" groupAlignment="3" attributes="0">
59+
<Component id="titleTextField" alignment="3" min="-2" max="-2" attributes="0"/>
60+
<Component id="dueDateDatePicker" alignment="3" min="-2" max="-2" attributes="0"/>
61+
</Group>
62+
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
63+
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
64+
<EmptySpace min="-2" max="-2" attributes="0"/>
65+
<Component id="descriptionScrollPane" max="32767" attributes="0"/>
66+
<EmptySpace min="-2" max="-2" attributes="0"/>
67+
<Component id="errorLabel" min="-2" max="-2" attributes="0"/>
68+
<EmptySpace min="-2" max="-2" attributes="0"/>
69+
</Group>
70+
</Group>
71+
</DimensionLayout>
72+
</Layout>
73+
<SubComponents>
74+
<Component class="javax.swing.JLabel" name="titleLabel">
75+
<Properties>
76+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
77+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="MilestonePanel.titleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
78+
</Property>
79+
</Properties>
80+
</Component>
81+
<Component class="javax.swing.JTextField" name="titleTextField">
82+
<Properties>
83+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
84+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="MilestonePanel.titleTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
85+
</Property>
86+
</Properties>
87+
</Component>
88+
<Component class="javax.swing.JLabel" name="descriptionLabel">
89+
<Properties>
90+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
91+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="MilestonePanel.descriptionLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
92+
</Property>
93+
</Properties>
94+
</Component>
95+
<Component class="org.jdesktop.swingx.JXDatePicker" name="dueDateDatePicker">
96+
</Component>
97+
<Component class="javax.swing.JLabel" name="dueDateLabel">
98+
<Properties>
99+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
100+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="MilestonePanel.dueDateLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
101+
</Property>
102+
</Properties>
103+
</Component>
104+
<Component class="javax.swing.JLabel" name="errorLabel">
105+
<Properties>
106+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
107+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="MilestonePanel.errorLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
108+
</Property>
109+
</Properties>
110+
</Component>
111+
<Container class="javax.swing.JScrollPane" name="descriptionScrollPane">
112+
<AuxValues>
113+
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
114+
</AuxValues>
115+
116+
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
117+
<SubComponents>
118+
<Component class="javax.swing.JTextArea" name="descriptionTextArea">
119+
<Properties>
120+
<Property name="columns" type="int" value="20"/>
121+
<Property name="rows" type="int" value="5"/>
122+
</Properties>
123+
</Component>
124+
</SubComponents>
125+
</Container>
126+
</SubComponents>
127+
</Form>

0 commit comments

Comments
 (0)