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 21690 - Make filechoosers more aware of their Unix environment
Summary: Make filechoosers more aware of their Unix environment
Status: RESOLVED FIXED
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: All Solaris
: P2 blocker (vote)
Assignee: issues@ide
URL:
Keywords: UI
Depends on:
Blocks:
 
Reported: 2002-03-18 22:40 UTC by Torbjorn Norbye
Modified: 2006-04-24 13:06 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2002-03-18 22:40:27 UTC
I've filed this as an enhancement but from a user's perspective
the current behavior is really a bug.

(1) Filechoosers do not recognize the "~" character
(2) Filechoosers do not recognize the "$" character

Specifically, given a path string, a file chooser should
  (a) replace ~<string>/ with /home/<string>/
  (b) replace ~/ with $HOME
  (c) replace $<string> with the expansion of
      the environment variable named by <string>
      (possibly repeatedly)

This should probably only be done when Utilities.getOperatingSystem()
returns a unix-style operating system such as Solaris and Linux.

For the full discussion (and explanation) please see the thread
  [nbui] UI Specification: Filechoosers Defaults
on nbui (some of that thread is irrelevant to this, so see in particualr
the following post:
http://www.netbeans.org/servlets/ReadMsg?msgId=281112&listName=nbui

Note - I can give you (properly SPL'ed) the code which given
a path string expands it properly. What you need to do is plug this
into the file choosers, most likely by creating a FileSystem (in the
JFileChooser sense, not the OpenIDE sense) which performs this 
expansion and then plug this filesystem into file choosers as they
are created. This issue may also require some modules to be modified
but as soon as a central file-expander is available that should be
straightforward. 

Let me know if you want the code.
Comment 1 Marek Grummich 2002-07-22 08:30:38 UTC
Target milestone was changed from '3.4' to TBD.
Comment 2 Marek Grummich 2002-07-22 08:34:30 UTC
Target milestone was changed from '3.4' to TBD.
Comment 3 mslama 2002-11-05 21:54:24 UTC
If I understand it correctly it should expand string you enter Object
Name field (in new ui spec) or File Name in JFileChooser after you
press Enter. Am I right?
Comment 4 Jesse Glick 2002-11-07 01:53:58 UTC
IMHO this is an RFE for Swing, not NetBeans. What is NetBeans-specific
about it? It just refers to the fact that JFileChooser is not as
usable as it should be, e.g. not as usable as the Gnome chooser. If
JFileChooser had GNU-readline-style completion, this would be a
natural part of that feature.
Comment 5 Torbjorn Norbye 2002-11-07 14:03:18 UTC
NetBeans is in a special position to do this because it has access to
environment variables; Swing doesn't. I agree that Swing should at
least handle ~. But since we're going to support jdk1.3 "forever", and
since as far as I know jdk1.4 also doesn't fix this, we could enhance
the user experience for users by fixing this. I pointed to this bug on
nbui because we were already going to provide a special NetBeans
filechooser (probably using JFileChooser). So I think fixing this
problem there provides a nice way to remove a major annoyance for Unix
users; besides, I was under the impression that we already have a
number of "value-adds" over Swing (e.g. org.openide.awt) although
that's only a vague impression not based on analysis.
Comment 6 Jesse Glick 2002-11-07 21:18:20 UTC
Hmm, perhaps... but we are trying to get rid of "value add"
components, not add more of them. They do not interact well with
custom L&Fs, and a lot of our users use custom L&Fs. I would oppose
adding new GUI components unless we really have to. If we want to
adjust the look of a standard component, we should be creating a
ComponentUI for it, not using a new component; in Kunststoff L&F the
existing UI may be just fine, for example.

If the ~ and $ expansion can happen entirely without GUI involvement,
this is a plus, though I still feel they would be more natural when
combined e.g. with readline support, which involves the L&F.

BTW if we *are* using filechoosers for data objects or file objects,
rather than java.io.File's, then ~ and $ expansion will be a little
trickier: you will have to "map" the expansion into the internal
object which represents it.
Comment 7 Torbjorn Norbye 2002-11-07 23:09:45 UTC
Yes, I believe this can be done without getting into the area of
L&F's; as I explained in the e-mail on nbui about this you just
install a delegating FileSystemView on the JFileChooser. It should
work regardless of which L&F is in effect. In fact, I thought perhaps
you'd already replace the FileSystemView to make it more NetBeans like
(e.g. show mounted filesystems as opposed to local disks (when
appropriate)).
Comment 8 mslama 2002-11-08 09:09:49 UTC
I implement Object Selector using JFileChooser: I create fake
java.io.File hierarchy from node hierarchy (in DataObjectEditor I add
JFileChooser optionally in addition to current tree view), I overwrite
File, FileView and FileSystemView. I did not check yet where this
expansion could be done.
Comment 9 Jesse Glick 2005-08-09 02:53:10 UTC
BTW: contrib/quickfilechooser already handles '~' correctly (I think). It
doesn't handle $VAR yet, but it would be quite easy to make it do so if anyone
cares enough. Note that System.getenv works again in 1.5.
Comment 10 Jesse Glick 2005-08-09 19:03:49 UTC
I just added envvar expansion (not completion) to quickfilechooser, if you want
to play with it.
Comment 11 Jesse Glick 2006-04-24 13:06:31 UTC
If you want this kind of behavior, quickfilechooser provides it. If you want
"standard" L&F filechoosers, request that the Swing team doing the GTK L&F
improve their filechooser to behave something like the real one, which has at
least ~ expansion.