File Type in showFileSaveDailog()

Hi Folks

Is it possible to limit the “plugins.file.showFileSaveDialog()” to a single type of file (PDF’s for example)?

although you can pass a suggestion (for example ‘c:*.pdf’) the plugin doesn’t filter.
Seems like a nice feature request :wink:

The ‘getFolderContents’ function does have filter abilities.
So it depends how badly you need the function, otherwise you can write your own dialog…

Last option if you need to force input of a certain type: use the JSFile getContentType() function to test the selected file.
True: a user can select a ‘wrong type’ file, but your application won’t process it…

Hope this helps.

Thanks for the feedback Marc - this is a function of the Win API so seems like it should be available in Servoy File Plugin.

I’ll mention it in the Request section.

showFileOpenDialog already also have filter support
That is all open source now so somebody (like patrick ;)) can make a patch quickly if needed.

jcompagner:
showFileOpenDialog already also have filter support
That is all open source now so somebody (like patrick ;)) can make a patch quickly if needed.

Alternatively, you can use the latest BrowserSuite (v0.9.37+)

The BrowserSuite client plugin now offer access to Native dialogs (gives you true native look and feel + automatic thumbnails among other stuff)
So to get a PDF file you could use:

var dir = plugins.file.getDesktopFolder();
var file = plugins.BrowserSuite.saveFileChooser(
    {
        confirmOverwrite: true,
        title: 'Save to PDF',
        acceptedExtensions: ['*.pdf '],
        acceptedLabels: ['PDF File'],
        defaultFile: (dir+'/report.pdf')
    }
);

Patrick - that is ridiculous (in a good way), for two reasons:

  1. Browser Suite does EVERYTING… :shock:

  2. Servoy have decided that, now its OS you should fix EVERYTHING… :shock:

Personally, I’m glad its now your responsibility :wink: - I’ve been paying Servoy a quite a bit of money for some time and I’m pleased they have now commissioned you to fix the bits that are missing / don’t work! :twisted: :twisted:
The futures bright - the futures Patrick :lol:

ptalbot:
The BrowserSuite client plugin now offer access to Native dialogs (gives you true native look and feel + automatic thumbnails among other stuff)

great stuff… I’ve seen a lot of happy faces this morning (especially Mac people)

awesome Patrick!!! :-)

but is it really needed to install the whole browsersuite for that? Can this be patched also, to the OSS version of the file plugin?
Not every project we have, is/want using the browsersuite…

Harjo:
Not every project we have, is/want using the browsersuite…

Why not, it’s such a great product! :mrgreen:

mboegem:

Harjo:
Not every project we have, is/want using the browsersuite…

Why not, it’s such a great product! :mrgreen:

Exactly! A Servoy install without the BrowserSuite is only half a Servoy install. :lol:

@Harjo: unfortunately, this functionality comes from the native capabilities of the DJNativeSwing-SWT project, meaning that in any case you would need the DJNative libs, JNA and SWT at least (not XULRunner though), so 80% of the BrowserSuite anyway.

is there a big difference between the native FileDialog through SWT and the java.awt.FileDialog ?

jcompagner:
is there a big difference between the native FileDialog through SWT and the java.awt.FileDialog ?

One that I know about is about Thumbnails: in Java you have to manage your own thumbnails creation, but there is little ways to manage that efficiently (using a cache, creating thumbnails for only the files seen in the panel, etc…)

If you try that on a folder with hundreds of high resolution jpeg files and you will see the difference straight away: you will be lucky if the awt dialog doesn’t break your application, in any case in terms of response time, memory and cpu consumption there’s no comparing the native dialog.

So yes, the overhead if you only need a native file dialog is very big, but if you do already have the BrowserSuite, then using NativeDialogs is better.

awt dialog should be the native stuff (i am talking about java.awt.FileDialog not JDialog of swing!)

I just tested it, it is not really the native dialog that i get form file open dialogs in other stuff
But it uses native parts (i see for example the Libraries node and so on) But i agree that dialog is still not really nice.

Yes, java.awt.FileDialog has a native peer, but the API is quite limited.