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-2006 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:
042: package org.netbeans.modules.project.ui.groups;
043:
044: /**
045: * Panel to configure state of an existing ad-hoc group.
046: * Applicable in advanced mode.
047: * @author Jesse Glick
048: */
049: public class AdHocGroupEditPanel extends GroupEditPanel {
050:
051: private final AdHocGroup g;
052:
053: public AdHocGroupEditPanel(AdHocGroup g) {
054: this .g = g;
055: initComponents();
056: nameField.setText(g.getName());
057: autoSynchCheckbox.setSelected(g.isAutoSynch());
058: updateSynchButton();
059: }
060:
061: public void applyChanges() {
062: g.setName(nameField.getText().trim());
063: g.setAutoSynch(autoSynchCheckbox.isSelected());
064: }
065:
066: private void updateSynchButton() {
067: synchButton.setEnabled(!autoSynchCheckbox.isSelected()
068: && !g.isPristine());
069: }
070:
071: /** This method is called from within the constructor to
072: * initialize the form.
073: * WARNING: Do NOT modify this code. The content of this method is
074: * always regenerated by the Form Editor.
075: */
076: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
077: private void initComponents() {
078:
079: nameLabel = new javax.swing.JLabel();
080: nameField = new javax.swing.JTextField();
081: autoSynchCheckbox = new javax.swing.JCheckBox();
082: synchButton = new javax.swing.JButton();
083:
084: nameLabel.setLabelFor(nameField);
085: org.openide.awt.Mnemonics.setLocalizedText(nameLabel,
086: org.openide.util.NbBundle.getMessage(
087: AdHocGroupEditPanel.class,
088: "AdHocGroupEditPanel.nameLabel.text")); // NOI18N
089:
090: org.openide.awt.Mnemonics.setLocalizedText(autoSynchCheckbox,
091: org.openide.util.NbBundle.getMessage(
092: AdHocGroupEditPanel.class,
093: "AdHocGroupEditPanel.autoSynchCheckbox.text")); // NOI18N
094: autoSynchCheckbox.setBorder(javax.swing.BorderFactory
095: .createEmptyBorder(0, 0, 0, 0));
096: autoSynchCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
097: autoSynchCheckbox
098: .addActionListener(new java.awt.event.ActionListener() {
099: public void actionPerformed(
100: java.awt.event.ActionEvent evt) {
101: autoSynchCheckboxActionPerformed(evt);
102: }
103: });
104:
105: org.openide.awt.Mnemonics.setLocalizedText(synchButton,
106: org.openide.util.NbBundle.getMessage(
107: AdHocGroupEditPanel.class,
108: "AdHocGroupEditPanel.synchButton.text")); // NOI18N
109: synchButton
110: .addActionListener(new java.awt.event.ActionListener() {
111: public void actionPerformed(
112: java.awt.event.ActionEvent evt) {
113: synchButtonActionPerformed(evt);
114: }
115: });
116:
117: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
118: this );
119: this .setLayout(layout);
120: layout
121: .setHorizontalGroup(layout
122: .createParallelGroup(
123: org.jdesktop.layout.GroupLayout.LEADING)
124: .add(
125: layout
126: .createSequentialGroup()
127: .addContainerGap()
128: .add(
129: layout
130: .createParallelGroup(
131: org.jdesktop.layout.GroupLayout.LEADING)
132: .add(
133: layout
134: .createSequentialGroup()
135: .add(
136: nameLabel)
137: .addPreferredGap(
138: org.jdesktop.layout.LayoutStyle.RELATED)
139: .add(
140: nameField,
141: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
142: 363,
143: Short.MAX_VALUE))
144: .add(
145: autoSynchCheckbox)
146: .add(
147: layout
148: .createSequentialGroup()
149: .add(
150: synchButton)
151: .addPreferredGap(
152: org.jdesktop.layout.LayoutStyle.RELATED,
153: 272,
154: Short.MAX_VALUE)))
155: .addContainerGap()));
156: layout
157: .setVerticalGroup(layout
158: .createParallelGroup(
159: org.jdesktop.layout.GroupLayout.LEADING)
160: .add(
161: layout
162: .createSequentialGroup()
163: .addContainerGap()
164: .add(
165: layout
166: .createParallelGroup(
167: org.jdesktop.layout.GroupLayout.BASELINE)
168: .add(nameLabel)
169: .add(
170: nameField,
171: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
172: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
173: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
174: .addPreferredGap(
175: org.jdesktop.layout.LayoutStyle.RELATED)
176: .add(autoSynchCheckbox)
177: .addPreferredGap(
178: org.jdesktop.layout.LayoutStyle.RELATED)
179: .add(synchButton)
180: .addContainerGap(
181: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
182: Short.MAX_VALUE)));
183: }// </editor-fold>//GEN-END:initComponents
184:
185: private void synchButtonActionPerformed(
186: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_synchButtonActionPerformed
187: g.synch();
188: updateSynchButton();
189: }//GEN-LAST:event_synchButtonActionPerformed
190:
191: private void autoSynchCheckboxActionPerformed(
192: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoSynchCheckboxActionPerformed
193: updateSynchButton();
194: }//GEN-LAST:event_autoSynchCheckboxActionPerformed
195:
196: // Variables declaration - do not modify//GEN-BEGIN:variables
197: private javax.swing.JCheckBox autoSynchCheckbox;
198: private javax.swing.JTextField nameField;
199: private javax.swing.JLabel nameLabel;
200: private javax.swing.JButton synchButton;
201: // End of variables declaration//GEN-END:variables
202:
203: }
|