001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.java.source.tasklist;
042:
043: import java.util.HashMap;
044: import java.util.Map;
045: import java.util.Map.Entry;
046: import java.util.prefs.Preferences;
047: import javax.swing.JCheckBox;
048: import javax.swing.UIManager;
049: import javax.swing.event.ChangeListener;
050: import org.netbeans.modules.java.source.usages.RepositoryUpdater;
051: import org.openide.util.ChangeSupport;
052:
053: /**
054: *
055: * @author Jan Lahoda
056: */
057: public class TasklistOptionsPanel extends javax.swing.JPanel {
058:
059: private ChangeSupport cs;
060: private Map<JCheckBox, String> compilerSettings;
061:
062: /** Creates new form TasklistOptionsPanel */
063: public TasklistOptionsPanel() {
064: cs = new ChangeSupport(this );
065: initComponents();
066:
067: if ("Windows".equals(UIManager.getLookAndFeel().getID())) //NOI18N
068: setOpaque(false);
069:
070: }
071:
072: void addChangeListener(ChangeListener l) {
073: cs.addChangeListener(l);
074: }
075:
076: /** This method is called from within the constructor to
077: * initialize the form.
078: * WARNING: Do NOT modify this code. The content of this method is
079: * always regenerated by the Form Editor.
080: */
081: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
082: private void initComponents() {
083: java.awt.GridBagConstraints gridBagConstraints;
084:
085: enableTasklist = new javax.swing.JCheckBox();
086: enableDependencies = new javax.swing.JCheckBox();
087: enableBadges = new javax.swing.JCheckBox();
088:
089: setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8,
090: 8));
091: setLayout(new java.awt.GridBagLayout());
092:
093: org.openide.awt.Mnemonics.setLocalizedText(enableTasklist,
094: org.openide.util.NbBundle.getBundle(
095: TasklistOptionsPanel.class).getString(
096: "jCheckBox1.text")); // NOI18N
097: enableTasklist.setBorder(javax.swing.BorderFactory
098: .createEmptyBorder(0, 0, 0, 0));
099: enableTasklist.setMargin(new java.awt.Insets(0, 0, 0, 0));
100: enableTasklist.setOpaque(false);
101: enableTasklist
102: .addChangeListener(new javax.swing.event.ChangeListener() {
103: public void stateChanged(
104: javax.swing.event.ChangeEvent evt) {
105: enableTasklistStateChanged(evt);
106: }
107: });
108: gridBagConstraints = new java.awt.GridBagConstraints();
109: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
110: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
111: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
112: gridBagConstraints.weightx = 1.0;
113: gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
114: add(enableTasklist, gridBagConstraints);
115: enableTasklist.getAccessibleContext().setAccessibleDescription(
116: org.openide.util.NbBundle.getMessage(
117: TasklistOptionsPanel.class,
118: "ACD_EnableTaskList")); // NOI18N
119:
120: org.openide.awt.Mnemonics.setLocalizedText(enableDependencies,
121: org.openide.util.NbBundle.getBundle(
122: TasklistOptionsPanel.class).getString(
123: "jCheckBox2.text")); // NOI18N
124: enableDependencies.setBorder(javax.swing.BorderFactory
125: .createEmptyBorder(0, 0, 0, 0));
126: enableDependencies.setMargin(new java.awt.Insets(0, 0, 0, 0));
127: enableDependencies.setOpaque(false);
128: gridBagConstraints = new java.awt.GridBagConstraints();
129: gridBagConstraints.gridx = 0;
130: gridBagConstraints.gridy = 1;
131: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
132: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
133: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
134: gridBagConstraints.weightx = 1.0;
135: gridBagConstraints.insets = new java.awt.Insets(0, 20, 8, 0);
136: add(enableDependencies, gridBagConstraints);
137: enableDependencies.getAccessibleContext()
138: .setAccessibleDescription(
139: org.openide.util.NbBundle.getMessage(
140: TasklistOptionsPanel.class,
141: "ACD_EnableDependencies")); // NOI18N
142:
143: org.openide.awt.Mnemonics.setLocalizedText(enableBadges,
144: org.openide.util.NbBundle.getBundle(
145: TasklistOptionsPanel.class).getString(
146: "jCheckBox1.text_1")); // NOI18N
147: enableBadges.setBorder(javax.swing.BorderFactory
148: .createEmptyBorder(0, 0, 0, 0));
149: enableBadges.setMargin(new java.awt.Insets(0, 0, 0, 0));
150: enableBadges.setOpaque(false);
151: gridBagConstraints = new java.awt.GridBagConstraints();
152: gridBagConstraints.gridx = 0;
153: gridBagConstraints.gridy = 2;
154: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
155: gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
156: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
157: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
158: gridBagConstraints.weightx = 1.0;
159: gridBagConstraints.weighty = 1.0;
160: gridBagConstraints.insets = new java.awt.Insets(0, 20, 8, 0);
161: add(enableBadges, gridBagConstraints);
162: enableBadges.getAccessibleContext().setAccessibleDescription(
163: org.openide.util.NbBundle.getMessage(
164: TasklistOptionsPanel.class,
165: "ACD_EnableErrorBadges")); // NOI18N
166:
167: getAccessibleContext().setAccessibleName(
168: org.openide.util.NbBundle.getMessage(
169: TasklistOptionsPanel.class,
170: "ACN_TaskListOptionsPanel")); // NOI18N
171: getAccessibleContext().setAccessibleDescription(
172: org.openide.util.NbBundle.getMessage(
173: TasklistOptionsPanel.class,
174: "ACD_TaskListOptionsPanel")); // NOI18N
175: }// </editor-fold>//GEN-END:initComponents
176:
177: private void enableTasklistStateChanged(
178: javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_enableTasklistStateChanged
179: // TODO add your handling code here:
180: updateEnabled();
181: }//GEN-LAST:event_enableTasklistStateChanged
182:
183: //XXX: shoudl fire changes
184:
185: // Variables declaration - do not modify//GEN-BEGIN:variables
186: private javax.swing.JCheckBox enableBadges;
187: private javax.swing.JCheckBox enableDependencies;
188: private javax.swing.JCheckBox enableTasklist;
189:
190: // End of variables declaration//GEN-END:variables
191:
192: public void setTasklistEnabled(boolean enabled) {
193: enableTasklist.setSelected(enabled);
194: updateEnabled();
195: }
196:
197: public void setDependenciesEnabled(boolean enabled) {
198: enableDependencies.setSelected(enabled);
199: }
200:
201: public void setBadgesEnabled(boolean enabled) {
202: enableBadges.setSelected(enabled);
203: }
204:
205: public boolean getTasklistEnabled() {
206: return enableTasklist.isSelected();
207: }
208:
209: public boolean getDependenciesEnabled() {
210: return enableDependencies.isSelected();
211: }
212:
213: public boolean getBadgesEnabled() {
214: return enableBadges.isSelected();
215: }
216:
217: private void updateEnabled() {
218: enableDependencies.setEnabled(enableTasklist.isSelected());
219: enableBadges.setEnabled(enableTasklist.isSelected());
220: }
221:
222: // public void fillInCompilerSettings() {
223: // Preferences p = CompilerSettings.getNode();
224: //
225: // for (Entry<JCheckBox, String> e : compilerSettings.entrySet()) {
226: // e.getKey().setSelected(CompilerSettings.get(p, e.getValue()));
227: // }
228: //
229: // updateCompilerSettingsEnabled();
230: // }
231: //
232:
233: // public boolean isCompilerSettingsChanged() {
234: // Preferences p = CompilerSettings.getNode();
235: //
236: // for (Entry<JCheckBox, String> e : compilerSettings.entrySet()) {
237: // if (e.getKey().isSelected() != CompilerSettings.get(p, e.getValue()))
238: // return true;
239: // }
240: //
241: // return false;
242: // }
243: //
244: // public void storeCompilerSettings() {
245: //
246: // Preferences p = CompilerSettings.getNode();
247: //
248: // for (Entry<JCheckBox, String> e : compilerSettings.entrySet()) {
249: // p.putBoolean(e.getValue(), e.getKey().isSelected());
250: // }
251: // RepositoryUpdater.getDefault().rebuildAll(false);
252: // }
253:
254: }
|