use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class OprofileSetupTab method showFileDialog.
// Displays a file dialog to allow the user to select the kernel image file
private void showFileDialog(Shell shell) {
try {
proxy = RemoteProxyManager.getInstance().getFileProxy(getOprofileProject());
} catch (CoreException e) {
e.printStackTrace();
}
FileDialog d = new FileDialog(shell, SWT.OPEN);
IFileStore kernel = proxy.getResource(options.getKernelImageFile());
if (!kernel.fetchInfo().exists()) {
// $NON-NLS-1$
kernel = proxy.getResource("/boot");
if (!kernel.fetchInfo().exists()) {
// $NON-NLS-1$
kernel = proxy.getResource("/");
}
}
d.setFileName(kernel.toString());
// $NON-NLS-1$
d.setText(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.text"));
String newKernel = d.open();
if (newKernel != null) {
kernel = proxy.getResource(newKernel);
if (!kernel.fetchInfo().exists()) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
// $NON-NLS-1$
mb.setMessage(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.error.kernelDoesNotExist.text"));
switch(mb.open()) {
case SWT.RETRY:
// Ok, it's recursive, but it shouldn't matter
showFileDialog(shell);
break;
default:
case SWT.CANCEL:
break;
}
} else {
kernelImageFileText.setText(newKernel);
}
}
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class LocalResourceSelectorProxy method selectFile.
@Override
public URI selectFile(String scheme, String initialPath, String prompt, Shell shell) {
FileDialog dialog = new FileDialog(shell, SWT.SHEET);
dialog.setText(prompt);
dialog.setFilterPath(initialPath);
try {
String path = dialog.open();
if (path != null)
return new URI(path);
else
return null;
} catch (URISyntaxException e) {
return null;
}
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class SystemTapScriptOptionsTab method createControl.
@Override
public void createControl(Composite parent) {
GridLayout singleColumnGridLayout = new GridLayout();
singleColumnGridLayout.numColumns = 1;
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
comp.setLayout(singleColumnGridLayout);
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
this.fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
fileDialog.setText(Messages.SystemTapScriptOptionsTab_selectExec);
fileDialog.setFilterPath(Platform.getLocation().toOSString());
// Target Executable path
Group targetExecutableGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
targetExecutableGroup.setText(Messages.SystemTapScriptOptionsTab_targetExec);
targetExecutableGroup.setToolTipText(Messages.SystemTapScriptOptionsTab_targetToolTip);
targetExecutableGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout twoColumnGridLayout = new GridLayout();
twoColumnGridLayout.numColumns = 2;
targetExecutableGroup.setLayout(twoColumnGridLayout);
this.targetProgramText = new Text(targetExecutableGroup, SWT.SINGLE | SWT.BORDER);
targetProgramText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
targetProgramText.addModifyListener(modifyListener);
Button selectTargetProgramButton = new Button(targetExecutableGroup, 0);
GridData gridData = new GridData();
selectTargetProgramButton.setLayoutData(gridData);
selectTargetProgramButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_browse);
selectTargetProgramButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String fileName = fileDialog.open();
if (fileName != null) {
targetProgramText.setText(fileName);
}
}));
// Check boxes
Composite cmpChkBoxes = new Composite(comp, SWT.NONE);
cmpChkBoxes.setLayout(twoColumnGridLayout);
cmpChkBoxes.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
for (int i = 0; i < IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS.length; i++) {
checkBox[i] = new Button(cmpChkBoxes, SWT.CHECK);
checkBox[i].setText(IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.LABEL] + " (" + IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.FLAG] + // $NON-NLS-1$//$NON-NLS-2$
")");
checkBox[i].addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
});
checkBox[i].setToolTipText(IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.TOOLTIP]);
if (IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.FLAG].contains(Messages.SystemTapScriptOptionsTab_dyninst)) {
this.dyninstCheckBox = checkBox[i];
}
}
// Labels and Text fields
Composite cmpTxtBoxes = new Composite(comp, SWT.NONE);
cmpTxtBoxes.setLayout(twoColumnGridLayout);
cmpTxtBoxes.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
Label label;
for (int i = 0; i < IDEPreferenceConstants.STAP_STRING_OPTIONS.length; i++) {
label = new Label(cmpTxtBoxes, SWT.NONE);
label.setText(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.LABEL] + " (" + IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.FLAG] + // $NON-NLS-1$ //$NON-NLS-2$
")");
label.setToolTipText(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.TOOLTIP]);
text[i] = new Text(cmpTxtBoxes, SWT.BORDER);
text[i].setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
text[i].addModifyListener(modifyListener);
text[i].setToolTipText(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.TOOLTIP]);
if (IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.FLAG].contains("-x")) {
// $NON-NLS-1$
this.targetPidText = text[i];
}
}
label = new Label(cmpTxtBoxes, SWT.NONE);
label.setText(Messages.SystemTapScriptOptionsTab_otherOptions);
miscCommandsText = new Text(cmpTxtBoxes, SWT.BORDER);
miscCommandsText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
miscCommandsText.addModifyListener(modifyListener);
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class CreateVMPage method onSearchImage.
private SelectionListener onSearchImage() {
return SelectionListener.widgetSelectedAdapter(e -> {
FileDialog fd = new FileDialog(getShell());
String location = fd.open();
if (location != null && !location.isEmpty()) {
model.setBoxRef(location);
}
});
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class STPEditor method queryFile.
private static File queryFile() {
FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
dialog.setText(Messages.NewFileHandler_NewFile);
String path = dialog.open();
if (path != null && !path.isEmpty()) {
return new File(path);
}
return null;
}
Aggregations