This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 48198
Collapse All | Expand All

(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties (+8 lines)
Lines 166-168 Link Here
166
ACSD_PanelOptionsVisual=N/A
166
ACSD_PanelOptionsVisual=N/A
167
167
168
ACSN_PanelOptionsVisual=N/A
168
ACSN_PanelOptionsVisual=N/A
169
170
MSG_FoundClassFiles=The folder {0} contains some class files. Do you want to delete it?
171
BTN_Delete=Delete
172
BTN_Keep=Keep
173
MSG_FoundClassFiles_Title=Confirmation
174
TXT_DeleteOption=Delete
175
TXT_KeepOption=Keep
176
TXT_CancelOption=Cancel
(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProject.java (-1 / +7 lines)
Lines 21-33 Link Here
21
import javax.swing.event.ChangeEvent;
21
import javax.swing.event.ChangeEvent;
22
import javax.swing.event.ChangeListener;
22
import javax.swing.event.ChangeListener;
23
import org.openide.WizardDescriptor;
23
import org.openide.WizardDescriptor;
24
import org.openide.WizardValidationException;
24
import org.openide.util.HelpCtx;
25
import org.openide.util.HelpCtx;
25
26
26
/**
27
/**
27
 * Panel just asking for basic info.
28
 * Panel just asking for basic info.
28
 * @author Jesse Glick
29
 * @author Jesse Glick
29
 */
30
 */
30
final class PanelConfigureProject implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel {
31
final class PanelConfigureProject implements WizardDescriptor.Panel, WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
31
    
32
    
32
    private WizardDescriptor wizardDescriptor;
33
    private WizardDescriptor wizardDescriptor;
33
    private int type;
34
    private int type;
Lines 105-110 Link Here
105
106
106
    public boolean isFinishPanel() {
107
    public boolean isFinishPanel() {
107
        return true;
108
        return true;
109
    }
110
    
111
    public void validate () throws WizardValidationException {
112
        getComponent ();
113
        component.validate (wizardDescriptor);
108
    }
114
    }
109
115
110
}
116
}
(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelConfigureProjectVisual.java (+5 lines)
Lines 19-24 Link Here
19
import javax.swing.event.DocumentListener;
19
import javax.swing.event.DocumentListener;
20
import javax.swing.text.Document;
20
import javax.swing.text.Document;
21
import org.openide.WizardDescriptor;
21
import org.openide.WizardDescriptor;
22
import org.openide.WizardValidationException;
22
import org.openide.util.NbBundle;
23
import org.openide.util.NbBundle;
23
24
24
/** First panel in the NewProject wizard. Used for filling in
25
/** First panel in the NewProject wizard. Used for filling in
Lines 87-92 Link Here
87
        
88
        
88
        projectLocationPanel.store( d );
89
        projectLocationPanel.store( d );
89
        optionsPanel.store( d );        
90
        optionsPanel.store( d );        
91
    }
92
    
93
    void validate (WizardDescriptor d) throws WizardValidationException {
94
        projectLocationPanel.validate (d);
90
    }
95
    }
91
    
96
    
92
    
97
    
(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelOptionsVisual.java (+5 lines)
Lines 25-30 Link Here
25
import org.openide.DialogDisplayer;
25
import org.openide.DialogDisplayer;
26
import org.openide.NotifyDescriptor;
26
import org.openide.NotifyDescriptor;
27
import org.openide.WizardDescriptor;
27
import org.openide.WizardDescriptor;
28
import org.openide.WizardValidationException;
28
import org.openide.util.NbBundle;
29
import org.openide.util.NbBundle;
29
30
30
/**
31
/**
Lines 175-180 Link Here
175
    
176
    
176
    void read (WizardDescriptor d) {
177
    void read (WizardDescriptor d) {
177
        //TODO:
178
        //TODO:
179
    }
180
    
181
    void validate (WizardDescriptor d) throws WizardValidationException {
182
        // nothing to validate
178
    }
183
    }
179
184
180
    void store( WizardDescriptor d ) {
185
    void store( WizardDescriptor d ) {
(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelProjectLocationVisual.java (+4 lines)
Lines 24-29 Link Here
24
import org.netbeans.spi.project.support.ant.PropertyUtils;
24
import org.netbeans.spi.project.support.ant.PropertyUtils;
25
import org.netbeans.spi.project.ui.support.ProjectChooser;
25
import org.netbeans.spi.project.ui.support.ProjectChooser;
26
import org.openide.WizardDescriptor;
26
import org.openide.WizardDescriptor;
27
import org.openide.WizardValidationException;
27
import org.openide.filesystems.FileUtil;
28
import org.openide.filesystems.FileUtil;
28
import org.openide.util.NbBundle;
29
import org.openide.util.NbBundle;
29
30
Lines 261-266 Link Here
261
        this.projectNameTextField.selectAll();
262
        this.projectNameTextField.selectAll();
262
    }
263
    }
263
        
264
        
265
    void validate (WizardDescriptor d) throws WizardValidationException {
266
        // nothing to validate
267
    }
264
    
268
    
265
    // Variables declaration - do not modify//GEN-BEGIN:variables
269
    // Variables declaration - do not modify//GEN-BEGIN:variables
266
    private javax.swing.JButton browseButton;
270
    private javax.swing.JButton browseButton;
(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelSourceFolders.java (-1 / +62 lines)
Lines 13-28 Link Here
13
13
14
package org.netbeans.modules.java.j2seproject.ui.wizards;
14
package org.netbeans.modules.java.j2seproject.ui.wizards;
15
15
16
import java.awt.Dialog;
16
import java.io.File;
17
import java.io.File;
17
import java.io.IOException;
18
import java.io.IOException;
18
import java.text.MessageFormat;
19
import java.text.MessageFormat;
20
import java.util.Enumeration;
19
import javax.swing.JFileChooser;
21
import javax.swing.JFileChooser;
20
import javax.swing.event.DocumentEvent;
22
import javax.swing.event.DocumentEvent;
21
import javax.swing.event.DocumentListener;
23
import javax.swing.event.DocumentListener;
22
import org.netbeans.api.project.ProjectManager;
24
import org.netbeans.api.project.ProjectManager;
23
import org.netbeans.modules.java.j2seproject.ui.FoldersListSettings;
25
import org.netbeans.modules.java.j2seproject.ui.FoldersListSettings;
24
import org.netbeans.spi.project.ui.support.ProjectChooser;
26
import org.netbeans.spi.project.ui.support.ProjectChooser;
27
import org.openide.DialogDisplayer;
28
import org.openide.ErrorManager;
29
import org.openide.NotifyDescriptor;
25
import org.openide.WizardDescriptor;
30
import org.openide.WizardDescriptor;
31
import org.openide.WizardValidationException;
26
import org.openide.filesystems.FileObject;
32
import org.openide.filesystems.FileObject;
27
import org.openide.filesystems.FileUtil;
33
import org.openide.filesystems.FileUtil;
28
import org.openide.util.NbBundle;
34
import org.openide.util.NbBundle;
Lines 271-277 Link Here
271
        }
277
        }
272
        return null;
278
        return null;
273
    }
279
    }
274
280
    
281
    void validate (WizardDescriptor d) throws WizardValidationException {
282
        // sources root
283
        searchClassFiles (FileUtil.toFileObject (FileUtil.normalizeFile(new File (sources.getText ()))));
284
        // test root
285
        searchClassFiles (FileUtil.toFileObject (FileUtil.normalizeFile(new File (tests.getText ()))));
286
    }
287
    
288
    private void searchClassFiles (FileObject folder) throws WizardValidationException {
289
        Enumeration en = folder.getData (true);
290
        boolean found = false;
291
        while (!found && en.hasMoreElements ()) {
292
            Object obj = en.nextElement ();
293
            assert obj instanceof FileObject : "Instance of FileObject: " + obj;
294
            FileObject fo = (FileObject) en.nextElement ();
295
            found = "class".equals (fo.getExt ());
296
        }
297
        
298
        if (found) {
299
            
300
            Object DELETE_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_DeleteOption"); // NOI18N
301
            Object KEEP_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_KeepOption"); // NOI18N
302
            Object CANCEL_OPTION = NbBundle.getMessage (PanelSourceFolders.class, "TXT_CancelOption"); // NOI18N
303
            NotifyDescriptor desc = new NotifyDescriptor (
304
                    NbBundle.getMessage (PanelSourceFolders.class, "MSG_FoundClassFiles", FileUtil.getFileDisplayName (folder)), // NOI18N
305
                    NbBundle.getMessage (PanelSourceFolders.class, "MSG_FoundClassFiles_Title"), // NOI18N
306
                    NotifyDescriptor.YES_NO_CANCEL_OPTION,
307
                    NotifyDescriptor.QUESTION_MESSAGE,
308
                    new Object[] {DELETE_OPTION, KEEP_OPTION, CANCEL_OPTION},
309
                    null
310
                    );
311
            
312
            Object result = DialogDisplayer.getDefault().notify(desc);
313
            if (DELETE_OPTION.equals (result)) {
314
                //deleteClassFiles (folder);
315
            } else if (!KEEP_OPTION.equals (result)) {
316
                // cancel, back to wizard
317
                throw new WizardValidationException (sources, "", ""); // NOI18N
318
            }            
319
        }
320
    }
321
    
322
    private void deleteClassFiles (FileObject folder) {
323
        Enumeration en = folder.getData (true);
324
        while (en.hasMoreElements ()) {
325
            Object obj = en.nextElement ();
326
            assert obj instanceof FileObject : "Instance of FileObject: " + obj;
327
            FileObject fo = (FileObject) obj;
328
            try {
329
                fo.delete ();
330
            } catch (IOException ioe) {
331
                ErrorManager.getDefault ().notify (ioe);
332
            }
333
        }
334
    }
335
    
275
    /** This method is called from within the constructor to
336
    /** This method is called from within the constructor to
276
     * initialize the form.
337
     * initialize the form.
277
     * WARNING: Do NOT modify this code. The content of this method is
338
     * WARNING: Do NOT modify this code. The content of this method is
(-)src/org/netbeans/modules/java/j2seproject/ui/wizards/SettingsPanel.java (+3 lines)
Lines 15-20 Link Here
15
15
16
import javax.swing.JPanel;
16
import javax.swing.JPanel;
17
import org.openide.WizardDescriptor;
17
import org.openide.WizardDescriptor;
18
import org.openide.WizardValidationException;
18
19
19
20
20
abstract class SettingsPanel extends JPanel {
21
abstract class SettingsPanel extends JPanel {
Lines 24-27 Link Here
24
    abstract void read (WizardDescriptor settings);
25
    abstract void read (WizardDescriptor settings);
25
26
26
    abstract boolean valid (WizardDescriptor settings);
27
    abstract boolean valid (WizardDescriptor settings);
28
    
29
    abstract void validate (WizardDescriptor settings) throws WizardValidationException;
27
}
30
}

Return to bug 48198