use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class ContainerDataVolumeDialog method onHostFilePath.
private SelectionListener onHostFilePath() {
return SelectionListener.widgetSelectedAdapter(e -> {
final FileDialog fileDialog = new FileDialog(getShell());
final String selectedPath = fileDialog.open();
if (selectedPath != null) {
model.setHostPathMount(selectedPath);
}
});
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class GprofNoGmonDialog method browseFileSystemHandler.
/**
* Browse file sytem to find gmon.out. Return null if bad input.
*/
private static String browseFileSystemHandler(Shell shell, IProject project) {
FileDialog dialog = new FileDialog((shell != null) ? shell : new Shell(), SWT.OPEN);
dialog.setText(GprofLaunchMessages.GprofNoGmonDialog_OpenGmon);
// Open Project path.
if (project != null) {
dialog.setFilterPath(project.getLocation().toOSString());
}
//
return dialog.open();
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class OpenGmonDialog method handleBrowse.
private void handleBrowse(String msg, Text text) {
FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN);
dialog.setText(msg);
String t = text.getText();
IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
try {
t = mgr.performStringSubstitution(t, false);
} catch (CoreException e) {
// do nothing: never occurs
}
File f = new File(t);
t = f.getParent();
if (t == null || t.length() == 0) {
t = this.gmonFile.removeLastSegments(1).toOSString();
}
dialog.setFilterPath(t);
String s = dialog.open();
if (s != null) {
text.setText(s);
}
}
use of org.eclipse.swt.widgets.FileDialog in project knime-core by knime.
the class ExportPreferencesDialog method createFileSelection.
protected void createFileSelection(final Composite parent) {
Composite panel = new Composite(parent, SWT.FILL);
GridData fillBoth = new GridData(GridData.FILL_BOTH);
panel.setLayoutData(fillBoth);
panel.setLayout(new GridLayout(1, true));
Group border = new Group(panel, SWT.SHADOW_IN);
border.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
border.setLayout(new GridLayout(2, false));
border.setText("File to store preferences:");
final Text filenameUI = new Text(border, SWT.FILL | SWT.SINGLE | SWT.BORDER);
filenameUI.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
filenameUI.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(final Event event) {
m_filename = filenameUI.getText().trim();
validate();
}
});
final Button browse = new Button(border, SWT.PUSH);
browse.setText("Select...");
browse.setToolTipText("Opens a file selection dialog.");
browse.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(final SelectionEvent se) {
FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE);
fileDialog.setFilterExtensions(new String[] { "*.epf", "*.*" });
fileDialog.setText("Specify the preferences export file.");
if (m_filename != null) {
fileDialog.setFileName(m_filename);
}
String filePath = fileDialog.open();
if (filePath != null && filePath.trim().length() > 0) {
if (filePath.length() < 5 || filePath.lastIndexOf('.') < filePath.length() - 4) {
// they have no extension - add .epf
filePath += ".epf";
}
m_filename = filePath;
filenameUI.setText(filePath);
validate();
}
}
@Override
public void widgetDefaultSelected(final SelectionEvent se) {
widgetSelected(se);
}
});
}
use of org.eclipse.swt.widgets.FileDialog in project knime-core by knime.
the class WorkflowExportPage method handleExportFileBrowse.
/**
* Uses the standard file selection dialog to choose the export file name.
*/
private void handleExportFileBrowse() {
FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE);
fileDialog.setFilterExtensions(FILTER_EXTENSION);
fileDialog.setText("Specify export file.");
if (m_fileText.getText() != null && !m_fileText.getText().trim().isEmpty()) {
String exportString = m_fileText.getText().trim();
IPath p = new Path(exportString);
if (p.segmentCount() > 1) {
fileDialog.setFilterPath(p.removeLastSegments(1).toOSString());
fileDialog.setFileName(p.lastSegment());
}
}
String filePath = fileDialog.open();
if (filePath.trim().length() > 0) {
// remember the selected path
// append "zip" extension if not there.
String extension = filePath.substring(filePath.length() - 4, filePath.length());
if (!extension.equals(".zip")) {
filePath = filePath + ".zip";
}
}
m_fileText.setText(filePath);
setLastSelectedExportLocation();
}
Aggregations