/** * Computes a file name to save the file. Defaults to the action default file name parametrized in the action. * * @param context * the action context. * @return the file name to save the file under. */ protected String getFileName(Map<String, Object> context) { return getDefaultFileName(); }
/** * Gets the fileOpenCallback. * * @param context the action context. * @return the fileOpenCallback. */ protected IFileOpenCallback getFileOpenCallback(Map<String, Object> context) { return (IFileOpenCallback) super.getFileCallback(context); }
/** * Sets the fileOpenCallback. * * @param fileOpenCallback * the fileOpenCallback to set. */ public void setFileOpenCallback(IFileOpenCallback fileOpenCallback) { super.setFileCallback(fileOpenCallback); }
fileChooser.setDialogTitle(getI18nName(getTranslationProvider(context), getLocale(context))); Map<String, List<String>> executionFileFilter = getFileFilter(context); if (executionFileFilter != null) { for (Map.Entry<String, List<String>> fileTypeEntry : executionFileFilter .getValue(), getTranslationProvider(context).getTranslation( fileTypeEntry.getKey(), getLocale(context)) + extensionsDescription.toString())); String fileName = getFileName(context); if (fileName != null) { fileChooser.setSelectedFile(new File(fileName));
if (fileChooser == null) { fileChooser = new JFileChooser(); fileChooser.setDialogTitle(getI18nName(getTranslationProvider(context), getLocale(context))); if (fileFilter != null) { for (Map.Entry<String, List<String>> fileTypeEntry : fileFilter fileTypeEntry.getValue(), getTranslationProvider(context) .getTranslation(fileTypeEntry.getKey(), getLocale(context)) + extensionsDescription.toString()));
fileSaveCallback.cancel(context); return super.execute(actionHandler, context);
/** * Computes a file name to save the file. Queries the file save callback for a * file name and defaults to the action default one if none is returned. * * @param context * the action context. * @return the file name to save the file under. */ @Override protected String getFileName(Map<String, Object> context) { IFileSaveCallback saveCallback = getFileSaveCallback(context); if (saveCallback != null) { String fileName = saveCallback.getFileName(context); if (fileName != null && fileName.length() > 0) { return fileName; } } return super.getFileName(context); } }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { JFileChooser currentFileChooser = getFileChooser(context); int returnVal = currentFileChooser.showOpenDialog(SwingUtil .getVisibleWindow(getSourceComponent(context))); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = currentFileChooser.getSelectedFile(); if (file != null) { try { fileOpenCallback.fileChosen(new FileInputStream(file), file .getAbsolutePath(), actionHandler, context); } catch (FileNotFoundException ex) { fileOpenCallback.cancel(actionHandler, context); } } else { fileOpenCallback.cancel(actionHandler, context); } } else { fileOpenCallback.cancel(actionHandler, context); } return super.execute(actionHandler, context); }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { JFileChooser currentFileChooser = createFileChooser(context); int returnVal = currentFileChooser.showOpenDialog(SwingUtil .getVisibleWindow(getSourceComponent(context))); IFileOpenCallback openCallback = getFileOpenCallback(context); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = currentFileChooser.getSelectedFile(); if (file != null) { try { openCallback.fileChosen(file.getName(), new FileInputStream(file), actionHandler, context); } catch (FileNotFoundException ex) { openCallback.cancel(actionHandler, context); } } else { openCallback.cancel(actionHandler, context); } } else { openCallback.cancel(actionHandler, context); } return super.execute(actionHandler, context); }
/** * Gets the fileSaveCallback. * * @param context the action context. * @return the fileSaveCallback. */ protected IFileSaveCallback getFileSaveCallback(Map<String, Object> context) { return (IFileSaveCallback) super.getFileCallback(context); }
/** * Sets the fileSaveCallback. * * @param fileSaveCallback * the fileSaveCallback to set. */ public void setFileSaveCallback(IFileSaveCallback fileSaveCallback) { super.setFileCallback(fileSaveCallback); }
saveCallback.cancel(actionHandler, context); return super.execute(actionHandler, context);