Bug 52707 - Make Open File dialog use last opened file folder as start folder
Summary: Make Open File dialog use last opened file folder as start folder
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.6
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2012-02-19 13:59 UTC by Philippe Mouawad
Modified: 2014-10-29 08:50 UTC (History)
3 users (show)



Attachments
FileDialoger&Load patch (1.79 KB, patch)
2014-10-22 08:47 UTC, Dzmitry Kashlach
Details | Diff
NPE fix (700 bytes, patch)
2014-10-29 07:07 UTC, Dzmitry Kashlach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2012-02-19 13:59:32 UTC
JMeter Open File dialog should use the last Opened file directory as base.
Many Programs work this way nowadays:
- Eclipse
- PSPAD
- UltraEdit
- Acrobat Reader
...


For example:
- Today : Open last recent file, next open a new File, JMeter will start from <JMETER_HOME>/bin
- After enhancement : Open last recent file, next open a new File, JMeter will start from the last opened file folder
Comment 1 Sebb 2012-02-20 01:03:49 UTC
I'm not sure it's a good idea for JMeter to do this.

Need to be careful this does not affect relative file names.

If the base directory changes, this could be very confusing when using relative file names for sample result files.
Comment 2 immanuel.hayden 2012-02-20 09:24:43 UTC
+1 for this from me and my teammates here at the company :)

regarding relative file names: Can anybody think of a use case where this matters?
1) If you open a file with relative paths then the base directory is changed to that file's anyhow.
2) using relative paths in a file that you have not saved and thus don't know the final location is ... well, let's call it adventurous ...
3) At least for the include-controller (which is where I use relative paths to link to some common setup stuff) you have to save the file you include something into first anyhow in order to get it evaluated.
Comment 3 Sebb 2012-02-20 15:11:36 UTC
(In reply to comment #2)
> regarding relative file names: Can anybody think of a use case where this
> matters?

I was thinking of Listener file names. If the test plan uses relative names for one or more such files, then it would be very counter-intuitive if the location for that file depended on whatever directory happened to be opened last.
Comment 4 immanuel.hayden 2012-02-20 15:54:48 UTC
(In reply to comment #3)
> I was thinking of Listener file names. If the test plan uses relative names for
> one or more such files, then it would be very counter-intuitive if the location
> for that file depended on whatever directory happened to be opened last.
theoretically speaking, yes, but see #2 of my previous post ... generally relative file paths are only meaningful in the context of having a predefined location already which imo you don't have when you don't save your file somewhere first. Eg. if I don't know where my file will go there is no use in specifying a relative path and if I want my file to always access the same static location in the file system regardless of where I place it then that's the prime example for using an absolute path.
Comment 5 Sebb 2012-02-20 16:35:15 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > I was thinking of Listener file names. If the test plan uses relative names for
> > one or more such files, then it would be very counter-intuitive if the location
> > for that file depended on whatever directory happened to be opened last.
> theoretically speaking, yes, but see #2 of my previous post ... generally
> relative file paths are only meaningful in the context of having a predefined
> location already which imo you don't have when you don't save your file
> somewhere first. Eg. if I don't know where my file will go there is no use in
> specifying a relative path and if I want my file to always access the same
> static location in the file system regardless of where I place it then that's
> the prime example for using an absolute path.

I was referring to an existing test plan with relative listener file names.
When running non-GUI, the output will be relative to the launch directory.

The same needs to be true of GUI runs.
Comment 6 immanuel.hayden 2012-02-20 17:55:47 UTC
(In reply to comment #5)
> I was referring to an existing test plan with relative listener file names.
> When running non-GUI, the output will be relative to the launch directory.
> 
> The same needs to be true of GUI runs.
... so the relative file names in listeners have a different behaviour than relative file names in the include controller? Or is this a discrepancy between opening files from the command line vs. opening them from file->open?

Because I always use jmeter in gui-mode running from C:\data\progs\jmeter\bin and have my jmx files in C:\data\svn\tests\jmeter\[module1,2,3/common] (where common contains setup sequences which are included with an include controller and a path like "../common/setup.jmx"). When I open them through file->open the path of the include controller is calculated relative to the jmx file's location.
So maybe this explains why I am all "wtf is he talking about?" :D
Comment 7 Dzmitry Kashlach 2014-10-22 08:47:43 UTC
Created attachment 32135 [details]
FileDialoger&Load patch

I propose add a setter for recent directory to FileDialoger(patch is attached).
This will allow update current directory on every LOAD command, e.g.  JMeter will always prompt user to open file from recent directory. And this change do not involve non-gui part.
Comment 8 Philippe Mouawad 2014-10-28 21:13:25 UTC
Date: Tue Oct 28 21:11:59 2014
New Revision: 1634989

URL: http://svn.apache.org/r1634989
Log:
Bug 52707 - Make Open File dialog use last opened file folder as start folder
Bugzilla Id: 52707

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileDialoger.java
    jmeter/trunk/xdocs/changes.xml
Comment 9 Philippe Mouawad 2014-10-28 21:13:42 UTC
Thanks for patch, commited.
Comment 10 Dzmitry Kashlach 2014-10-29 07:06:02 UTC
Got an NPE when trying to open JMX right after JMeter start. Fix is attached.

2014/10/29 09:57:53 ERROR - jmeter.gui.action.ActionRouter: Error processing org.apache.jmeter.gui.action.Load@1ab98b9 java.lang.NullPointerException
	at java.io.File.<init>(File.java:277)
	at org.apache.jmeter.gui.util.FileDialoger.promptToOpenFile(FileDialoger.java:104)
	at org.apache.jmeter.gui.util.FileDialoger.promptToOpenFile(FileDialoger.java:68)
	at org.apache.jmeter.gui.action.Load.doAction(Load.java:79)
	at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:81)
	at org.apache.jmeter.gui.action.ActionRouter.access$000(ActionRouter.java:40)
	at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:63)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Comment 11 Dzmitry Kashlach 2014-10-29 07:07:34 UTC
Created attachment 32160 [details]
NPE fix
Comment 12 Philippe Mouawad 2014-10-29 08:50:31 UTC
Date: Wed Oct 29 08:49:49 2014
New Revision: 1635070

URL: http://svn.apache.org/r1635070
Log:
Bug 52707 - Make Open File dialog use last opened file folder as start folder
FIx NPE
Bugzilla Id: 52707

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileDialoger.java
Comment 13 The ASF infrastructure team 2022-09-24 20:37:49 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2745