1 19 20 package org.netbeans.modules.web.wizards; 21 22 import java.awt.event.ActionListener ; 23 import java.io.File ; 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import javax.swing.event.ChangeEvent ; 28 import javax.swing.event.ChangeListener ; 29 import javax.swing.event.DocumentListener ; 30 import org.netbeans.api.project.Project; 31 import org.netbeans.api.project.ProjectUtils; 32 import org.netbeans.api.project.SourceGroup; 33 import org.netbeans.api.project.Sources; 34 import org.netbeans.spi.project.support.GenericSources; 35 import org.openide.filesystems.FileObject; 36 import org.openide.filesystems.FileUtil; 37 import org.openide.util.NbBundle; 38 import org.netbeans.modules.web.api.webmodule.WebModule; 39 40 import org.netbeans.modules.web.taglib.TLDDataObject; 41 import org.netbeans.spi.project.ui.templates.support.Templates; 42 import org.netbeans.modules.web.core.Util; 43 44 46 50 public class TargetChooserPanelGUI extends javax.swing.JPanel implements ActionListener , DocumentListener { 51 private static final String TAG_FILE_FOLDER="WEB-INF/tags"; private static final String TAG_FILE_IN_JAVALIB_FOLDER="META-INF/tags"; private static final String TLD_FOLDER="WEB-INF/tlds"; private static final String TLD_IN_JAVALIB_FOLDER="META-INF"; 56 private TargetChooserPanel wizardPanel; 57 private Project project; 58 private String expectedExtension; 59 private final List listeners = new ArrayList (); 60 private SourceGroup[] folders; 61 private FileType fileType; 62 private WebModule wm; 63 private javax.swing.ButtonGroup buttonGroup1; 65 private javax.swing.JTextArea descriptionArea; 66 private javax.swing.JScrollPane jScrollPane1; 67 private javax.swing.JRadioButton jspSyntaxButton, xmlSyntaxButton; 68 private javax.swing.JCheckBox segmentBox, tldCheckBox; 69 private javax.swing.JButton browseButton1; 70 private javax.swing.JLabel descriptionLabel, optionLabel; 71 private javax.swing.JPanel optionsPanel; 72 73 private java.util.Set tagValues; 74 private String tagName; 75 76 private javax.swing.JTextField uriTextField,prefixTextField, tldTextField, tagNameTextField; 78 private javax.swing.JLabel uriLabel, prefixLabel; 79 private boolean uriWasTyped,prefixWasTyped; 80 boolean tagFileValid=true; 81 private FileObject tldFo; 82 83 84 public TargetChooserPanelGUI(final TargetChooserPanel wizardPanel, Project project, SourceGroup[] folders, FileType fileType) { 85 this.wizardPanel = wizardPanel; 86 this.project = project; 87 this.folders=folders; 88 this.fileType=fileType; 89 initComponents(); 90 getAccessibleContext().setAccessibleDescription( 91 NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_TargetPanel",fileType.toString())); 92 93 if (FileType.JSP.equals(fileType) || FileType.TAG.equals(fileType)) { 94 buttonGroup1 = new javax.swing.ButtonGroup (); 95 jScrollPane1 = new javax.swing.JScrollPane (); 96 descriptionArea = new javax.swing.JTextArea (); 97 segmentBox = new javax.swing.JCheckBox (); 98 descriptionLabel = new javax.swing.JLabel (); 99 optionLabel = new javax.swing.JLabel (); 100 jspSyntaxButton = new javax.swing.JRadioButton (); 101 xmlSyntaxButton = new javax.swing.JRadioButton (); 102 optionsPanel = new javax.swing.JPanel (); 103 104 optionsPanel.setLayout(new java.awt.GridBagLayout ()); 105 106 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.gridx = 0; 108 gridBagConstraints.gridy = 0; 109 gridBagConstraints.gridwidth = 4; 110 gridBagConstraints.weightx = 2; 111 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 112 customPanel.add(optionsPanel, gridBagConstraints); 114 115 segmentBox.addItemListener(new java.awt.event.ItemListener () { 116 public void itemStateChanged(java.awt.event.ItemEvent evt) { 117 checkBoxChanged(evt); 118 } 119 }); 120 121 optionLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Options")); 122 gridBagConstraints = new java.awt.GridBagConstraints (); 123 gridBagConstraints.gridx = 0; 124 gridBagConstraints.gridy = 0; 125 gridBagConstraints.gridheight = 2; 126 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 127 optionsPanel.add(optionLabel, gridBagConstraints); 128 129 jspSyntaxButton.setSelected(true); 130 if (FileType.JSP.equals(fileType)) 131 jspSyntaxButton.setMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_JspStandard_mnem").charAt(0)); 132 else 133 jspSyntaxButton.setMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_TagStandard_mnem").charAt(0)); 134 buttonGroup1.add(jspSyntaxButton); 135 jspSyntaxButton.addItemListener(new java.awt.event.ItemListener () { 136 public void itemStateChanged(java.awt.event.ItemEvent evt) { 137 checkBoxChanged(evt); 138 } 139 }); 140 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 1; 143 gridBagConstraints.gridy = 0; 144 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 145 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 146 optionsPanel.add(jspSyntaxButton, gridBagConstraints); 147 148 xmlSyntaxButton.setMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_JspXml_mnem").charAt(0)); 149 buttonGroup1.add(xmlSyntaxButton); 150 xmlSyntaxButton.addItemListener(new java.awt.event.ItemListener () { 151 public void itemStateChanged(java.awt.event.ItemEvent evt) { 152 checkBoxChanged(evt); 153 } 154 }); 155 156 gridBagConstraints = new java.awt.GridBagConstraints (); 157 gridBagConstraints.gridx = 2; 158 gridBagConstraints.gridy = 0; 159 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 160 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 161 optionsPanel.add(xmlSyntaxButton, gridBagConstraints); 162 163 gridBagConstraints = new java.awt.GridBagConstraints (); 164 gridBagConstraints.gridx = 1; 165 gridBagConstraints.gridy = 1; 166 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 167 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 168 segmentBox.setMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_JspSegment_mnem").charAt(0)); 169 optionsPanel.add(segmentBox, gridBagConstraints); 170 171 gridBagConstraints = new java.awt.GridBagConstraints (); 172 gridBagConstraints.gridx = 3; 173 gridBagConstraints.gridy = 0; 174 gridBagConstraints.gridheight = 2; 175 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 176 gridBagConstraints.weightx = 2.0; 177 optionsPanel.add(new javax.swing.JPanel (), gridBagConstraints); 178 179 descriptionLabel.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_description")); 180 descriptionLabel.setDisplayedMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_Description_mnem").charAt(0)); 181 gridBagConstraints = new java.awt.GridBagConstraints (); 182 gridBagConstraints.gridx = 0; 183 gridBagConstraints.gridy = 1; 184 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 185 gridBagConstraints.insets = new java.awt.Insets (0, 0, 2, 0); 186 descriptionLabel.setLabelFor(descriptionArea); 187 customPanel.add(descriptionLabel, gridBagConstraints); 188 189 descriptionArea.setEditable(false); 190 descriptionArea.setLineWrap(true); 191 descriptionArea.setRows(2); 192 descriptionArea.setWrapStyleWord(true); 193 descriptionArea.setOpaque(false); 194 descriptionArea.getAccessibleContext().setAccessibleDescription(descriptionLabel.getText()); 195 jScrollPane1.setViewportView(descriptionArea); 196 jScrollPane1.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER); 197 198 gridBagConstraints = new java.awt.GridBagConstraints (); 199 gridBagConstraints.gridx = 0; 200 gridBagConstraints.gridy = 2; 201 gridBagConstraints.gridwidth = 4; 202 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 203 gridBagConstraints.weightx = 1.0; 204 gridBagConstraints.weighty = 2.0; 205 customPanel.add(jScrollPane1, gridBagConstraints); 206 if (FileType.TAG.equals(fileType)) { 207 208 tldCheckBox = new javax.swing.JCheckBox (); 210 tldCheckBox.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_AddToTLD_mnem").charAt(0)); 211 tldCheckBox.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_addTagFileToTLD")); 212 gridBagConstraints = new java.awt.GridBagConstraints (); 213 gridBagConstraints.gridx = 0; 214 gridBagConstraints.gridy = 3; 215 gridBagConstraints.gridwidth = 4; 216 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 217 gridBagConstraints.insets = new java.awt.Insets (6, 0, 2, 0); 218 customPanel.add(tldCheckBox, gridBagConstraints); 219 tldCheckBox.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("OPT_addToTLD")); 220 232 javax.swing.JLabel tldFileLabel = new javax.swing.JLabel (); 233 tldFileLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TLDName_mnem").charAt(0)); 234 tldFileLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_tldFile")); 235 gridBagConstraints = new java.awt.GridBagConstraints (); 236 gridBagConstraints.gridx = 0; 237 gridBagConstraints.gridy = 5; 238 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 239 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 0); 240 customPanel.add(tldFileLabel, gridBagConstraints); 241 242 tldTextField = new javax.swing.JTextField (); 243 tldTextField.setEditable(false); 244 gridBagConstraints = new java.awt.GridBagConstraints (); 245 gridBagConstraints.gridx = 1; 246 gridBagConstraints.gridy = 5; 247 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 248 gridBagConstraints.weightx = 1.0; 249 gridBagConstraints.gridwidth = 2; 250 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 251 customPanel.add(tldTextField, gridBagConstraints); 252 tldTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TLDFile")); 253 tldFileLabel.setLabelFor(tldTextField); 254 255 browseButton1 = new javax.swing.JButton (); 256 browseButton1.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_Browse1_Mnemonic").charAt(0)); 257 browseButton1.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Browse")); 258 browseButton1.addActionListener(new java.awt.event.ActionListener () { 259 public void actionPerformed(java.awt.event.ActionEvent evt) { 260 browseButton1ActionPerformed(evt); 261 } 262 }); 263 browseButton1.setEnabled(false); 264 265 gridBagConstraints = new java.awt.GridBagConstraints (); 266 gridBagConstraints.gridx = 3; 267 gridBagConstraints.gridy = 5; 268 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 269 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 270 customPanel.add(browseButton1, gridBagConstraints); 271 272 browseButton1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("LBL_Browse")); 273 tldCheckBox.addItemListener(new java.awt.event.ItemListener () { 274 public void itemStateChanged(java.awt.event.ItemEvent evt) { 275 tagNameTextField.setEditable(tldCheckBox.isSelected()); 276 browseButton1.setEnabled(tldCheckBox.isSelected()); 277 if (tldCheckBox.isSelected()) { 278 if (tagName==null) { 279 String name = documentNameTextField.getText().trim(); 280 if (name.length()>0) { 281 tagNameTextField.setText(name); 282 tagName = name; 283 } 284 } 285 } 286 wizardPanel.fireChange(); 287 } 288 }); 289 290 javax.swing.JLabel tagNameLabel = new javax.swing.JLabel (); 291 tagNameLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_TagName_mnem").charAt(0)); 292 tagNameLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_tagName")); 293 gridBagConstraints = new java.awt.GridBagConstraints (); 294 gridBagConstraints.gridx = 0; 295 gridBagConstraints.gridy = 6; 296 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 297 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 298 customPanel.add(tagNameLabel, gridBagConstraints); 299 300 tagNameTextField = new javax.swing.JTextField (); 301 tagNameTextField.setEditable(false); 303 gridBagConstraints = new java.awt.GridBagConstraints (); 304 gridBagConstraints.gridx = 1; 305 gridBagConstraints.gridy = 6; 306 gridBagConstraints.weightx = 1.0; 307 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 308 gridBagConstraints.insets = new java.awt.Insets (6, 12, 0, 0); 309 customPanel.add(tagNameTextField, gridBagConstraints); 310 tagNameTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/wizards/Bundle").getString("A11Y_DESC_TagName")); 311 tagNameLabel.setLabelFor(tagNameTextField); 312 tagNameTextField.addKeyListener(new java.awt.event.KeyAdapter () { 313 public void keyReleased(java.awt.event.KeyEvent evt) { 314 tagName = tagNameTextField.getText().trim(); 315 wizardPanel.fireChange(); 316 } 317 }); 318 319 gridBagConstraints = new java.awt.GridBagConstraints (); 320 gridBagConstraints.gridx = 2; 321 gridBagConstraints.gridy = 6; 322 gridBagConstraints.weightx = 1.0; 323 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 324 customPanel.add(new javax.swing.JPanel (), gridBagConstraints); 325 } 326 } else if (FileType.TAGLIBRARY.equals(fileType)) { 327 java.awt.GridBagConstraints gridBagConstraints; 328 uriTextField = new javax.swing.JTextField (); 329 uriTextField.setColumns(20); 330 prefixTextField = new javax.swing.JTextField (); 331 prefixTextField.setColumns(5); 332 333 uriLabel = new javax.swing.JLabel (NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_URI")); 334 uriLabel.setToolTipText(NbBundle.getMessage(TargetChooserPanelGUI.class, "TTT_URI")); 335 uriLabel.setLabelFor(uriTextField); 336 uriLabel.setDisplayedMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_URI_mnem").charAt(0)); 337 uriTextField.getAccessibleContext().setAccessibleDescription( 338 NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_URI")); 339 gridBagConstraints = new java.awt.GridBagConstraints (); 340 gridBagConstraints.gridx = 0; 341 gridBagConstraints.gridy = 0; 342 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 343 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 344 customPanel.add(uriLabel, gridBagConstraints); 345 346 gridBagConstraints = new java.awt.GridBagConstraints (); 347 gridBagConstraints.gridx = 1; 348 gridBagConstraints.gridy = 0; 349 gridBagConstraints.gridwidth = 2; 350 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 351 gridBagConstraints.insets = new java.awt.Insets (6, 6, 6, 0); 352 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 353 gridBagConstraints.weightx = 1.0; 354 customPanel.add(uriTextField, gridBagConstraints); 355 356 prefixLabel = new javax.swing.JLabel (NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Prefix")); 357 prefixLabel.setLabelFor(prefixTextField); 358 prefixLabel.setToolTipText(NbBundle.getMessage(TargetChooserPanelGUI.class, "TTT_prefix")); 359 prefixLabel.setDisplayedMnemonic(NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_Prefix_mnem").charAt(0)); 360 prefixTextField.getAccessibleContext().setAccessibleDescription( 361 NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_Prefix")); 362 gridBagConstraints = new java.awt.GridBagConstraints (); 363 gridBagConstraints.gridx = 0; 364 gridBagConstraints.gridy = 1; 365 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 366 customPanel.add(prefixLabel, gridBagConstraints); 367 368 gridBagConstraints = new java.awt.GridBagConstraints (); 369 gridBagConstraints.gridx = 1; 370 gridBagConstraints.gridy = 1; 371 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 372 gridBagConstraints.weightx = 1.0; 373 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 374 gridBagConstraints.weightx = 1.0; 375 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 376 customPanel.add(prefixTextField, gridBagConstraints); 377 378 gridBagConstraints = new java.awt.GridBagConstraints (); 379 gridBagConstraints.gridx = 3; 380 gridBagConstraints.gridy = 0; 381 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 382 gridBagConstraints.gridheight = 2; 383 gridBagConstraints.weightx = 2.0; 384 customPanel.add(new javax.swing.JPanel (), gridBagConstraints); 385 386 gridBagConstraints = new java.awt.GridBagConstraints (); 387 gridBagConstraints.gridx = 2; 388 gridBagConstraints.gridy = 1; 389 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 390 gridBagConstraints.weightx = 1.0; 391 customPanel.add(new javax.swing.JPanel (), gridBagConstraints); 392 393 uriTextField.addKeyListener(new java.awt.event.KeyAdapter () { 394 public void keyReleased(java.awt.event.KeyEvent evt) { 395 uriWasTyped=true; 396 wizardPanel.fireChange(); 397 } 398 }); 399 400 prefixTextField.addKeyListener(new java.awt.event.KeyAdapter () { 401 public void keyReleased(java.awt.event.KeyEvent evt) { 402 prefixWasTyped=true; 403 wizardPanel.fireChange(); 404 } 405 }); 406 } 407 408 409 browseButton.addActionListener( this ); 411 documentNameTextField.getDocument().addDocumentListener( this ); 412 folderTextField.getDocument().addDocumentListener( this ); 413 414 setName( NbBundle.getMessage(TargetChooserPanelGUI.class,"TITLE_name_location")); 415 416 if (fileType.equals(FileType.JSP)) { 417 nameLabel.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_JspName")); 418 jspSyntaxButton.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_JspSyntax")); 419 jspSyntaxButton.getAccessibleContext().setAccessibleDescription( 420 NbBundle.getMessage(TargetChooserPanelGUI.class, "DESC_JSP")); 421 xmlSyntaxButton.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_XmlSyntax")); 422 xmlSyntaxButton.getAccessibleContext().setAccessibleDescription( 423 NbBundle.getMessage(TargetChooserPanelGUI.class, "DESC_JSP_XML")); 424 segmentBox.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_JspSegment")); 425 segmentBox.getAccessibleContext().setAccessibleDescription( 426 NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_JSP_segment")); 427 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_JSP")); 428 } else if (fileType.equals(FileType.TAG)) { 429 nameLabel.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_TagFileName")); 430 jspSyntaxButton.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_TagFileJsp")); 431 jspSyntaxButton.getAccessibleContext().setAccessibleDescription( 432 NbBundle.getMessage(TargetChooserPanelGUI.class, "DESC_TagFile")); 433 xmlSyntaxButton.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_TagFileXml")); 434 xmlSyntaxButton.getAccessibleContext().setAccessibleDescription( 435 NbBundle.getMessage(TargetChooserPanelGUI.class, "DESC_TagFileXml")); 436 segmentBox.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "OPT_TagFileSegment")); 437 segmentBox.getAccessibleContext().setAccessibleDescription( 438 NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_TagFile_segment")); 439 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_TagFile")); 440 } else if (fileType.equals(FileType.TAGLIBRARY)) { 441 nameLabel.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_TldName")); 442 } else if (fileType.equals(FileType.HTML)) { 443 nameLabel.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_HtmlName")); 444 locationCB.addActionListener(new java.awt.event.ActionListener () { 446 public void actionPerformed(java.awt.event.ActionEvent evt) { 447 changedUpdate(null); 448 } 449 }); 450 } else if (fileType.equals(FileType.XHTML)) { 451 nameLabel.setText(NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_XHtmlName")); 452 locationCB.addActionListener(new java.awt.event.ActionListener () { 454 public void actionPerformed(java.awt.event.ActionEvent evt) { 455 changedUpdate(null); 456 } 457 }); 458 } 459 } 460 461 WebModule getWebModule() { 462 return wm; 463 } 464 465 public void initValues( Project p, FileObject template, FileObject preselectedFolder ) { 466 projectTextField.setText(ProjectUtils.getInformation(p).getDisplayName()); 467 if (folders!=null && folders.length>0) { 469 locationCB.setModel(new javax.swing.DefaultComboBoxModel (getLocations(folders))); 470 wm = WebModule.getWebModule(folders[0].getRootFolder()); 471 } else 472 locationCB.setModel(new javax.swing.DefaultComboBoxModel ( 473 new Object []{new LocationItem(p.getProjectDirectory())})); 474 475 String target=null; 477 FileObject docBase = getLocationRoot(); 478 if ( preselectedFolder != null && FileUtil.isParentOf( docBase, preselectedFolder ) ) { 479 target = FileUtil.getRelativePath( docBase, preselectedFolder ); 480 } 481 482 if (wm==null) { 484 if (FileType.TAG.equals(fileType) && target!=null && !target.startsWith(TAG_FILE_IN_JAVALIB_FOLDER)) { 485 target=null; 486 } 487 if (FileType.TAGLIBRARY.equals(fileType) && target!=null && !target.startsWith(TLD_IN_JAVALIB_FOLDER)) { 488 target=null; 489 } 490 } 491 492 if (FileType.TAG.equals(fileType)) { 494 if (wm!=null) { 495 if (target==null || !target.startsWith(TAG_FILE_FOLDER)) 496 folderTextField.setText(TAG_FILE_FOLDER+"/"); else folderTextField.setText( target == null ? "" : target ); } else { 499 if (target==null || !target.startsWith(TAG_FILE_IN_JAVALIB_FOLDER)) 500 folderTextField.setText(TAG_FILE_IN_JAVALIB_FOLDER+"/"); else folderTextField.setText( target == null ? "" : target ); } 503 } else if (FileType.TAGLIBRARY.equals(fileType) && target==null) { 504 if (wm==null) folderTextField.setText(TLD_IN_JAVALIB_FOLDER+"/"); else folderTextField.setText(TLD_FOLDER+"/"); } else 507 folderTextField.setText( target == null ? "" : target ); String ext = template == null ? "" : template.getExt(); expectedExtension = ext.length() == 0 ? "" : "." + ext; } 511 512 private Object [] getLocations(SourceGroup[] folders) { 513 Object [] loc = new Object [folders.length]; 514 for (int i=0;i<folders.length;i++) loc[i] = new LocationItem(folders[i]); 515 return loc; 516 } 517 518 private String getRelativeSourcesFolder() { 519 String sourceDir=""; 520 if (wm!=null) { 521 FileObject docBase = wm.getDocumentBase(); 522 FileObject sourcesBase = ((LocationItem)locationCB.getModel().getSelectedItem()).getFileObject(); 523 sourceDir = FileUtil.getRelativePath( docBase, sourcesBase ); 524 525 if (sourceDir == null) 527 sourceDir = ""; 528 } 529 return sourceDir.length()==0?"":sourceDir+"/"; 530 } 531 532 public String getRelativeTargetFolder() { 533 return getRelativeSourcesFolder()+getNormalizedFolder(); 534 } 535 536 public String getNormalizedFolder() { 537 String norm = folderTextField.getText().trim(); 538 if (norm.length()==0) return ""; 539 norm = norm.replace('\\','/'); 540 int i=0; 542 while (i<norm.length() && norm.charAt(i)=='/') i++; 543 if (i==norm.length()) return ""; norm = norm.substring(i); 545 546 java.util.StringTokenizer tokens = new java.util.StringTokenizer (norm,"/"); 548 java.util.List list = new java.util.ArrayList (); 549 StringBuffer buf = new StringBuffer (tokens.nextToken()); 550 while (tokens.hasMoreTokens()) { 551 String token = tokens.nextToken(); 552 if (token.length()>0) buf.append("/"+token); 553 } 554 return buf.toString(); 555 } 556 557 public String getTargetFolder() { 558 return getTargetFile().getPath(); 559 } 560 561 public File getTargetFile() { 562 String text = getRelativeTargetFolder(); 563 564 if ( text.length() == 0 ) { 565 if (wm==null) 566 return FileUtil.toFile(getLocationRoot()); 567 else 568 return FileUtil.toFile( wm.getDocumentBase()); 569 } 570 else { 571 if (wm==null) { 573 return new File ( FileUtil.toFile(getLocationRoot()), text ); 574 } else { 575 return new File ( FileUtil.toFile( wm.getDocumentBase() ), text ); 576 } 577 } 578 } 579 public String getTargetName() { 580 581 String text = documentNameTextField.getText().trim(); 582 583 if ( text.length() == 0 ) { 584 return null; 585 } 586 else { 587 return text; 588 } 589 } 590 607 608 613 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 615 616 nameLabel = new javax.swing.JLabel (); 617 documentNameTextField = new javax.swing.JTextField (); 618 projectLabel = new javax.swing.JLabel (); 619 projectTextField = new javax.swing.JTextField (); 620 locationLabel = new javax.swing.JLabel (); 621 locationCB = new javax.swing.JComboBox (); 622 folderLabel = new javax.swing.JLabel (); 623 folderTextField = new javax.swing.JTextField (); 624 browseButton = new javax.swing.JButton (); 625 pathLabel = new javax.swing.JLabel (); 626 fileTextField = new javax.swing.JTextField (); 627 targetSeparator = new javax.swing.JSeparator (); 628 customPanel = new javax.swing.JPanel (); 629 fillerPanel = new javax.swing.JPanel (); 630 631 setLayout(new java.awt.GridBagLayout ()); 632 633 nameLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_FileName_mnem").charAt(0)); 634 nameLabel.setLabelFor(documentNameTextField); 635 nameLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_JspName")); 636 gridBagConstraints = new java.awt.GridBagConstraints (); 637 gridBagConstraints.gridx = 0; 638 gridBagConstraints.gridy = 0; 639 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 640 add(nameLabel, gridBagConstraints); 641 642 gridBagConstraints = new java.awt.GridBagConstraints (); 643 gridBagConstraints.gridx = 1; 644 gridBagConstraints.gridy = 0; 645 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 646 gridBagConstraints.weightx = 1.0; 647 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 648 add(documentNameTextField, gridBagConstraints); 649 documentNameTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_FileName")); 650 651 projectLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_Project_mnem").charAt(0)); 652 projectLabel.setLabelFor(projectTextField); 653 projectLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Project")); 654 gridBagConstraints = new java.awt.GridBagConstraints (); 655 gridBagConstraints.gridx = 0; 656 gridBagConstraints.gridy = 1; 657 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 658 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 659 add(projectLabel, gridBagConstraints); 660 661 projectTextField.setEditable(false); 662 gridBagConstraints = new java.awt.GridBagConstraints (); 663 gridBagConstraints.gridx = 1; 664 gridBagConstraints.gridy = 1; 665 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 666 gridBagConstraints.weightx = 1.0; 667 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 668 add(projectTextField, gridBagConstraints); 669 projectTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_Project")); 670 671 locationLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_Location_mnem").charAt(0)); 672 locationLabel.setLabelFor(locationCB); 673 locationLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Location")); 674 gridBagConstraints = new java.awt.GridBagConstraints (); 675 gridBagConstraints.gridx = 0; 676 gridBagConstraints.gridy = 2; 677 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 678 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 679 add(locationLabel, gridBagConstraints); 680 681 gridBagConstraints = new java.awt.GridBagConstraints (); 682 gridBagConstraints.gridx = 1; 683 gridBagConstraints.gridy = 2; 684 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 685 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 686 add(locationCB, gridBagConstraints); 687 locationCB.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_Location")); 688 689 folderLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_Folder_mnem").charAt(0)); 690 folderLabel.setLabelFor(folderTextField); 691 folderLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Folder")); 692 gridBagConstraints = new java.awt.GridBagConstraints (); 693 gridBagConstraints.gridx = 0; 694 gridBagConstraints.gridy = 3; 695 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 696 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 697 add(folderLabel, gridBagConstraints); 698 699 gridBagConstraints = new java.awt.GridBagConstraints (); 700 gridBagConstraints.gridx = 1; 701 gridBagConstraints.gridy = 3; 702 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 703 gridBagConstraints.weightx = 1.0; 704 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 705 add(folderTextField, gridBagConstraints); 706 folderTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_Folder")); 707 708 browseButton.setMnemonic(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Browse_Mnemonic").charAt(0)); 709 browseButton.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_Browse")); 710 gridBagConstraints = new java.awt.GridBagConstraints (); 711 gridBagConstraints.gridx = 2; 712 gridBagConstraints.gridy = 3; 713 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 714 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 715 add(browseButton, gridBagConstraints); 716 browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "ACSD_Browse")); 717 718 pathLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_CreatedFile_mnem").charAt(0)); 719 pathLabel.setLabelFor(fileTextField); 720 pathLabel.setText(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "LBL_CreatedFile")); 721 gridBagConstraints = new java.awt.GridBagConstraints (); 722 gridBagConstraints.gridx = 0; 723 gridBagConstraints.gridy = 4; 724 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 725 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 726 add(pathLabel, gridBagConstraints); 727 728 fileTextField.setEditable(false); 729 gridBagConstraints = new java.awt.GridBagConstraints (); 730 gridBagConstraints.gridx = 1; 731 gridBagConstraints.gridy = 4; 732 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 733 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 734 gridBagConstraints.weightx = 1.0; 735 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 736 add(fileTextField, gridBagConstraints); 737 fileTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TargetChooserPanelGUI.class, "A11Y_DESC_CreatedFile")); 738 739 gridBagConstraints = new java.awt.GridBagConstraints (); 740 gridBagConstraints.gridx = 0; 741 gridBagConstraints.gridy = 5; 742 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 743 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 744 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 745 add(targetSeparator, gridBagConstraints); 746 747 customPanel.setLayout(new java.awt.GridBagLayout ()); 748 749 gridBagConstraints = new java.awt.GridBagConstraints (); 750 gridBagConstraints.gridx = 0; 751 gridBagConstraints.gridy = 6; 752 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 753 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 754 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 755 add(customPanel, gridBagConstraints); 756 757 gridBagConstraints = new java.awt.GridBagConstraints (); 758 gridBagConstraints.gridx = 0; 759 gridBagConstraints.gridy = 7; 760 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 761 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 762 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 763 gridBagConstraints.weighty = 1.0; 764 add(fillerPanel, gridBagConstraints); 765 766 } 768 769 770 private javax.swing.JButton browseButton; 772 private javax.swing.JPanel customPanel; 773 private javax.swing.JTextField documentNameTextField; 774 private javax.swing.JTextField fileTextField; 775 private javax.swing.JPanel fillerPanel; 776 private javax.swing.JLabel folderLabel; 777 private javax.swing.JTextField folderTextField; 778 private javax.swing.JComboBox locationCB; 779 private javax.swing.JLabel locationLabel; 780 private javax.swing.JLabel nameLabel; 781 private javax.swing.JLabel pathLabel; 782 private javax.swing.JLabel projectLabel; 783 private javax.swing.JTextField projectTextField; 784 private javax.swing.JSeparator targetSeparator; 785 787 789 public void actionPerformed(java.awt.event.ActionEvent e) { 790 if ( browseButton == e.getSource() ) { 791 FileObject fo=null; 792 if (folders!=null) fo = BrowseFolders.showDialog(folders, 794 org.openide.loaders.DataFolder.class, 795 folderTextField.getText().replace( File.separatorChar, '/' ) ); 796 else { 797 Sources sources = ProjectUtils.getSources(project); 798 fo = BrowseFolders.showDialog( sources.getSourceGroups( Sources.TYPE_GENERIC ), 799 org.openide.loaders.DataFolder.class, 800 folderTextField.getText().replace( File.separatorChar, '/' ) ); 801 } 802 803 if ( fo != null && fo.isFolder() ) { 804 FileObject root = ((LocationItem)locationCB.getSelectedItem()).getFileObject(); 805 folderTextField.setText( FileUtil.getRelativePath( root, fo ) ); 806 } 807 808 } 809 } 810 811 813 public void changedUpdate(javax.swing.event.DocumentEvent e) { 814 815 File rootDirFile = FileUtil.toFile(((LocationItem)locationCB.getSelectedItem()).getFileObject()); 816 if (rootDirFile != null) { 817 String documentName = documentNameTextField.getText().trim(); 818 if (documentName.length() == 0) { 819 fileTextField.setText(""); } else { 821 File newFile = new File (new File (rootDirFile, folderTextField.getText().replace('/', File.separatorChar)), 822 documentName + expectedExtension+(isSegment()?"f":(isXml()?"x":""))); fileTextField.setText(newFile.getAbsolutePath()); 824 } 825 } else { 826 fileTextField.setText(""); } 829 if (FileType.TAGLIBRARY.equals(fileType)) { 830 if (!uriWasTyped) { 831 String norm=getNormalizedFolder(); 832 if (wm==null) { 834 String pack = getPackageNameInMetaInf(); 835 uriTextField.setText((pack.length()>0?pack+".":"")+documentNameTextField.getText()); 836 } 837 else uriTextField.setText((norm.length()==0?"":"/"+getNormalizedFolder())+ "/"+documentNameTextField.getText().trim()); } 840 if (!prefixWasTyped) 842 prefixTextField.setText(documentNameTextField.getText().trim().toLowerCase()); 843 } 844 wizardPanel.fireChange(); 845 } 846 847 private String getPackageNameInMetaInf() { 848 String pack = getRelativeTargetFolder(); 849 if (pack.startsWith("META-INF")) { pack = pack.substring(8); 851 if (pack.length()==0) return ""; 852 if (pack.startsWith("/")) pack=pack.substring(1); } 854 if (pack.length()==0) return ""; pack = pack.replace('/', '.'); 856 return pack; 857 } 858 859 860 862 private void checkBoxChanged(java.awt.event.ItemEvent evt) { 863 if (fileType.equals(FileType.JSP)) { 865 if (isSegment()) { 866 if (isXml()) { 867 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_segment_XML")); 868 } else { 869 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_segment")); 870 } 871 String createdFile = fileTextField.getText(); 872 if (createdFile.endsWith("jspx")) fileTextField.setText(createdFile.substring(0,createdFile.length()-1)+"f"); else if (createdFile.endsWith("jsp")) fileTextField.setText(createdFile+"f"); } else { 877 String createdFile = fileTextField.getText(); 878 if (isXml()) { 879 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_JSP_XML")); 880 if (createdFile.endsWith("jspf")) { fileTextField.setText(createdFile.substring(0,createdFile.length()-1)+"x"); } else if (createdFile.endsWith("jsp")) { fileTextField.setText(createdFile+"x"); } 885 } else { 886 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_JSP")); 887 if (createdFile.endsWith("jspf") || createdFile.endsWith("jspx")) { fileTextField.setText(createdFile.substring(0,createdFile.length()-1)); } 890 } 891 } 892 } else if (fileType.equals(FileType.TAG)){ 893 if (isSegment()) { 894 if (isXml()) { 895 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_TagFileSegmentXml")); 896 } else { 897 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_TagFileSegment")); 898 } 899 String createdFile = fileTextField.getText(); 900 if (createdFile.endsWith("tagx")) fileTextField.setText(createdFile.substring(0,createdFile.length()-1)+"f"); else if (createdFile.endsWith("tag")) fileTextField.setText(createdFile+"f"); } else { 905 String createdFile = fileTextField.getText(); 906 if (isXml()) { 907 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_TagFileXml")); 908 if (createdFile.endsWith("tagf")) { fileTextField.setText(createdFile.substring(0,createdFile.length()-1)+"x"); } else if (createdFile.endsWith("tag")) { fileTextField.setText(createdFile+"x"); } 913 } else { 914 descriptionArea.setText(NbBundle.getMessage(TargetChooserPanelGUI.class,"DESC_TagFile")); 915 if (createdFile.endsWith("tagf") || createdFile.endsWith("tagx")) { fileTextField.setText(createdFile.substring(0,createdFile.length()-1)); } 918 } 919 } 920 } 921 wizardPanel.fireChange(); 922 } 923 924 public void insertUpdate(javax.swing.event.DocumentEvent e) { 925 changedUpdate( e ); 926 } 927 928 public void removeUpdate(javax.swing.event.DocumentEvent e) { 929 changedUpdate( e ); 930 } 931 932 boolean isXml() { 933 if (xmlSyntaxButton==null) return false; 934 else return xmlSyntaxButton.isSelected(); 935 } 936 937 boolean isSegment() { 938 if (segmentBox==null) return false; 939 else return segmentBox.isSelected(); 940 } 941 942 String getUri() { 943 if (uriTextField==null) return ""; 944 else return uriTextField.getText(); 945 } 946 String getPrefix() { 947 if (prefixTextField==null) return ""; 948 else return prefixTextField.getText(); 949 } 950 951 String getErrorMessage() { 952 if (FileType.JSP.equals(fileType)) { 953 if (isSegment() && !getNormalizedFolder().startsWith("WEB-INF/jspf")) return NbBundle.getMessage(TargetChooserPanelGUI.class,"NOTE_segment"); 955 } else if (FileType.TAG.equals(fileType)) { 956 tagFileValid=true; 957 if (wm!=null) { 958 if (!getNormalizedFolder().startsWith(TAG_FILE_FOLDER)) { 959 tagFileValid=false; 960 return NbBundle.getMessage(TargetChooserPanelGUI.class,"MSG_TagFile"); 961 } 962 } else { 963 if (!getNormalizedFolder().startsWith(TAG_FILE_IN_JAVALIB_FOLDER)) { 964 tagFileValid=false; 965 return NbBundle.getMessage(TargetChooserPanelGUI.class,"MSG_TagFileInJavalib"); 966 } 967 } 968 } else if (FileType.TAGLIBRARY.equals(fileType)) { 969 if (wm==null) { 970 if (!getNormalizedFolder().startsWith(TLD_IN_JAVALIB_FOLDER)) 971 return NbBundle.getMessage(TargetChooserPanelGUI.class,"NOTE_TLDInJavalib"); 972 } else 973 if (!getNormalizedFolder().startsWith("WEB-INF")) return NbBundle.getMessage(TargetChooserPanelGUI.class,"NOTE_TLDInWeb"); 975 if (getUri().length()==0) return NbBundle.getMessage(TargetChooserPanelGUI.class,"MSG_missingUri"); 977 if (getPrefix().length()==0) return NbBundle.getMessage(TargetChooserPanelGUI.class,"MSG_missingPrefix"); 979 } 980 return null; 981 } 982 983 boolean isPanelValid() { 984 if (FileType.TAGLIBRARY.equals(fileType) && 985 (getUri().length()==0 || getPrefix().length()==0)) 986 return false; 987 if (FileType.TAG.equals(fileType) && !tagFileValid) 988 return false; 989 return true; 990 } 991 992 FileObject getLocationRoot() { 993 return ((LocationItem)locationCB.getModel().getSelectedItem()).getFileObject(); 994 } 995 996 public static class LocationItem { 997 FileObject fo; 998 SourceGroup group; 999 public LocationItem(FileObject fo) { 1000 this.fo=fo; 1001 } 1002 public LocationItem(SourceGroup group) { 1003 this.fo=group.getRootFolder(); 1004 this.group=group; 1005 } 1006 public FileObject getFileObject() { 1007 return fo; 1008 } 1009 1010 public String toString() { 1011 return (group==null?fo.getName():group.getDisplayName()); 1012 } 1013 } 1014 1015 private void browseButton1ActionPerformed(java.awt.event.ActionEvent evt) { 1016 org.openide.filesystems.FileObject fo=null; 1018 if (folders!=null) fo = BrowseFolders.showDialog(folders, TLDDataObject.class, 1020 folderTextField.getText().replace( File.separatorChar, '/' ) ); 1021 else { 1022 Sources sources = ProjectUtils.getSources(project); 1023 fo = BrowseFolders.showDialog( sources.getSourceGroups( Sources.TYPE_GENERIC ), 1024 org.openide.loaders.DataFolder.class, 1025 folderTextField.getText().replace( File.separatorChar, '/' ) ); 1026 } 1027 1028 if ( fo != null) { 1029 tldFo=fo; 1030 FileObject targetFolder=Templates.getTargetFolder(wizardPanel.getTemplateWizard()); 1031 WebModule wm = (targetFolder==null?null:WebModule.getWebModule(targetFolder)); 1032 tldTextField.setText( FileUtil.getRelativePath( (wm==null?project.getProjectDirectory():wm.getDocumentBase()), fo ) ); 1033 try { 1034 java.io.InputStream is = tldFo.getInputStream(); 1035 tagValues = Util.getTagValues(is, new String []{"tag","tag-file"},"name"); is.close(); 1038 } catch (java.io.IOException ex) {} 1039 catch (org.xml.sax.SAXException ex ){} 1040 wizardPanel.fireChange(); 1041 } 1042 } 1043 1044 boolean isTldCheckBoxSelected() { 1045 return tldCheckBox.isSelected(); 1046 } 1047 1048 String getTagName() { 1049 return tagName; 1050 } 1051 1052 FileObject getTldFileObject() { 1053 return tldFo; 1054 } 1055 1056 boolean isValidTagName(String name) { 1057 if (name==null) return false; 1058 return org.apache.xerces.util.XMLChar.isValidNCName(name); 1059 } 1060 1061 boolean tagNameExists(String name) { 1062 if (tagValues!=null && tagValues.contains(name)) return true; 1063 else return false; 1064 } 1065 1066 public String getCreatedFilePath() { 1067 return fileTextField.getText(); 1068 } 1069 1070} 1071 | Popular Tags |