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 |