Skip to content

Commit 1505752

Browse files
committed
Merge branch 'nb80'
2 parents 6817a5f + 7775449 commit 1505752

18 files changed

Lines changed: 1175 additions & 50 deletions

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This plugin provides support for GitHub Issue Tracker.
1313
- Create a new label
1414
- Create a new milestone
1515
- Add issues to schedule categories
16+
- Insert and manage templates
1617

1718
## Usage
1819

@@ -29,6 +30,14 @@ This plugin provides support for GitHub Issue Tracker.
2930

3031
If an issue has a milestone and it has a due date, the issue is added to schedule category.
3132

33+
### Insert and manage templates
34+
35+
You can insert a template and manage templates using buttons below the description.
36+
All templates are used globally. (i.e. It isn't templates per repository.)
37+
38+
**NOTE:**You cannot remove the default template. If you remove it, it will be initilized.
39+
You cannot edit a template name. So, if you want to change it, just remove it, then add a new template.
40+
3241
## Default queries
3342

3443
1. Open

pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.junichi11</groupId>
55
<artifactId>netbeans-github-issues</artifactId>
6-
<version>0.1.2</version>
6+
<version>0.1.3</version>
77
<packaging>nbm</packaging>
88
<build>
99
<plugins>
@@ -96,7 +96,7 @@
9696
<dependency>
9797
<groupId>org.eclipse.mylyn.github</groupId>
9898
<artifactId>org.eclipse.egit.github.core</artifactId>
99-
<version>3.6.0-SNAPSHOT</version>
99+
<version>4.1.0-SNAPSHOT</version>
100100
</dependency>
101101
<dependency>
102102
<groupId>junit</groupId>
@@ -134,6 +134,11 @@
134134
<artifactId>swingx-0.9.5</artifactId>
135135
<version>RELEASE72</version>
136136
</dependency>
137+
<dependency>
138+
<groupId>com.google.code.gson</groupId>
139+
<artifactId>gson</artifactId>
140+
<version>2.3.1</version>
141+
</dependency>
137142
</dependencies>
138143
<properties>
139144
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
*/
5151
public enum GitHubIssueState {
5252

53+
NEW("new"), // NOI18N
5354
OPEN("open"), // NOI18N
5455
CLOSED("closed"); // NOI18N
5556

@@ -67,6 +68,9 @@ private GitHubIssueState(String state) {
6768
}
6869

6970
public static GitHubIssueState toEnum(String name) {
71+
if (name == null || name.isEmpty()) {
72+
return NEW;
73+
}
7074
return states.get(name);
7175
}
7276

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

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@
4848
import java.text.DateFormat;
4949
import java.text.ParseException;
5050
import java.text.SimpleDateFormat;
51+
import java.util.ArrayList;
52+
import java.util.Arrays;
5153
import java.util.Date;
5254
import java.util.prefs.BackingStoreException;
5355
import java.util.prefs.Preferences;
5456
import org.openide.util.Exceptions;
57+
import org.openide.util.NbBundle;
5558
import org.openide.util.NbPreferences;
5659

5760
/**
@@ -67,6 +70,8 @@ public final class GitHubIssuesConfig {
6770
private static final String SCHEDULE = "schedule"; // NOI18N
6871
private static final String SCHEDULE_DUE_DATE = "schedule.due"; // NOI18N
6972
private static final String SCHEDULE_INTERVAL = "schedule.interval"; // NOI18N
73+
private static final String TEMPLATE = "template"; // NOI18N
74+
private static final String DEFAULT_TEMPLATE_NAME = "default"; // NOI18N
7075

7176
private GitHubIssuesConfig() {
7277
}
@@ -82,7 +87,7 @@ public static GitHubIssuesConfig getInstance() {
8287
* @return saved query names
8388
*/
8489
public String[] getQueryNames(GitHubRepository repository) {
85-
Preferences preferences = getPreferences().node(repository.getID()).node(QUERY);
90+
Preferences preferences = getPreferences(repository).node(QUERY);
8691
try {
8792
return preferences.childrenNames();
8893
} catch (BackingStoreException ex) {
@@ -99,7 +104,7 @@ public String[] getQueryNames(GitHubRepository repository) {
99104
* @return query parameters if name exists, otherwise {@code null}
100105
*/
101106
public String getQueryParams(GitHubRepository repository, String queryName) {
102-
Preferences preferences = getPreferences().node(repository.getID()).node(QUERY).node(queryName);
107+
Preferences preferences = getPreferences(repository).node(QUERY).node(queryName);
103108
return preferences.get(QUERY_PARAMS, null);
104109
}
105110

@@ -110,8 +115,7 @@ public String getQueryParams(GitHubRepository repository, String queryName) {
110115
* @param query query
111116
*/
112117
public void setQueryParams(GitHubRepository repository, GitHubQuery query) {
113-
String id = repository.getID();
114-
Preferences preferences = getPreferences().node(id).node(QUERY).node(query.getDisplayName());
118+
Preferences preferences = getPreferences(repository).node(QUERY).node(query.getDisplayName());
115119
preferences.put(QUERY_PARAMS, query.getQueryParam());
116120
}
117121

@@ -126,7 +130,7 @@ public void removeQuery(GitHubRepository repository, GitHubQuery query) {
126130
if (StringUtils.isEmpty(displayName)) {
127131
return;
128132
}
129-
Preferences preferences = getPreferences().node(repository.getID()).node(QUERY).node(displayName);
133+
Preferences preferences = getPreferences(repository).node(QUERY).node(displayName);
130134
try {
131135
preferences.removeNode();
132136
} catch (BackingStoreException ex) {
@@ -193,6 +197,66 @@ public void removeSchedule(GitHubRepository repository, GitHubIssue issue) {
193197
}
194198
}
195199

200+
/**
201+
* Get the template for specified name.
202+
*
203+
* @param name the template name
204+
* @return the template
205+
*/
206+
@NbBundle.Messages("GitHubIssuesConfig.default.template=#### Overview description\n"
207+
+ "\n"
208+
+ "#### Steps to reproduce\n"
209+
+ "\n"
210+
+ "1. \n"
211+
+ "2. \n"
212+
+ "3. \n"
213+
+ "\n"
214+
+ "#### Actual results\n"
215+
+ "\n"
216+
+ "#### Expected results\n")
217+
public String getTemplate(String name) {
218+
return getPreferences().node(TEMPLATE).get(name, Bundle.GitHubIssuesConfig_default_template());
219+
}
220+
221+
/**
222+
* Set template.
223+
*
224+
* @param name the template name
225+
* @param template the template
226+
*/
227+
public void setTemplate(String name, String template) {
228+
getPreferences().node(TEMPLATE).put(name, template);
229+
}
230+
231+
/**
232+
* Remove a template. <b>NOTE:</b> Can't remove the default template. But
233+
* default template will be initialized.
234+
*
235+
* @param name the template name
236+
*/
237+
public void removeTemplate(String name) {
238+
getPreferences().node(TEMPLATE).remove(name);
239+
}
240+
241+
/**
242+
* Get all template names.
243+
*
244+
* @return all template names
245+
*/
246+
public String[] getTemplateNames() {
247+
ArrayList<String> names = new ArrayList<>();
248+
names.add(DEFAULT_TEMPLATE_NAME);
249+
Preferences preferences = getPreferences().node(TEMPLATE);
250+
try {
251+
String[] childrenNames = preferences.keys();
252+
names.addAll(Arrays.asList(childrenNames));
253+
return names.toArray(new String[childrenNames.length + 1]);
254+
} catch (BackingStoreException ex) {
255+
Exceptions.printStackTrace(ex);
256+
}
257+
return names.toArray(new String[1]);
258+
}
259+
196260
public void removeRepository(GitHubRepository repository) {
197261
Preferences preferences = getPreferences(repository);
198262
try {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void setAttributes(Issue issue, GitHubRepository repository) {
101101
if (milestone != null) {
102102
milestoneNameLabel.setText(milestone.getTitle());
103103

104-
// tooptip
104+
// tooltip
105105
Date dueDate = milestone.getDueOn();
106106
String description = milestone.getDescription();
107107
StringBuilder sb = new StringBuilder();

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

Lines changed: 83 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22

33
<Form version="1.4" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4+
<NonVisualComponents>
5+
<Container class="javax.swing.JPanel" name="mainCommentsPanel">
6+
7+
<Layout>
8+
<DimensionLayout dim="0">
9+
<Group type="103" groupAlignment="0" attributes="0">
10+
<Component id="dummyCommentsPanel" alignment="0" pref="791" max="32767" attributes="0"/>
11+
</Group>
12+
</DimensionLayout>
13+
<DimensionLayout dim="1">
14+
<Group type="103" groupAlignment="0" attributes="0">
15+
<Component id="dummyCommentsPanel" alignment="0" pref="13" max="32767" attributes="0"/>
16+
</Group>
17+
</DimensionLayout>
18+
</Layout>
19+
<SubComponents>
20+
<Container class="javax.swing.JPanel" name="dummyCommentsPanel">
21+
22+
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
23+
</Container>
24+
</SubComponents>
25+
</Container>
26+
</NonVisualComponents>
427
<AuxValues>
528
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
629
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@@ -241,17 +264,23 @@
241264
<Layout>
242265
<DimensionLayout dim="0">
243266
<Group type="103" groupAlignment="0" attributes="0">
267+
<Component id="attributesViewPanel" alignment="0" max="32767" attributes="0"/>
244268
<Group type="102" attributes="0">
245269
<EmptySpace max="-2" attributes="0"/>
246270
<Group type="103" groupAlignment="0" attributes="0">
247271
<Group type="102" alignment="1" attributes="0">
248272
<Group type="103" groupAlignment="0" attributes="0">
249273
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
250274
<Component id="titleLabel" alignment="0" min="-2" max="-2" attributes="0"/>
275+
<Group type="102" alignment="0" attributes="0">
276+
<Component id="insertTemplateButton" min="-2" max="-2" attributes="0"/>
277+
<EmptySpace max="-2" attributes="0"/>
278+
<Component id="manageTemplatesButton" min="-2" max="-2" attributes="0"/>
279+
</Group>
251280
</Group>
252-
<EmptySpace min="-2" pref="37" max="-2" attributes="0"/>
281+
<EmptySpace type="separate" max="-2" attributes="0"/>
253282
<Group type="103" groupAlignment="0" attributes="0">
254-
<Component id="descriptionTabbedPanel" pref="512" max="32767" attributes="0"/>
283+
<Component id="descriptionTabbedPanel" max="32767" attributes="0"/>
255284
<Component id="titleTextField" max="32767" attributes="0"/>
256285
</Group>
257286
<EmptySpace max="-2" attributes="0"/>
@@ -284,11 +313,10 @@
284313
<EmptySpace max="-2" attributes="0"/>
285314
<Component id="newCommentButton" min="-2" max="-2" attributes="0"/>
286315
</Group>
316+
<Component id="commentsCollapsibleSectionPanel" alignment="0" max="32767" attributes="0"/>
287317
</Group>
288318
<EmptySpace max="-2" attributes="0"/>
289319
</Group>
290-
<Component id="attributesViewPanel" alignment="0" max="32767" attributes="0"/>
291-
<Component id="mainCommetnsPanel" alignment="0" max="32767" attributes="0"/>
292320
</Group>
293321
</DimensionLayout>
294322
<DimensionLayout dim="1">
@@ -317,14 +345,19 @@
317345
</Group>
318346
<Group type="102" attributes="0">
319347
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
320-
<EmptySpace min="-2" pref="271" max="-2" attributes="0"/>
348+
<EmptySpace max="-2" attributes="0"/>
349+
<Group type="103" groupAlignment="0" attributes="0">
350+
<Component id="insertTemplateButton" min="-2" max="-2" attributes="0"/>
351+
<Component id="manageTemplatesButton" min="-2" max="-2" attributes="0"/>
352+
</Group>
353+
<EmptySpace min="-2" pref="237" max="-2" attributes="0"/>
321354
</Group>
322355
<Component id="descriptionTabbedPanel" min="-2" max="-2" attributes="0"/>
323356
</Group>
324357
<EmptySpace max="-2" attributes="0"/>
325358
<Component id="attributesViewPanel" min="-2" max="-2" attributes="0"/>
326-
<EmptySpace max="-2" attributes="0"/>
327-
<Component id="mainCommetnsPanel" min="-2" max="-2" attributes="0"/>
359+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
360+
<Component id="commentsCollapsibleSectionPanel" min="-2" max="-2" attributes="0"/>
328361
<EmptySpace min="-2" max="-2" attributes="0"/>
329362
<Group type="103" groupAlignment="0" attributes="0">
330363
<Component id="newCommentLabel" min="-2" max="-2" attributes="0"/>
@@ -335,7 +368,7 @@
335368
<Component id="newCommentButton" alignment="3" min="-2" max="-2" attributes="0"/>
336369
<Component id="newCommentCloseReopenIssueButton" alignment="3" min="-2" max="-2" attributes="0"/>
337370
</Group>
338-
<EmptySpace max="32767" attributes="0"/>
371+
<EmptySpace pref="69" max="32767" attributes="0"/>
339372
</Group>
340373
</Group>
341374
</DimensionLayout>
@@ -449,10 +482,6 @@
449482
</Component>
450483
<Component class="com.junichi11.netbeans.modules.github.issues.issue.ui.AttributesViewPanel" name="attributesViewPanel">
451484
</Component>
452-
<Container class="javax.swing.JPanel" name="mainCommetnsPanel">
453-
454-
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
455-
</Container>
456485
<Component class="org.netbeans.modules.bugtracking.commons.LinkButton" name="assignYourselfLinkButton">
457486
<Properties>
458487
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -463,6 +492,48 @@
463492
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="assignYourselfLinkButtonActionPerformed"/>
464493
</Events>
465494
</Component>
495+
<Component class="org.netbeans.modules.bugtracking.commons.CollapsibleSectionPanel" name="commentsCollapsibleSectionPanel">
496+
<Properties>
497+
<Property name="content" type="javax.swing.JComponent" editor="org.netbeans.modules.form.ComponentChooserEditor">
498+
<ComponentRef name="mainCommentsPanel"/>
499+
</Property>
500+
<Property name="label" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
501+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.commentsCollapsibleSectionPanel.label" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
502+
</Property>
503+
</Properties>
504+
</Component>
505+
<Component class="javax.swing.JButton" name="insertTemplateButton">
506+
<Properties>
507+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
508+
<Image iconType="2" name="/home/junichi11/NetBeansProjects/netbeans-github-issues/src/main/resources/com/junichi11/netbeans/modules/github/issues/resources/template_16.png"/>
509+
</Property>
510+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
511+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.insertTemplateButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
512+
</Property>
513+
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
514+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.insertTemplateButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
515+
</Property>
516+
</Properties>
517+
<Events>
518+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="insertTemplateButtonActionPerformed"/>
519+
</Events>
520+
</Component>
521+
<Component class="javax.swing.JButton" name="manageTemplatesButton">
522+
<Properties>
523+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
524+
<Image iconType="2" name="/home/junichi11/NetBeansProjects/netbeans-github-issues/src/main/resources/com/junichi11/netbeans/modules/github/issues/resources/template_settings_16.png"/>
525+
</Property>
526+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
527+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.manageTemplatesButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
528+
</Property>
529+
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
530+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.manageTemplatesButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
531+
</Property>
532+
</Properties>
533+
<Events>
534+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="manageTemplatesButtonActionPerformed"/>
535+
</Events>
536+
</Component>
466537
</SubComponents>
467538
</Container>
468539
</SubComponents>

0 commit comments

Comments
 (0)