|
| 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