Index: src/core/org/apache/jmeter/gui/util/FileDialoger.java =================================================================== --- src/core/org/apache/jmeter/gui/util/FileDialoger.java (revision 1538289) +++ src/core/org/apache/jmeter/gui/util/FileDialoger.java (working copy) @@ -23,6 +23,7 @@ import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.JMeterFileFilter; @@ -43,6 +44,15 @@ private FileDialoger() { } + + public static JFileChooser promptToOpenFile() { + return promptToOpenFile((String)null); + } + + public static JFileChooser promptToOpenFile(String existingFileName) { + return promptToOpenFile(new String[0], existingFileName); + } + /** * Prompts the user to choose a file from their filesystems for our own * devious uses. This method maintains the last directory the user visited @@ -55,9 +65,27 @@ * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String[] exts) { + return promptToOpenFile(exts, null); + } + + /** + * Prompts the user to choose a file from their filesystems for our own + * devious uses. This method maintains the last directory the user visited + * before dismissing the dialog. This does NOT imply they actually chose a + * file from that directory, only that they closed the dialog there. It is + * the caller's responsibility to check to see if the selected file is + * non-null. + * + * @return the JFileChooser that interacted with the user, after they are + * finished using it - null if no file was chosen + */ + public static JFileChooser promptToOpenFile(String[] exts, String existingFileName) { // JFileChooser jfc = null; - if (lastJFCDirectory == null) { + if(!StringUtils.isEmpty(existingFileName)) { + jfc.setCurrentDirectory(new File(existingFileName)); + } + else if (lastJFCDirectory == null) { String start = System.getProperty("user.dir", ""); //$NON-NLS-1$//$NON-NLS-2$ if (start.length() > 0) { @@ -87,10 +115,6 @@ } } - public static JFileChooser promptToOpenFile() { - return promptToOpenFile(new String[0]); - } - /** * Prompts the user to choose a file from their filesystems for our own * devious uses. This method maintains the last directory the user visited Index: src/core/org/apache/jmeter/gui/util/FilePanelEntry.java =================================================================== --- src/core/org/apache/jmeter/gui/util/FilePanelEntry.java (revision 1538289) +++ src/core/org/apache/jmeter/gui/util/FilePanelEntry.java (working copy) @@ -136,9 +136,9 @@ if (e.getActionCommand().equals(ACTION_BROWSE)) { JFileChooser chooser; if(filetypes == null || filetypes.length == 0){ - chooser = FileDialoger.promptToOpenFile(); + chooser = FileDialoger.promptToOpenFile(filename.getText()); } else { - chooser = FileDialoger.promptToOpenFile(filetypes); + chooser = FileDialoger.promptToOpenFile(filetypes, filename.getText()); } if (chooser != null && chooser.getSelectedFile() != null) { filename.setText(chooser.getSelectedFile().getPath());