jfilechooser - Java FileFilter to select certain directories -


i trying create filefilter allow user open directory contains file. use case these directories workspaces have file called smart.workspace inside.

currently filter follows...

class smartworkspacefilter extends javax.swing.filechooser.filefilter {      string description = "smart workspace";     string filenamefilter = "smart.workspace";      smartworkspacefilter() {      }      @override     public boolean accept(file file) {          log.debug("testing file: " + file.getname());          if (file.isfile()) {             return false;         }          if (file.isdirectory()) {             file[] files = file.listfiles();             (file f : files) {                  log.debug("directory: " + f.isdirectory());                 log.debug("name: " + f.getname());                  if (f.isdirectory()) {                     return true;                 }                  if (f.getname().equals(filenamefilter)) {                     return true;                 }             }         }         return false;     }      @override     public string getdescription() {         return description;     } } 

obviously problem allow user navigate workspace folder have allow sub directories.

for file chooser using option directories_only.

is possible allow user select directory based on directories contents?

for example directory 'workspace' exists @ c://folder1/folder2/wokspace, want allow filechooser 'start' @ c:// , allow user navigate 'workspace' folder , accept it. filechooser shouldn't allow acceptance of folder1 or folder2 still allow navigation through folder1 , folder2.

i dont think can make filefilter differentiate between "files/directories should displayed can accessed" , "files/directories can selected".

a solution problem comes mind is: let user search/select smart.workspace file , navigate there parent folder.

if need dialog described above have involved in detail jfilechooser. extending class gives enough access change behaviour desired.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -