Skip to content

Commit 3eba870

Browse files
committed
Merge branch 'nb80'
2 parents c1b3288 + 9954327 commit 3eba870

22 files changed

Lines changed: 1167 additions & 93 deletions

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<version>3.13</version>
1414
<extensions>true</extensions>
1515
<configuration>
16+
<codeNameBase>com.junichi11.netbeans.github.issues</codeNameBase>
1617
<verifyRuntime>warn</verifyRuntime>
1718
<licenseName>Common Development and Distribution License (CDDL) v1.0 and GNU General Public License (GPL) v2</licenseName>
1819
<licenseFile>license.txt</licenseFile>
@@ -111,6 +112,16 @@
111112
<artifactId>org-netbeans-modules-team-commons</artifactId>
112113
<version>RELEASE80</version>
113114
</dependency>
115+
<dependency>
116+
<groupId>org.netbeans.api</groupId>
117+
<artifactId>org-openide-util-lookup</artifactId>
118+
<version>RELEASE80</version>
119+
</dependency>
120+
<dependency>
121+
<groupId>org.netbeans.api</groupId>
122+
<artifactId>org-netbeans-modules-options-api</artifactId>
123+
<version>RELEASE80</version>
124+
</dependency>
114125
</dependencies>
115126
<properties>
116127
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.junichi11.netbeans.modules.github.issues.issue.GitHubIssue;
4545
import com.junichi11.netbeans.modules.github.issues.query.GitHubQuery;
4646
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
47+
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepositoryManager;
4748
import org.netbeans.modules.bugtracking.api.Repository;
4849
import org.netbeans.modules.bugtracking.spi.BugtrackingConnector;
4950
import org.netbeans.modules.bugtracking.spi.BugtrackingSupport;
@@ -81,6 +82,7 @@ public Repository createRepository(RepositoryInfo info) {
8182
}
8283

8384
private Repository createRepository(GitHubRepository repository) {
85+
GitHubRepositoryManager.getInstance().add(repository);
8486
GitHubIssues githubIssues = GitHubIssues.getInstance();
8587
BugtrackingSupport<GitHubRepository, GitHubQuery, GitHubIssue> bugtrackingSupport = githubIssues.getBugtrackingSupport();
8688
return bugtrackingSupport.createRepository(

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
*/
4242
package com.junichi11.netbeans.modules.github.issues.issue;
4343

44+
import com.junichi11.netbeans.modules.github.issues.GitHubIssueState;
4445
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
4546
import java.beans.PropertyChangeListener;
4647
import java.beans.PropertyChangeSupport;
@@ -50,6 +51,8 @@
5051
import java.util.Date;
5152
import java.util.LinkedList;
5253
import java.util.List;
54+
import java.util.logging.Level;
55+
import java.util.logging.Logger;
5356
import javax.swing.JTable;
5457
import org.eclipse.egit.github.core.Comment;
5558
import org.eclipse.egit.github.core.Issue;
@@ -79,6 +82,7 @@ public final class GitHubIssue {
7982
public static final String LABEL_NAME_UPDATED = "github.issue.updated"; // NOI18N
8083
public static final String LABEL_NAME_CREATED_BY = "github.issue.created.by"; // NOI18N
8184
public static final String LABEL_NAME_ASSIGNEE = "github.issue.assignee"; // NOI18N
85+
private static final Logger LOGGER = Logger.getLogger(GitHubIssue.class.getName());
8286

8387
public GitHubIssue(GitHubRepository repository) {
8488
this(repository, null);
@@ -194,8 +198,19 @@ public void refreshIssue() {
194198
getRepository().refresh(this);
195199
}
196200

197-
public void addComment(String comment, boolean reresolveAsFixed) {
198-
// TODO addComment
201+
public void addComment(String comment, boolean resolveAsFixed) {
202+
if (resolveAsFixed) {
203+
// close an issue
204+
Issue i = getIssue();
205+
if (i != null) {
206+
GitHubIssueState state = GitHubIssueState.toEnum(i.getState());
207+
if (state != GitHubIssueState.OPEN) {
208+
LOGGER.log(Level.INFO, "This issue({0} #{1}) state is already closed.", new Object[]{i.getTitle(), i.getNumber()}); // NOI18N
209+
return;
210+
}
211+
GitHubIssueSupport.toggleState(this);
212+
}
213+
}
199214
}
200215

201216
public void attachFile(File file, String string, boolean bln) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public void run() {
336336
}
337337

338338
private boolean closeReopen() {
339-
return GitHubIssueSupport.closeReopen(getPanel().getIssue());
339+
return GitHubIssueSupport.toggleState(getPanel().getIssue());
340340
}
341341

342342
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private GitHubIssueSupport() {
7575
* @param gitHubIssue
7676
* @return {@code true} if state was changed, otherwise {@code false}
7777
*/
78-
public static boolean closeReopen(GitHubIssue gitHubIssue) {
78+
public static boolean toggleState(GitHubIssue gitHubIssue) {
7979
if (gitHubIssue == null) {
8080
return false;
8181
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7+
* Other names may be trademarks of their respective owners.
8+
*
9+
* The contents of this file are subject to the terms of either the GNU
10+
* General Public License Version 2 only ("GPL") or the Common
11+
* Development and Distribution License("CDDL") (collectively, the
12+
* "License"). You may not use this file except in compliance with the
13+
* License. You can obtain a copy of the License at
14+
* http://www.netbeans.org/cddl-gplv2.html
15+
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16+
* specific language governing permissions and limitations under the
17+
* License. When distributing the software, include this License Header
18+
* Notice in each file and include the License file at
19+
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
20+
* particular file as subject to the "Classpath" exception as provided
21+
* by Oracle in the GPL Version 2 section of the License file that
22+
* accompanied this code. If applicable, add the following below the
23+
* License Header, with the fields enclosed by brackets [] replaced by
24+
* your own identifying information:
25+
* "Portions Copyrighted [year] [name of copyright owner]"
26+
*
27+
* If you wish your version of this file to be governed by only the CDDL
28+
* or only the GPL Version 2, indicate your decision by adding
29+
* "[Contributor] elects to include this software in this distribution
30+
* under the [CDDL or GPL Version 2] license." If you do not indicate a
31+
* single choice of license, a recipient has the option to distribute
32+
* your version of this file under either the CDDL, the GPL Version 2 or
33+
* to extend the choice of license to its licensees as provided above.
34+
* However, if you add GPL Version 2 code and therefore, elected the GPL
35+
* Version 2 license, then the option applies only if the new code is
36+
* made subject to such option by the copyright holder.
37+
*
38+
* Contributor(s):
39+
*
40+
* Portions Copyrighted 2014 Sun Microsystems, Inc.
41+
*/
42+
package com.junichi11.netbeans.modules.github.issues.options;
43+
44+
import com.junichi11.netbeans.modules.github.issues.query.GitHubDefaultQueries;
45+
import com.junichi11.netbeans.modules.github.issues.query.GitHubDefaultQueries.Type;
46+
import java.util.HashMap;
47+
import java.util.Map;
48+
import java.util.prefs.Preferences;
49+
import org.openide.util.NbPreferences;
50+
51+
/**
52+
*
53+
* @author junichi11
54+
*/
55+
public final class GitHubIssuesOptions {
56+
57+
public static final String SUB_PATH = "Team/GitHubIssues"; // NOI18N
58+
private static final String PREFERENCES_PATH = "github.issues"; // NOI18N
59+
private static final GitHubIssuesOptions INSTANCE = new GitHubIssuesOptions();
60+
61+
private GitHubIssuesOptions() {
62+
}
63+
64+
public static GitHubIssuesOptions getInstance() {
65+
return INSTANCE;
66+
}
67+
68+
public void setOpenQuery(boolean isEnabled) {
69+
getPreferences().putBoolean(Type.OPEN.getOptionKey(), isEnabled);
70+
}
71+
72+
public boolean isOpenQuery() {
73+
return isDefaultQuery(Type.OPEN);
74+
}
75+
76+
public void setAssignedToMeQuery(boolean isEnabled) {
77+
getPreferences().putBoolean(Type.ASSIGNED_TO_ME.getOptionKey(), isEnabled);
78+
}
79+
80+
public boolean isAssignedToMeQuery() {
81+
return isDefaultQuery(Type.ASSIGNED_TO_ME);
82+
}
83+
84+
public void setCreatedByMeQuery(boolean isEnabled) {
85+
getPreferences().putBoolean(Type.CREATED_BY_ME.getOptionKey(), isEnabled);
86+
}
87+
88+
public boolean isCreatedByMeQuery() {
89+
return isDefaultQuery(Type.CREATED_BY_ME);
90+
}
91+
92+
private boolean isDefaultQuery(Type type) {
93+
boolean defaultValue = false;
94+
if (type == Type.OPEN) {
95+
defaultValue = true;
96+
}
97+
return getPreferences().getBoolean(type.getOptionKey(), defaultValue);
98+
}
99+
100+
public Map<GitHubDefaultQueries.Type, Boolean> getDefaultQueryOptions() {
101+
Map<GitHubDefaultQueries.Type, Boolean> map = new HashMap<>();
102+
for (GitHubDefaultQueries.Type type : GitHubDefaultQueries.Type.values()) {
103+
map.put(type, isDefaultQuery(type));
104+
}
105+
return map;
106+
}
107+
108+
private Preferences getPreferences() {
109+
return NbPreferences.forModule(GitHubIssuesOptions.class).node(PREFERENCES_PATH);
110+
}
111+
112+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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="defaultQueriesLabel" min="-2" max="-2" attributes="0"/>
23+
<Group type="102" alignment="0" attributes="0">
24+
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
25+
<Group type="103" groupAlignment="0" attributes="0">
26+
<Component id="createdByMeCheckBox" min="-2" max="-2" attributes="0"/>
27+
<Component id="openCheckBox" min="-2" max="-2" attributes="0"/>
28+
<Component id="assignedToMeCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
29+
</Group>
30+
</Group>
31+
</Group>
32+
<EmptySpace max="32767" attributes="0"/>
33+
</Group>
34+
</Group>
35+
</DimensionLayout>
36+
<DimensionLayout dim="1">
37+
<Group type="103" groupAlignment="0" attributes="0">
38+
<Group type="102" alignment="0" attributes="0">
39+
<EmptySpace max="-2" attributes="0"/>
40+
<Component id="defaultQueriesLabel" min="-2" max="-2" attributes="0"/>
41+
<EmptySpace max="-2" attributes="0"/>
42+
<Component id="openCheckBox" min="-2" max="-2" attributes="0"/>
43+
<EmptySpace max="-2" attributes="0"/>
44+
<Component id="assignedToMeCheckBox" min="-2" max="-2" attributes="0"/>
45+
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
46+
<Component id="createdByMeCheckBox" min="-2" max="-2" attributes="0"/>
47+
<EmptySpace max="32767" attributes="0"/>
48+
</Group>
49+
</Group>
50+
</DimensionLayout>
51+
</Layout>
52+
<SubComponents>
53+
<Component class="javax.swing.JLabel" name="defaultQueriesLabel">
54+
<Properties>
55+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
56+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/options/Bundle.properties" key="GitHubIssuesOptionsPanel.defaultQueriesLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
57+
</Property>
58+
</Properties>
59+
</Component>
60+
<Component class="javax.swing.JCheckBox" name="openCheckBox">
61+
<Properties>
62+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
63+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/options/Bundle.properties" key="GitHubIssuesOptionsPanel.openCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
64+
</Property>
65+
</Properties>
66+
</Component>
67+
<Component class="javax.swing.JCheckBox" name="assignedToMeCheckBox">
68+
<Properties>
69+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
70+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/options/Bundle.properties" key="GitHubIssuesOptionsPanel.assignedToMeCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
71+
</Property>
72+
</Properties>
73+
</Component>
74+
<Component class="javax.swing.JCheckBox" name="createdByMeCheckBox">
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/options/Bundle.properties" key="GitHubIssuesOptionsPanel.createdByMeCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
78+
</Property>
79+
</Properties>
80+
</Component>
81+
</SubComponents>
82+
</Form>

0 commit comments

Comments
 (0)