Mario,
I read the wiki before I sent the question. I know that so seldom happens on this list. :-)

I've implemented a FileChooser based on Swing's code, but using VFS instead of the standard java.io.File classes. However, I've run into a couple of problems that I can't seem to get past. Implementing Swing-compatible file filters is one of them. In my VFSFileChooser class there are a couple of methods from the Swing JFileChooser that I can't figure out how to implement with VFS. The problem boils down to the fact that I can't instantiate or create FileSelectInfo objects used by the filter.

   public void setFileFilter(FileFilter filter) {
       FileFilter oldValue = fileFilter;
       fileFilter = filter;
       if (filter != null) {
           if (isMultiSelectionEnabled() && selectedFiles != null
                   && selectedFiles.length > 0) {
               Vector fList = new Vector();
               boolean failed = false;
               for (int i = 0; i < selectedFiles.length; i++) {
                   //if (filter.accept(selectedFiles[i])) { FIXME
                       fList.add(selectedFiles[i]);
                   //} else {
                   //    failed = true;
                   //}
               }
               if (failed) {
                   setSelectedFiles((fList.size() == 0) ? null
: (FileObject[]) fList.toArray(new FileObject[fList.size()]));
               }
} else if (selectedFile != null ) { //&& !filter.accept(selectedFile) FIXME
               setSelectedFile(null);
           }
       }
firePropertyChange(FILE_FILTER_CHANGED_PROPERTY, oldValue, fileFilter);
   }


   public boolean accept(FileObject f) {
       boolean shown = true;
       if (f != null && fileFilter != null) {
           //shown = fileFilter.accept(f); FIXME
       }
       return shown;
   }

As far as I can tell, I can't instantiate FileSelectInfo, and I can't find any method that actually creates FileSelectInfo classes. So when I run into code such as the stuff shown above, I'm stuck because I can't create a FileSelectInfo object.

In general, most of my problems with FileSelectInfo and a few other classes in VFS is that rather than building upon the java.io classes (or at the very least deriving an interface based upon the File class and building upon that), they go off in some other (incompatible) direction. So when people like me are trying to use VFS with Swing classes or other standard Java classes, they run into problem after problem.

I'm hoping that in later releases of VFS, that the some work is done to simplify and standardize the API. This might improve its chances to be used on JSR 203. Even if it means creating adapter classes that bridge VFS and java.io classes, this would help improve VFS's adoption.

Mark


Mario Ivankovits wrote:
Hi!
There doesn't seem to be a way to turn a FileObject into a
FileSelectInfo object.  And even though you mentioned that the
FileSelectInfo gives you access to the root, and a few other things, I
still don't see what value that has when you're trying to filter based
on either name or metadata.
And I dont get your problems with the FileSelectInfo ;-)

Why would you turn a FileObject into a FileSelectInfo. This is something
VFS do for you.

On http://wiki.apache.org/jakarta-commons/VfsFaq you will find an
example how to use a selector.

To get the FileObject in question you can call fileSelectInfo.getFile().


Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to