use of org.eclipse.swt.widgets.FileDialog in project cogtool by cogtool.
the class DefaultInteraction method selectFile.
public File selectFile(boolean forInput, String def, String[] allowedExtensions) {
FileDialog dialog = selectFileName(forInput ? SWT.OPEN : SWT.SAVE, new String[] { "XML Files (*.xml)" }, allowedExtensions, def);
if (dialog == null) {
return null;
}
File path = new File(dialog.getFilterPath());
return new File(path, dialog.getFileName());
}
use of org.eclipse.swt.widgets.FileDialog in project cogtool by cogtool.
the class DefaultInteraction method selectCSVFileDest.
/**
* A file selection dialog for selecting .csv files
* to write to.
*/
public File selectCSVFileDest(String defaultFileName) {
FileDialog dialog = selectFileName(SWT.SAVE, new String[] { "CSV Files (*.csv)" }, new String[] { "*.csv" }, (defaultFileName + ".csv"));
if (dialog == null) {
setStatusMessage(exportCanceledMsg);
return null;
}
File path = new File(dialog.getFilterPath());
String name = dialog.getFileName();
if (!name.endsWith(".csv")) {
name += ".csv";
}
File dest = new File(path, name);
if (dest.exists() && OSUtils.WINDOWS) {
int choice = shouldReplaceFile(dest);
if (choice == SWT.NO) {
return selectCSVFileDest(defaultFileName);
}
if (choice == SWT.CANCEL) {
setStatusMessage(exportCanceledMsg);
return null;
}
}
return dest;
}
use of org.eclipse.swt.widgets.FileDialog in project otertool by wuntee.
the class GuiWorkshop method selectFile.
public static String selectFile(Shell shell, String[] filters) {
FileDialog fileDialog = new FileDialog(shell);
fileDialog.setText("Please select a file");
fileDialog.setFilterExtensions(filters);
return (fileDialog.open());
}
use of org.eclipse.swt.widgets.FileDialog in project otertool by wuntee.
the class GuiWorkshop method selectSaveFile.
public static String selectSaveFile(Shell shell, String[] filters) {
FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
fileDialog.setText("Please select a file");
fileDialog.setFilterExtensions(filters);
return (fileDialog.open());
}
use of org.eclipse.swt.widgets.FileDialog in project tdi-studio-se by Talend.
the class ImportItemWizardPage method handleLocationArchiveButtonPressed.
/**
* The browse button has been selected. Select the location.
*/
protected void handleLocationArchiveButtonPressed() {
FileDialog dialog = new FileDialog(archivePathField.getShell());
dialog.setFilterExtensions(FILE_IMPORT_MASK);
// dialog.setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle);
//$NON-NLS-1$
dialog.setText(Messages.getString(".WizardProjectsImportPage_SelectArchiveDialogTitle"));
String fileName = archivePathField.getText().trim();
if (fileName.length() == 0) {
fileName = previouslyBrowsedArchive;
}
if (fileName.length() == 0) {
dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
} else {
File path = new File(fileName);
if (path.exists()) {
dialog.setFilterPath(new Path(fileName).toOSString());
}
}
String selectedArchive = dialog.open();
if (selectedArchive != null) {
previouslyBrowsedArchive = selectedArchive;
archivePathField.setText(previouslyBrowsedArchive);
updateItemsList(selectedArchive, false);
}
}
Aggregations