KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > project > ui > groups > AdHocGroupEditPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.project.ui.groups;
21
22 /**
23  * Panel to configure state of an existing ad-hoc group.
24  * Applicable in advanced mode.
25  * @author Jesse Glick
26  */

27 public class AdHocGroupEditPanel extends GroupEditPanel {
28
29     private final AdHocGroup g;
30
31     public AdHocGroupEditPanel(AdHocGroup g) {
32         this.g = g;
33         initComponents();
34         nameField.setText(g.getName());
35         autoSynchCheckbox.setSelected(g.isAutoSynch());
36         updateSynchButton();
37     }
38
39     public void applyChanges() {
40         g.setName(nameField.getText().trim());
41         g.setAutoSynch(autoSynchCheckbox.isSelected());
42     }
43
44     private void updateSynchButton() {
45         synchButton.setEnabled(!autoSynchCheckbox.isSelected() && !g.isPristine());
46     }
47
48     /** This method is called from within the constructor to
49      * initialize the form.
50      * WARNING: Do NOT modify this code. The content of this method is
51      * always regenerated by the Form Editor.
52      */

53     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
54
private void initComponents() {
55
56         nameLabel = new javax.swing.JLabel JavaDoc();
57         nameField = new javax.swing.JTextField JavaDoc();
58         autoSynchCheckbox = new javax.swing.JCheckBox JavaDoc();
59         synchButton = new javax.swing.JButton JavaDoc();
60
61         nameLabel.setLabelFor(nameField);
62         org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(AdHocGroupEditPanel.class, "AdHocGroupEditPanel.nameLabel.text")); // NOI18N
63

64         org.openide.awt.Mnemonics.setLocalizedText(autoSynchCheckbox, org.openide.util.NbBundle.getMessage(AdHocGroupEditPanel.class, "AdHocGroupEditPanel.autoSynchCheckbox.text")); // NOI18N
65
autoSynchCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
66         autoSynchCheckbox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
67         autoSynchCheckbox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
68             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
69                 autoSynchCheckboxActionPerformed(evt);
70             }
71         });
72
73         org.openide.awt.Mnemonics.setLocalizedText(synchButton, org.openide.util.NbBundle.getMessage(AdHocGroupEditPanel.class, "AdHocGroupEditPanel.synchButton.text")); // NOI18N
74
synchButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
75             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
76                 synchButtonActionPerformed(evt);
77             }
78         });
79
80         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
81         this.setLayout(layout);
82         layout.setHorizontalGroup(
83             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
84             .add(layout.createSequentialGroup()
85                 .addContainerGap()
86                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
87                     .add(layout.createSequentialGroup()
88                         .add(nameLabel)
89                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
90                         .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 363, Short.MAX_VALUE))
91                     .add(autoSynchCheckbox)
92                     .add(layout.createSequentialGroup()
93                         .add(synchButton)
94                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 272, Short.MAX_VALUE)))
95                 .addContainerGap())
96         );
97         layout.setVerticalGroup(
98             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
99             .add(layout.createSequentialGroup()
100                 .addContainerGap()
101                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
102                     .add(nameLabel)
103                     .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
104                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
105                 .add(autoSynchCheckbox)
106                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
107                 .add(synchButton)
108                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
109         );
110     }// </editor-fold>//GEN-END:initComponents
111

112     private void synchButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_synchButtonActionPerformed
113
g.synch();
114         updateSynchButton();
115     }//GEN-LAST:event_synchButtonActionPerformed
116

117     private void autoSynchCheckboxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_autoSynchCheckboxActionPerformed
118
updateSynchButton();
119     }//GEN-LAST:event_autoSynchCheckboxActionPerformed
120

121     
122     // Variables declaration - do not modify//GEN-BEGIN:variables
123
private javax.swing.JCheckBox JavaDoc autoSynchCheckbox;
124     private javax.swing.JTextField JavaDoc nameField;
125     private javax.swing.JLabel JavaDoc nameLabel;
126     private javax.swing.JButton JavaDoc synchButton;
127     // End of variables declaration//GEN-END:variables
128

129 }
130
Popular Tags