1 19 20 package org.netbeans.modules.web.project.ui.wizards; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeEvent ; 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.text.MessageFormat ; 27 import java.util.ArrayList ; 28 import java.util.Enumeration ; 29 import java.util.Iterator ; 30 import javax.swing.JFileChooser ; 31 import javax.swing.event.ChangeEvent ; 32 import javax.swing.event.ChangeListener ; 33 import javax.swing.event.DocumentEvent ; 34 import javax.swing.event.DocumentListener ; 35 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 36 import org.netbeans.modules.web.project.ProjectWebModule; 37 import org.openide.DialogDisplayer; 38 import org.openide.ErrorManager; 39 import org.openide.NotifyDescriptor; 40 import org.openide.WizardDescriptor; 41 import org.openide.WizardValidationException; 42 import org.openide.filesystems.FileObject; 43 import org.openide.filesystems.FileUtil; 44 import org.openide.util.HelpCtx; 45 import org.openide.util.NbBundle; 46 47 49 53 public class PanelSourceFolders extends SettingsPanel implements PropertyChangeListener { 54 55 private Panel firer; 56 private WizardDescriptor wizardDescriptor; 57 58 59 public PanelSourceFolders (Panel panel) { 60 this.firer = panel; 61 initComponents(); 62 this.setName(NbBundle.getMessage(PanelSourceFolders.class,"LAB_ConfigureSourceRoots")); 63 this.putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelSourceFolders.class,"TXT_WebExtSources")); this.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PanelSourceFolders.class,"AN_PanelSourceFolders")); 65 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelSourceFolders.class,"AD_PanelSourceFolders")); 66 this.sourcePanel.addPropertyChangeListener (this); 67 this.testsPanel.addPropertyChangeListener(this); 68 ((FolderList)this.sourcePanel).setRelatedFolderList((FolderList)this.testsPanel); 69 ((FolderList)this.testsPanel).setRelatedFolderList((FolderList)this.sourcePanel); 70 71 DocumentListener pl = new DocumentListener () { 72 public void changedUpdate(DocumentEvent e) { 73 firer.fireChangeEvent(); 74 } 75 76 public void insertUpdate(DocumentEvent e) { 77 firer.fireChangeEvent(); 78 } 79 80 public void removeUpdate(DocumentEvent e) { 81 firer.fireChangeEvent(); 82 } 83 }; 84 jTextFieldWebPages.getDocument().addDocumentListener(pl); 85 86 } 87 88 public void initValues(FileObject fo) { 89 ((FolderList) this.sourcePanel).setLastUsedDir(FileUtil.toFile(fo)); 90 ((FolderList) this.testsPanel).setLastUsedDir(FileUtil.toFile(fo)); 91 92 FileObject guessFO; 93 String webPages = ""; String libraries = ""; File javaRoots [] = null; 96 97 guessFO = FileSearchUtility.guessDocBase(fo); 98 if (guessFO != null) 99 webPages = FileUtil.toFile(guessFO).getPath(); 100 guessFO = FileSearchUtility.guessLibrariesFolder(fo); 101 if (guessFO != null) 102 libraries = FileUtil.toFile(guessFO).getPath(); 103 javaRoots = FileSearchUtility.guessJavaRootsAsFiles(fo); 104 105 if (jTextFieldWebPages.getText().trim().equals("")) 107 jTextFieldWebPages.setText(webPages); 108 if (jTextFieldLibraries.getText().trim().equals("")) 109 jTextFieldLibraries.setText(libraries); 110 111 if (((FolderList) this.sourcePanel).getFiles().length == 0 && javaRoots.length > 0) 112 ((FolderList) this.sourcePanel).setFiles(javaRoots); 113 } 114 115 public void propertyChange(PropertyChangeEvent evt) { 116 if (FolderList.PROP_FILES.equals(evt.getPropertyName())) { 117 this.dataChanged(); 118 } else if (FolderList.PROP_LAST_USED_DIR.equals (evt.getPropertyName())) { 119 if (evt.getSource() == this.sourcePanel) { 120 ((FolderList)this.testsPanel).setLastUsedDir 121 ((File )evt.getNewValue()); 122 } 123 else if (evt.getSource() == this.testsPanel) { 124 ((FolderList)this.sourcePanel).setLastUsedDir 125 ((File )evt.getNewValue()); 126 } 127 } 128 } 129 130 private void dataChanged () { 131 this.firer.fireChangeEvent(); 132 } 133 134 void read (WizardDescriptor settings) { 135 this.wizardDescriptor = settings; 136 File [] srcRoot = (File []) settings.getProperty (WizardProperties.JAVA_ROOT); if (srcRoot!=null) { 138 ((FolderList)this.sourcePanel).setFiles(srcRoot); 139 } 140 File [] testRoot = (File []) settings.getProperty (WizardProperties.TEST_ROOT); if (testRoot != null) { 142 ((FolderList)this.testsPanel).setFiles (testRoot); 143 } 144 File projectLocation = (File ) settings.getProperty(WizardProperties.SOURCE_ROOT); 145 ((FolderList)this.sourcePanel).setProjectFolder(projectLocation); 146 ((FolderList)this.testsPanel).setProjectFolder(projectLocation); 147 148 initValues(FileUtil.toFileObject(projectLocation)); 149 } 150 151 void store (WizardDescriptor settings) { 152 File [] sourceRoots = ((FolderList)this.sourcePanel).getFiles(); 153 File [] testRoots = ((FolderList)this.testsPanel).getFiles(); 154 settings.putProperty (WizardProperties.JAVA_ROOT,sourceRoots); settings.putProperty(WizardProperties.TEST_ROOT,testRoots); settings.putProperty(WizardProperties.DOC_BASE, jTextFieldWebPages.getText().trim()); 157 settings.putProperty(WizardProperties.LIB_FOLDER, jTextFieldLibraries.getText().trim()); 158 } 159 160 boolean valid (WizardDescriptor settings) { 161 File projectLocation = (File ) settings.getProperty (WizardProperties.PROJECT_DIR); 163 if (jTextFieldWebPages.getText().trim().length() == 0) { 164 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(PanelSourceFolders.class, "MSG_WebPagesMandatory")); return false; 166 } 167 168 File webPages = getWebPages(); 169 File [] sourceRoots = ((FolderList)this.sourcePanel).getFiles(); 170 File [] testRoots = ((FolderList)this.testsPanel).getFiles(); 171 String result = checkValidity (projectLocation, webPages, sourceRoots, testRoots); 172 if (result == null) { 173 wizardDescriptor.putProperty( "WizardPanel_errorMessage",""); return true; 175 } 176 else { 177 wizardDescriptor.putProperty( "WizardPanel_errorMessage",result); return false; 179 } 180 } 181 182 private String checkValidity (final File projectLocation, final File webPages, final File [] sources, final File [] tests) { 183 String ploc = projectLocation.getAbsolutePath (); 184 185 if (projectLocation.equals(webPages)) 186 return NbBundle.getMessage(PanelSourceFolders.class, "MSG_WebPagesFolderOverlapsProjectFolder"); 188 if (!webPages.exists() || !webPages.isDirectory()) 189 return NbBundle.getMessage(PanelSourceFolders.class, "MSG_WebPagesFolderDoesNotExist"); 191 FileObject webInf = FileUtil.toFileObject(webPages).getFileObject(ProjectWebModule.FOLDER_WEB_INF); 192 if (webInf == null) 193 return NbBundle.getMessage(PanelSourceFolders.class, "MSG_WebInfCorrupted", webPages.getPath()); else { 195 FileObject webXml = webInf.getFileObject(ProjectWebModule.FILE_DD); 196 197 if (webXml != null && !webXml.isValid()) 200 webXml = null; 201 202 String j2eeLevel = (String ) wizardDescriptor.getProperty(WizardProperties.J2EE_LEVEL); 203 if (webXml == null && (j2eeLevel.equals(J2eeModule.J2EE_13) || j2eeLevel.equals(J2eeModule.J2EE_14))) 204 return NbBundle.getMessage(PanelSourceFolders.class, "MSG_FileNotFound", webPages.getPath()); } 206 207 for (int i=0; i<sources.length;i++) { 208 if (!sources[i].isDirectory() || !sources[i].canRead()) { 209 return MessageFormat.format(NbBundle.getMessage(PanelSourceFolders.class,"MSG_IllegalSources"), new Object [] {sources[i].getAbsolutePath()}); 211 } 212 String sloc = sources[i].getAbsolutePath (); 213 if (ploc.equals (sloc) || ploc.startsWith (sloc + File.separatorChar)) { 214 return NbBundle.getMessage(PanelSourceFolders.class,"MSG_IllegalProjectFolder"); } 216 } 217 for (int i=0; i<tests.length; i++) { 218 if (!tests[i].isDirectory() || !tests[i].canRead()) { 219 return MessageFormat.format(NbBundle.getMessage(PanelSourceFolders.class,"MSG_IllegalTests"), new Object [] {sources[i].getAbsolutePath()}); 221 } 222 String tloc = tests[i].getAbsolutePath(); 223 if (ploc.equals(tloc) || ploc.startsWith(tloc + File.separatorChar)) { 224 return NbBundle.getMessage(PanelSourceFolders.class,"MSG_IllegalProjectFolder"); } 226 } 227 return null; 228 } 229 230 void validate (WizardDescriptor d) throws WizardValidationException { 231 searchClassFiles (((FolderList)this.sourcePanel).getFiles()); 233 } 236 237 private void searchClassFiles (File [] folders) throws WizardValidationException { 238 boolean found = false; 239 for (int i=0; i<folders.length; i++) { 240 FileObject folder = FileUtil.toFileObject(folders[i]); 241 if (folder != null) { 242 Enumeration en = folder.getData (true); 243 while (!found && en.hasMoreElements ()) { 244 Object obj = en.nextElement (); 245 assert obj instanceof FileObject : "Instance of FileObject: " + obj; FileObject fo = (FileObject) obj; 247 found = "class".equals (fo.getExt ()); } 249 } 250 } 251 if (found) { 252 Object DELETE_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_DeleteOption"); Object KEEP_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_KeepOption"); Object CANCEL_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_CancelOption"); NotifyDescriptor desc = new NotifyDescriptor ( 256 NbBundle.getMessage (PanelSourceFolders.class, "MSG_FoundClassFiles"), NbBundle.getMessage (PanelSourceFolders.class, "MSG_FoundClassFiles_Title"), NotifyDescriptor.YES_NO_CANCEL_OPTION, 259 NotifyDescriptor.QUESTION_MESSAGE, 260 new Object [] {DELETE_OPTION, KEEP_OPTION, CANCEL_OPTION}, 261 null 262 ); 263 Object result = DialogDisplayer.getDefault().notify(desc); 264 if (DELETE_OPTION.equals (result)) { 265 deleteClassFiles (folders); 266 } else if (!KEEP_OPTION.equals (result)) { 267 throw new WizardValidationException (this.sourcePanel, "", ""); } 270 } 271 } 272 273 private void deleteClassFiles (File [] folders) { 274 for (int i=0; i<folders.length; i++) { 275 FileObject folder = FileUtil.toFileObject(folders[i]); 276 Enumeration en = folder.getData (true); 277 while (en.hasMoreElements ()) { 278 Object obj = en.nextElement (); 279 assert obj instanceof FileObject : "Instance of FileObject: " + obj; 280 FileObject fo = (FileObject) obj; 281 try { 282 if ("class".equals (fo.getExt ())) { fo.delete (); 284 } 285 } catch (IOException ioe) { 286 ErrorManager.getDefault ().notify (ioe); 287 } 288 } 289 } 290 } 291 292 297 private void initComponents() { 299 java.awt.GridBagConstraints gridBagConstraints; 300 301 jLabel3 = new javax.swing.JLabel (); 302 jLabelWebPages = new javax.swing.JLabel (); 303 jTextFieldWebPages = new javax.swing.JTextField (); 304 jButtonWebpagesLocation = new javax.swing.JButton (); 305 jLabelLibraries = new javax.swing.JLabel (); 306 jTextFieldLibraries = new javax.swing.JTextField (); 307 jButtonLibraries = new javax.swing.JButton (); 308 sourcePanel = new FolderList (NbBundle.getMessage(PanelSourceFolders.class,"CTL_SourceRoots"), NbBundle.getMessage(PanelSourceFolders.class,"MNE_SourceRoots").charAt(0),NbBundle.getMessage(PanelSourceFolders.class,"AD_SourceRoots"), NbBundle.getMessage(PanelSourceFolders.class,"CTL_AddSourceRoot"), 309 NbBundle.getMessage(PanelSourceFolders.class,"MNE_AddSourceFolder").charAt(0), NbBundle.getMessage(PanelSourceFolders.class,"AD_AddSourceFolder"),NbBundle.getMessage(PanelSourceFolders.class,"MNE_RemoveSourceFolder").charAt(0), NbBundle.getMessage(PanelSourceFolders.class,"AD_RemoveSourceFolder")); 310 testsPanel = new FolderList (NbBundle.getMessage(PanelSourceFolders.class,"CTL_TestRoots"), NbBundle.getMessage(PanelSourceFolders.class,"MNE_TestRoots").charAt(0),NbBundle.getMessage(PanelSourceFolders.class,"AD_TestRoots"), NbBundle.getMessage(PanelSourceFolders.class,"CTL_AddTestRoot"), 311 NbBundle.getMessage(PanelSourceFolders.class,"MNE_AddTestFolder").charAt(0), NbBundle.getMessage(PanelSourceFolders.class,"AD_AddTestFolder"),NbBundle.getMessage(PanelSourceFolders.class,"MNE_RemoveTestFolder").charAt(0), NbBundle.getMessage(PanelSourceFolders.class,"AD_RemoveTestFolder")); 312 313 setPreferredSize(new java.awt.Dimension (500, 340)); 314 setLayout(new java.awt.GridBagLayout ()); 315 316 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "LBL_IW_LocationDesc_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 318 gridBagConstraints.gridy = 0; 319 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 320 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 321 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 322 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 323 add(jLabel3, gridBagConstraints); 324 jLabel3.getAccessibleContext().setAccessibleName(null); 325 jLabel3.getAccessibleContext().setAccessibleDescription(null); 326 327 jLabelWebPages.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "LBL_IW_WebPagesLocation_LabelMnemonic").charAt(0)); 328 jLabelWebPages.setLabelFor(jTextFieldWebPages); 329 jLabelWebPages.setText(NbBundle.getMessage(PanelSourceFolders.class, "LBL_IW_WebPagesLocation_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 331 gridBagConstraints.gridx = 0; 332 gridBagConstraints.gridy = 1; 333 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 334 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 335 add(jLabelWebPages, gridBagConstraints); 336 gridBagConstraints = new java.awt.GridBagConstraints (); 337 gridBagConstraints.gridx = 1; 338 gridBagConstraints.gridy = 1; 339 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 340 gridBagConstraints.weightx = 1.0; 341 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 342 add(jTextFieldWebPages, gridBagConstraints); 343 jTextFieldWebPages.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "ACSD_WebPagesFolder")); 345 jButtonWebpagesLocation.setMnemonic(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "LBL_WebPagesFolder_MNE").charAt(0)); 346 jButtonWebpagesLocation.setText(NbBundle.getMessage(PanelSourceFolders.class, "LBL_BrowseWebPagesLocation_Button")); jButtonWebpagesLocation.addActionListener(new java.awt.event.ActionListener () { 348 public void actionPerformed(java.awt.event.ActionEvent evt) { 349 jButtonWebpagesLocationActionPerformed(evt); 350 } 351 }); 352 gridBagConstraints = new java.awt.GridBagConstraints (); 353 gridBagConstraints.gridx = 2; 354 gridBagConstraints.gridy = 1; 355 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 356 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 357 add(jButtonWebpagesLocation, gridBagConstraints); 358 jButtonWebpagesLocation.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "ACSD_BrowseWebPageFolder")); 360 jLabelLibraries.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "LBL_IW_LibrariesLocation_LabelMnemonic").charAt(0)); 361 jLabelLibraries.setLabelFor(jTextFieldLibraries); 362 jLabelLibraries.setText(NbBundle.getMessage(PanelSourceFolders.class, "LBL_IW_LibrariesLocation_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 364 gridBagConstraints.gridx = 0; 365 gridBagConstraints.gridy = 2; 366 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 367 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 368 add(jLabelLibraries, gridBagConstraints); 369 gridBagConstraints = new java.awt.GridBagConstraints (); 370 gridBagConstraints.gridx = 1; 371 gridBagConstraints.gridy = 2; 372 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 373 gridBagConstraints.weightx = 1.0; 374 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 375 add(jTextFieldLibraries, gridBagConstraints); 376 jTextFieldLibraries.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "ACSD_LibrariesFolder")); 378 jButtonLibraries.setMnemonic(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "MNE_BrowseLibrariesLocation").charAt(0)); 379 jButtonLibraries.setText(NbBundle.getMessage(PanelSourceFolders.class, "LBL_BrowseLibrariesLocation_Button")); jButtonLibraries.addActionListener(new java.awt.event.ActionListener () { 381 public void actionPerformed(java.awt.event.ActionEvent evt) { 382 jButtonLibrariesActionPerformed(evt); 383 } 384 }); 385 gridBagConstraints = new java.awt.GridBagConstraints (); 386 gridBagConstraints.gridx = 2; 387 gridBagConstraints.gridy = 2; 388 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 389 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 390 add(jButtonLibraries, gridBagConstraints); 391 jButtonLibraries.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelSourceFolders.class, "ACSD_BrowseLibrariesFolder")); 393 gridBagConstraints = new java.awt.GridBagConstraints (); 394 gridBagConstraints.gridy = 3; 395 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 396 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 397 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 398 gridBagConstraints.weightx = 1.0; 399 gridBagConstraints.weighty = 0.45; 400 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 401 add(sourcePanel, gridBagConstraints); 402 gridBagConstraints = new java.awt.GridBagConstraints (); 403 gridBagConstraints.gridy = 4; 404 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 405 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 406 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 407 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 408 gridBagConstraints.weightx = 1.0; 409 gridBagConstraints.weighty = 0.45; 410 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 411 add(testsPanel, gridBagConstraints); 412 413 getAccessibleContext().setAccessibleName(null); 414 getAccessibleContext().setAccessibleDescription(null); 415 } 417 private void jButtonLibrariesActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (); 419 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 420 chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY); 421 if (jTextFieldLibraries.getText().length() > 0 && getLibraries().exists()) { 422 chooser.setSelectedFile(getLibraries()); 423 } else { 424 chooser.setCurrentDirectory((File ) wizardDescriptor.getProperty(WizardProperties.SOURCE_ROOT)); 425 } 426 if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 427 File configFilesDir = FileUtil.normalizeFile(chooser.getSelectedFile()); 428 jTextFieldLibraries.setText(configFilesDir.getAbsolutePath()); 429 } 430 } 432 private void jButtonWebpagesLocationActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (); 434 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 435 chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY); 436 if (jTextFieldWebPages.getText().length() > 0 && getWebPages().exists()) { 437 chooser.setSelectedFile(getWebPages()); 438 } else { 439 chooser.setCurrentDirectory((File ) wizardDescriptor.getProperty(WizardProperties.SOURCE_ROOT)); 440 } 441 if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 442 File webPagesDir = FileUtil.normalizeFile(chooser.getSelectedFile()); 443 jTextFieldWebPages.setText(webPagesDir.getAbsolutePath()); 444 } 445 } 447 448 449 private javax.swing.JButton jButtonLibraries; 451 private javax.swing.JButton jButtonWebpagesLocation; 452 private javax.swing.JLabel jLabel3; 453 private javax.swing.JLabel jLabelLibraries; 454 private javax.swing.JLabel jLabelWebPages; 455 private javax.swing.JTextField jTextFieldLibraries; 456 private javax.swing.JTextField jTextFieldWebPages; 457 private javax.swing.JPanel sourcePanel; 458 private javax.swing.JPanel testsPanel; 459 461 462 static class Panel implements WizardDescriptor.ValidatingPanel { 463 464 private ArrayList listeners; 465 private PanelSourceFolders component; 466 private WizardDescriptor settings; 467 468 public synchronized void removeChangeListener(ChangeListener l) { 469 if (this.listeners == null) { 470 return; 471 } 472 this.listeners.remove(l); 473 } 474 475 public void addChangeListener(ChangeListener l) { 476 if (this.listeners == null) { 477 this.listeners = new ArrayList (); 478 } 479 this.listeners.add (l); 480 } 481 482 public void readSettings(Object settings) { 483 this.settings = (WizardDescriptor) settings; 484 this.component.read (this.settings); 485 Object substitute = component.getClientProperty ("NewProjectWizard_Title"); if (substitute != null) { 489 this.settings.putProperty ("NewProjectWizard_Title", substitute); } 491 } 492 493 public void storeSettings(Object settings) { 494 this.component.store (this.settings); 495 } 496 497 public void validate() throws WizardValidationException { 498 this.component.validate(this.settings); 499 } 500 501 public boolean isValid() { 502 return this.component.valid (this.settings); 503 } 504 505 public synchronized java.awt.Component getComponent() { 506 if (this.component == null) { 507 this.component = new PanelSourceFolders (this); 508 } 509 return this.component; 510 } 511 512 public HelpCtx getHelp() { 513 return new HelpCtx (PanelSourceFolders.class); 514 } 515 516 private void fireChangeEvent () { 517 Iterator it = null; 518 synchronized (this) { 519 if (this.listeners == null) { 520 return; 521 } 522 it = ((ArrayList )this.listeners.clone()).iterator(); 523 } 524 ChangeEvent event = new ChangeEvent (this); 525 while (it.hasNext()) { 526 ((ChangeListener )it.next()).stateChanged(event); 527 } 528 } 529 530 } 531 532 private File getAsFile(String filename) { 533 return FileUtil.normalizeFile(new File (filename)); 534 } 535 536 public File getWebPages() { 537 return getAsFile(jTextFieldWebPages.getText()); 538 } 539 540 public File getLibraries() { 541 return getAsFile(jTextFieldLibraries.getText()); 542 } 543 } 544 | Popular Tags |