KickJava   Java API By Example, From Geeks To Geeks.

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


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.web.wizards;
21
22
23 import javax.swing.DefaultCellEditor JavaDoc;
24 import javax.swing.ListSelectionModel JavaDoc;
25 import javax.swing.event.ListSelectionListener JavaDoc;
26 import javax.swing.table.JTableHeader JavaDoc;
27 import javax.swing.table.TableColumnModel JavaDoc;
28 import javax.swing.DefaultCellEditor JavaDoc;
29 import org.netbeans.api.project.ProjectUtils;
30
31 import org.openide.filesystems.FileObject;
32 import org.openide.filesystems.FileUtil;
33 import org.openide.util.NbBundle;
34 import org.openide.ErrorManager;
35 import org.openide.DialogDisplayer;
36 import org.openide.NotifyDescriptor;
37
38 import org.netbeans.api.project.Project;
39 import org.netbeans.api.project.Sources;
40 import org.netbeans.api.project.SourceGroup;
41 import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
42 import org.netbeans.modules.web.api.webmodule.WebModule;
43 import org.netbeans.spi.project.support.GenericSources;
44
45 import org.openide.loaders.TemplateWizard;
46
47 import org.netbeans.modules.web.taglib.TLDDataObject;
48 import org.netbeans.spi.project.ui.templates.support.Templates;
49
50 import org.netbeans.modules.web.core.Util;
51 import org.netbeans.modules.xml.multiview.ui.EditDialog;
52
53  /**
54  * @author mk115033
55  */

56 public class TagHandlerPanelGUI extends javax.swing.JPanel JavaDoc implements ListSelectionListener JavaDoc {
57     
58     private TagInfoPanel panel;
59     private TemplateWizard wiz;
60     private Project proj;
61     private SourceGroup[] folders;
62     private String JavaDoc target;
63     private FileObject tldFo;
64     private java.util.Set JavaDoc tagValues;
65     
66     /** Creates new form TagHandlerPanelGUI */
67     public TagHandlerPanelGUI(TemplateWizard wiz, final TagInfoPanel panel, Project proj, SourceGroup[] folders) {
68         initComponents();
69         this.wiz=wiz;
70         this.panel=panel;
71         this.proj=proj;
72         this.folders=folders;
73         attrTable.setModel(new AttrTableModel(
74             new String JavaDoc[]{"attrName","attrType","attrRequired","attrRtexprvalue"}));//NOI18N
75
attrTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
76         attrTable.setIntercellSpacing(new java.awt.Dimension JavaDoc(6, 6));
77         //DefaultCellEditor dce = new DefaultCellEditor(new javax.swing.JCheckBox());
78
//DefaultCellEditor dce1 = new DefaultCellEditor(new javax.swing.JComboBox());
79
//attrTable.getColumnModel().getColumn(1).setCellEditor(dce1);
80
//attrTable.getColumnModel().getColumn(2).setCellEditor(dce);
81
//attrTable.getColumnModel().getColumn(3).setCellEditor(dce);
82
attrTable.setPreferredScrollableViewportSize(new java.awt.Dimension JavaDoc(300, 200));
83         setName( org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class,"LBL_configure_TLD"));
84         attrTable.getSelectionModel().addListSelectionListener(this);
85         nameTextField.getDocument().addDocumentListener(new javax.swing.event.DocumentListener JavaDoc() {
86             public void removeUpdate(javax.swing.event.DocumentEvent JavaDoc evt) {
87                 panel.fireChangeEvent();
88             }
89             public void insertUpdate(javax.swing.event.DocumentEvent JavaDoc evt) {
90                 panel.fireChangeEvent();
91             }
92             public void changedUpdate(javax.swing.event.DocumentEvent JavaDoc evt) {
93                 panel.fireChangeEvent();
94             }
95         });
96     }
97
98     /** This method is called from within the constructor to
99      * initialize the form.
100      * WARNING: Do NOT modify this code. The content of this method is
101      * always regenerated by the Form Editor.
102      */

103     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
104
private void initComponents() {
105         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
106
107         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
108         tldTextField = new javax.swing.JTextField JavaDoc();
109         browseButton = new javax.swing.JButton JavaDoc();
110         tldFileLabel = new javax.swing.JLabel JavaDoc();
111         tagNameLabel = new javax.swing.JLabel JavaDoc();
112         nameTextField = new javax.swing.JTextField JavaDoc();
113         tagClassLabel = new javax.swing.JLabel JavaDoc();
114         classTextField = new javax.swing.JTextField JavaDoc();
115         jPanel1 = new javax.swing.JPanel JavaDoc();
116         emptyButton = new javax.swing.JRadioButton JavaDoc();
117         scriptlessButton = new javax.swing.JRadioButton JavaDoc();
118         tegdependentButton = new javax.swing.JRadioButton JavaDoc();
119         jPanel2 = new javax.swing.JPanel JavaDoc();
120         attrLabel = new javax.swing.JLabel JavaDoc();
121         jPanel3 = new javax.swing.JPanel JavaDoc();
122         newButton = new javax.swing.JButton JavaDoc();
123         editButton = new javax.swing.JButton JavaDoc();
124         deleteButton = new javax.swing.JButton JavaDoc();
125         bodyContentLb = new javax.swing.JLabel JavaDoc();
126         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
127         descriptionLabel = new javax.swing.JLabel JavaDoc();
128         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
129         attrTable = new javax.swing.JTable JavaDoc();
130
131         setLayout(new java.awt.GridBagLayout JavaDoc());
132
133         getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagHandlerPanel2"));
134         tldTextField.setEditable(false);
135         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
136         gridBagConstraints.gridx = 1;
137         gridBagConstraints.gridy = 2;
138         gridBagConstraints.gridwidth = 2;
139         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
140         gridBagConstraints.weightx = 2.0;
141         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 12, 0);
142         add(tldTextField, gridBagConstraints);
143         tldTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TLDFile"));
144
145         browseButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_Browse_Mnemonic").charAt(0));
146         browseButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_Browse"));
147         browseButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
148             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
149                 browseButtonActionPerformed(evt);
150             }
151         });
152
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 3;
155         gridBagConstraints.gridy = 2;
156         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
157         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 12, 6);
158         add(browseButton, gridBagConstraints);
159         browseButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_Browse"));
160
161         tldFileLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TLDName_mnem").charAt(0));
162         tldFileLabel.setLabelFor(tldTextField);
163         tldFileLabel.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_tldFile"));
164         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
165         gridBagConstraints.gridx = 0;
166         gridBagConstraints.gridy = 2;
167         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
168         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 12, 0);
169         add(tldFileLabel, gridBagConstraints);
170
171         tagNameLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TagName_mnem").charAt(0));
172         tagNameLabel.setLabelFor(nameTextField);
173         tagNameLabel.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_tagName"));
174         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
175         gridBagConstraints.gridx = 0;
176         gridBagConstraints.gridy = 3;
177         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
178         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 6, 0);
179         add(tagNameLabel, gridBagConstraints);
180
181         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
182         gridBagConstraints.gridx = 1;
183         gridBagConstraints.gridy = 3;
184         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
185         gridBagConstraints.weightx = 1.0;
186         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 6, 0);
187         add(nameTextField, gridBagConstraints);
188         nameTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagName"));
189
190         tagClassLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_ClassName_mnem").charAt(0));
191         tagClassLabel.setLabelFor(classTextField);
192         tagClassLabel.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_tagHandlerClass"));
193         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
194         gridBagConstraints.gridx = 0;
195         gridBagConstraints.gridy = 4;
196         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
197         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
198         add(tagClassLabel, gridBagConstraints);
199
200         classTextField.setEditable(false);
201         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
202         gridBagConstraints.gridx = 1;
203         gridBagConstraints.gridy = 4;
204         gridBagConstraints.gridwidth = 2;
205         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
206         gridBagConstraints.weightx = 2.0;
207         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
208         add(classTextField, gridBagConstraints);
209         classTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagClass"));
210
211         buttonGroup1.add(emptyButton);
212         emptyButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TagEmpty_mnem").charAt(0));
213         emptyButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "OPT_emptyBodyContent"));
214         jPanel1.add(emptyButton);
215         emptyButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagEmpty"));
216
217         buttonGroup1.add(scriptlessButton);
218         scriptlessButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TagScriptless_mnem").charAt(0));
219         scriptlessButton.setSelected(true);
220         scriptlessButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "OPT_scriptlessBodyContent"));
221         jPanel1.add(scriptlessButton);
222         scriptlessButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagScriptless"));
223
224         buttonGroup1.add(tegdependentButton);
225         tegdependentButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TagTagdependent_mnem").charAt(0));
226         tegdependentButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "OPT_tagdependentBodyContent"));
227         jPanel1.add(tegdependentButton);
228         tegdependentButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagTagdependent"));
229
230         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
231         gridBagConstraints.gridx = 1;
232         gridBagConstraints.gridy = 6;
233         gridBagConstraints.gridwidth = 2;
234         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
235         gridBagConstraints.weightx = 1.0;
236         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 0, 0);
237         add(jPanel1, gridBagConstraints);
238
239         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
240         gridBagConstraints.gridx = 2;
241         gridBagConstraints.gridy = 3;
242         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
243         gridBagConstraints.weightx = 1.0;
244         add(jPanel2, gridBagConstraints);
245
246         attrLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_Attribs_mnem").charAt(0));
247         attrLabel.setLabelFor(attrTable);
248         attrLabel.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "TITLE_attributes"));
249         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
250         gridBagConstraints.gridx = 0;
251         gridBagConstraints.gridy = 7;
252         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
253         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 6, 6, 0);
254         add(attrLabel, gridBagConstraints);
255
256         jPanel3.setLayout(new java.awt.GridBagLayout JavaDoc());
257
258         newButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_new_mnemonic").charAt(0));
259         newButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_newButton"));
260         newButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
261             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
262                 newButtonActionPerformed(evt);
263             }
264         });
265
266         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
267         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
268         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
269         jPanel3.add(newButton, gridBagConstraints);
270         newButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_newButton"));
271
272         editButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_edit_mnemonic").charAt(0));
273         editButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_editButton"));
274         editButton.setEnabled(false);
275         editButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
276             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
277                 editButtonActionPerformed(evt);
278             }
279         });
280
281         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
282         gridBagConstraints.gridx = 0;
283         gridBagConstraints.gridy = 1;
284         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
285         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
286         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
287         jPanel3.add(editButton, gridBagConstraints);
288         editButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_editButton"));
289
290         deleteButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_delete_mnemonic").charAt(0));
291         deleteButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_deleteButton"));
292         deleteButton.setEnabled(false);
293         deleteButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
294             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
295                 deleteButtonActionPerformed(evt);
296             }
297         });
298
299         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
300         gridBagConstraints.gridx = 0;
301         gridBagConstraints.gridy = 2;
302         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
303         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
304         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
305         jPanel3.add(deleteButton, gridBagConstraints);
306         deleteButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_deleteButton"));
307
308         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
309         gridBagConstraints.gridx = 3;
310         gridBagConstraints.gridy = 8;
311         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
312         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
313         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 6, 0);
314         add(jPanel3, gridBagConstraints);
315
316         bodyContentLb.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "LBL_bodyContent"));
317         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
318         gridBagConstraints.gridx = 0;
319         gridBagConstraints.gridy = 6;
320         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
321         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 6, 0, 0);
322         add(bodyContentLb, gridBagConstraints);
323
324         jCheckBox1.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_AddToTLD_mnem").charAt(0));
325         jCheckBox1.setSelected(true);
326         jCheckBox1.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "OPT_addToTLD"));
327         jCheckBox1.addItemListener(new java.awt.event.ItemListener JavaDoc() {
328             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
329                 jCheckBox1ItemStateChanged(evt);
330             }
331         });
332
333         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
334         gridBagConstraints.gridx = 0;
335         gridBagConstraints.gridy = 0;
336         gridBagConstraints.gridwidth = 4;
337         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
338         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 12, 0);
339         add(jCheckBox1, gridBagConstraints);
340         jCheckBox1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("OPT_addToTLD"));
341
342         descriptionLabel.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "HINT_tldFile"));
343         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
344         gridBagConstraints.gridx = 0;
345         gridBagConstraints.gridy = 1;
346         gridBagConstraints.gridwidth = 4;
347         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
348         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
349         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 6, 6);
350         add(descriptionLabel, gridBagConstraints);
351
352         jScrollPane1.setViewportView(attrTable);
353         attrTable.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_AttrTable"));
354
355         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
356         gridBagConstraints.gridx = 0;
357         gridBagConstraints.gridy = 8;
358         gridBagConstraints.gridwidth = 3;
359         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
360         gridBagConstraints.weightx = 1.0;
361         gridBagConstraints.weighty = 1.0;
362         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 6, 0);
363         add(jScrollPane1, gridBagConstraints);
364
365     }
366     // </editor-fold>//GEN-END:initComponents
367

368     private void deleteButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_deleteButtonActionPerformed
369
// TODO add your handling code here:
370
int row = attrTable.getSelectedRow();
371         if (row>=0) {
372             ((AttrTableModel)attrTable.getModel()).removeRow(row);
373             ((AttrTableModel)attrTable.getModel()).fireTableRowsDeleted(row, row);
374         }
375     }//GEN-LAST:event_deleteButtonActionPerformed
376

377     private void newButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_newButtonActionPerformed
378
// TODO add your handling code here:
379
String JavaDoc title = org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "TITLE_attr_add"); //NOI18N
380
final AttrDialog panel = new AttrDialog();
381         final AttrTableModel tableModel = (AttrTableModel)attrTable.getModel();
382         EditDialog editDialog = new EditDialog(panel,title, true) {
383             protected String JavaDoc validate() {
384                 String JavaDoc newAttrName = panel.getAttrName();
385                 //String errorMessage=null;
386
if (newAttrName.length()==0) {
387                     return NbBundle.getMessage(TagHandlerPanelGUI.class,
388                                                        "MSG_attr_no_name");
389                 } else if (!isJavaIdentifier(newAttrName)) {
390                     return NbBundle.getMessage(TagHandlerPanelGUI.class,
391                                                        "MSG_wrong_attr_name",newAttrName);
392                 } else {
393                     Object JavaDoc[][] attrs = tableModel.getAttributes();
394                     for (int i=0;i<attrs.length;i++){
395                         if (newAttrName.equals(attrs[i][0])) {
396                             return NbBundle.getMessage(TagHandlerPanelGUI.class,
397                                                            "MSG_attr_exists");
398                         }
399                     }
400                 }
401                 return null;
402             }
403         };
404         editDialog.setValid(false);
405         javax.swing.event.DocumentListener JavaDoc docListener = new EditDialog.DocListener(editDialog);
406         panel.getAttrNameTF().getDocument().addDocumentListener(docListener);
407         java.awt.Dialog JavaDoc d = org.openide.DialogDisplayer.getDefault().createDialog(editDialog);
408         d.getAccessibleContext().setAccessibleDescription(editDialog.getDialogPanel().getAccessibleContext().getAccessibleDescription());
409         d.show();
410         panel.getAttrNameTF().getDocument().removeDocumentListener(docListener);
411         
412         if (editDialog.getValue().equals(EditDialog.OK_OPTION)) {
413                 int rowCount = tableModel.getRowCount();
414                 tableModel.addRow(panel.getAttrName(),panel.getAttrType(),panel.isRequired(),panel.isRtexpr());
415                 tableModel.fireTableRowsInserted(rowCount, rowCount);
416         }
417     }//GEN-LAST:event_newButtonActionPerformed
418

419     private void browseButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseButtonActionPerformed
420
// TODO add your handling code here:
421
if ( browseButton == evt.getSource() ) {
422             org.openide.filesystems.FileObject fo=null;
423             // Show the browse dialog
424
if (folders!=null) fo = BrowseFolders.showDialog(folders,
425                     TLDDataObject.class,
426                     "");
427             else {
428                 Sources sources = ProjectUtils.getSources(proj);
429                 fo = BrowseFolders.showDialog( sources.getSourceGroups( Sources.TYPE_GENERIC ),
430                                                org.openide.loaders.DataFolder.class,
431                                                "");
432             }
433             
434             if ( fo != null) {
435                 tldFo=fo;
436                 FileObject targetFolder=Templates.getTargetFolder(wiz);
437                 WebModule wm = WebModule.getWebModule(targetFolder);
438                 //tldTextField.setText(target==null || target.length()==0?fo.getNameExt():target+"/"+fo.getNameExt());
439
tldTextField.setText( FileUtil.getRelativePath( (wm==null?proj.getProjectDirectory():wm.getDocumentBase()), fo ) );
440                 try {
441                     java.io.InputStream JavaDoc is = tldFo.getInputStream();
442                     // get existing tag names for testing duplicity
443
tagValues = Util.getTagValues(is, new String JavaDoc[]{"tag","tag-file"},"name"); //NOI18N
444
is.close();
445                 } catch (java.io.IOException JavaDoc ex) {}
446                   catch (org.xml.sax.SAXException JavaDoc ex ){}
447                 panel.fireChangeEvent();
448             }
449                         
450         }
451     }//GEN-LAST:event_browseButtonActionPerformed
452

453     public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc e) {
454         if (e.getValueIsAdjusting()) return;
455         if (attrTable.getSelectionModel().isSelectionEmpty()) {
456             editButton.setEnabled(false);
457             deleteButton.setEnabled(false);
458         } else {
459             editButton.setEnabled(true);
460             deleteButton.setEnabled(true);
461         }
462     }
463
464     private void jCheckBox1ItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_jCheckBox1ItemStateChanged
465
// TODO add your handling code here:
466
if (jCheckBox1.isSelected()) {
467             //tldTextField.setEnabled(true);
468
browseButton.setEnabled(true);
469             nameTextField.setEnabled(true);
470             emptyButton.setEnabled(true);
471             scriptlessButton.setEnabled(true);
472             tegdependentButton.setEnabled(true);
473         } else {
474             //tldTextField.setEnabled(false);
475
browseButton.setEnabled(false);
476             nameTextField.setEnabled(false);
477             emptyButton.setEnabled(false);
478             scriptlessButton.setEnabled(false);
479             tegdependentButton.setEnabled(false);
480         }
481         panel.fireChangeEvent();
482     }//GEN-LAST:event_jCheckBox1ItemStateChanged
483

484     private void editButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_editButtonActionPerformed
485
// TODO add your handling code here:
486
String JavaDoc title = org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "TITLE_attr_edit"); //NOI18N
487
final AttrTableModel tableModel = (AttrTableModel)attrTable.getModel();
488         final int row = attrTable.getSelectedRow();
489         String JavaDoc attrName = (String JavaDoc)tableModel.getValueAt(row,0);
490         String JavaDoc attrType = (String JavaDoc)tableModel.getValueAt(row,1);
491         boolean required = ((Boolean JavaDoc)tableModel.getValueAt(row,2)).booleanValue();
492         boolean rtexpr = ((Boolean JavaDoc)tableModel.getValueAt(row,3)).booleanValue();
493         final AttrDialog panel = new AttrDialog(attrName,attrType,required,rtexpr);
494         EditDialog editDialog = new EditDialog(panel,title, false) {
495             protected String JavaDoc validate() {
496                 String JavaDoc newAttrName = panel.getAttrName();
497                 if (newAttrName.length()==0) {
498                     return NbBundle.getMessage(TagHandlerPanelGUI.class,
499                                                        "MSG_attr_no_name");
500                 } else if (!isJavaIdentifier(newAttrName)) {
501                     return NbBundle.getMessage(TagHandlerPanelGUI.class,
502                                                        "MSG_wrong_attr_name",newAttrName);
503                 } else {
504                     Object JavaDoc[][] attrs = tableModel.getAttributes();
505                     for (int i=0;i<attrs.length;i++){
506                         if (i!=row && newAttrName.equals(attrs[i][0])) {
507                             return NbBundle.getMessage(TagHandlerPanelGUI.class,
508                                                            "MSG_attr_exists");
509                         }
510                     }
511                 }
512                 return null;
513             }
514         };
515         javax.swing.event.DocumentListener JavaDoc docListener = new EditDialog.DocListener(editDialog);
516         panel.getAttrNameTF().getDocument().addDocumentListener(docListener);
517
518         java.awt.Dialog JavaDoc d = org.openide.DialogDisplayer.getDefault().createDialog(editDialog);
519         d.getAccessibleContext().setAccessibleDescription(editDialog.getDialogPanel().getAccessibleContext().getAccessibleDescription());
520         d.show();
521         panel.getAttrNameTF().getDocument().removeDocumentListener(docListener);
522         if (editDialog.getValue().equals(EditDialog.OK_OPTION)) {
523             tableModel.setData(panel.getAttrName(),panel.getAttrType(),panel.isRequired(),panel.isRtexpr(),row);
524             tableModel.fireTableRowsUpdated(row, row);
525         }
526     }//GEN-LAST:event_editButtonActionPerformed
527

528     
529     // Variables declaration - do not modify//GEN-BEGIN:variables
530
private javax.swing.JLabel JavaDoc attrLabel;
531     private javax.swing.JTable JavaDoc attrTable;
532     private javax.swing.JLabel JavaDoc bodyContentLb;
533     private javax.swing.JButton JavaDoc browseButton;
534     private javax.swing.ButtonGroup JavaDoc buttonGroup1;
535     private javax.swing.JTextField JavaDoc classTextField;
536     private javax.swing.JButton JavaDoc deleteButton;
537     private javax.swing.JLabel JavaDoc descriptionLabel;
538     private javax.swing.JButton JavaDoc editButton;
539     private javax.swing.JRadioButton JavaDoc emptyButton;
540     private javax.swing.JCheckBox JavaDoc jCheckBox1;
541     private javax.swing.JPanel JavaDoc jPanel1;
542     private javax.swing.JPanel JavaDoc jPanel2;
543     private javax.swing.JPanel JavaDoc jPanel3;
544     private javax.swing.JScrollPane JavaDoc jScrollPane1;
545     private javax.swing.JTextField JavaDoc nameTextField;
546     private javax.swing.JButton JavaDoc newButton;
547     private javax.swing.JRadioButton JavaDoc scriptlessButton;
548     private javax.swing.JLabel JavaDoc tagClassLabel;
549     private javax.swing.JLabel JavaDoc tagNameLabel;
550     private javax.swing.JRadioButton JavaDoc tegdependentButton;
551     private javax.swing.JLabel JavaDoc tldFileLabel;
552     private javax.swing.JTextField JavaDoc tldTextField;
553     // End of variables declaration//GEN-END:variables
554

555     
556     String JavaDoc getTagName() {
557         return nameTextField.getText();
558     }
559     
560     void setTagName(String JavaDoc name) {
561         nameTextField.setText(name);
562     }
563     
564     void setClassName(String JavaDoc name) {
565         classTextField.setText(name);
566     }
567     
568     FileObject getTLDFile() {
569         return tldFo;
570     }
571     
572     java.util.Set JavaDoc getTagValues() {
573         return tagValues;
574     }
575     
576     boolean isEmpty() {
577         return emptyButton.isSelected();
578     }
579     boolean isScriptless() {
580         return scriptlessButton.isSelected();
581     }
582     boolean isTegdependent() {
583         return tegdependentButton.isSelected();
584     }
585     
586     boolean writeToTLD() {
587         return jCheckBox1.isSelected();
588     }
589     
590     Object JavaDoc[][] getAttributes() {
591         return ((AttrTableModel)attrTable.getModel()).getAttributes();
592     }
593     
594     void setBodySupport(boolean bodySupport) {
595         if (bodySupport) scriptlessButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "OPT_jspBodyContent"));
596         else scriptlessButton.setText(org.openide.util.NbBundle.getMessage(TagHandlerPanelGUI.class, "OPT_scriptlessBodyContent"));
597     }
598     
599     private boolean isJavaIdentifier(String JavaDoc s) {
600         if (s.length()==0) return false;
601         if (!Character.isJavaIdentifierStart(s.charAt(0))) return false;
602         for (int i=1;i<s.length();i++)
603             if (!Character.isJavaIdentifierPart(s.charAt(i))) return false;
604         return true;
605     }
606     
607 }
608
Popular Tags