Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SM4 introduces erratic behaviour in function

Featured Replies

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.