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.

Bug 154667 - Save As dialog is limited to using the TopComponent's FileObject's target folder
Summary: Save As dialog is limited to using the TopComponent's FileObject's target folder
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
: 155038 155617 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-12-05 02:22 UTC by John Baker
Modified: 2009-02-19 22:53 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Suggested fix (1.90 KB, text/plain)
2008-12-09 23:41 UTC, John Baker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Baker 2008-12-05 02:22:14 UTC
I would like to supply another name and path to the Save As dialog by default (not the name and path of the
TopComponent's FileObject).

However, SaveAsAction is restricted to only using the FileObject of the TopComponent as the current FileObject which
forms the path and name that is supplied to the Save As dialog.

Suggested change:
Instead of using the FileObject from TopComponent, use the FileObject created in an instance of
DataEditorSupport.saveAs(...)

But this would require an API change to DataEditorSupport.saveAs to return the FileObject.

Currently, oddly, it's possible for the user to save a file using File->Save As,  but (if implemented) the instance of
DataEditorSupport could override saveAs(...) and cause a completely different folder and name to be saved to disk.

So, by making the suggested change  above this odd hack would not be allowed.
Comment 1 John Baker 2008-12-06 00:56:18 UTC
Please evaluate.  This has an unfavorable consequence in 7.0, when saving SQL files using Save As.

Use case is:

1) User opens Services, opens a connection, selects a database table and chooses View->Data
and then wants to save the generated SQL as another file in a directory outside the userdir

2) User chooses File->Save As

The Save As dialog opens and the destination path is the folder SQLCommands in the userdir

If the user wants to save many results of View->Data then everytime the user has to navigate outside the userdir and
this is a hassle.
Comment 2 John Baker 2008-12-06 07:08:31 UTC
I have a better suggestion.

The way Save As should work is to cache the destination location chosen by the user.

For example, the first time opening Save As on a temporary file, the initial destination directory will be
$userdir/config/Databases/SQLCommands

If the user changes this directory within the Save As dialog to $HOME then for the remainder of the NetBeans session
each time the Save As dialog opens for all SQL files, the destination directory will be $HOME, until the user changes
the destination directory.

Each time the user changes the destination directory within the Save As dialog, SaveAsAction needs to cache this directory. 
Comment 3 John Baker 2008-12-09 17:17:55 UTC
*** Issue 155038 has been marked as a duplicate of this issue. ***
Comment 4 John Baker 2008-12-09 23:40:43 UTC
Attached is a diff containing the suggested fix.

Use case is 

1) User opens Services, opens a connection, selects a database table and chooses View->Data
and then wants to save the generated SQL as another file in a directory outside the userdir

2) User chooses File->Save As
The target folder is $userdir/config/Databases/SQLCommands

3) Within the Save As dialog, the user changes the target folder to the user's home directory.
and clicks OK to save the file.

4) User repeats steps 1 and 2 , but the new target folder, as expected, is the user's home directory
Comment 5 John Baker 2008-12-09 23:41:32 UTC
Created attachment 74770 [details]
Suggested fix
Comment 6 John Baker 2008-12-12 09:09:47 UTC
Please evaluate the attached suggested fix.

The Database team would like this change made for 7.0.  Thanks
Comment 7 _ wadechandler 2008-12-12 20:55:13 UTC
Seems odd to show the user the NB user dir. They should not have to be intimate with it in my opinion. Better, to
default to the current main projects directory, users home, or something like that. .netbeans is a hidden folder, and
the user dir will usually be under this folder unless overridden by the user when running or in their conf file, and
things under the NB user directory are not guaranteed to be more than temporary for the users concerns.
Comment 8 Stanislav Aubrecht 2008-12-18 16:08:05 UTC
the patch looks ok to me with one minor change - if no last used dir is found in nbpreferences then the directory in
save as window should default to user's home dir (to take care of issue 155617)

i can integrate the patch into nb70m2
Comment 9 Stanislav Aubrecht 2008-12-18 16:08:31 UTC
*** Issue 155617 has been marked as a duplicate of this issue. ***
Comment 10 John Baker 2008-12-18 20:34:56 UTC
> if no last used dir is found in nbpreferences then the directory in save as window should default to user's home dir
(to take care of issue 155617)

Sounds good to me

Thanks!
Comment 11 Stanislav Aubrecht 2008-12-19 09:58:48 UTC
actually, i think that even better algorithm is presenting last used dir (if available) or user's home dir when the
FileObject's parent points to <userdir> and use FileObject's parent in all other cases

jbaker, does that make sense to you?
Comment 12 _ wadechandler 2008-12-19 17:11:56 UTC
I may be missing something, but there is a big difference between the userdir (NB specific) and the user home (OS
specific). Which one are we talking about? Notice my comment about the user directory and that on different systems this
is a hidden directory. Too, the users should not have to be intimate with the user directory, but their home directory:
Windows: %userprofile%
Linux/Unix: $HOME

makes great sense. Now, if in the IDE they have a FileObject which actually has a parent which is not in the user
directory (not their home), then that would make sense, but to me if one of the parents in the hierarchy is the user
directory then the Save As should default to choosing the users home instead of trying to get them to save it in the
userdir. If not the user home then at least the users project directory. I know on Linux for example. I can't see the
.netbeans folder unless I change the way file access works in other applications dialogs or on the command line perform a:
ls -lsda .*
ls -a 

etc.

So it seems if the dialog a user is saving with doesn't show them their full tree of where they are saving the file,
they may later go looking for it thinking like other things it would be an easily visible folder under their home
folder, and not find it. Too, the userdir isn't somewhere users need to be arbitrarily poking around. They can really
mess up their IDE...well at least until they delete the user directory and let another one get created, but then they
can mess up and lose libraries, updates, 3rd party plugins etc.
Comment 13 Stanislav Aubrecht 2008-12-19 17:32:57 UTC
ok, here's my clarification:

- if FileObject's parent points to netbeans user dir (the hidden folder) then the Save As dialog will offer either last
used folder (if available) or user's home dir (os dependent) as initial save location

- if FileObject's parent does not point to netbeans user dir then the Save As dialog will use FileObject's parent as
initial save location
Comment 14 _ wadechandler 2008-12-19 18:00:04 UTC
Sounds reasonable to me. Definitely different from a Save operation on some temporary buffer where no parent will exist,
and that makes it work more like other applications I'm using on my desktop right now.
Comment 15 John Baker 2008-12-19 18:19:16 UTC
Thanks for re-clarifying.

I too agree with the latest proposal in desc14.

Some users may use Save As for renaming a file in the same directory (userdir is the exception)

Comment 16 Stanislav Aubrecht 2009-01-05 11:17:11 UTC
fixed

e30b572cf670
Comment 17 John Baker 2009-01-06 01:33:23 UTC
Thank you.
Works well now.
Comment 18 Quality Engineering 2009-01-06 05:28:43 UTC
Integrated into 'main-golden', will be available in build *200901060201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/e30b572cf670
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #154667 - don't show netbeans user dir in 'save as' file chooser