Design of File Choosers

R

Rhino

I would like to have a file chooser that lets me look at all of the entries
in a Jar (and maybe a Zip file) the way that a standard JFileChooser lets me
look at all of the entries in a directory. Ideally, the jar could be located
in the filesystem, on or off the classpath, or even online at a location
described like this: jar:http:/xyz.com/images/photoJar!/

Standard JFileChoosers don't have any constructors for finding files in a
jar. Would I be able to get that functionality by subclassing JFileChooser
and adding new constructors that handle files in jars? Or would I have to
create a whole new class that reads jars?

I'd like to leverage the functionality built into existing JFileChoosers if
possible but my theory is weak in some areas and I can't quite figure out
how to do so.

Can anyone suggest a good approach?


--
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare
 
R

Rhino

Ben_ said:
Got addicated to Jar these days ? :)))
That's one way to look at it! :)

But really, I'm just trying to make some components that are as "universal"
as possible for accessing files. I'm toying with the idea of a "universal
file chooser" that could view any of these things:
- standalone files
- files in jars
- files in databases (stored as blobs, for example)
- files in zips
- files on network shares
- files that are online (maybe in jars, maybe not)
- etc. etc.

I'd like to get as much mileage out of the existing components as I can
though; the standard features of JFileChoosers are pretty useful and I don't
really want to "re-invent the wheel".

I'm using the newsgroup as a sounding board; maybe people can suggest some
good approaches for me - or some that should be avoided like the plague.

Rhino
 
A

Andrey Kuznetsov

But really, I'm just trying to make some components that are as
"universal"
as possible for accessing files. I'm toying with the idea of a "universal
file chooser" that could view any of these things:
- standalone files
- files in jars
- files in databases (stored as blobs, for example)
- files in zips
- files on network shares
- files that are online (maybe in jars, maybe not)
- etc. etc.

I'd like to get as much mileage out of the existing components as I can
though; the standard features of JFileChoosers are pretty useful and I
don't
really want to "re-invent the wheel".

I'm using the newsgroup as a sounding board; maybe people can suggest some
good approaches for me - or some that should be avoided like the plague.

I wrote Dynamic Tree Framework - with it you can view most of things
you need (except files in databases).
The bad news is that I there are no way to use it with java's JFileChooser.
The good news is that you can use it with simple JTree and you can easy
implement your own handler (for example for database).

see tutorial
http://jgui.imagero.com/tutorial.html#explore
http://jgui.imagero.com/tutorial.html#browseURL
http://jgui.imagero.com/tutorial.html#browseANY

and javadoc
http://jgui.imagero.com/doc/com/imagero/gui/swing/tree/package-summary.html
http://jgui.imagero.com/doc/com/imagero/gui/swing/tree/handler/package-summary.html
http://jgui.imagero.com/doc/com/imagero/gui/swing/tree/node/package-summary.html
http://jgui.imagero.com/doc/com/imagero/gui/swing/tree/util/package-summary.html

it is part of JGui (JGui 1.38 is open source - GPL)
download here http://jgui.imagero.com/download.php

Another (may be better) way could be to create interface (e.g. VirtualFile)
and implement it.

For one project I started with following:

public interface VFile {
String getName();
String getDisplayName(); //for specific things (like desktop in
windows)
String getParent();
VFile getParentFile();
String getAbsolutePath();
boolean isDirectory();
boolean isHidden();
String [] list();
String [] list(VFilenameFilter filter);
VFile create(String name); //create child with specified name
boolean exists();
int getPos(); //for sorting purposes
InputStream getInputStream() throws VFileNotFoundException;
OutputStream getOutputStream() throws IOException;
}

I implemented it currently only for standalone files, but want to add
implementation for database.
 
R

Rhino

Andrey Kuznetsov said:
But really, I'm just trying to make some components that are as
"universal"
as possible for accessing files. I'm toying with the idea of a "universal
file chooser" that could view any of these things:
- standalone files
- files in jars
- files in databases (stored as blobs, for example)
- files in zips
- files on network shares
- files that are online (maybe in jars, maybe not)
- etc. etc.

I'd like to get as much mileage out of the existing components as I can
though; the standard features of JFileChoosers are pretty useful and I
don't
really want to "re-invent the wheel".

I'm using the newsgroup as a sounding board; maybe people can suggest some
good approaches for me - or some that should be avoided like the plague.

I wrote Dynamic Tree Framework - with it you can view most of things
you need (except files in databases).
The bad news is that I there are no way to use it with java's JFileChooser.
The good news is that you can use it with simple JTree and you can easy
implement your own handler (for example for database).

see tutorial
http://jgui.imagero.com/tutorial.html#explore
http://jgui.imagero.com/tutorial.html#browseURL
http://jgui.imagero.com/tutorial.html#browseANY

and javadoc
http://jgui.imagero.com/doc/com/ima...gero/gui/swing/tree/util/package-summary.html

it is part of JGui (JGui 1.38 is open source - GPL)
download here http://jgui.imagero.com/download.php

Another (may be better) way could be to create interface (e.g. VirtualFile)
and implement it.

For one project I started with following:

public interface VFile {
String getName();
String getDisplayName(); //for specific things (like desktop in
windows)
String getParent();
VFile getParentFile();
String getAbsolutePath();
boolean isDirectory();
boolean isHidden();
String [] list();
String [] list(VFilenameFilter filter);
VFile create(String name); //create child with specified name
boolean exists();
int getPos(); //for sorting purposes
InputStream getInputStream() throws VFileNotFoundException;
OutputStream getOutputStream() throws IOException;
}

I implemented it currently only for standalone files, but want to add
implementation for database.

--
Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
It looks as if you have already developed the components I'm just starting
to imagine; well done!! I will look further into your components - and maybe
add some enhancements of my own :)

It just seems to me that the source of the files should be unimportant to
the programs that use them; the program should work the same regardless of
where the files originate. This seems like a good step in that direction....

Rhino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top