Skip to content

Commit 5a34079

Browse files
committed
Add Options
1 parent c1b3288 commit 5a34079

6 files changed

Lines changed: 486 additions & 0 deletions

File tree

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
<artifactId>org-netbeans-modules-team-commons</artifactId>
112112
<version>RELEASE80</version>
113113
</dependency>
114+
<dependency>
115+
<groupId>org.netbeans.api</groupId>
116+
<artifactId>org-openide-util-lookup</artifactId>
117+
<version>RELEASE80</version>
118+
</dependency>
119+
<dependency>
120+
<groupId>org.netbeans.api</groupId>
121+
<artifactId>org-netbeans-modules-options-api</artifactId>
122+
<version>RELEASE80</version>
123+
</dependency>
114124
</dependencies>
115125
<properties>
116126
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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 java.util.prefs.Preferences;
45+
import org.openide.util.NbPreferences;
46+
47+
/**
48+
*
49+
* @author junichi11
50+
*/
51+
public final class GitHubIssuesOptions {
52+
53+
public static final String SUB_PATH = "Team/GitHubIssues"; // NOI18N
54+
private static final String PREFERENCES_PATH = "github.issues"; // NOI18N
55+
private static final String QUERY_ASSIGNED_TO_ME = "query.assigned.to.me"; // NOI18N
56+
private static final String QUERY_CREATED_BY_ME = "query.created.by.me"; // NOI18N
57+
private static final String QUERY_OPEN = "query.open"; // NOI18N
58+
private static final GitHubIssuesOptions INSTANCE = new GitHubIssuesOptions();
59+
60+
private GitHubIssuesOptions() {
61+
}
62+
63+
public static GitHubIssuesOptions getInstance() {
64+
return INSTANCE;
65+
}
66+
67+
public void setOpenQuery(boolean isEnabled) {
68+
getPreferences().putBoolean(QUERY_OPEN, isEnabled);
69+
}
70+
71+
public boolean isOpenQuery() {
72+
return getPreferences().getBoolean(QUERY_OPEN, true);
73+
}
74+
75+
public void setAssignedToMeQuery(boolean isEnabled) {
76+
getPreferences().putBoolean(QUERY_ASSIGNED_TO_ME, isEnabled);
77+
}
78+
79+
public boolean isAssignedToMeQuery() {
80+
return getPreferences().getBoolean(QUERY_ASSIGNED_TO_ME, false);
81+
}
82+
83+
public void setCreatedByMeQuery(boolean isEnabled) {
84+
getPreferences().putBoolean(QUERY_CREATED_BY_ME, isEnabled);
85+
}
86+
87+
public boolean isCreatedByMeQuery() {
88+
return getPreferences().getBoolean(QUERY_CREATED_BY_ME, false);
89+
}
90+
91+
private Preferences getPreferences() {
92+
return NbPreferences.forModule(GitHubIssuesOptions.class).node(PREFERENCES_PATH);
93+
}
94+
95+
}
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>
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
final class GitHubIssuesOptionsPanel extends javax.swing.JPanel {
45+
46+
private static final long serialVersionUID = 1179834339454169527L;
47+
48+
private final GitHubIssuesOptionsPanelController controller;
49+
50+
GitHubIssuesOptionsPanel(GitHubIssuesOptionsPanelController controller) {
51+
this.controller = controller;
52+
initComponents();
53+
// TODO listen to changes in form fields and call controller.changed()
54+
}
55+
56+
/**
57+
* This method is called from within the constructor to initialize the form.
58+
* WARNING: Do NOT modify this code. The content of this method is always
59+
* regenerated by the Form Editor.
60+
*/
61+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
62+
private void initComponents() {
63+
64+
defaultQueriesLabel = new javax.swing.JLabel();
65+
openCheckBox = new javax.swing.JCheckBox();
66+
assignedToMeCheckBox = new javax.swing.JCheckBox();
67+
createdByMeCheckBox = new javax.swing.JCheckBox();
68+
69+
org.openide.awt.Mnemonics.setLocalizedText(defaultQueriesLabel, org.openide.util.NbBundle.getMessage(GitHubIssuesOptionsPanel.class, "GitHubIssuesOptionsPanel.defaultQueriesLabel.text")); // NOI18N
70+
71+
org.openide.awt.Mnemonics.setLocalizedText(openCheckBox, org.openide.util.NbBundle.getMessage(GitHubIssuesOptionsPanel.class, "GitHubIssuesOptionsPanel.openCheckBox.text")); // NOI18N
72+
73+
org.openide.awt.Mnemonics.setLocalizedText(assignedToMeCheckBox, org.openide.util.NbBundle.getMessage(GitHubIssuesOptionsPanel.class, "GitHubIssuesOptionsPanel.assignedToMeCheckBox.text")); // NOI18N
74+
75+
org.openide.awt.Mnemonics.setLocalizedText(createdByMeCheckBox, org.openide.util.NbBundle.getMessage(GitHubIssuesOptionsPanel.class, "GitHubIssuesOptionsPanel.createdByMeCheckBox.text")); // NOI18N
76+
77+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
78+
this.setLayout(layout);
79+
layout.setHorizontalGroup(
80+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
81+
.addGroup(layout.createSequentialGroup()
82+
.addContainerGap()
83+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
84+
.addComponent(defaultQueriesLabel)
85+
.addGroup(layout.createSequentialGroup()
86+
.addGap(12, 12, 12)
87+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
88+
.addComponent(createdByMeCheckBox)
89+
.addComponent(openCheckBox)
90+
.addComponent(assignedToMeCheckBox))))
91+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
92+
);
93+
layout.setVerticalGroup(
94+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95+
.addGroup(layout.createSequentialGroup()
96+
.addContainerGap()
97+
.addComponent(defaultQueriesLabel)
98+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
99+
.addComponent(openCheckBox)
100+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
101+
.addComponent(assignedToMeCheckBox)
102+
.addGap(7, 7, 7)
103+
.addComponent(createdByMeCheckBox)
104+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
105+
);
106+
}// </editor-fold>//GEN-END:initComponents
107+
108+
void load() {
109+
GitHubIssuesOptions options = GitHubIssuesOptions.getInstance();
110+
setOpenQuery(options.isOpenQuery());
111+
setAssignedToMeQuery(options.isAssignedToMeQuery());
112+
setCreatedByMeQuery(options.isCreatedByMeQuery());
113+
}
114+
115+
void store() {
116+
GitHubIssuesOptions options = GitHubIssuesOptions.getInstance();
117+
options.setOpenQuery(isOpenQuery());
118+
options.setAssignedToMeQuery(isAssignedToMeQuery());
119+
options.setCreatedByMeQuery(isCreatedByMeQuery());
120+
}
121+
122+
boolean valid() {
123+
// TODO check whether form is consistent and complete
124+
return true;
125+
}
126+
127+
private boolean isOpenQuery() {
128+
return openCheckBox.isSelected();
129+
}
130+
131+
private boolean isAssignedToMeQuery() {
132+
return assignedToMeCheckBox.isSelected();
133+
}
134+
135+
private boolean isCreatedByMeQuery() {
136+
return createdByMeCheckBox.isSelected();
137+
}
138+
139+
private void setOpenQuery(boolean isEnabled) {
140+
openCheckBox.setSelected(isEnabled);
141+
}
142+
143+
private void setAssignedToMeQuery(boolean isEnabled) {
144+
assignedToMeCheckBox.setSelected(isEnabled);
145+
}
146+
147+
private void setCreatedByMeQuery(boolean isEnabled) {
148+
createdByMeCheckBox.setSelected(isEnabled);
149+
}
150+
151+
// Variables declaration - do not modify//GEN-BEGIN:variables
152+
private javax.swing.JCheckBox assignedToMeCheckBox;
153+
private javax.swing.JCheckBox createdByMeCheckBox;
154+
private javax.swing.JLabel defaultQueriesLabel;
155+
private javax.swing.JCheckBox openCheckBox;
156+
// End of variables declaration//GEN-END:variables
157+
}

0 commit comments

Comments
 (0)