KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > SetupPanel


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.autoupdate;
21
22 import javax.swing.JPanel JavaDoc;
23 import java.beans.*;
24
25 import org.openide.WizardDescriptor;
26 import org.openide.util.NbBundle;
27
28 /** Setup wizard panel UI component that represents AU settings.
29  * Plays role of UI for SetupWizardPanel.
30  *
31  * @author akemr
32  */

33 class SetupPanel extends javax.swing.JPanel JavaDoc implements PropertyChangeListener {
34
35     private JPanel JavaDoc lPanel;
36
37     /** Creates new form SetupPanel */
38     public SetupPanel() {
39         initComponents ();
40         jLabel1.setDisplayedMnemonic (getBundle ("AutoCheckInfo.jLabel2.mnemonic").charAt (0));
41         jLabel1.setLabelFor (periodComboBox);
42         beforeCheckBox.setMnemonic (getBundle ("AutoCheckInfo.jCheckBox1.mnemonic").charAt (0));
43         negativCheckBox.setMnemonic (getBundle ("AutoCheckInfo.jCheckBox2.mnemonic").charAt (0));
44         setName(getBundle ("CTL_Settings_Name"));
45         putClientProperty ("WizardPanel_contentData", new String JavaDoc[] {getName ()}); // NOI18N
46
putClientProperty ("WizardPanel_contentSelectedIndex", new Integer JavaDoc (0)); // NOI18N
47
setPreferredSize(new java.awt.Dimension JavaDoc(500, 300));
48
49         String JavaDoc[] tags = (new Settings.PeriodPropertyEditor()).getTags();
50         for ( int i = 0; i < tags.length; i++ )
51             periodComboBox.addItem( tags[i] );
52
53         beforeCheckBox.getAccessibleContext().setAccessibleDescription(getBundle("ACS_AutoCheckInfo.jCheckBox1.text"));
54         negativCheckBox.getAccessibleContext().setAccessibleDescription(getBundle("ACS_AutoCheckInfo.jCheckBox2.text"));
55         getAccessibleContext().setAccessibleDescription(getBundle("ACS_AutoCheckInfo"));
56         periodComboBox.getAccessibleContext ().setAccessibleDescription (getBundle("ACS_AutoCheckInfo.jLabel2.text")); //NOI18N
57

58         
59         initializePanel();
60     }
61
62     /** This method is called from within the constructor to
63      * initialize the form.
64      * WARNING: Do NOT modify this code. The content of this method is
65      * always regenerated by the Form Editor.
66      */

67     private void initComponents() {//GEN-BEGIN:initComponents
68
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
69
70         periodPanel = new javax.swing.JPanel JavaDoc();
71         jLabel1 = new javax.swing.JLabel JavaDoc();
72         periodComboBox = new javax.swing.JComboBox JavaDoc();
73         checkPanel = new javax.swing.JPanel JavaDoc();
74         beforeCheckBox = new javax.swing.JCheckBox JavaDoc();
75         negativCheckBox = new javax.swing.JCheckBox JavaDoc();
76
77         setLayout(new java.awt.GridBagLayout JavaDoc());
78
79         periodPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
80
81         jLabel1.setText(getBundle("AutoCheckInfo.jLabel2.text"));
82         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
83         gridBagConstraints.gridx = 0;
84         gridBagConstraints.gridy = 0;
85         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
86         gridBagConstraints.ipadx = 8;
87         gridBagConstraints.ipady = 14;
88         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
89         periodPanel.add(jLabel1, gridBagConstraints);
90
91         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
92         gridBagConstraints.gridx = 1;
93         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
94         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
95         periodPanel.add(periodComboBox, gridBagConstraints);
96
97         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
98         gridBagConstraints.gridx = 0;
99         gridBagConstraints.gridy = 0;
100         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
101         gridBagConstraints.weightx = 1.0;
102         add(periodPanel, gridBagConstraints);
103
104         checkPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
105
106         beforeCheckBox.setText(getBundle("AutoCheckInfo.jCheckBox1.text"));
107         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
108         gridBagConstraints.gridx = 0;
109         gridBagConstraints.gridy = 0;
110         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
111         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
112         gridBagConstraints.weightx = 1.0;
113         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 20, 0, 0);
114         checkPanel.add(beforeCheckBox, gridBagConstraints);
115
116         negativCheckBox.setText(getBundle("AutoCheckInfo.jCheckBox2.text"));
117         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
118         gridBagConstraints.gridx = 0;
119         gridBagConstraints.gridy = 1;
120         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
121         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
122         gridBagConstraints.weightx = 1.0;
123         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
124         checkPanel.add(negativCheckBox, gridBagConstraints);
125
126         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
127         gridBagConstraints.gridx = 0;
128         gridBagConstraints.gridy = 1;
129         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
130         add(checkPanel, gridBagConstraints);
131
132     }//GEN-END:initComponents
133

134
135     // Variables declaration - do not modify//GEN-BEGIN:variables
136
private javax.swing.JPanel JavaDoc periodPanel;
137     private javax.swing.JCheckBox JavaDoc negativCheckBox;
138     private javax.swing.JCheckBox JavaDoc beforeCheckBox;
139     private javax.swing.JPanel JavaDoc checkPanel;
140     private javax.swing.JComboBox JavaDoc periodComboBox;
141     private javax.swing.JLabel JavaDoc jLabel1;
142     // End of variables declaration//GEN-END:variables
143

144     /** Initialize panel from NB setting
145      */

146     private void initializePanel() {
147         Settings settings = Settings.getShared();
148         int period = settings.getPeriod();
149         
150         beforeCheckBox.setSelected( settings.isAskBefore() );
151         negativCheckBox.setSelected( settings.isNegativeResults() );
152
153         periodComboBox.setSelectedIndex( period );
154         
155         if ( lPanel != null ) remove(lPanel);
156         lPanel = new ServerPanel();
157         
158         java.awt.GridBagConstraints JavaDoc gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
159         gridBagConstraints1.gridx = 0;
160         gridBagConstraints1.gridy = 2;
161         gridBagConstraints1.insets = new java.awt.Insets JavaDoc(12, 20, 0, 0);
162         gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
163         gridBagConstraints1.weightx = 1.0;
164         gridBagConstraints1.weighty = 1.0;
165         add(lPanel, gridBagConstraints1);
166     }
167     
168     /** Initializes component from values stored in given descriptor.
169      * Should be called only once, in AWT thread.
170      * Called from aggregator SetupWizardPanel
171      */

172     public void initFromSettings(WizardDescriptor wd) {
173         wd.addPropertyChangeListener(this);
174         if (Boolean.TRUE.equals(wd.getProperty("initializePanel")))
175             initializePanel();
176     }
177     
178     /** Handling of property changes in node structure and setup wizard descriptor
179      */

180     public void propertyChange(PropertyChangeEvent evt) {
181         if ((evt.getSource() instanceof WizardDescriptor)
182             && (WizardDescriptor.PROP_VALUE.equals(evt.getPropertyName()))) {
183                 
184             WizardDescriptor wd = (WizardDescriptor)evt.getSource();
185             if (wd.getValue() == wd.FINISH_OPTION) {
186                 wd.removePropertyChangeListener(this);
187                 Settings settings = Settings.getShared();
188                 settings.setAskBefore( beforeCheckBox.isSelected() );
189                 settings.setNegativeResults( negativCheckBox.isSelected() );
190                 settings.setPeriod( periodComboBox.getSelectedIndex() );
191             }
192         }
193     }
194     
195     private static String JavaDoc getBundle( String JavaDoc key ) {
196         return NbBundle.getMessage( SetupPanel.class, key );
197     }
198 }
199
Popular Tags