KickJava   Java API By Example, From Geeks To Geeks.

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


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
23 import org.openide.DialogDescriptor;
24 import org.openide.DialogDisplayer;
25 import org.openide.NotifyDescriptor;
26 import org.openide.util.NbBundle;
27
28 /** Panel and dialog for Finish wizard action.
29  * @author Ales Kemr
30  */

31 class FinishDialog extends javax.swing.JPanel JavaDoc {
32
33     /** The only Finish panel instance in system */
34     private static FinishDialog finishPanel;
35     /** The dialog descriptor of Finish dialog */
36     private static DialogDescriptor dialogDescriptor = null;
37     /** The Finish dialog */
38     private static java.awt.Dialog JavaDoc dialog = null;
39     
40     private static boolean restart = true;
41     
42     static final long serialVersionUID =-4861236822808181670L;
43     /** Creates new form FinishPanel */
44     public FinishDialog() {
45         initComponents ();
46         
47         initAccessibility();
48     }
49
50     /** This method is called from within the constructor to
51      * initialize the form.
52      * WARNING: Do NOT modify this code. The content of this method is
53      * always regenerated by the FormEditor.
54      */

55     private void initComponents() {//GEN-BEGIN:initComponents
56
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
57
58         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
59         commentTextArea = new javax.swing.JTextArea JavaDoc();
60         restartRadioButton = new javax.swing.JRadioButton JavaDoc();
61         laterRadioButton = new javax.swing.JRadioButton JavaDoc();
62
63         setLayout(new java.awt.GridBagLayout JavaDoc());
64
65         commentTextArea.setBackground(restartRadioButton.getBackground());
66         commentTextArea.setColumns(50);
67         commentTextArea.setEditable(false);
68         commentTextArea.setLineWrap(true);
69         commentTextArea.setRows(6);
70         commentTextArea.setText(getBundle("LBL_Finish_Comment"));
71         commentTextArea.setWrapStyleWord(true);
72         commentTextArea.setDisabledTextColor(java.awt.Color.black);
73         commentTextArea.setEnabled(false);
74         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
75         gridBagConstraints.gridx = 0;
76         gridBagConstraints.gridy = 0;
77         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
78         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
79         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
80         gridBagConstraints.weightx = 1.0;
81         add(commentTextArea, gridBagConstraints);
82
83         restartRadioButton.setMnemonic(getBundle("CTL_Finish_Restart_Mnemonic").charAt(0));
84         restartRadioButton.setSelected(true);
85         restartRadioButton.setText(getBundle("CTL_Finish_Restart"));
86         buttonGroup1.add(restartRadioButton);
87         restartRadioButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
88             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
89                 restartRadioButtonActionPerformed(evt);
90             }
91         });
92
93         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
94         gridBagConstraints.gridx = 0;
95         gridBagConstraints.gridy = 1;
96         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
97         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
98         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 24, 3, 0);
99         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
100         add(restartRadioButton, gridBagConstraints);
101
102         laterRadioButton.setMnemonic(getBundle("CTL_Finish_Later_Mnemonic").charAt(0));
103         laterRadioButton.setText(getBundle("CTL_Finish_Later"));
104         buttonGroup1.add(laterRadioButton);
105         laterRadioButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
106             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
107                 laterRadioButtonActionPerformed(evt);
108             }
109         });
110
111         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
112         gridBagConstraints.gridx = 0;
113         gridBagConstraints.gridy = 2;
114         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
115         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
116         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
117         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 24, 0, 0);
118         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
119         gridBagConstraints.weighty = 1.0;
120         add(laterRadioButton, gridBagConstraints);
121
122     }//GEN-END:initComponents
123

124     private void laterRadioButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_laterRadioButtonActionPerformed
125
restart = false;
126     }//GEN-LAST:event_laterRadioButtonActionPerformed
127

128     private void restartRadioButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_restartRadioButtonActionPerformed
129
restart = true;
130     }//GEN-LAST:event_restartRadioButtonActionPerformed
131

132     private void initAccessibility(){
133         getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("LBL_Finish_Comment"));
134         getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("CTL_Finish_Title"));
135         commentTextArea.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSD_Comment_Text"));
136         commentTextArea.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACSN_Comment_Text"));
137         restartRadioButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACS_Finish_Restart"));
138         laterRadioButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/autoupdate/Bundle").getString("ACS_Finish_Later"));
139     }
140
141     // Variables declaration - do not modify//GEN-BEGIN:variables
142
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
143     private javax.swing.JTextArea JavaDoc commentTextArea;
144     private javax.swing.JRadioButton JavaDoc laterRadioButton;
145     private javax.swing.JRadioButton JavaDoc restartRadioButton;
146     // End of variables declaration//GEN-END:variables
147

148     static boolean showDialog() {
149         if ( dialogDescriptor == null ) {
150             createDialog();
151         }
152         
153         return DialogDisplayer.getDefault().notify( dialogDescriptor ).equals( NotifyDescriptor.OK_OPTION );
154     }
155     
156     static boolean isRestart() {
157         return restart;
158     }
159     
160     private static void createDialog() {
161         finishPanel = new FinishDialog();
162         
163         dialogDescriptor = new DialogDescriptor(
164                                  finishPanel,
165                                  getBundle( "CTL_Finish_Title" ));
166     }
167
168     private static String JavaDoc getBundle( String JavaDoc key ) {
169         return NbBundle.getMessage( FinishDialog.class, key );
170     }
171 }
172
Popular Tags