Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties 23 Aug 2004 21:09:07 -0000 1.33 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties 20 Sep 2004 11:14:14 -0000 @@ -166,3 +166,11 @@ ACSD_PanelOptionsVisual=N/A ACSN_PanelOptionsVisual=N/A + +MSG_FoundClassFiles=The folder {0} contains some class files. Do you want to delete it? +BTN_Delete=Delete +BTN_Keep=Keep +MSG_FoundClassFiles_Title=Confirmation +TXT_DeleteOption=Delete +TXT_KeepOption=Keep +TXT_CancelOption=Cancel Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProject.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProject.java,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProject.java 3 Aug 2004 17:16:55 -0000 1.8 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProject.java 20 Sep 2004 11:14:14 -0000 @@ -21,13 +21,14 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; import org.openide.util.HelpCtx; /** * Panel just asking for basic info. * @author Jesse Glick */ -final class PanelConfigureProject implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel { +final class PanelConfigureProject implements WizardDescriptor.Panel, WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { private WizardDescriptor wizardDescriptor; private int type; @@ -105,6 +106,11 @@ public boolean isFinishPanel() { return true; + } + + public void validate () throws WizardValidationException { + getComponent (); + component.validate (wizardDescriptor); } } Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProjectVisual.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProjectVisual.java,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProjectVisual.java 8 Sep 2004 13:54:59 -0000 1.13 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProjectVisual.java 20 Sep 2004 11:14:14 -0000 @@ -19,6 +19,7 @@ import javax.swing.event.DocumentListener; import javax.swing.text.Document; import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; import org.openide.util.NbBundle; /** First panel in the NewProject wizard. Used for filling in @@ -87,6 +88,10 @@ projectLocationPanel.store( d ); optionsPanel.store( d ); + } + + void validate (WizardDescriptor d) throws WizardValidationException { + projectLocationPanel.validate (d); } Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelOptionsVisual.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelOptionsVisual.java,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelOptionsVisual.java 8 Sep 2004 13:54:59 -0000 1.16 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelOptionsVisual.java 20 Sep 2004 11:14:14 -0000 @@ -25,6 +25,7 @@ import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; import org.openide.util.NbBundle; /** @@ -175,6 +176,10 @@ void read (WizardDescriptor d) { //TODO: + } + + void validate (WizardDescriptor d) throws WizardValidationException { + // nothing to validate } void store( WizardDescriptor d ) { Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelProjectLocationVisual.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelProjectLocationVisual.java,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelProjectLocationVisual.java 15 Sep 2004 12:53:46 -0000 1.25 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelProjectLocationVisual.java 20 Sep 2004 11:14:14 -0000 @@ -24,6 +24,7 @@ import org.netbeans.spi.project.support.ant.PropertyUtils; import org.netbeans.spi.project.ui.support.ProjectChooser; import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; import org.openide.filesystems.FileUtil; import org.openide.util.NbBundle; @@ -261,6 +262,9 @@ this.projectNameTextField.selectAll(); } + void validate (WizardDescriptor d) throws WizardValidationException { + // nothing to validate + } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton browseButton; Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelSourceFolders.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelSourceFolders.java,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelSourceFolders.java 15 Sep 2004 12:53:46 -0000 1.28 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelSourceFolders.java 20 Sep 2004 11:14:14 -0000 @@ -13,16 +13,22 @@ package org.netbeans.modules.java.j2seproject.ui.wizards; +import java.awt.Dialog; import java.io.File; import java.io.IOException; import java.text.MessageFormat; +import java.util.Enumeration; import javax.swing.JFileChooser; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectManager; import org.netbeans.modules.java.j2seproject.ui.FoldersListSettings; import org.netbeans.spi.project.ui.support.ProjectChooser; +import org.openide.DialogDisplayer; +import org.openide.ErrorManager; +import org.openide.NotifyDescriptor; import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.NbBundle; @@ -271,7 +277,62 @@ } return null; } - + + void validate (WizardDescriptor d) throws WizardValidationException { + // sources root + searchClassFiles (FileUtil.toFileObject (FileUtil.normalizeFile(new File (sources.getText ())))); + // test root + searchClassFiles (FileUtil.toFileObject (FileUtil.normalizeFile(new File (tests.getText ())))); + } + + private void searchClassFiles (FileObject folder) throws WizardValidationException { + Enumeration en = folder.getData (true); + boolean found = false; + while (!found && en.hasMoreElements ()) { + Object obj = en.nextElement (); + assert obj instanceof FileObject : "Instance of FileObject: " + obj; + FileObject fo = (FileObject) en.nextElement (); + found = "class".equals (fo.getExt ()); + } + + if (found) { + + Object DELETE_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_DeleteOption"); // NOI18N + Object KEEP_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_KeepOption"); // NOI18N + Object CANCEL_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_CancelOption"); // NOI18N + NotifyDescriptor desc = new NotifyDescriptor ( + NbBundle.getMessage (PanelSourceFolders.class, "MSG_FoundClassFiles", FileUtil.getFileDisplayName (folder)), // NOI18N + NbBundle.getMessage (PanelSourceFolders.class, "MSG_FoundClassFiles_Title"), // NOI18N + NotifyDescriptor.YES_NO_CANCEL_OPTION, + NotifyDescriptor.QUESTION_MESSAGE, + new Object[] {DELETE_OPTION, KEEP_OPTION, CANCEL_OPTION}, + null + ); + + Object result = DialogDisplayer.getDefault().notify(desc); + if (DELETE_OPTION.equals (result)) { + //deleteClassFiles (folder); + } else if (!KEEP_OPTION.equals (result)) { + // cancel, back to wizard + throw new WizardValidationException (sources, "", ""); // NOI18N + } + } + } + + private void deleteClassFiles (FileObject folder) { + Enumeration en = folder.getData (true); + while (en.hasMoreElements ()) { + Object obj = en.nextElement (); + assert obj instanceof FileObject : "Instance of FileObject: " + obj; + FileObject fo = (FileObject) obj; + try { + fo.delete (); + } catch (IOException ioe) { + ErrorManager.getDefault ().notify (ioe); + } + } + } + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is Index: src/org/netbeans/modules/java/j2seproject/ui/wizards/SettingsPanel.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/SettingsPanel.java,v --- src/org/netbeans/modules/java/j2seproject/ui/wizards/SettingsPanel.java 17 May 2004 14:59:03 -0000 1.1 +++ src/org/netbeans/modules/java/j2seproject/ui/wizards/SettingsPanel.java 20 Sep 2004 11:14:14 -0000 @@ -15,6 +15,7 @@ import javax.swing.JPanel; import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; abstract class SettingsPanel extends JPanel { @@ -24,4 +25,6 @@ abstract void read (WizardDescriptor settings); abstract boolean valid (WizardDescriptor settings); + + abstract void validate (WizardDescriptor settings) throws WizardValidationException; }