/** * 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); }
/** * 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(); }
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 fileChooser.addChoosableFileFilter(new FileFilterAdapter(fileTypeEntry .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 fileChooser.addChoosableFileFilter(new FileFilterAdapter( fileTypeEntry.getValue(), getTranslationProvider(context) .getTranslation(fileTypeEntry.getKey(), getLocale(context)) + extensionsDescription.toString()));
/** * {@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); }
/** * {@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); }
/** * Constructs a new {@code OpenFileAsBinaryPropertyAction} instance. */ public OpenFileAsBinaryPropertyAction() { fileOpenCallback = new ConnectorValueSetterCallback(); setFileOpenCallback(fileOpenCallback); }
/** * Constructs a new <code>OpenFileAsBinaryPropertyAction</code> instance. */ public SaveBinaryPropertyAsFileAction() { setFileSaveCallback(new ConnectorValueGetterCallback()); }
/** * {@inheritDoc} */ @Override protected Map<String, List<String>> getFileFilter(Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) getModelDescriptor(getModelPath(context), context); return modelDescriptor.getFileFilter(); }
/** * {@inheritDoc} */ @Override protected Map<String, List<String>> getFileFilter(Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) getModelDescriptor(getModelPath(context), context); return modelDescriptor.getFileFilter(); }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) context .get(ActionContextConstants.MODEL_DESCRIPTOR); setFileFilter(modelDescriptor.getFileFilter()); return super.execute(actionHandler, context); } }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) context .get(ActionContextConstants.MODEL_DESCRIPTOR); setFileFilter(modelDescriptor.getFileFilter()); 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); } }
/** * Retrieve the binary content to display the infos on. * * @param context * the action context. * @return The binary content to display the infos on or null. */ protected byte[] getBinaryContent(Map<String, Object> context) { Object connectorValue = getViewConnector(context).getConnectorValue(); byte[] content; if (connectorValue instanceof String) { content = ((String) connectorValue).getBytes(); } else { content = (byte[]) connectorValue; } return content; } }
/** * Constructs a new <code>OpenFileAsBinaryPropertyAction</code> instance. */ public OpenFileAsBinaryPropertyAction() { setFileOpenCallback(new ConnectorValueSetterCallback()); }
/** * Constructs a new {@code OpenFileAsBinaryPropertyAction} instance. */ public SaveBinaryPropertyAsFileAction() { fileSaveCallback = new ConnectorValueGetterCallback(); setFileSaveCallback(fileSaveCallback); }
/** * {@inheritDoc} */ @Override protected Integer getFileMaxSize(Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) getModelDescriptor(getModelPath(context), context); return modelDescriptor.getMaxLength(); }
/** * 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); }