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 5286 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

The following code is part of a solution that I am close to finishing. It appears to have stopped working properly under the 4.02 plugin while it works perfectly in both Groovy Console 1.7 and SM3.34

This will go to a folder ready to select a PDf to return the name so it can be imported into a container, BUT if you click on the button 75percent of the time it locks up FM with a beachball of death.. This doesn't happen if you double click the file chosen

FM11.2 on Mac 10.6.4, only your plugin..

Any ideas???

def fm_Path = "a valid path"

def fm_Message = "Pick a FILE"

def fm_Button = "Get PDF"

def fm_FileType = "p"

def fm_Select = "f"







// ChooseFiltered(fm_Path, fm_Message, fm_FileType, fm_Button, fm_Select)

// 10_06_10_JR WORKING

// v1

// fm_Path startpath for dialog

// fm_Message for dialog title

// fm_Button sets text for default 'accept' button

// fm_FileType selects file filter - p == pdf, i == images

// ... d == documents, x == data files, z == archives, a == all filters, null == no filters

// fm_Select is flag to set what is selected - f == files, d == dirs, null == both



import javax.swing.JFileChooser

import javax.swing.filechooser.FileNameExtensionFilter



chooser = new JFileChooser()

if (fm_Select == "d"){

    chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY )

} 

if (fm_Select == "f"){

    chooser.setFileSelectionMode( JFileChooser.FILES_ONLY )

} else chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES )

if( fm_Path != null ) chooser.setCurrentDirectory( new File(fm_Path) )

if( fm_Message != null ) chooser.setDialogTitle( fm_Message )

//chooser.setFileHidingEnabled(false)

// sets whether or not hidden files are shown

pdf = new FileNameExtensionFilter( "PDF files", "pdf" )

img = new FileNameExtensionFilter( "Image files", "jpg", "gif", "jpeg", "png", "tif", "bmp" )

doc = new FileNameExtensionFilter( "Documents", "doc", "docx", "txt", "wri", "htm", "html", "css", "log" )

xml = new FileNameExtensionFilter( "Data files", "csv", "xls", "xlsx", "xml", "tab", "xsl" )

zip = new FileNameExtensionFilter( "Archives", "zip", "dmg", "jar", "rar" )

if ( fm_FileType == "i"){

    chooser.setFileFilter(img)

    }

if ( fm_FileType == "d"){

    chooser.setFileFilter(doc)

    }

if ( fm_FileType == "p"){

    chooser.setFileFilter(pdf)

    }

if ( fm_FileType == "x"){

    chooser.setFileFilter(xml)

    }

if ( fm_FileType == "z"){

    chooser.setFileFilter(zip)

    }

if ( fm_FileType == "a"){

    chooser.addChoosableFileFilter(img)

    chooser.addChoosableFileFilter(doc)

    chooser.addChoosableFileFilter(pdf)

    chooser.addChoosableFileFilter(xml)

    chooser.addChoosableFileFilter(zip)

    chooser.setAcceptAllFileFilterUsed(true)

    }

else if ( fm_FileType == null){

    chooser.setAcceptAllFileFilterUsed(true)

}

chooser.setApproveButtonText(fm_Button)

chooser.setApproveButtonToolTipText("Import this file")

//chooser.setAcceptAllFileFilterUsed(false)

if( chooser.showOpenDialog( null ) == JFileChooser.APPROVE_OPTION ) {

    // select depending on format you require to be returned

    //return chooser.getSelectedFile().getCanonicalPath()

    return chooser.getSelectedFile().getAbsolutePath()

} else return false



///Volumes/MacBookPro/Users/RWU/Documents/SpringFM

//C:Documents and SettingsJohnMy DocumentsFM output

This topic is 5286 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.