KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > wizards > TagHandlerPanel


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.wizards;
21
22 import java.awt.Dimension JavaDoc;
23 import org.openide.util.NbBundle;
24 import org.netbeans.modules.web.api.webmodule.WebModule;
25
26 /** A single panel for a wizard - the GUI portion.
27  *
28  * @author mk115033
29  */

30 public class TagHandlerPanel extends javax.swing.JPanel JavaDoc {
31
32     /** The wizard panel descriptor associated with this GUI panel.
33      * If you need to fire state changes or something similar, you can
34      * use this handle to do so.
35      */

36     private TagHandlerSelection wizardPanel;
37     private String JavaDoc j2eeVersion;
38     /** Create the wizard panel and set up some basic properties. */
39     public TagHandlerPanel(TagHandlerSelection wizardPanel, String JavaDoc j2eeVersion) {
40         this.wizardPanel=wizardPanel;
41         this.j2eeVersion=j2eeVersion;
42         initComponents();
43         // Provide a name in the title bar.
44
setName(NbBundle.getMessage(TagHandlerPanel.class, "TITLE_tagHandlerPanel"));
45         if (WebModule.J2EE_13_LEVEL.equals(j2eeVersion)) {
46             simpleTagButton.setEnabled(false);
47             bodyTagButton.setSelected(true);
48         } else {
49             simpleTagButton.setSelected(true);
50         }
51         /*
52         // Optional: provide a special description for this pane.
53         // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed
54         // (see descriptor in standard iterator template for an example of this).
55         try {
56             putClientProperty ("WizardPanel_helpURL", // NOI18N
57                 new URL ("nbresloc:/org/netbeans/modules/web/wizards/TagHandlerHelp.html")); // NOI18N
58         } catch (MalformedURLException mfue) {
59             throw new IllegalStateException (mfue.toString ());
60         }
61          */

62         // a11y part
63

64         //issue #84131
65
int height = jLabel1.getFontMetrics(jLabel1.getFont()).getHeight() * 6 + 35;
66         if (height > this.getHeight()) {
67             Dimension JavaDoc dim = new Dimension JavaDoc(this.getWidth(), height);
68             setMinimumSize(dim);
69             setPreferredSize(dim);
70         }
71
72     }
73     
74     /** This method is called from within the constructor to
75      * initialize the form.
76      * WARNING: Do NOT modify this code. The content of this method is
77      * always regenerated by the Form Editor.
78      */

79     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
80
private void initComponents() {
81         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
82
83         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
84         simpleTagButton = new javax.swing.JRadioButton JavaDoc();
85         bodyTagButton = new javax.swing.JRadioButton JavaDoc();
86         jLabel1 = new javax.swing.JLabel JavaDoc();
87         jLabel2 = new javax.swing.JLabel JavaDoc();
88         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
89         descriptionArea = new javax.swing.JTextArea JavaDoc();
90
91         setRequestFocusEnabled(false);
92         setLayout(new java.awt.GridBagLayout JavaDoc());
93
94         buttonGroup1.add(simpleTagButton);
95         simpleTagButton.setMnemonic(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "LBL_SimpleTag_Mnemonic").charAt(0));
96         simpleTagButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "OPT_SimpleTag")); // NOI18N
97
simpleTagButton.setMargin(new java.awt.Insets JavaDoc(2, 2, 0, 2));
98         simpleTagButton.addItemListener(new java.awt.event.ItemListener JavaDoc() {
99             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
100                 TagHandlerPanel.this.itemStateChanged(evt);
101             }
102         });
103         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
104         gridBagConstraints.gridx = 0;
105         gridBagConstraints.gridy = 1;
106         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
107         add(simpleTagButton, gridBagConstraints);
108         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle"); // NOI18N
109
simpleTagButton.getAccessibleContext().setAccessibleDescription(bundle.getString("DESC_SimpleTag")); // NOI18N
110

111         buttonGroup1.add(bodyTagButton);
112         bodyTagButton.setMnemonic(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "LBL_BodyTag_Mnemonic").charAt(0));
113         bodyTagButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "OPT_BodyTag")); // NOI18N
114
bodyTagButton.setMargin(new java.awt.Insets JavaDoc(0, 2, 2, 2));
115         bodyTagButton.addItemListener(new java.awt.event.ItemListener JavaDoc() {
116             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
117                 TagHandlerPanel.this.itemStateChanged(evt);
118             }
119         });
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
121         gridBagConstraints.gridx = 0;
122         gridBagConstraints.gridy = 2;
123         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
124         add(bodyTagButton, gridBagConstraints);
125         bodyTagButton.getAccessibleContext().setAccessibleDescription(bundle.getString("DESC_BodyTag")); // NOI18N
126

127         jLabel1.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "LBL_TagSupportClass")); // NOI18N
128
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
129         gridBagConstraints.gridx = 0;
130         gridBagConstraints.gridy = 0;
131         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
132         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 2, 0);
133         add(jLabel1, gridBagConstraints);
134
135         jLabel2.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_Description_mnem").charAt(0));
136         jLabel2.setLabelFor(descriptionArea);
137         jLabel2.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "LBL_description")); // NOI18N
138
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
139         gridBagConstraints.gridx = 0;
140         gridBagConstraints.gridy = 3;
141         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
142         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 0, 0);
143         add(jLabel2, gridBagConstraints);
144
145         descriptionArea.setEditable(false);
146         descriptionArea.setLineWrap(true);
147         descriptionArea.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "DESC_SimpleTag")); // NOI18N
148
descriptionArea.setWrapStyleWord(true);
149         jScrollPane1.setViewportView(descriptionArea);
150         descriptionArea.getAccessibleContext().setAccessibleDescription(bundle.getString("A11Y_DESC_Description")); // NOI18N
151

152         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
153         gridBagConstraints.gridx = 0;
154         gridBagConstraints.gridy = 4;
155         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
156         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
157         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
158         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
159         gridBagConstraints.weightx = 1.0;
160         gridBagConstraints.weighty = 1.0;
161         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 6);
162         add(jScrollPane1, gridBagConstraints);
163     }// </editor-fold>//GEN-END:initComponents
164

165     private void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_itemStateChanged
166
// TODO add your handling code here:
167
if (simpleTagButton.isSelected())
168             descriptionArea.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "DESC_SimpleTag"));
169         else
170             descriptionArea.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanel.class, "DESC_BodyTag"));
171         wizardPanel.fireChangeEvent();
172     }//GEN-LAST:event_itemStateChanged
173

174     // Variables declaration - do not modify//GEN-BEGIN:variables
175
private javax.swing.JRadioButton JavaDoc bodyTagButton;
176     private javax.swing.ButtonGroup JavaDoc buttonGroup1;
177     private javax.swing.JTextArea JavaDoc descriptionArea;
178     private javax.swing.JLabel JavaDoc jLabel1;
179     private javax.swing.JLabel JavaDoc jLabel2;
180     private javax.swing.JScrollPane JavaDoc jScrollPane1;
181     private javax.swing.JRadioButton JavaDoc simpleTagButton;
182     // End of variables declaration//GEN-END:variables
183

184     boolean isBodyTagSupport() {
185         return bodyTagButton.isSelected();
186     }
187
188 }
189
Popular Tags