KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > core > wizard > DocumentPanel


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 package org.netbeans.modules.xml.core.wizard;
20
21 /**
22  *
23  * @author Petr Kuzel
24  */

25 public class DocumentPanel extends AbstractPanel {
26     /** Serial Version UID */
27     private static final long serialVersionUID = 3793605846188902177L;
28
29
30     /** Creates new form DocumentPanel */
31     public DocumentPanel() {
32         initComponents();
33         initAccessibility();
34
35         // switch off extensibity point - not implemented
36
otherRadioButton.setVisible(false);
37         otherComboBox.setVisible(false);
38     }
39
40     /** This method is called from within the constructor to
41      * initialize the form.
42      * WARNING: Do NOT modify this code. The content of this method is
43      * always regenerated by the Form Editor.
44      */

45     private void initComponents() {//GEN-BEGIN:initComponents
46
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
47
48         buttonGroup = new javax.swing.ButtonGroup JavaDoc();
49         descTextArea = new javax.swing.JTextArea JavaDoc();
50         wellformedRadioButton = new javax.swing.JRadioButton JavaDoc();
51         dtdConstrainedRadioButton = new javax.swing.JRadioButton JavaDoc();
52         schemaConstrainedRadioButton = new javax.swing.JRadioButton JavaDoc();
53         otherRadioButton = new javax.swing.JRadioButton JavaDoc();
54         otherComboBox = new javax.swing.JComboBox JavaDoc();
55         fillPanel = new javax.swing.JPanel JavaDoc();
56
57         setLayout(new java.awt.GridBagLayout JavaDoc());
58
59         setName(Util.THIS.getString("PROP_doc_panel_name"));
60         descTextArea.setEditable(false);
61         descTextArea.setLineWrap(true);
62         descTextArea.setText(Util.THIS.getString("MSG_document_panel_desc"));
63         descTextArea.setWrapStyleWord(true);
64         descTextArea.setDisabledTextColor(descTextArea.getForeground());
65         descTextArea.setEnabled(false);
66         descTextArea.setOpaque(false);
67         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
68         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
69         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
70         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 12, 0);
71         add(descTextArea, gridBagConstraints);
72
73         wellformedRadioButton.setText(Util.THIS.getString("PROP_wellformed_name"));
74         wellformedRadioButton.setToolTipText(Util.THIS.getString("PROP_doc_wellformedRadioButton_desc"));
75         buttonGroup.add(wellformedRadioButton);
76         wellformedRadioButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
77             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
78                 wellformedRadioButtonActionPerformed(evt);
79             }
80         });
81
82         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
83         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
84         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
85         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
86         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 12, 0);
87         add(wellformedRadioButton, gridBagConstraints);
88
89         dtdConstrainedRadioButton.setText(Util.THIS.getString("PROP_dtd_doc_name"));
90         dtdConstrainedRadioButton.setToolTipText(Util.THIS.getString("PROP_doc_dtdConstrainedRadioButton_desc"));
91         buttonGroup.add(dtdConstrainedRadioButton);
92         dtdConstrainedRadioButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
93             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
94                 dtdConstrainedRadioButtonActionPerformed(evt);
95             }
96         });
97
98         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
99         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
100         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
101         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
102         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 12, 0);
103         add(dtdConstrainedRadioButton, gridBagConstraints);
104
105         schemaConstrainedRadioButton.setText(Util.THIS.getString("PROP_schema_doc_name"));
106         schemaConstrainedRadioButton.setToolTipText(Util.THIS.getString("PROP_doc_schemaConstrainedRadioButton_desc"));
107         buttonGroup.add(schemaConstrainedRadioButton);
108         schemaConstrainedRadioButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
109             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
110                 schemaConstrainedRadioButtonActionPerformed(evt);
111             }
112         });
113
114         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
115         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
116         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
117         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
118         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 12, 0);
119         add(schemaConstrainedRadioButton, gridBagConstraints);
120
121         otherRadioButton.setText(Util.THIS.getString("PROP_other_doc_name"));
122         buttonGroup.add(otherRadioButton);
123         otherRadioButton.setEnabled(false);
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
126         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 12);
127         add(otherRadioButton, gridBagConstraints);
128
129         otherComboBox.setEnabled(false);
130         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
131         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
132         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
133         gridBagConstraints.weightx = 1.0;
134         add(otherComboBox, gridBagConstraints);
135
136         fillPanel.setLayout(null);
137
138         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
139         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
140         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
141         gridBagConstraints.weightx = 1.0;
142         gridBagConstraints.weighty = 1.0;
143         add(fillPanel, gridBagConstraints);
144
145     }//GEN-END:initComponents
146

147     private void initAccessibility() {
148
149         Util util = Util.THIS;
150         wellformedRadioButton.setMnemonic(util.getChar("PROP_doc_wellformedRadioButton_mne"));
151         schemaConstrainedRadioButton.setMnemonic(util.getChar("PROP_doc_schemaConstrainedRadioButton_mne"));
152         dtdConstrainedRadioButton.setMnemonic(util.getChar("PROP_doc_dtdConstrainedRadioButton_mne"));
153         getAccessibleContext().setAccessibleDescription(descTextArea.getText());
154     }
155     
156     private void schemaConstrainedRadioButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_schemaConstrainedRadioButtonActionPerformed
157
updateModel();
158     }//GEN-LAST:event_schemaConstrainedRadioButtonActionPerformed
159

160     private void dtdConstrainedRadioButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_dtdConstrainedRadioButtonActionPerformed
161
updateModel();
162     }//GEN-LAST:event_dtdConstrainedRadioButtonActionPerformed
163

164     private void wellformedRadioButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_wellformedRadioButtonActionPerformed
165
updateModel();
166     }//GEN-LAST:event_wellformedRadioButtonActionPerformed
167

168     /** User just entered the panel, init view by model values
169      */

170     protected void initView() {
171         int type = model.getType();
172         switch (type) {
173             case DocumentModel.NONE:
174                 wellformedRadioButton.setSelected(true);
175                 break;
176             case DocumentModel.DTD:
177                 dtdConstrainedRadioButton.setSelected(true);
178                 break;
179             case DocumentModel.SCHEMA:
180                 schemaConstrainedRadioButton.setSelected(true);
181                 break;
182             case DocumentModel.OTHER:
183                 otherRadioButton.setSelected(true);
184                 break;
185             default:
186                 throw new IllegalStateException JavaDoc();
187         }
188     }
189     
190     /** User just leaved the panel, update model
191      */

192     protected void updateModel() {
193         if (wellformedRadioButton.isSelected()) {
194             model.setType(model.NONE);
195         } else if (dtdConstrainedRadioButton.isSelected()) {
196             model.setType(model.DTD);
197         } else if (schemaConstrainedRadioButton.isSelected()) {
198             model.setType(model.SCHEMA);
199         } else {
200             model.setType(model.OTHER);
201         }
202     }
203     
204     /** User just reentered the panel.
205      */

206     protected void updateView() {
207         // no dynamic update needed
208
}
209     
210     // Variables declaration - do not modify//GEN-BEGIN:variables
211
private javax.swing.ButtonGroup JavaDoc buttonGroup;
212     private javax.swing.JRadioButton JavaDoc otherRadioButton;
213     private javax.swing.JRadioButton JavaDoc wellformedRadioButton;
214     private javax.swing.JRadioButton JavaDoc schemaConstrainedRadioButton;
215     private javax.swing.JComboBox JavaDoc otherComboBox;
216     private javax.swing.JTextArea JavaDoc descTextArea;
217     private javax.swing.JRadioButton JavaDoc dtdConstrainedRadioButton;
218     private javax.swing.JPanel JavaDoc fillPanel;
219     // End of variables declaration//GEN-END:variables
220

221 }
222
Popular Tags