Skip to content

Commit 3f46d3e

Browse files
committed
Add GitHubOpenQuery as a default query
1 parent 155db0d commit 3f46d3e

3 files changed

Lines changed: 83 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ 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-
private static final String QUERY_OPEN = "query.open"; // NOI18N
6059
private static final GitHubIssuesOptions INSTANCE = new GitHubIssuesOptions();
6160

6261
private GitHubIssuesOptions() {
@@ -67,11 +66,11 @@ public static GitHubIssuesOptions getInstance() {
6766
}
6867

6968
public void setOpenQuery(boolean isEnabled) {
70-
getPreferences().putBoolean(QUERY_OPEN, isEnabled);
69+
getPreferences().putBoolean(Type.OPEN.getOptionKey(), isEnabled);
7170
}
7271

7372
public boolean isOpenQuery() {
74-
return getPreferences().getBoolean(QUERY_OPEN, true);
73+
return isDefaultQuery(Type.OPEN);
7574
}
7675

7776
public void setAssignedToMeQuery(boolean isEnabled) {
@@ -92,6 +91,9 @@ public boolean isCreatedByMeQuery() {
9291

9392
private boolean isDefaultQuery(Type type) {
9493
boolean defaultValue = false;
94+
if (type == Type.OPEN) {
95+
defaultValue = true;
96+
}
9597
return getPreferences().getBoolean(type.getOptionKey(), defaultValue);
9698
}
9799

src/main/java/com/junichi11/netbeans/modules/github/issues/query/GitHubDefaultQueries.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public final class GitHubDefaultQueries {
5858
public enum Type {
5959

6060
// must not change option key name
61+
OPEN("query.open"), // NOI18N
6162
ASSIGNED_TO_ME("query.assigned.to.me"), // NOI18N
6263
CREATED_BY_ME("query.created.by.me"); // NOI18N
6364
private final String optionKey;
@@ -110,6 +111,9 @@ private GitHubQuery getQuery(@NonNull GitHubRepository repository, @NonNull Type
110111
GitHubQuery query = defaultQueries.get(type);
111112
if (query == null) {
112113
switch (type) {
114+
case OPEN:
115+
query = new GitHubOpenQuery(repository);
116+
break;
113117
case ASSIGNED_TO_ME:
114118
query = new GitHubAssignedToMeQuery(repository);
115119
break;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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.query;
43+
44+
import com.junichi11.netbeans.modules.github.issues.issue.GetIssuesParams;
45+
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
46+
import java.util.Map;
47+
import org.openide.util.NbBundle;
48+
49+
public class GitHubOpenQuery extends GitHubDefaultQuery {
50+
51+
public GitHubOpenQuery(GitHubRepository repository) {
52+
super(repository);
53+
}
54+
55+
private GitHubOpenQuery(GitHubRepository repository, String name) {
56+
super(repository, name);
57+
}
58+
59+
@Override
60+
@NbBundle.Messages({
61+
"GitHubOpenQuery.displayName=Open"
62+
})
63+
public String getDisplayName() {
64+
return Bundle.GitHubOpenQuery_displayName();
65+
}
66+
67+
@Override
68+
protected Map<String, String> getFilter() {
69+
GetIssuesParams issuesParams = new GetIssuesParams()
70+
.state(GetIssuesParams.State.OPEN);
71+
return issuesParams.toFilterMap();
72+
}
73+
74+
}

0 commit comments

Comments
 (0)