@Override /** * When the 'export to XML' button is clicked, this method is called. It creates a new {@link * FileDialog}, in which the user can find the location to save the XML file to and enter its * name, followed by the .xml extension. If the user completes these steps, the method will export * the current configuration to an XML file. */ public void mouseUp(MouseEvent m) { FileDialog fd = new FileDialog(((Button) m.getSource()).getShell(), SWT.SAVE); fd.setText("Export configuration"); String[] ext = new String[1]; ext[0] = "*.xml"; fd.setFilterExtensions(ext); String selected = fd.open(); if (selected != null) { try { GUIBridge.synchronizeModulesFrontToBack(); new ExportModuleConfiguration().exportModuleConfiguration(selected); } catch (Exception e) { // TODO proper visual errors e.printStackTrace(); } } }
public OutputStream getOutputStream(Shell shell) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); String filterPath; String relativeFileName; int lastIndexOfFileSeparator = defaultFileName.lastIndexOf(File.separator); if (lastIndexOfFileSeparator >= 0) { filterPath = defaultFileName.substring(0, lastIndexOfFileSeparator); relativeFileName = defaultFileName.substring(lastIndexOfFileSeparator + 1); } else { filterPath = "/"; // $NON-NLS-1$ relativeFileName = defaultFileName; } dialog.setFilterPath(filterPath); dialog.setOverwrite(true); dialog.setFileName(relativeFileName); dialog.setFilterNames(defaultFilterNames); dialog.setFilterExtensions(defaultFilterExtensions); String fileName = dialog.open(); if (fileName == null) { return null; } try { return new PrintStream(fileName); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } }
public void selectOutputFile() { FileDialog dlg = new FileDialog(getParentShell(), SWT.SAVE); ArrayList<String> extensionList = new ArrayList<String>(); if (chosenOutputFormat != null && chosenOutputFormat.getFileSuffix() != null) { extensionList.add("*." + chosenOutputFormat.getFileSuffix()); // $NON-NLS-1$ } extensionList.add("*.*"); // $NON-NLS-1$ dlg.setFilterExtensions(extensionList.toArray(new String[extensionList.size()])); dlg.setFileName(getDefaultOutputFilename()); dlg.setOverwrite(true); String path; if (isFilePath()) { path = getOldFolderPath(); } else { path = defaultFolder; } if (LOG.isDebugEnabled()) { LOG.debug("File dialog path set to: " + path); // $NON-NLS-1$ } dlg.setFilterPath(path); String fn = dlg.open(); if (fn != null) { textFile.setText(fn); getButton(IDialogConstants.OK_ID).setEnabled(true); } }
private boolean saveAs() { FileDialog saveDialog = new FileDialog(shell, SWT.SAVE); saveDialog.setFilterExtensions(new String[] {"*.adr;", "*.*"}); saveDialog.setFilterNames(new String[] {"Address Books (*.adr)", "All Files "}); saveDialog.open(); String name = saveDialog.getFileName(); if (name.equals("")) return false; if (name.indexOf(".adr") != name.length() - 4) { name += ".adr"; } File file = new File(saveDialog.getFilterPath(), name); if (file.exists()) { MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO); box.setText(resAddressBook.getString("Save_as_title")); box.setMessage( resAddressBook.getString("File") + file.getName() + " " + resAddressBook.getString("Query_overwrite")); if (box.open() != SWT.YES) { return false; } } this.file = file; return save(); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); IWorkbenchPage page = window.getActivePage(); View view = (View) page.findView(View.ID); view.getViewer().refresh(); // open dialog to get path FileDialog filedlg = new FileDialog(window.getShell(), SWT.SAVE); filedlg.setText("Create Sequence Diagram File"); filedlg.setFilterPath("SystemRoot"); filedlg.setFilterExtensions(new String[] {"di"}); String selected = filedlg.open(); // create & initial the sequence diagram MyCreater myCreater = new MyCreater(); myCreater.init(window.getWorkbench(), new StructuredSelection()); // fixed bug IFile iFile = myCreater.create(selected); // create the model SequenceDiagram sdDiagram = new SequenceDiagram(); sdDiagram.setiFile(iFile); sdDiagram.setFilePath( new Path(selected).removeFileExtension().addFileExtension("uml").toOSString()); ModelManager.getInstance().AddModel(sdDiagram); // open the editor myCreater.open(iFile); // refresh the model viewer view.getViewer().refresh(); return null; }
public void save_Event() { FileDialog fd = new FileDialog(ZestDebuggerView.this.getSite().getShell(), SWT.SAVE); fd.setText("Save"); fd.setFilterPath("C:/"); String[] filterExt = {"*.jpg"}; fd.setFilterExtensions(filterExt); String selected = fd.open(); System.out.println(selected); if (selected != null) { GC gc = new GC(viewer.getControl()); org.eclipse.swt.graphics.Rectangle bounds = viewer.getControl().getBounds(); Image image = new Image(viewer.getControl().getDisplay(), bounds); try { gc.copyArea(image, 0, 0); ImageLoader imageLoader = new ImageLoader(); imageLoader.data = new ImageData[] {image.getImageData()}; imageLoader.save(selected, SWT.IMAGE_JPEG); MessageDialog.openInformation( ZestDebuggerView.this.getSite().getShell(), "Success", "The image has been saved successfully"); } catch (Exception e) { e.printStackTrace(); MessageDialog.openError( ZestDebuggerView.this.getSite().getShell(), "Failure", "The image can't be saved"); } finally { image.dispose(); gc.dispose(); } } }
public void run(IAction action) { FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE); fileDialog.setFilterPath(fileDirectory); fileDialog.setFilterNames(filterName); fileDialog.setFilterExtensions(filterExtension); if (action.isChecked()) { String filename = fileDialog.open(); // check if file Exists. Gaelle 16/03/2009 if (filename != null && recordInThisFile(filename)) { FableJep.record(true); try { FableJep.getFableJep().setScriptFileName(filename); } catch (Throwable e) { e.printStackTrace(); } // action.setText("Stop Recording Script"); action.setToolTipText("Stop recording python actions."); } else { action.setChecked(false); FableJep.record(false); // action.setText("Record Script"); action.setToolTipText("Record python actions in a script."); } } else { FableJep.record(false); // action.setText("Record Script"); action.setToolTipText("Record python actions in a script."); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event); FileDialog dialog = new FileDialog(workbenchWindow.getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[] {"*.xlsx", "*.xls"}); dialog.setText("Select the Excel file to upload"); final String filePath = dialog.open(); final String fileName = dialog.getFileName(); if (filePath != null) { ImportWindow importWindow = new ImportWindow(); String importMode = importWindow.open(); if (importMode != null) { MenuCommand cmd = new MenuCommand() { @Override public void execute(IProject project, IFile file) throws Exception { importExcelAndGenerateFiles(project, filePath, fileName, importMode); } }; MenuCommandWindow window = new MenuCommandWindow(workbenchWindow.getShell(), cmd, true, null); window.open(); } } return null; }
public void get() { try { // As the user for a file to use as a reference // FileDialog dialog = new FileDialog(shell, SWT.OPEN); dialog.setFilterExtensions(new String[] {"*.sas7bdat;*.SAS7BDAT", "*.*"}); dialog.setFilterNames( new String[] { BaseMessages.getString(PKG, "SASInputDialog.FileType.SAS7BAT") + ", " + BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") }); if (dialog.open() != null) { String filename = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName(); SasInputHelper helper = new SasInputHelper(filename); BaseStepDialog.getFieldsFromPrevious( helper.getRowMeta(), wFields, 1, new int[] {1}, new int[] {3}, 4, 5, null); } } catch (Exception e) { new ErrorDialog(shell, "Error", "Error reading information from file", e); } }
/** Export the selected values from the table to a csv file */ private void export() { FileDialog dialog = new FileDialog(shell, SWT.SAVE); String[] filterNames = new String[] {"CSV Files", "All Files (*)"}; String[] filterExtensions = new String[] {"*.csv;", "*"}; String filterPath = "/"; String platform = SWT.getPlatform(); if (platform.equals("win32") || platform.equals("wpf")) { filterNames = new String[] {"CSV Files", "All Files (*.*)"}; filterExtensions = new String[] {"*.csv", "*.*"}; filterPath = "c:\\"; } dialog.setFilterNames(filterNames); dialog.setFilterExtensions(filterExtensions); dialog.setFilterPath(filterPath); try { dialog.setFileName(this.getCurrentKey() + ".csv"); } catch (Exception e) { dialog.setFileName("export.csv"); } String fileName = dialog.open(); FileOutputStream fos; OutputStreamWriter out; try { fos = new FileOutputStream(fileName); out = new OutputStreamWriter(fos, "UTF-8"); } catch (Exception e) { MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); messageBox.setMessage("Error creating export file " + fileName + " : " + e.getMessage()); messageBox.open(); return; } Vector<TableItem> sel = new Vector<TableItem>(this.dataTable.getSelection().length); sel.addAll(Arrays.asList(this.dataTable.getSelection())); Collections.reverse(sel); for (TableItem item : sel) { String date = item.getText(0); String value = item.getText(1); try { out.write(date + ";" + value + "\n"); } catch (IOException e) { continue; } } try { out.close(); fos.close(); } catch (IOException e) { MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); messageBox.setMessage("Error writing export file " + fileName + " : " + e.getMessage()); messageBox.open(); e.printStackTrace(); } }
void openFile() { if (fileDialog == null) { fileDialog = new org.eclipse.swt.widgets.FileDialog(shell, SWT.OPEN); } fileDialog.setFilterExtensions(new java.lang.String[] {"*.java", "*.*"}); java.lang.String name = fileDialog.open(); open(name); }
private static String saveAs(Shell parent) { FileDialog fd = new FileDialog(parent, SWT.SAVE); fd.setText(Messages.Screenshots_SaveAsDialog); String[] filterExt = {"*" + EXTENSION}; // $NON-NLS-1$ fd.setFilterExtensions(filterExt); fd.setFileName(getDefaultFilename()); return fd.open(); }
private String browseForSourceFile(String[] extensions) { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); String wkspRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); dialog.setFileName(wkspRoot); dialog.setFilterExtensions(extensions); String result = dialog.open(); return result; }
public String askUserForOutputFilename() { Shell shell = UiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); FileDialog dlg = new FileDialog(shell, SWT.SAVE); dlg.setFilterExtensions(new String[] {"*.txt", "*.*"}); // $NON-NLS-1$ //$NON-NLS-2$ dlg.setText(UiConstants.Util.getString(EXPORT_SQL_DIALOG_TITLE)); dlg.setFileName(UiConstants.Util.getString(EXPORT_DEFAULT_FILENAME)); return dlg.open(); }
/** * Opens a modal dialogue to select a file from the file system. If the file selection is * cancelled, null is returned. * * @return the file, or null at dialogue cancel */ protected File openFileSelectionDialogue() { FileDialog fd = new FileDialog(btnDatei.getShell(), SWT.OPEN); fd.setText(Messages.TranspTextWizardPage_windowsfiledialogtitle); fd.setFilterPath(null); String[] filterExt = {"*.*"}; // $NON-NLS-1$ fd.setFilterExtensions(filterExt); String selected = fd.open(); if (selected == null) return null; return new File(selected); }
protected String getImportFile(ExecutionEvent event) throws ExecutionException { final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); final FileDialog fileDialog = new FileDialog(window.getShell(), SWT.OPEN); fileDialog.setFilterExtensions( new String[] { "*.csv", }); final String importFileName = fileDialog.open(); return importFileName; }
public void addManifestation() { final FileDialog fileDialog = new FileDialog(getSite().getShell(), SWT.OPEN); fileDialog.setFilterExtensions(new String[] {"*.xml;*.raid", "*.raid"}); fileDialog.setFilterNames( new String[] {"Fichiers chronosRAID (*.xml,*.raid)", "Projet ChronosRAID (*.raid)"}); final String fileName = fileDialog.open(); if (fileName != null) { ProjectManager.openProject(fileName); } }
private void openAddressBook() { FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); fileDialog.setFilterExtensions(new String[] {"*.messages;", "*.*"}); fileDialog.setFilterNames( new String[] { resMessages.getString("Book_filter_name") + " (*.messages)", resMessages.getString("All_filter_name") + " (*.*)" }); String name = fileDialog.open(); openAddressBook(name); }
/** * Browse button for application file selection using file system. Only JAR, WAR and EAR files can * be selected. */ private void browseBtnListener() { FileDialog dialog = new FileDialog(this.getShell()); String[] extensions = new String[3]; extensions[0] = "*.WAR"; extensions[1] = "*.JAR"; extensions[2] = "*.EAR"; dialog.setFilterExtensions(extensions); String file = dialog.open(); if (file != null) { fileTxt.setText(file); } }
public void saveRWorkspace() { String selected = null; Shell s = new Shell(); FileDialog fd = new FileDialog(s, SWT.SAVE); fd.setText("Save"); if (ApplicationWorkbenchWindowAdvisor.getOS().equals("Windows")) { prefs = Preferences.userNodeForPackage(this.getClass()); String lastOutputDir = prefs.get("R_FILE_DIR", ""); fd.setFilterPath(lastOutputDir); String[] filterExt = {"*.RData"}; fd.setFilterExtensions(filterExt); fd.setOverwrite(true); selected = fd.open(); prefs.put("R_FILE_DIR", fd.getFilterPath()); if (selected != null) { selected = selected.replace("\\", "\\\\"); selected = selected.replace("ä", "ae"); selected = selected.replace("ü", "ue"); selected = selected.replace("ö", "oe"); saveRData(selected); } } else { prefs = Preferences.userNodeForPackage(this.getClass()); String lastOutputDir = prefs.get("R_FILE_DIR", ""); fd.setFilterPath(lastOutputDir); String[] filterExt = {"*.RData"}; fd.setFilterExtensions(filterExt); fd.setOverwrite(true); selected = fd.open(); prefs.put("R_FILE_DIR", fd.getFilterPath()); if (selected != null) { saveRData(selected); } } }
private void selectFile() { FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN); fileDialog.setText("Select JSHint library file"); File file = new File(preferences.getCustomLibPath()); fileDialog.setFileName(file.getName()); fileDialog.setFilterPath(file.getParent()); fileDialog.setFilterNames(new String[] {"JavaScript files"}); fileDialog.setFilterExtensions(new String[] {"*.js", ""}); String selectedPath = fileDialog.open(); if (selectedPath != null) { customLibPathText.setText(selectedPath); } }
/** Open a resource chooser to select a PDA program */ protected void browseLispExeFiles() { FileDialog fd = new FileDialog(getShell()); fd.setFileName(fProgramText.getText()); if (exename != null && exename != "") { fd.setFilterNames(new String[] {exename}); } else if (System.getProperty("os.name").toLowerCase().contains("windows")) { fd.setFilterExtensions(new String[] {"*.exe"}); } String fileName = fd.open(); if (fileName != null) { fProgramText.setText(fileName); } }
private void export() { FileDialog fd = new FileDialog(getShell(), SWT.SAVE); String[] filterExt = {"*.csv"}; fd.setFilterExtensions(filterExt); String selected = fd.open(); if (null != selected) { try { CsvExport.export(selected, selectedSetData); } catch (IOException e) { throw new KeyException("Ошибка при экспорте", e); } } }
/** Override this to plugin custom OutputStream. */ protected OutputStream getOutputStream(ExportToExcelCommand command) throws IOException { FileDialog dialog = new FileDialog(command.getShell(), SWT.SAVE); dialog.setFilterPath("/"); dialog.setOverwrite(true); dialog.setFileName("table_export.xls"); dialog.setFilterExtensions(new String[] {"Microsoft Office Excel Workbook(.xls)"}); String fileName = dialog.open(); if (fileName == null) { return null; } return new PrintStream(fileName); }
/** * Ask user for file name to save to * * @return */ private String askSaveFile() { FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); dialog.setText(Messages.ExportAsImageAction_0); dialog.setFilterExtensions( new String[] {"*.png", "*.jpg;*.jpeg", "*.bmp"}); // $NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ String path = dialog.open(); if (path == null) { return null; } // Only Windows adds the extension by default switch (dialog.getFilterIndex()) { case 0: if (!path.endsWith(".png")) { // $NON-NLS-1$ path += ".png"; // $NON-NLS-1$ } break; case 1: if (!path.endsWith(".jpg") && !path.endsWith(".jpeg")) { // $NON-NLS-1$ //$NON-NLS-2$ path += ".jpg"; // $NON-NLS-1$ } break; case 2: if (!path.endsWith(".bmp")) { // $NON-NLS-1$ path += ".bmp"; // $NON-NLS-1$ } break; default: break; } // Make sure the file does not already exist File file = new File(path); if (file.exists()) { boolean result = MessageDialog.openQuestion( Display.getCurrent().getActiveShell(), Messages.ExportAsImageAction_0, NLS.bind(Messages.ExportAsImageAction_1, file)); if (!result) { return null; } } return path; }
private String buildFileDialog() { // file field FileDialog fd = new FileDialog(parentShell, SWT.SAVE); fd.setText("Open"); fd.setFilterPath("C:/"); String[] filterExt = {"*.xml", "*.csv", "*.*"}; fd.setFilterExtensions(filterExt); String selected = fd.open(); if (!(fd.getFileName()).equalsIgnoreCase("")) { return fd.getFilterPath() + System.getProperty("file.separator") + fd.getFileName(); } else { return ""; } }
@Override public void run() { final FileDialog fileChooser = new FileDialog(imageCanvas.getShell(), SWT.SAVE); fileChooser.setText("Save .dot file"); fileChooser.setFilterPath(""); fileChooser.setFilterExtensions(new String[] {"*.dot"}); fileChooser.setFilterNames(new String[] {"Graphviz file " + " (dot)"}); final String filename = fileChooser.open(); if (filename != null) { try { FileUtils.copyFile(dotFile, new File(filename)); } catch (final IOException e) { MessageDialog.openError(imageCanvas.getShell(), "Saving error", e.getMessage()); } } }
private ArrayList<String> promptJarFiles() { String projectPath = this.getJavaProject().getProject().getLocation().toString(); FileDialog dialog = new FileDialog(getShell(), SWT.MULTI); dialog.setText(JptDbwsEclipseLinkUiMessages.JDBC_DRIVER_WIZARD_PAGE__CHOOSE_A_DRIVER_FILE); dialog.setFilterPath(projectPath); dialog.setFilterExtensions(new String[] {BINDINGS_FILE_FILTER}); dialog.open(); String path = dialog.getFilterPath(); String[] fileNames = dialog.getFileNames(); ArrayList<String> results = new ArrayList<String>(fileNames.length); for (String fileName : fileNames) { results.add(path + File.separator + fileName); } return results; }
/** {@inheritDoc} */ @Override void commandButtonExecute(MigrationEditorOperation editor) { LOGGER.info(MessageUtil.INF_ACTION_SAVE_CSV); TreeViewer treeViewer = editor.getTreeViewer(); List<JbmEditorMigrationRow> list = createEditorViewData(treeViewer); try { String temporaryCsvFilePath = PluginUtil.getPluginDir() + ApplicationPropertyUtil.OUTPUT_TEMPORARY_CSV; outputTemporaryCsv(list, temporaryCsvFilePath); FileDialog dialog = new FileDialog(treeViewer.getControl().getShell(), SWT.SAVE); String[] extensions = {ApplicationPropertyUtil.EXTENSION_CSV}; dialog.setFilterExtensions(extensions); dialog.setFileName(ApplicationPropertyUtil.DEFAULT_CSV_FILENAME); outputFilePath = temporaryCsvFilePath.replaceFirst(StringUtil.SLASH, StringUtil.EMPTY); final String formPath = outputFilePath; final String toPath = dialog.open(); if (toPath != null) { Job job = new Job(MessageUtil.INF_SAVE_CSV_START) { @Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask(MessageUtil.INF_SAVE_CSV_START, IProgressMonitor.UNKNOWN); // Cancellation process if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } // CSV output CmnFileUtil.copyFile(formPath, toPath); monitor.done(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } } catch (JbmException e) { PluginUtil.viewErrorDialog(ResourceUtil.OUTPUT_CSV, MessageUtil.ERR_OUTPUT_CSV, e); } catch (IOException e) { PluginUtil.viewErrorDialog(ResourceUtil.OUTPUT_CSV, MessageUtil.ERR_OUTPUT_CSV, e); } }
public void open() { qprint.verbose("Open pressed"); Shell shell = new Shell(); FileDialog fd = new FileDialog(shell, SWT.OPEN); fd.setText("Open"); if (null == workspace) { qprint.error("workspace not defined"); return; } fd.setFilterPath(workspace); String[] filterExt = {"*.txt", "*.log", "*"}; fd.setFilterExtensions(filterExt); String selected = fd.open(); qprint.verbose(selected); // add file to editor }