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

(-)src/core/org/apache/jmeter/gui/util/FileDialoger.java (-5 / +29 lines)
Lines 23-28 Link Here
23
import javax.swing.JFileChooser;
23
import javax.swing.JFileChooser;
24
import javax.swing.filechooser.FileFilter;
24
import javax.swing.filechooser.FileFilter;
25
25
26
import org.apache.commons.lang3.StringUtils;
26
import org.apache.jmeter.gui.GuiPackage;
27
import org.apache.jmeter.gui.GuiPackage;
27
import org.apache.jmeter.gui.JMeterFileFilter;
28
import org.apache.jmeter.gui.JMeterFileFilter;
28
29
Lines 43-48 Link Here
43
    private FileDialoger() {
44
    private FileDialoger() {
44
    }
45
    }
45
46
47
48
    public static JFileChooser promptToOpenFile() {
49
        return promptToOpenFile((String)null);
50
    }
51
52
    public static JFileChooser promptToOpenFile(String existingFileName) {
53
        return promptToOpenFile(new String[0], existingFileName);
54
    }
55
    
46
    /**
56
    /**
47
     * Prompts the user to choose a file from their filesystems for our own
57
     * Prompts the user to choose a file from their filesystems for our own
48
     * devious uses. This method maintains the last directory the user visited
58
     * devious uses. This method maintains the last directory the user visited
Lines 55-63 Link Here
55
     *         finished using it - null if no file was chosen
65
     *         finished using it - null if no file was chosen
56
     */
66
     */
57
    public static JFileChooser promptToOpenFile(String[] exts) {
67
    public static JFileChooser promptToOpenFile(String[] exts) {
68
        return promptToOpenFile(exts, null);
69
    }
70
    
71
    /**
72
     * Prompts the user to choose a file from their filesystems for our own
73
     * devious uses. This method maintains the last directory the user visited
74
     * before dismissing the dialog. This does NOT imply they actually chose a
75
     * file from that directory, only that they closed the dialog there. It is
76
     * the caller's responsibility to check to see if the selected file is
77
     * non-null.
78
     *
79
     * @return the JFileChooser that interacted with the user, after they are
80
     *         finished using it - null if no file was chosen
81
     */
82
    public static JFileChooser promptToOpenFile(String[] exts, String existingFileName) {
58
        // JFileChooser jfc = null;
83
        // JFileChooser jfc = null;
59
84
60
        if (lastJFCDirectory == null) {
85
        if(!StringUtils.isEmpty(existingFileName)) {
86
            jfc.setCurrentDirectory(new File(existingFileName));
87
        }
88
        else if (lastJFCDirectory == null) {
61
            String start = System.getProperty("user.dir", ""); //$NON-NLS-1$//$NON-NLS-2$
89
            String start = System.getProperty("user.dir", ""); //$NON-NLS-1$//$NON-NLS-2$
62
90
63
            if (start.length() > 0) {
91
            if (start.length() > 0) {
Lines 87-96 Link Here
87
        }
115
        }
88
    }
116
    }
89
117
90
    public static JFileChooser promptToOpenFile() {
91
        return promptToOpenFile(new String[0]);
92
    }
93
94
    /**
118
    /**
95
     * Prompts the user to choose a file from their filesystems for our own
119
     * Prompts the user to choose a file from their filesystems for our own
96
     * devious uses. This method maintains the last directory the user visited
120
     * devious uses. This method maintains the last directory the user visited
(-)src/core/org/apache/jmeter/gui/util/FilePanelEntry.java (-2 / +2 lines)
Lines 136-144 Link Here
136
        if (e.getActionCommand().equals(ACTION_BROWSE)) {
136
        if (e.getActionCommand().equals(ACTION_BROWSE)) {
137
            JFileChooser chooser;
137
            JFileChooser chooser;
138
            if(filetypes == null || filetypes.length == 0){
138
            if(filetypes == null || filetypes.length == 0){
139
                chooser = FileDialoger.promptToOpenFile();
139
                chooser = FileDialoger.promptToOpenFile(filename.getText());
140
            } else {
140
            } else {
141
                chooser = FileDialoger.promptToOpenFile(filetypes);
141
                chooser = FileDialoger.promptToOpenFile(filetypes, filename.getText());
142
            }
142
            }
143
            if (chooser != null && chooser.getSelectedFile() != null) {
143
            if (chooser != null && chooser.getSelectedFile() != null) {
144
                filename.setText(chooser.getSelectedFile().getPath());
144
                filename.setText(chooser.getSelectedFile().getPath());

Return to bug 55753