/** * Computes a file name to save the file. Defaults to the action default file * name parameterized 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(); } }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) getModelDescriptor(context); setFileFilter(modelDescriptor.getFileFilter()); return super.execute(actionHandler, context); } }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { IFileFilterable modelDescriptor = (IFileFilterable) getModelDescriptor(context); setFileFilter(modelDescriptor.getFileFilter()); return super.execute(actionHandler, context); } }
/** * {@inheritDoc} */ @Override public boolean execute(final IActionHandler actionHandler, final Map<String, Object> context) { SFileChooser fileChooser = new SFileChooser(); SOptionPane .showInputDialog(getSourceComponent(context), getTranslationProvider( context) .getTranslation("open.file.description", getLocale(context)), getTranslationProvider(context).getTranslation("open.file.name", getLocale(context)), fileChooser, new OpenFileActionListener( fileChooser, getController(context), context)); return super.execute(actionHandler, context); }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, final Map<String, Object> context) { if (fileSaveCallback != null) { DynamicResource resource = new DynamicResource( getSourceComponent(context).getParentFrame()) { private static final long serialVersionUID = 2216910348294774650L; public void write(Device device) throws IOException { DeviceOutputStream out = new DeviceOutputStream(device); fileSaveCallback.fileChosen(out, context); out.flush(); device.close(); } }; Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Disposition", "attachment; filename=" + getDefaultFileName()); String url = SessionManager.getSession().getExternalizeManager() .externalize(resource, headers.entrySet(), AbstractExternalizeManager.REQUEST); ScriptListener listener = new JavaScriptListener(null, null, "location.href='" + url.toString() + "'"); SessionManager.getSession().getScriptManager() .addScriptListener(listener); } return super.execute(actionHandler, context); }
if (fileSaveCallback != null) { DynamicResource resource = new DynamicResource( getSourceComponent(context).getParentFrame()) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Disposition", "attachment; filename=" + getFileName(context)); String url = SessionManager .getSession() .addScriptListener(listener); 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); } }
/** * {@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); } }
Integer size = new Integer(0); String unit = "Ko"; byte[] content = getBinaryContent(context); if (content != null) { if (content.length < 1024) { context.put(ActionContextConstants.ACTION_PARAM, getTranslationProvider( context).getTranslation("binary.info.message", new Object[] {size, unit}, getLocale(context))); return super.execute(actionHandler, context);
/** * Constructs a new <code>OpenFileAsBinaryPropertyAction</code> instance. */ public OpenFileAsBinaryPropertyAction() { setFileOpenCallback(new ConnectorValueSetterCallback()); }
/** * Constructs a new <code>SaveBinaryPropertyAsFileAction</code> instance. */ public SaveBinaryPropertyAsFileAction() { setFileSaveCallback(new ConnectorValueGetterCallback()); }
/** * 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) { if (fileSaveCallback != null) { String fileName = fileSaveCallback.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; } }
public void write(Device device) { DeviceOutputStream out = new DeviceOutputStream(device); try { fileSaveCallback.fileChosen(getName(), out, actionHandler, context); out.flush(); } catch (IOException ex) { throw new ActionException(ex); } finally { try { out.close(); device.close(); } catch (IOException ex) { // NO-OP. } } } };
/** * {@inheritDoc} */ @Override public boolean execute(final IActionHandler actionHandler, final Map<String, Object> context) { SFileChooser fileChooser = new SFileChooser(); SOptionPane .showInputDialog( getSourceComponent(context), getTranslationProvider(context).getTranslation( "open.file.description", getLocale(context)), getTranslationProvider(context).getTranslation("open.file.name", getLocale(context)), fileChooser, new OpenFileActionListener( fileChooser, getController(context), context)); return super.execute(actionHandler, context); }
/** * Constructs a new <code>OpenFileAsBinaryPropertyAction</code> instance. */ public OpenFileAsBinaryPropertyAction() { setFileOpenCallback(new ConnectorValueSetterCallback()); }
/** * Constructs a new <code>SaveBinaryPropertyAsFileAction</code> instance. */ public SaveBinaryPropertyAsFileAction() { setFileSaveCallback(new ConnectorValueGetterCallback()); }