Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4797 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm working with the Choose Folder function that is provided with ScriptMaster. This uses JFileChooser and says that in the chooser.setFileSelectionMode() step you can specify whether files, directories or both are shown in the Open Dialog box.

chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY);

//You can switch this to JFileChooser.FILES_ONLY or JFileChooser.FILES_AND_DIRECTORIES if you want the user to be able to pick files

My problem is that the FILES_ONLY choice gives me the same result as FILES_AND_DIRECTORIES - whichever option I use I see Directories and Files in the dialog window. DIRECTORIES_ONLY behaves correctly and only displays Directories

Is there a bug in jFileChooser?

I'm using Scriptmaster 4.02 (dated 3 Aug 2010) on Windows 7 with Filemaker 11 Adv.

Thanks

Brian

Posted

Brian,

I tested the ScriptMaster sample file and the Choose Folder module appeared to work fine. When using FILES_ONLY to set the file selection mode of the JFileChooser object, if you notice the "Choose" button in the popup is missing when a directory is selected. You can drill into the directory (and access other files) but can't choose the directory itself.

Posted

I believe what you are trying to do can be accomplished using the setFileFilter(FileFilter filter) method to control what gets displayed. It takes a FileFilter object as a parameter. You may want to try to get that to work if you need this implementation. Keep in mind though, that would likely eliminate being able to access any files deeper in the tree than the current directory.

Posted

Ah, I hadn't actually thought of picking the Directory and checking the state of the button.

We store various PDFs in nested folder structures on our file server. So for example our parts folder has a folder for drawings and a folder for tech specs; both of these contain a directory called archive which is where old versions are stored. If a user is associating a tech spec with the database, I want the ChooseFolder function to point him at the tech specs folder so he only sees the PDF files in that folder and doesn't see the archive folder, so precluding him from picking an out of date tech spec.

The down side of this approach is that if the user is clever enough to use the navigation icon in the dialog to move up a directory level, he won't be able to navigate down again as the folder he came from won't be visible. Do you know if it is possible to disable or remove the navigation item?

Brian

Posted

This is really more of a Java/Groovy question. It does look like using the setFileFilter(FileFilter filter) as referenced above would control the view. But you are likely right about them navigating themselves into trouble. I'm not sure about how to disable or remove navigation items in the JChooser. I didn't see a method for that in a quick glance of the JavaDocs but I may have missed it. You may also find something on StackOverflow or the like.

Posted

Maybe (if like me, you're more comfortable with FileMaker than with Java/Groovy), you can simply use another type of interface. "Choose folder" may not be the "right" option for this.

If you use the ScriptMaster sample files "List All Files In Directory"/"List All Files Recursively", you can very easily build lists of the files users would need to be able to pick from.

If you don't want to build the whole thing from scratch, you could probably take the samples from the 360Works FTPeek sample file and just adapt it to using lists from the file system rather than lists of files obtained though FTP.

This topic is 4797 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.