/** * 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(); } }
/** * 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); } }
/** * {@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); }
.addScriptListener(listener); 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(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); }