Search in sources :

Example 1 with IUploadData

use of com.servoy.j2db.plugins.IUploadData in project servoy-client by Servoy.

the class SmartClientPluginAccessProvider method showFileOpenDialog.

@Override
public void showFileOpenDialog(IMediaUploadCallback callback, String fileNameHint, boolean multiSelect, String[] filter, int selection, String dialogTitle) {
    File file = null;
    if (fileNameHint != null)
        file = new File(fileNameHint);
    if (multiSelect) {
        File[] files = FileChooserUtils.getFiles(getCurrentWindow(), file, selection, filter, dialogTitle);
        if (files != null && files.length > 0) {
            IUploadData[] data = new FileUploadData[files.length];
            for (int i = 0; i < files.length; i++) {
                data[i] = new FileUploadData(files[i]);
            }
            callback.uploadComplete(data);
        }
    } else {
        final File f = FileChooserUtils.getAReadFile(getCurrentWindow(), file, selection, filter, dialogTitle);
        if (f != null) {
            IUploadData data = new FileUploadData(f);
            callback.uploadComplete(new IUploadData[] { data });
        }
    }
}
Also used : IUploadData(com.servoy.j2db.plugins.IUploadData) File(java.io.File)

Example 2 with IUploadData

use of com.servoy.j2db.plugins.IUploadData in project servoy-client by Servoy.

the class MainPage method showOpenFileDialog.

@SuppressWarnings("nls")
public void showOpenFileDialog(final IMediaUploadCallback callback, boolean multiSelect, String acceptFilter, String title) {
    if ((isShowingInDialog() || isClosingAsDivPopup()) && callingContainer != null) {
        callingContainer.showOpenFileDialog(callback, multiSelect, acceptFilter, title);
    } else {
        touch();
        this.mediaUploadMultiSelect = multiSelect;
        this.mediaUploadFilter = acceptFilter;
        this.mediaUploadCallback = new IMediaUploadCallback() {

            boolean uploaded = false;

            public void uploadComplete(IUploadData[] fu) {
                touch();
                uploaded = true;
                mediaUploadCallback = null;
                addJSAction(new DivDialogAction(fileUploadWindow, DivDialogAction.OP_CLOSE));
                callback.uploadComplete(fu);
            }

            public void onSubmit() {
                if (!uploaded) {
                    mediaUploadCallback = null;
                    divDialogs.remove(FILE_UPLOAD_PAGEMAP);
                    fileUploadWindow.setPageMapName(null);
                    fileUploadWindow.remove(fileUploadWindow.getContentId());
                    addJSAction(new DivDialogAction(fileUploadWindow, DivDialogAction.OP_CLOSE));
                }
            }
        };
        fileUploadWindow.setPageMapName(FILE_UPLOAD_PAGEMAP);
        if (title == null) {
            fileUploadWindow.setTitle(client.getI18NMessage("servoy.filechooser.title"));
        } else if (!"".equals(title)) {
            fileUploadWindow.setTitle(title);
        }
        divDialogs.put(FILE_UPLOAD_PAGEMAP, fileUploadWindow);
        addJSAction(new DivDialogAction(fileUploadWindow, DivDialogAction.OP_SHOW, new Object[] { FILE_UPLOAD_PAGEMAP }));
    }
}
Also used : IUploadData(com.servoy.j2db.plugins.IUploadData) DivDialogAction(com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction) IMediaUploadCallback(com.servoy.j2db.plugins.IMediaUploadCallback)

Aggregations

IUploadData (com.servoy.j2db.plugins.IUploadData)2 IMediaUploadCallback (com.servoy.j2db.plugins.IMediaUploadCallback)1 DivDialogAction (com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction)1 File (java.io.File)1