Skip to content

Commit 7375a70

Browse files
committed
Insert the default template when a new issue panel is opened #39
1 parent 86b6c9d commit 7375a70

7 files changed

Lines changed: 180 additions & 31 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
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.2.0</version>
6+
<version>0.2.1-SNAPSHOT</version>
77
<packaging>nbm</packaging>
88
<build>
99
<plugins>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ public final class GitHubIssuesConfig {
7676
private static final String SCHEDULE = "schedule"; // NOI18N
7777
private static final String SCHEDULE_DUE_DATE = "schedule.due"; // NOI18N
7878
private static final String SCHEDULE_INTERVAL = "schedule.interval"; // NOI18N
79+
80+
// template
7981
private static final String TEMPLATE = "template"; // NOI18N
80-
private static final String DEFAULT_TEMPLATE_NAME = "default"; // NOI18N
82+
public static final String DEFAULT_TEMPLATE_NAME = "default"; // NOI18N
8183

8284
// status
8385
private static final String STATUS = "status"; // NOI18N

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import com.junichi11.netbeans.modules.github.issues.issue.GitHubIssueController.CreatePullRequestAction;
5656
import com.junichi11.netbeans.modules.github.issues.issue.GitHubIssueController.SubmitIssueAction;
5757
import com.junichi11.netbeans.modules.github.issues.issue.GitHubIssueSupport;
58+
import com.junichi11.netbeans.modules.github.issues.options.GitHubIssuesOptions;
5859
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
5960
import com.junichi11.netbeans.modules.github.issues.ui.AttributesListCellRenderer;
6061
import com.junichi11.netbeans.modules.github.issues.utils.GitHubIssuesUtils;
@@ -192,6 +193,19 @@ public boolean isNew() {
192193

193194
public void setIssue(GitHubIssue gitHubIssue) {
194195
this.gitHubIssue = gitHubIssue;
196+
197+
// insert the default template
198+
if (isNew()) {
199+
if (GitHubIssuesOptions.getInstance().insertDefaultTemplate()) {
200+
SwingUtilities.invokeLater(new Runnable() {
201+
@Override
202+
public void run() {
203+
String template = GitHubIssuesConfig.getInstance().getTemplate(GitHubIssuesConfig.DEFAULT_TEMPLATE_NAME);
204+
descriptionTabbedPanel.setText(template);
205+
}
206+
});
207+
}
208+
}
195209
}
196210

197211
public GitHubIssue getIssue() {

src/main/java/com/junichi11/netbeans/modules/github/issues/options/GitHubIssuesOptions.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ public final class GitHubIssuesOptions {
5656

5757
public static final String SUB_PATH = "Team/GitHubIssues"; // NOI18N
5858
private static final String PREFERENCES_PATH = "github.issues"; // NOI18N
59+
60+
// repositories
5961
private static final String SHOW_PARENT_REPO = "show.parent.repo"; // NOI18N
62+
63+
// issues
64+
private static final String INSERT_DEFAULT_TEMPLATE = "insert.default.template"; // NOI18N
6065
private static final GitHubIssuesOptions INSTANCE = new GitHubIssuesOptions();
6166

6267
private GitHubIssuesOptions() {
@@ -106,6 +111,7 @@ public Map<GitHubDefaultQueries.Type, Boolean> getDefaultQueryOptions() {
106111
return map;
107112
}
108113

114+
// repositories
109115
public boolean showParentRepository() {
110116
return getPreferences().getBoolean(SHOW_PARENT_REPO, false);
111117
}
@@ -114,6 +120,15 @@ public void setShowParentRepository(boolean showParent) {
114120
getPreferences().putBoolean(SHOW_PARENT_REPO, showParent);
115121
}
116122

123+
// issues
124+
public boolean insertDefaultTemplate() {
125+
return getPreferences().getBoolean(INSERT_DEFAULT_TEMPLATE, false);
126+
}
127+
128+
public void setInsertDefaultTemplate(boolean insert) {
129+
getPreferences().putBoolean(INSERT_DEFAULT_TEMPLATE, insert);
130+
}
131+
117132
private Preferences getPreferences() {
118133
return NbPreferences.forModule(GitHubIssuesOptions.class).node(PREFERENCES_PATH);
119134
}

src/main/java/com/junichi11/netbeans/modules/github/issues/options/GitHubIssuesOptionsPanel.form

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,83 @@
1919
<Group type="102" alignment="0" attributes="0">
2020
<EmptySpace max="-2" attributes="0"/>
2121
<Group type="103" groupAlignment="0" attributes="0">
22-
<Component id="defaultQueriesLabel" min="-2" max="-2" attributes="0"/>
23-
<Component id="repositoriesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
2422
<Group type="102" attributes="0">
2523
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
24+
<Component id="insertTemplateCheckBox" min="-2" max="-2" attributes="0"/>
25+
<EmptySpace max="32767" attributes="0"/>
26+
</Group>
27+
<Group type="102" attributes="0">
2628
<Group type="103" groupAlignment="0" attributes="0">
27-
<Component id="showParentRepositoryCheckBox" min="-2" max="-2" attributes="0"/>
28-
<Component id="createdByMeCheckBox" min="-2" max="-2" attributes="0"/>
29-
<Component id="openCheckBox" min="-2" max="-2" attributes="0"/>
30-
<Component id="assignedToMeCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
29+
<Group type="102" alignment="0" attributes="0">
30+
<Component id="issuesLabel" min="-2" max="-2" attributes="0"/>
31+
<EmptySpace max="-2" attributes="0"/>
32+
<Component id="issuesSeparator" max="32767" attributes="0"/>
33+
</Group>
34+
<Group type="102" alignment="0" attributes="0">
35+
<Component id="repositoriesLabel" min="-2" max="-2" attributes="0"/>
36+
<EmptySpace max="-2" attributes="0"/>
37+
<Component id="repositoriesSeparator" max="32767" attributes="0"/>
38+
</Group>
39+
<Group type="102" attributes="0">
40+
<Component id="defaultQueriesLabel" min="-2" max="-2" attributes="0"/>
41+
<EmptySpace max="-2" attributes="0"/>
42+
<Component id="defaultQueriesSeparator" max="32767" attributes="0"/>
43+
</Group>
44+
<Group type="102" attributes="0">
45+
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
46+
<Group type="103" groupAlignment="0" attributes="0">
47+
<Component id="showParentRepositoryCheckBox" min="-2" max="-2" attributes="0"/>
48+
<Component id="createdByMeCheckBox" min="-2" max="-2" attributes="0"/>
49+
<Component id="openCheckBox" min="-2" max="-2" attributes="0"/>
50+
<Component id="assignedToMeCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
51+
</Group>
52+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
53+
</Group>
3154
</Group>
55+
<EmptySpace max="-2" attributes="0"/>
3256
</Group>
3357
</Group>
34-
<EmptySpace max="32767" attributes="0"/>
3558
</Group>
3659
</Group>
3760
</DimensionLayout>
3861
<DimensionLayout dim="1">
3962
<Group type="103" groupAlignment="0" attributes="0">
4063
<Group type="102" alignment="0" attributes="0">
4164
<EmptySpace max="-2" attributes="0"/>
42-
<Component id="defaultQueriesLabel" min="-2" max="-2" attributes="0"/>
65+
<Group type="103" groupAlignment="1" attributes="0">
66+
<Component id="defaultQueriesLabel" min="-2" max="-2" attributes="0"/>
67+
<Component id="defaultQueriesSeparator" min="-2" pref="10" max="-2" attributes="0"/>
68+
</Group>
4369
<EmptySpace max="-2" attributes="0"/>
4470
<Component id="openCheckBox" min="-2" max="-2" attributes="0"/>
4571
<EmptySpace max="-2" attributes="0"/>
46-
<Component id="assignedToMeCheckBox" min="-2" max="-2" attributes="0"/>
47-
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
48-
<Component id="createdByMeCheckBox" min="-2" max="-2" attributes="0"/>
49-
<EmptySpace type="unrelated" max="-2" attributes="0"/>
50-
<Component id="repositoriesLabel" min="-2" max="-2" attributes="0"/>
72+
<Group type="103" groupAlignment="1" attributes="0">
73+
<Group type="102" attributes="0">
74+
<Component id="assignedToMeCheckBox" min="-2" max="-2" attributes="0"/>
75+
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
76+
<Component id="createdByMeCheckBox" min="-2" max="-2" attributes="0"/>
77+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
78+
<Component id="repositoriesLabel" min="-2" max="-2" attributes="0"/>
79+
</Group>
80+
<Component id="repositoriesSeparator" min="-2" pref="10" max="-2" attributes="0"/>
81+
</Group>
5182
<EmptySpace max="-2" attributes="0"/>
5283
<Component id="showParentRepositoryCheckBox" min="-2" max="-2" attributes="0"/>
53-
<EmptySpace pref="28" max="32767" attributes="0"/>
84+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
85+
<Group type="103" groupAlignment="1" attributes="0">
86+
<Component id="issuesLabel" min="-2" max="-2" attributes="0"/>
87+
<Component id="issuesSeparator" min="-2" pref="10" max="-2" attributes="0"/>
88+
</Group>
89+
<EmptySpace max="-2" attributes="0"/>
90+
<Component id="insertTemplateCheckBox" min="-2" max="-2" attributes="0"/>
91+
<EmptySpace max="32767" attributes="0"/>
5492
</Group>
5593
</Group>
5694
</DimensionLayout>
5795
</Layout>
5896
<SubComponents>
97+
<Component class="javax.swing.JSeparator" name="defaultQueriesSeparator">
98+
</Component>
5999
<Component class="javax.swing.JLabel" name="defaultQueriesLabel">
60100
<Properties>
61101
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -84,6 +124,8 @@
84124
</Property>
85125
</Properties>
86126
</Component>
127+
<Component class="javax.swing.JSeparator" name="repositoriesSeparator">
128+
</Component>
87129
<Component class="javax.swing.JLabel" name="repositoriesLabel">
88130
<Properties>
89131
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -101,5 +143,21 @@
101143
</Property>
102144
</Properties>
103145
</Component>
146+
<Component class="javax.swing.JSeparator" name="issuesSeparator">
147+
</Component>
148+
<Component class="javax.swing.JLabel" name="issuesLabel">
149+
<Properties>
150+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
151+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/options/Bundle.properties" key="GitHubIssuesOptionsPanel.issuesLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
152+
</Property>
153+
</Properties>
154+
</Component>
155+
<Component class="javax.swing.JCheckBox" name="insertTemplateCheckBox">
156+
<Properties>
157+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
158+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/options/Bundle.properties" key="GitHubIssuesOptionsPanel.insertTemplateCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
159+
</Property>
160+
</Properties>
161+
</Component>
104162
</SubComponents>
105163
</Form>

0 commit comments

Comments
 (0)