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 47737
Collapse All | Expand All

(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/CustomizerPanel.java (-45 / +29 lines)
Lines 60-66 Link Here
60
import java.util.List;
60
import java.util.List;
61
import java.util.Properties;
61
import java.util.Properties;
62
import javax.swing.DefaultListModel;
62
import javax.swing.DefaultListModel;
63
import javax.swing.JFileChooser;
64
import javax.swing.event.ChangeListener;
63
import javax.swing.event.ChangeListener;
65
import javax.swing.event.DocumentEvent;
64
import javax.swing.event.DocumentEvent;
66
import javax.swing.event.DocumentListener;
65
import javax.swing.event.DocumentListener;
Lines 72-77 Link Here
72
import org.openide.DialogDescriptor;
71
import org.openide.DialogDescriptor;
73
import org.openide.DialogDisplayer;
72
import org.openide.DialogDisplayer;
74
import org.openide.NotifyDescriptor;
73
import org.openide.NotifyDescriptor;
74
import org.openide.filesystems.FileChooserBuilder;
75
import org.openide.filesystems.FileObject;
75
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileUtil;
76
import org.openide.filesystems.FileUtil;
77
import org.openide.filesystems.URLMapper;
77
import org.openide.filesystems.URLMapper;
Lines 95-101 Link Here
95
    public static final String PROF_PROP = "kvem.profiler.enable"; // NOI18N
95
    public static final String PROF_PROP = "kvem.profiler.enable"; // NOI18N
96
    public static final String FALSE = "false"; // NOI18N
96
    public static final String FALSE = "false"; // NOI18N
97
    
97
    
98
    String fileChooserValue;
99
    J2MEPlatform platform;
98
    J2MEPlatform platform;
100
    DefaultListModel mSources;
99
    DefaultListModel mSources;
101
    DefaultListModel mJavaDocs;
100
    DefaultListModel mJavaDocs;
Lines 209-216 Link Here
209
        if (platform == null)
208
        if (platform == null)
210
            return;
209
            return;
211
        
210
        
212
        if (fileChooserValue == null)
213
            fileChooserValue = platform.getHomePath();
214
        final DefaultListModel mDevices = new DefaultListModel();
211
        final DefaultListModel mDevices = new DefaultListModel();
215
        final J2MEPlatform.Device[] devices = platform.getDevices();
212
        final J2MEPlatform.Device[] devices = platform.getDevices();
216
        if (devices != null) {
213
        if (devices != null) {
Lines 348-390 Link Here
348
        bJavaDocMoveUp.setEnabled(lJavaDocPaths.getSelectedIndex() > 0);
345
        bJavaDocMoveUp.setEnabled(lJavaDocPaths.getSelectedIndex() > 0);
349
        bJavaDocMoveDown.setEnabled(lJavaDocPaths.getSelectedIndex() >= 0  &&  lJavaDocPaths.getSelectedIndex() < mJavaDocs.getSize() - 1);
346
        bJavaDocMoveDown.setEnabled(lJavaDocPaths.getSelectedIndex() >= 0  &&  lJavaDocPaths.getSelectedIndex() < mJavaDocs.getSize() - 1);
350
    }
347
    }
351
    
348
352
    private String browseArchive(final String oldValue, final String title) {
349
    private String browseArchive(final String title) {
353
        final JFileChooser chooser = new JFileChooser();
350
        File f;
354
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
351
        if ((f = new FileChooserBuilder(CustomizerPanel.class).
355
        chooser.setFileFilter(new FileFilter() {
352
                setFilesOnly(true).setFileFilter(new ArchiveFilter()).
356
            public boolean accept(File f) {
353
                setTitle(title).showOpenDialog()) != null) {
357
                return (f.exists() && f.canRead() && (f.isDirectory() || (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")))); // NOI18N
354
            return f.getAbsolutePath();
358
            }
359
            public String getDescription() {
360
                return NbBundle.getMessage(CustomizerPanel.class,"TXT_Customizer_ZipFilter"); // NOI18N
361
            }
362
        });
363
        if (oldValue != null)
364
            chooser.setSelectedFile(new File(oldValue));
365
        chooser.setDialogTitle(title);
366
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
367
            return chooser.getSelectedFile().getAbsolutePath();
368
        }
355
        }
369
        return null;
356
        return null;
370
    }
357
    }
358
359
    private static final class FolderFilter extends FileFilter {
360
        public boolean accept(File f) {
361
            return f.exists() && f.canRead() && f.isDirectory();
362
        }
363
        public String getDescription() {
364
            return NbBundle.getMessage(CustomizerPanel.class,"TXT_Customizer_FolderFilter"); // NOI18N
365
        }
366
    }
371
    
367
    
372
    private String browseFolder(final String oldValue, final String title) {
368
    private String browseFolder(final String title) {
373
        final JFileChooser chooser = new JFileChooser();
369
        File defPath = platform.getHomePath() == null ? null :
374
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
370
            new File(platform.getHomePath());
375
        chooser.setFileFilter(new FileFilter() {
371
        File f;
376
            public boolean accept(File f) {
372
        if ((f = new FileChooserBuilder (getClass().getName() + ".fld").
377
                return f.exists() && f.canRead() && f.isDirectory();
373
                setFileFilter(new FolderFilter()).setTitle(title).
378
            }
374
                setDefaultWorkingDirectory(defPath).showOpenDialog()) != null) {
379
            public String getDescription() {
375
            return f.getAbsolutePath();
380
                return NbBundle.getMessage(CustomizerPanel.class,"TXT_Customizer_FolderFilter"); // NOI18N
381
            }
382
        });
383
        if (oldValue != null)
384
            chooser.setSelectedFile(new File(oldValue));
385
        chooser.setDialogTitle(title);
386
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
387
            return chooser.getSelectedFile().getAbsolutePath();
388
        }
376
        }
389
        return null;
377
        return null;
390
    }
378
    }
Lines 1016-1025 Link Here
1016
    private void bJavaDocAddFolderActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bJavaDocAddFolderActionPerformed
1004
    private void bJavaDocAddFolderActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bJavaDocAddFolderActionPerformed
1017
        if (platform == null)
1005
        if (platform == null)
1018
            return;
1006
            return;
1019
        final String value = browseFolder(fileChooserValue, NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectJavaDocFolder")); // NOI18N
1007
        final String value = browseFolder(NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectJavaDocFolder")); // NOI18N
1020
        if (value == null)
1008
        if (value == null)
1021
            return;
1009
            return;
1022
        fileChooserValue = value;
1023
        final URL o = J2MEPlatform.localfilepath2url(value);
1010
        final URL o = J2MEPlatform.localfilepath2url(value);
1024
        if (o != null) {
1011
        if (o != null) {
1025
            mJavaDocs.addElement(new ListItem<URL>(o));
1012
            mJavaDocs.addElement(new ListItem<URL>(o));
Lines 1038-1047 Link Here
1038
    private void bSourceAddFolderActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSourceAddFolderActionPerformed
1025
    private void bSourceAddFolderActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSourceAddFolderActionPerformed
1039
        if (platform == null)
1026
        if (platform == null)
1040
            return;
1027
            return;
1041
        final String value = browseFolder(fileChooserValue, NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectSourceFolder")); // NOI18N
1028
        final String value = browseFolder(NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectSourceFolder")); // NOI18N
1042
        if (value == null)
1029
        if (value == null)
1043
            return;
1030
            return;
1044
        fileChooserValue = value;
1045
        final FileObject o = platform.resolveRelativePathToFileObject(value);
1031
        final FileObject o = platform.resolveRelativePathToFileObject(value);
1046
        if (o != null) {
1032
        if (o != null) {
1047
            mSources.addElement(new ListItem<FileObject>(o));
1033
            mSources.addElement(new ListItem<FileObject>(o));
Lines 1068-1077 Link Here
1068
    private void bJavaDocAddArchiveActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bJavaDocAddArchiveActionPerformed
1054
    private void bJavaDocAddArchiveActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bJavaDocAddArchiveActionPerformed
1069
        if (platform == null)
1055
        if (platform == null)
1070
            return;
1056
            return;
1071
        final String value = browseArchive(fileChooserValue, NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectJavaDocArchive")); // NOI18N
1057
        final String value = browseArchive(NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectJavaDocArchive")); // NOI18N
1072
        if (value == null)
1058
        if (value == null)
1073
            return;
1059
            return;
1074
        fileChooserValue = value;
1075
        final URL o = J2MEPlatform.localfilepath2url(value);
1060
        final URL o = J2MEPlatform.localfilepath2url(value);
1076
        if (o != null) {
1061
        if (o != null) {
1077
            mJavaDocs.addElement(new ListItem<URL>(o));
1062
            mJavaDocs.addElement(new ListItem<URL>(o));
Lines 1090-1099 Link Here
1090
    private void bSourceAddArchiveActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSourceAddArchiveActionPerformed
1075
    private void bSourceAddArchiveActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSourceAddArchiveActionPerformed
1091
        if (platform == null)
1076
        if (platform == null)
1092
            return;
1077
            return;
1093
        final String value = browseArchive(fileChooserValue, NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectSourceArchive")); // NOI18N
1078
        final String value = browseArchive(NbBundle.getMessage(CustomizerPanel.class, "TITLE_Customizer_SelectSourceArchive")); // NOI18N
1094
        if (value == null)
1079
        if (value == null)
1095
            return;
1080
            return;
1096
        fileChooserValue = value;
1097
        final FileObject o = platform.resolveRelativePathToFileObject(value);
1081
        final FileObject o = platform.resolveRelativePathToFileObject(value);
1098
        if (o != null) {
1082
        if (o != null) {
1099
            mSources.addElement(new ListItem<FileObject>(o));
1083
            mSources.addElement(new ListItem<FileObject>(o));
(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/SrcDocPathsPanel.java (-26 / +10 lines)
Lines 51-67 Link Here
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.List;
52
import java.util.List;
53
import javax.swing.DefaultListModel;
53
import javax.swing.DefaultListModel;
54
import javax.swing.JFileChooser;
55
import javax.swing.event.ChangeEvent;
54
import javax.swing.event.ChangeEvent;
56
import javax.swing.event.ChangeListener;
55
import javax.swing.event.ChangeListener;
57
import javax.swing.event.ListSelectionEvent;
56
import javax.swing.event.ListSelectionEvent;
58
import javax.swing.event.ListSelectionListener;
57
import javax.swing.event.ListSelectionListener;
59
import javax.swing.filechooser.FileFilter;
60
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.URLMapper;
59
import org.openide.filesystems.URLMapper;
62
import org.openide.util.HelpCtx;
60
import org.openide.util.HelpCtx;
63
import org.openide.util.NbBundle;
61
import org.openide.util.NbBundle;
64
import org.openide.WizardDescriptor;
62
import org.openide.WizardDescriptor;
63
import org.openide.filesystems.FileChooserBuilder;
65
64
66
/**
65
/**
67
 *
66
 *
Lines 74-80 Link Here
74
    J2MEPlatform platform;
73
    J2MEPlatform platform;
75
    DefaultListModel srcModel;
74
    DefaultListModel srcModel;
76
    DefaultListModel docModel;
75
    DefaultListModel docModel;
77
    String fileChooserValue;
78
    
76
    
79
    /** Creates new form SrcDocPathsPanel */
77
    /** Creates new form SrcDocPathsPanel */
80
    public SrcDocPathsPanel() {
78
    public SrcDocPathsPanel() {
Lines 87-100 Link Here
87
        docModel = new DefaultListModel();
85
        docModel = new DefaultListModel();
88
        lDocPaths.setModel(docModel);
86
        lDocPaths.setModel(docModel);
89
        platform = null;
87
        platform = null;
90
        fileChooserValue = null;
91
    }
88
    }
92
    
89
    
93
    public void readData(final WizardDescriptor object) {
90
    public void readData(final WizardDescriptor object) {
94
        platform = (J2MEPlatform) object.getProperty(DetectPanel.PLATFORM);
91
        platform = (J2MEPlatform) object.getProperty(DetectPanel.PLATFORM);
95
        if (platform == null)
92
        if (platform == null)
96
            return;
93
            return;
97
        fileChooserValue = platform.getHomePath();
98
        final FileObject[] al = platform.getSourceFolders().getRoots();
94
        final FileObject[] al = platform.getSourceFolders().getRoots();
99
        srcModel.clear();
95
        srcModel.clear();
100
        if (al != null) 
96
        if (al != null) 
Lines 129-151 Link Here
129
        		u.add(((ListItem<URL>)osa).getObject());
125
        		u.add(((ListItem<URL>)osa).getObject());
130
        platform.setJavadocFolders(u);
126
        platform.setJavadocFolders(u);
131
    }
127
    }
132
    
128
133
    private String browse(final String oldValue, final String title) {
129
    private String browse(final String title) {
134
        final JFileChooser chooser = new JFileChooser();
130
        File f;
135
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
131
        if ((f = new FileChooserBuilder(SrcDocPathsPanel.class).
136
        chooser.setFileFilter(new FileFilter() {
132
                setFileFilter(new ArchiveFilter()).
137
            public boolean accept(File f) {
133
                setTitle(title).showOpenDialog()) != null) {
138
                return (f.exists() && f.canRead() && (f.isDirectory() || (f.getName().endsWith( ".zip") || f.getName().endsWith(".jar")))); //NOI18N
134
            return f.getAbsolutePath();
139
            }
140
            public String getDescription() {
141
                return NbBundle.getMessage(SrcDocPathsPanel.class,"TXT_ZipFilter"); // NOI18N
142
            }
143
        });
144
        if (oldValue != null)
145
            chooser.setSelectedFile(new File(oldValue));
146
        chooser.setDialogTitle(title);
147
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
148
            return chooser.getSelectedFile().getAbsolutePath();
149
        }
135
        }
150
        return null;
136
        return null;
151
    }
137
    }
Lines 316-325 Link Here
316
    private void bDocAddActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bDocAddActionPerformed
302
    private void bDocAddActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bDocAddActionPerformed
317
        if (platform == null)
303
        if (platform == null)
318
            return;
304
            return;
319
        final String value = browse(fileChooserValue, NbBundle.getMessage(SrcDocPathsPanel.class, "TITLE_SDPathsPanel_SelectJavaDoc")); // NOI18N
305
        final String value = browse(NbBundle.getMessage(SrcDocPathsPanel.class, "TITLE_SDPathsPanel_SelectJavaDoc")); // NOI18N
320
        if (value == null)
306
        if (value == null)
321
            return;
307
            return;
322
        fileChooserValue = value;
323
        final URL o = J2MEPlatform.localfilepath2url(value);
308
        final URL o = J2MEPlatform.localfilepath2url(value);
324
        if (o != null) {
309
        if (o != null) {
325
            final ListItem<URL> item = new ListItem<URL>(o);
310
            final ListItem<URL> item = new ListItem<URL>(o);
Lines 332-341 Link Here
332
    private void bSrcAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSrcAddActionPerformed
317
    private void bSrcAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSrcAddActionPerformed
333
        if (platform == null)
318
        if (platform == null)
334
            return;
319
            return;
335
        final String value = browse(fileChooserValue, NbBundle.getMessage(SrcDocPathsPanel.class, "TITLE_SDPathsPanel_SelectSource")); // NOI18N
320
        final String value = browse(NbBundle.getMessage(SrcDocPathsPanel.class, "TITLE_SDPathsPanel_SelectSource")); // NOI18N
336
        if (value == null)
321
        if (value == null)
337
            return;
322
            return;
338
        fileChooserValue = value;
339
        final FileObject o = platform.resolveRelativePathToFileObject(value);
323
        final FileObject o = platform.resolveRelativePathToFileObject(value);
340
        if (o != null) {
324
        if (o != null) {
341
            final ListItem<FileObject> item = new ListItem<FileObject>(o);
325
            final ListItem<FileObject> item = new ListItem<FileObject>(o);
(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/customwizard/ClasspathPanel.java (-24 / +4 lines)
Lines 50-60 Link Here
50
import javax.swing.text.html.HTMLEditorKit;
50
import javax.swing.text.html.HTMLEditorKit;
51
import javax.swing.event.ListSelectionEvent;
51
import javax.swing.event.ListSelectionEvent;
52
import javax.swing.event.ListSelectionListener;
52
import javax.swing.event.ListSelectionListener;
53
import javax.swing.filechooser.FileFilter;
54
import java.io.File;
53
import java.io.File;
55
import java.util.ArrayList;
54
import java.util.ArrayList;
56
import java.util.Arrays;
55
import java.util.Arrays;
57
import java.util.List;
56
import java.util.List;
57
import org.netbeans.modules.mobility.cldcplatform.ArchiveFilter;
58
import org.openide.filesystems.FileChooserBuilder;
58
59
59
/**
60
/**
60
 *
61
 *
Lines 66-72 Link Here
66
    
67
    
67
    final private DefaultListModel classpathListModel = new DefaultListModel();
68
    final private DefaultListModel classpathListModel = new DefaultListModel();
68
    private WizardPanel wizardPanel;
69
    private WizardPanel wizardPanel;
69
    private String fileChooserValue;
70
    private J2MEPlatform.J2MEProfile[] profiles;
70
    private J2MEPlatform.J2MEProfile[] profiles;
71
    
71
    
72
    /** Creates new form ClasspathPanel */
72
    /** Creates new form ClasspathPanel */
Lines 221-227 Link Here
221
    
221
    
222
    public void readSettings(final WizardDescriptor wizardDescriptor) {
222
    public void readSettings(final WizardDescriptor wizardDescriptor) {
223
        final J2MEPlatform platform = (J2MEPlatform) wizardDescriptor.getProperty(DetectPanel.PLATFORM);
223
        final J2MEPlatform platform = (J2MEPlatform) wizardDescriptor.getProperty(DetectPanel.PLATFORM);
224
        fileChooserValue = platform.getHomePath();
225
        final J2MEPlatform.Device previous = platform.getDevices()[0];
224
        final J2MEPlatform.Device previous = platform.getDevices()[0];
226
        final J2MEPlatform.J2MEProfile[] profiles = previous.getProfiles();
225
        final J2MEPlatform.J2MEProfile[] profiles = previous.getProfiles();
227
        if (profiles.length > 0) {
226
        if (profiles.length > 0) {
Lines 360-385 Link Here
360
    }
359
    }
361
    
360
    
362
    private File[] browse(final String title) {
361
    private File[] browse(final String title) {
363
        final String oldValue = fileChooserValue;
362
        return new FileChooserBuilder(getClass()).setTitle(title).
364
        final JFileChooser chooser = new JFileChooser();
363
                setFileFilter(new ArchiveFilter()).showMultiOpenDialog();
365
        chooser.setMultiSelectionEnabled(true);
366
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
367
        chooser.setFileFilter(new FileFilter() {
368
            public boolean accept(File f) {
369
                return (f.exists() && f.canRead() && (f.isDirectory() || (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")))); //NOI18N
370
            }
371
            
372
            public String getDescription() {
373
                return NbBundle.getMessage(CommandLinesPanel.class, "TXT_ZipFilter"); // NOI18N
374
            }
375
        });
376
        if (oldValue != null)
377
            chooser.setSelectedFile(new File(oldValue));
378
        chooser.setDialogTitle(title);
379
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
380
            fileChooserValue = chooser.getSelectedFile().getAbsolutePath();
381
            return chooser.getSelectedFiles();
382
        }
383
        return null;
384
    }
364
    }
385
}
365
}
(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/customwizard/CommandLinesPanel.java (-20 / +15 lines)
Lines 64-69 Link Here
64
import java.awt.event.FocusEvent;
64
import java.awt.event.FocusEvent;
65
import java.awt.event.FocusListener;
65
import java.awt.event.FocusListener;
66
import java.io.*;
66
import java.io.*;
67
import org.openide.filesystems.FileChooserBuilder;
67
68
68
/**
69
/**
69
 *
70
 *
Lines 72-78 Link Here
72
public class CommandLinesPanel extends javax.swing.JPanel implements WizardPanel.ComponentDescriptor {
73
public class CommandLinesPanel extends javax.swing.JPanel implements WizardPanel.ComponentDescriptor {
73
    
74
    
74
    protected WizardPanel wizardPanel;
75
    protected WizardPanel wizardPanel;
75
    private String fileChooserValue;
76
    private static final Set<Character> INVALID_CHARACTERS = new HashSet();
76
    private static final Set<Character> INVALID_CHARACTERS = new HashSet();
77
    {
77
    {
78
        for (char c : "\\^$?*+-!.;:,=<>|/\"'[]{}()".toCharArray()) INVALID_CHARACTERS.add(c); //NOI18N
78
        for (char c : "\\^$?*+-!.;:,=<>|/\"'[]{}()".toCharArray()) INVALID_CHARACTERS.add(c); //NOI18N
Lines 472-497 Link Here
472
        return false;
472
        return false;
473
    }
473
    }
474
    
474
    
475
    
475
    private static final class FolderFilter extends FileFilter {
476
        public boolean accept(File f) {
477
            return f.exists() && f.canRead() && f.isDirectory();
478
        }
479
480
        public String getDescription() {
481
            return NbBundle.getMessage(CommandLinesPanel.class, "TXT_FolderFilter"); // NOI18N
482
        }
483
    }
484
476
    private String browseFolder(final String title) {
485
    private String browseFolder(final String title) {
477
        final String oldValue = fileChooserValue;
486
        File f;
478
        final JFileChooser chooser = new JFileChooser();
487
        if ((f = new FileChooserBuilder(getClass()).setTitle(title).
479
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
488
                setDirectoriesOnly(true).setFileFilter(new FolderFilter()).showOpenDialog()) != null) {
480
        chooser.setFileFilter(new FileFilter() {
489
            return f.getAbsolutePath();
481
            public boolean accept(File f) {
482
                return f.exists() && f.canRead() && f.isDirectory();
483
            }
484
            
485
            public String getDescription() {
486
                return NbBundle.getMessage(CommandLinesPanel.class, "TXT_FolderFilter"); // NOI18N
487
            }
488
        });
489
        if (oldValue != null)
490
            chooser.setSelectedFile(new File(oldValue));
491
        chooser.setDialogTitle(title);
492
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
493
            fileChooserValue = chooser.getSelectedFile().getAbsolutePath();
494
            return fileChooserValue;
495
        }
490
        }
496
        return null;
491
        return null;
497
    }
492
    }
(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/DetectPanel.java (-19 / +16 lines)
Lines 57-62 Link Here
57
import org.openide.WizardDescriptor;
57
import org.openide.WizardDescriptor;
58
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.URLMapper;
59
import org.openide.filesystems.URLMapper;
60
import org.openide.filesystems.FileChooserBuilder;
60
import org.openide.util.HelpCtx;
61
import org.openide.util.HelpCtx;
61
import org.openide.util.Lookup;
62
import org.openide.util.Lookup;
62
import org.openide.util.RequestProcessor;
63
import org.openide.util.RequestProcessor;
Lines 104-111 Link Here
104
    
105
    
105
    protected static final Color COLOR_GRAY = UIManager.getColor("Label.disabledForeground"); //NOI18N
106
    protected static final Color COLOR_GRAY = UIManager.getColor("Label.disabledForeground"); //NOI18N
106
    protected static final Color COLOR_RED = new Color(192, 0, 0);
107
    protected static final Color COLOR_RED = new Color(192, 0, 0);
107
    
108
    private String fileChooserValue;
109
    
108
    
110
    protected DetectWizardPanel wizardPanel;
109
    protected DetectWizardPanel wizardPanel;
111
    private WizardDescriptor wizardDescriptor;
110
    private WizardDescriptor wizardDescriptor;
Lines 694-719 Link Here
694
            sb.append(NbBundle.getMessage(DetectPanel.class, "Msg_DetectPanel_None")); //NOI18N
693
            sb.append(NbBundle.getMessage(DetectPanel.class, "Msg_DetectPanel_None")); //NOI18N
695
        }
694
        }
696
    }
695
    }
696
697
    private static final class BrowseFilter extends FileFilter {
698
        public boolean accept(File f) {
699
            return (f.exists() && f.canRead() && (f.isDirectory() || (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")))); //NOI18N
700
        }
701
702
        public String getDescription() {
703
            return NbBundle.getMessage(DetectPanel.class, "TXT_ZipFilter"); // NOI18N
704
        }
705
    }
697
    
706
    
698
    private String browse(final String title) {
707
    private String browse(final String title) {
699
        final String oldValue = fileChooserValue;
708
        File f;
700
        final JFileChooser chooser = new JFileChooser();
709
        if ((f = new FileChooserBuilder(getClass()).
701
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
710
                setFileFilter(new BrowseFilter()).
702
        chooser.setFileFilter(new FileFilter() {
711
                setTitle(title).showOpenDialog()) != null) {
703
            public boolean accept(File f) {
704
                return (f.exists() && f.canRead() && (f.isDirectory() || (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")))); //NOI18N
705
            }
706
            
712
            
707
            public String getDescription() {
713
            return f.getAbsolutePath();
708
                return NbBundle.getMessage(DetectPanel.class, "TXT_ZipFilter"); // NOI18N
709
            }
710
        });
711
        if (oldValue != null)
712
            chooser.setSelectedFile(new File(oldValue));
713
        chooser.setDialogTitle(title);
714
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
715
            fileChooserValue = chooser.getSelectedFile().getAbsolutePath();
716
            return fileChooserValue;
717
        }
714
        }
718
        return null;
715
        return null;
719
    }
716
    }
(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/FindPanel.java (-14 / +102 lines)
Lines 58-71 Link Here
58
import java.awt.event.KeyEvent;
58
import java.awt.event.KeyEvent;
59
import java.io.File;
59
import java.io.File;
60
import java.util.*;
60
import java.util.*;
61
import javax.swing.filechooser.FileFilter;
62
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
63
import org.netbeans.spi.mobility.cldcplatform.CustomCLDCPlatformConfigurator;
64
import org.openide.filesystems.FileChooserBuilder;
65
import org.openide.filesystems.FileStateInvalidException;
66
import org.openide.util.ImageUtilities;
67
import org.openide.util.Lookup;
68
import org.openide.util.Utilities;
61
69
62
/**
70
/**
63
 *
71
 *
64
 * @author Adam Sotona
72
 * @author Adam Sotona
65
 */
73
 */
66
final public class FindPanel extends javax.swing.JPanel implements SearchRunnable.Notifier {
74
final public class FindPanel extends javax.swing.JPanel implements SearchRunnable.Notifier {
67
    
68
    static File DEFAULT_DIR = null;
69
    
75
    
70
    static final String PROP_PLATFORM_FOLDERS = "PlatformFolders"; // NOI18N
76
    static final String PROP_PLATFORM_FOLDERS = "PlatformFolders"; // NOI18N
71
    
77
    
Lines 166-188 Link Here
166
    
172
    
167
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
173
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
168
        if (searchTask != null && !searchTask.isFinished()) return;
174
        if (searchTask != null && !searchTask.isFinished()) return;
169
        if (DEFAULT_DIR == null) {
175
        String aDescription = NbBundle.getMessage(FindPanel.class, "AD_LocationChooser"); //NOI18N
170
            final File[] roots = File.listRoots();
176
        String title = NbBundle.getMessage(FindPanel.class, "Title_FindPanel_Choose_To_Search"); //NOI18N
171
            if (roots.length > 0) DEFAULT_DIR = roots[0];
177
        Badger badger = new Badger();
172
        }
178
        File dir;
173
        final LocationChooser jfc = new LocationChooser(DEFAULT_DIR);
179
        if ((dir = new FileChooserBuilder(getClass().getName()).setDirectoriesOnly(true).
174
        jfc.setDialogType(JFileChooser.OPEN_DIALOG);
180
                setTitle(title).
175
        jfc.setControlButtonsAreShown(true);
181
                setAccessibleDescription(aDescription).
176
        jfc.setDialogTitle(NbBundle.getMessage(FindPanel.class, "Title_FindPanel_Choose_To_Search")); //NOI18N
182
                setBadgeProvider(badger).
177
        if (jfc.showDialog(this, NbBundle.getMessage(FindPanel.class, "LBL_FindPanel_Search")) == JFileChooser.APPROVE_OPTION) { //NOI18N
183
                setDefaultWorkingDirectory(File.listRoots().length > 0 ? File.listRoots()[0] : null).
178
            searchRunnable = new SearchRunnable(this, jfc.getSelectedFile(), -1);
184
                setFileFilter(badger).showOpenDialog()) != null) {
185
186
            searchRunnable = new SearchRunnable(this, dir, -1);
179
            jButton1.setEnabled(false);
187
            jButton1.setEnabled(false);
180
            showError(NbBundle.getMessage(FindPanel.class, "WARN_SearchInProgress"));//NOI18N
188
            showError(NbBundle.getMessage(FindPanel.class, "WARN_SearchInProgress"));//NOI18N
181
            searchTask = RequestProcessor.getDefault().post(searchRunnable);
189
            searchTask = RequestProcessor.getDefault().post(searchRunnable);
182
        }
190
        }
183
        DEFAULT_DIR = jfc.getSelectedFile();
184
    }//GEN-LAST:event_jButton1ActionPerformed
191
    }//GEN-LAST:event_jButton1ActionPerformed
185
    
192
193
    private static final class Badger extends FileFilter implements FileChooserBuilder.BadgeProvider {
194
        final Icon badge = new ImageIcon (ImageUtilities.loadImage(
195
                "org/netbeans/modules/java/platform/resources/platformBadge.gif"));
196
197
        public boolean accept(File f) {
198
            return f.isDirectory();
199
        }
200
201
        public String getDescription() {
202
            return NbBundle.getMessage(Badger.class, "TXT_PlatformFolder"); //NOI18N
203
        }
204
        
205
        public Icon getBadge(File file) {
206
            if (isPlatformDir (file)) {
207
                return badge;
208
            }
209
            return null;
210
        }
211
212
        public int getXOffset() {
213
            return -1;
214
        }
215
216
        public int getYOffset() {
217
            return -1;
218
        }
219
220
        private boolean isPlatformDir(File f) {
221
            //XXX: Workaround of hard NFS mounts on Solaris.
222
            final int osId = Utilities.getOperatingSystem();
223
            if (osId == Utilities.OS_SOLARIS || osId == Utilities.OS_SUNOS) {
224
                return false;
225
            }
226
            FileObject fo = (f != null) ? convertToValidDir(f) : null;
227
            if (fo != null) {
228
                //XXX: Workaround of /net folder on Unix, the folders in the root are not badged as platforms.
229
                // User can still select them.
230
                try {
231
                    if (Utilities.isUnix() && (fo.getParent() == null ||
232
                        fo.getFileSystem().getRoot().equals(fo.getParent()))) {
233
                        return false;
234
                    }
235
                } catch (FileStateInvalidException e) {
236
                    return false;
237
                }
238
                return isPossibleJ2MEPlatform(FileUtil.toFile(fo));
239
            }
240
            return false;
241
        }
242
243
        public boolean isPossibleJ2MEPlatform(final File directory) {
244
            Collection <? extends CustomCLDCPlatformConfigurator> customConfigurators = Lookup.getDefault().lookupAll(CustomCLDCPlatformConfigurator.class);
245
            for ( CustomCLDCPlatformConfigurator pc : customConfigurators )
246
                if (pc.isPossiblePlatform(directory)) return true;
247
            final FileObject dir = FileUtil.toFileObject(directory);
248
            return dir != null && J2MEPlatform.findTool("emulator", Collections.singletonList(dir)) != null // NOI18N
249
                    && J2MEPlatform.findTool("preverify", Collections.singletonList(dir)) != null; //NOI18N
250
        }
251
252
        private static FileObject convertToValidDir(File f) {
253
            FileObject fo;
254
            File testFile = new File(f.getPath());
255
            if (testFile == null || testFile.getParent() == null) {
256
                // BTW this means that roots of file systems can't be project
257
                // directories.
258
                return null;
259
            }
260
261
            /**ATTENTION: on Windows may occure dir.isDirectory () == dir.isFile () == true then
262
             * its used testFile instead of dir.
263
             */
264
            if (!testFile.isDirectory()) {
265
                return null;
266
            }
267
268
            fo = FileUtil.toFileObject(FileUtil.normalizeFile(f));
269
            return fo;
270
        }
271
272
    }
273
186
    
274
    
187
    // Variables declaration - do not modify//GEN-BEGIN:variables
275
    // Variables declaration - do not modify//GEN-BEGIN:variables
188
    private javax.swing.JButton jButton1;
276
    private javax.swing.JButton jButton1;
(-)a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/LocationChooser.java (-281 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.mobility.cldcplatform.wizard;
42
43
import java.awt.Container;
44
import java.awt.Dimension;
45
import java.awt.Window;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.KeyEvent;
48
import java.beans.PropertyChangeEvent;
49
import java.beans.PropertyChangeListener;
50
import java.io.File;
51
import java.util.Collection;
52
import java.util.Collections;
53
import javax.swing.AbstractAction;
54
import javax.swing.BorderFactory;
55
import javax.swing.Icon;
56
import javax.swing.ImageIcon;
57
import javax.swing.JFileChooser;
58
import javax.swing.KeyStroke;
59
import javax.swing.filechooser.FileFilter;
60
import javax.swing.filechooser.FileSystemView;
61
import javax.swing.filechooser.FileView;
62
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
63
import org.netbeans.spi.java.platform.PlatformInstall;
64
import org.netbeans.spi.mobility.cldcplatform.CustomCLDCPlatformConfigurator;
65
import org.openide.WizardDescriptor;
66
import org.openide.filesystems.FileObject;
67
import org.openide.filesystems.FileStateInvalidException;
68
import org.openide.filesystems.FileUtil;
69
import org.openide.util.ChangeSupport;
70
import org.openide.util.ImageUtilities;
71
import org.openide.util.Lookup;
72
import org.openide.util.NbBundle;
73
import org.openide.util.Utilities;
74
75
/**
76
 * Copied from Java Platform
77
 * @author  sd99038, Tomas  Zezula
78
 */
79
public class LocationChooser extends JFileChooser implements PropertyChangeListener {
80
81
    private static final Dimension PREFERRED_SIZE = new Dimension(600, 340);
82
    private WizardDescriptor.InstantiatingIterator<WizardDescriptor> iterator;
83
    private final ChangeSupport cs = new ChangeSupport(this);
84
    private PlatformFileView platformFileView;
85
86
   public LocationChooser(File dir) {
87
        super(dir);
88
        this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
89
        this.setName(NbBundle.getMessage(LocationChooser.class, "Title_FindPanel_Choose_To_Search"));
90
        this.setFileSelectionMode(DIRECTORIES_ONLY);
91
        this.setMultiSelectionEnabled(false);
92
        this.setControlButtonsAreShown(false);
93
        this.setFileFilter(new PlatformFileFilter());
94
        this.platformFileView = new PlatformFileView(this.getFileSystemView());
95
        this.setFileView(this.platformFileView);
96
        this.addPropertyChangeListener(this);
97
        this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(LocationChooser.class, "AD_LocationChooser"));
98
99
        //XXX JFileChooser workaround
100
        getActionMap().put("cancel",
101
                new AbstractAction() {
102
103
                    public void actionPerformed(ActionEvent e) {
104
                        Container parent = LocationChooser.this.getParent();
105
                        do {
106
                            parent = parent.getParent();
107
                        } while (parent != null && !(parent instanceof Window));
108
                        if (parent != null) {
109
                            ((Window) parent).setVisible(false);
110
                        }
111
                    }
112
                });
113
        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
114
        this.setBorder(null);
115
    }
116
117
    @Override
118
    public Dimension getPreferredSize() {
119
        return PREFERRED_SIZE;
120
    }
121
122
    public void propertyChange(PropertyChangeEvent evt) {
123
        if (SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
124
            this.iterator = null;
125
            File file = this.getSelectedFile();
126
            if (file != null) {
127
                file = FileUtil.normalizeFile(file);
128
                FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(file));
129
                if (fo != null) {
130
                    PlatformInstall install = this.platformFileView.getPlatformInstall();
131
                    if (install != null && install.accept(fo)) {
132
                        this.iterator = install.createIterator(fo);
133
                    }
134
                }
135
            }
136
            cs.fireChange();
137
        }
138
    }
139
    
140
    private static class PlatformFileFilter extends FileFilter {
141
142
        public boolean accept(File f) {
143
            return f.isDirectory();
144
        }
145
146
        public String getDescription() {
147
            return NbBundle.getMessage(LocationChooser.class, "TXT_PlatformFolder");
148
        }
149
    }
150
    private static class MergedIcon implements Icon {
151
152
        private Icon icon1;
153
        private Icon icon2;
154
        private int xMerge;
155
        private int yMerge;
156
157
        MergedIcon(Icon icon1, Icon icon2, int xMerge, int yMerge) {
158
159
            this.icon1 = icon1;
160
            this.icon2 = icon2;
161
162
            if (xMerge == -1) {
163
                xMerge = icon1.getIconWidth() - icon2.getIconWidth();
164
            }
165
166
            if (yMerge == -1) {
167
                yMerge = icon1.getIconHeight() - icon2.getIconHeight();
168
            }
169
170
            this.xMerge = xMerge;
171
            this.yMerge = yMerge;
172
        }
173
174
        public int getIconHeight() {
175
            return Math.max(icon1.getIconHeight(), yMerge + icon2.getIconHeight());
176
        }
177
178
        public int getIconWidth() {
179
            return Math.max(icon1.getIconWidth(), yMerge + icon2.getIconWidth());
180
        }
181
182
        public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) {
183
            icon1.paintIcon(c, g, x, y);
184
            icon2.paintIcon(c, g, x + xMerge, y + yMerge);
185
        }
186
    }
187
188
    private static class PlatformFileView extends FileView {
189
190
        private final Icon BADGE = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/java/platform/resources/platformBadge.gif")); // NOI18N
191
        private final Icon EMPTY = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/java/platform/resources/empty.gif")); // NOI18N
192
        private FileSystemView fsv;
193
        private Icon lastOriginal;
194
        private Icon lastMerged;
195
        private PlatformInstall platformInstall;
196
197
        public PlatformFileView(FileSystemView fsv) {
198
            this.fsv = fsv;
199
        }
200
201
        public
202
        @Override
203
        Icon getIcon( File _f) {
204
            File f = FileUtil.normalizeFile(_f);
205
            Icon original = fsv.getSystemIcon(f);
206
            if (original == null) {
207
                // L&F (e.g. GTK) did not specify any icon.
208
                original = EMPTY;
209
            }
210
            if (isPlatformDir(f)) {
211
                if (original.equals(lastOriginal)) {
212
                    return lastMerged;
213
                }
214
                lastOriginal = original;
215
                lastMerged = new MergedIcon(original, BADGE, -1, -1);
216
                return lastMerged;
217
            } else {
218
                return original;
219
            }
220
        }
221
222
        public void setPlatformInstall(PlatformInstall platformInstall) {
223
            this.platformInstall = platformInstall;
224
        }
225
226
        public PlatformInstall getPlatformInstall() {
227
            return this.platformInstall;
228
        }
229
230
        private boolean isPlatformDir(File f) {
231
            //XXX: Workaround of hard NFS mounts on Solaris.
232
            final int osId = Utilities.getOperatingSystem();
233
            if (osId == Utilities.OS_SOLARIS || osId == Utilities.OS_SUNOS) {
234
                return false;
235
            }
236
            FileObject fo = (f != null) ? convertToValidDir(f) : null;
237
            if (fo != null) {
238
                //XXX: Workaround of /net folder on Unix, the folders in the root are not badged as platforms.
239
                // User can still select them.
240
                try {
241
                    if (Utilities.isUnix() && (fo.getParent() == null || fo.getFileSystem().getRoot().equals(fo.getParent()))) {
242
                        return false;
243
                    }
244
                } catch (FileStateInvalidException e) {
245
                    return false;
246
                }
247
                return isPossibleJ2MEPlatform(FileUtil.toFile(fo));
248
            }
249
            return false;
250
        }
251
252
        public boolean isPossibleJ2MEPlatform(final File directory) {
253
            Collection <? extends CustomCLDCPlatformConfigurator> customConfigurators = Lookup.getDefault().lookupAll(CustomCLDCPlatformConfigurator.class);
254
            for ( CustomCLDCPlatformConfigurator pc : customConfigurators )
255
                if (pc.isPossiblePlatform(directory)) return true;
256
            final FileObject dir = FileUtil.toFileObject(directory);
257
            return dir != null && J2MEPlatform.findTool("emulator", Collections.singletonList(dir)) != null // NOI18N
258
                    && J2MEPlatform.findTool("preverify", Collections.singletonList(dir)) != null; //NOI18N
259
        }
260
261
        private static FileObject convertToValidDir(File f) {
262
            FileObject fo;
263
            File testFile = new File(f.getPath());
264
            if (testFile == null || testFile.getParent() == null) {
265
                // BTW this means that roots of file systems can't be project
266
                // directories.
267
                return null;
268
            }
269
270
            /**ATTENTION: on Windows may occure dir.isDirectory () == dir.isFile () == true then
271
             * its used testFile instead of dir. 
272
             */
273
            if (!testFile.isDirectory()) {
274
                return null;
275
            }
276
277
            fo = FileUtil.toFileObject(FileUtil.normalizeFile(f));
278
            return fo;
279
        }
280
    }
281
}
(-)a/openide.util/src/org/openide/util/Utilities.java (+1 lines)
Lines 2061-2066 Link Here
2061
     * @param parent
2061
     * @param parent
2062
     * @param approveButtonText
2062
     * @param approveButtonText
2063
     * @deprecated Not needed in JDK 1.4.
2063
     * @deprecated Not needed in JDK 1.4.
2064
     * @see @org-openide-filesystems@FileChooserBuilder
2064
     */
2065
     */
2065
    @Deprecated
2066
    @Deprecated
2066
    public static final int showJFileChooser(
2067
    public static final int showJFileChooser(
(-)a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/wizard/ProjectSelectionPanel.java (-6 / +5 lines)
Lines 77-82 Link Here
77
import org.openide.DialogDescriptor;
77
import org.openide.DialogDescriptor;
78
import org.openide.DialogDisplayer;
78
import org.openide.DialogDisplayer;
79
import org.openide.NotifyDescriptor;
79
import org.openide.NotifyDescriptor;
80
import org.openide.filesystems.FileChooserBuilder;
80
81
81
/**
82
/**
82
 * Represent "Project to import" step(panel) in the Eclipse importer wizard.
83
 * Represent "Project to import" step(panel) in the Eclipse importer wizard.
Lines 588-599 Link Here
588
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectSelectionPanel.class, "ACSD_ProjectSelectionPanel_NA")); // NOI18N
589
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectSelectionPanel.class, "ACSD_ProjectSelectionPanel_NA")); // NOI18N
589
    }// </editor-fold>//GEN-END:initComponents
590
    }// </editor-fold>//GEN-END:initComponents
590
591
591
    private void chooseDestButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                 
592
    private void chooseDestButtonActionPerformed(java.awt.event.ActionEvent evt) {
592
        JFileChooser chooser = new JFileChooser();
593
        File dest = new FileChooserBuilder(getClass()).setDirectoriesOnly(true).showOpenDialog();
593
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
594
        if (dest != null) {
594
        int ret = chooser.showOpenDialog(this);
595
            destination.setText (dest.getAbsolutePath());
595
        if (ret == JFileChooser.APPROVE_OPTION) {
596
            destination.setText(chooser.getSelectedFile().getAbsolutePath());
597
        }
596
        }
598
    }                                                     
597
    }                                                     
599
598
(-)a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/wizard/SelectionPanel.form (-3 / +4 lines)
Lines 16-21 Link Here
16
  <AuxValues>
16
  <AuxValues>
17
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
17
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
18
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
18
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
19
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
19
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
20
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
20
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
21
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
21
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
22
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
Lines 30-42 Link Here
30
          <Group type="102" alignment="0" attributes="0">
31
          <Group type="102" alignment="0" attributes="0">
31
              <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
32
              <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
32
              <Group type="103" groupAlignment="0" attributes="0">
33
              <Group type="103" groupAlignment="0" attributes="0">
33
                  <Component id="note" alignment="0" pref="509" max="32767" attributes="0"/>
34
                  <Component id="note" alignment="0" pref="527" max="32767" attributes="0"/>
34
                  <Component id="jLabel1" alignment="0" pref="509" max="32767" attributes="0"/>
35
                  <Component id="jLabel1" alignment="0" pref="527" max="32767" attributes="0"/>
35
                  <Group type="102" alignment="0" attributes="0">
36
                  <Group type="102" alignment="0" attributes="0">
36
                      <EmptySpace min="12" pref="12" max="12" attributes="0"/>
37
                      <EmptySpace min="12" pref="12" max="12" attributes="0"/>
37
                      <Component id="workSpaceLBL" min="-2" max="-2" attributes="0"/>
38
                      <Component id="workSpaceLBL" min="-2" max="-2" attributes="0"/>
38
                      <EmptySpace max="-2" attributes="0"/>
39
                      <EmptySpace max="-2" attributes="0"/>
39
                      <Component id="workspaceDir" pref="278" max="32767" attributes="0"/>
40
                      <Component id="workspaceDir" pref="281" max="32767" attributes="0"/>
40
                      <EmptySpace max="-2" attributes="0"/>
41
                      <EmptySpace max="-2" attributes="0"/>
41
                      <Component id="worskpaceBrowse" min="-2" max="-2" attributes="0"/>
42
                      <Component id="worskpaceBrowse" min="-2" max="-2" attributes="0"/>
42
                  </Group>
43
                  </Group>
(-)a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/wizard/SelectionPanel.java (-18 / +10 lines)
Lines 47-52 Link Here
47
import javax.swing.event.DocumentEvent;
47
import javax.swing.event.DocumentEvent;
48
import javax.swing.event.DocumentListener;
48
import javax.swing.event.DocumentListener;
49
import org.netbeans.modules.projectimport.eclipse.core.EclipseUtils;
49
import org.netbeans.modules.projectimport.eclipse.core.EclipseUtils;
50
import org.openide.filesystems.FileChooserBuilder;
50
import org.openide.filesystems.FileUtil;
51
import org.openide.filesystems.FileUtil;
51
52
52
/**
53
/**
Lines 314-325 Link Here
314
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SelectionPanel.class, "ACSD_SelectionPanel_NA")); // NOI18N
315
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SelectionPanel.class, "ACSD_SelectionPanel_NA")); // NOI18N
315
    }// </editor-fold>//GEN-END:initComponents
316
    }// </editor-fold>//GEN-END:initComponents
316
    private void projectDestBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_projectDestBrowseActionPerformed
317
    private void projectDestBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_projectDestBrowseActionPerformed
317
        JFileChooser chooser = new JFileChooser(projectDestDir.getText());
318
        File dir = new FileChooserBuilder(getClass()).setDirectoriesOnly(true).showOpenDialog();
318
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
319
        if (dir != null) {
319
        chooser.setFileHidingEnabled(false);
320
            projectDestDir.setText(dir.getAbsolutePath());
320
        int ret = chooser.showOpenDialog(this);
321
        if (ret == JFileChooser.APPROVE_OPTION) {
322
            projectDestDir.setText(chooser.getSelectedFile().getAbsolutePath());
323
        }//GEN-LAST:event_projectDestBrowseActionPerformed
321
        }//GEN-LAST:event_projectDestBrowseActionPerformed
324
    }                                                 
322
    }                                                 
325
            
323
            
Lines 350-371 Link Here
350
    }
348
    }
351
    
349
    
352
    private void projectBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_projectBrowseActionPerformed
350
    private void projectBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_projectBrowseActionPerformed
353
        JFileChooser chooser = new JFileChooser(projectDir.getText());
351
        File file = new FileChooserBuilder(getClass()).setDirectoriesOnly(true).forceUseOfDefaultWorkingDirectory(true).showOpenDialog();
354
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
352
        if (file != null) {
355
        chooser.setFileHidingEnabled(false);
353
            projectDir.setText (file.getAbsolutePath());
356
        int ret = chooser.showOpenDialog(this);
357
        if (ret == JFileChooser.APPROVE_OPTION) {
358
            projectDir.setText(chooser.getSelectedFile().getAbsolutePath());
359
        }//GEN-LAST:event_projectBrowseActionPerformed
354
        }//GEN-LAST:event_projectBrowseActionPerformed
360
    }                                             
355
    }                                             
361
    
356
    
362
    private void worskpaceBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_worskpaceBrowseActionPerformed
357
    private void worskpaceBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_worskpaceBrowseActionPerformed
363
        JFileChooser chooser = new JFileChooser(getWorkspaceDir());
358
        File file = new FileChooserBuilder(getClass()).setDirectoriesOnly(true).showOpenDialog();
364
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
359
        if (file != null) {
365
        chooser.setFileHidingEnabled(false);
360
            workspaceDir.setText(file.getAbsolutePath());
366
        int ret = chooser.showOpenDialog(this);
367
        if (ret == JFileChooser.APPROVE_OPTION) {
368
            workspaceDir.setText(chooser.getSelectedFile().getAbsolutePath());
369
        }//GEN-LAST:event_worskpaceBrowseActionPerformed
361
        }//GEN-LAST:event_worskpaceBrowseActionPerformed
370
    }                                               
362
    }                                               
371
    
363
    
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectCopyPanel.java (-10 / +8 lines)
Lines 52-57 Link Here
52
import org.netbeans.api.project.Project;
52
import org.netbeans.api.project.Project;
53
import org.netbeans.spi.project.support.ProjectOperations;
53
import org.netbeans.spi.project.support.ProjectOperations;
54
import org.netbeans.api.project.ProjectUtils;
54
import org.netbeans.api.project.ProjectUtils;
55
import org.openide.filesystems.FileChooserBuilder;
55
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.filesystems.FileUtil;
57
import org.openide.util.ChangeSupport;
58
import org.openide.util.ChangeSupport;
Lines 264-279 Link Here
264
265
265
    private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
266
    private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
266
// TODO add your handling code here:
267
// TODO add your handling code here:
267
        File current = new File(projectLocation.getText());
268
        String dlgTitle = NbBundle.getMessage(ProjectCopyPanel.class, "TITLE_BrowseProjectLocation");
268
        JFileChooser chooser = new JFileChooser(current);
269
        String okText = NbBundle.getMessage(ProjectCopyPanel.class, "LBL_BrowseProjectLocation_OK_Button");
269
        
270
        File dir = new FileChooserBuilder(getClass()).setDefaultWorkingDirectory(
270
        chooser.setMultiSelectionEnabled(false);
271
            new File(projectLocation.getText())).setDirectoriesOnly(
271
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
272
            true).setTitle(dlgTitle).setApproveText(okText).showOpenDialog();
272
        chooser.setDialogTitle(NbBundle.getMessage(ProjectCopyPanel.class, "TITLE_BrowseProjectLocation"));
273
        if (dir != null) {
273
        chooser.setApproveButtonText(NbBundle.getMessage(ProjectCopyPanel.class, "LBL_BrowseProjectLocation_OK_Button"));
274
            projectLocation.setText(dir.getAbsolutePath());
274
                
275
        if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
276
            projectLocation.setText(chooser.getSelectedFile().getAbsolutePath());
277
        }
275
        }
278
    }//GEN-LAST:event_browseActionPerformed
276
    }//GEN-LAST:event_browseActionPerformed
279
    
277
    

Return to bug 47737