use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.
the class GprofNoGmonDialog method browseWorkspaceHandler.
/**
* Handle the case when the user browses the Workspace.
* @param parent
* @return gmon.out location or null if bad.
*/
private static String browseWorkspaceHandler(Shell shell, IProject project) {
// New tree Dialogue.
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
// Set dialogue settings.
dialog.setTitle(GprofLaunchMessages.GprofNoGmonDialog_OpenGmon);
dialog.setMessage(GprofLaunchMessages.GprofNoGmonDialog_OpenGmon);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setAllowMultiple(false);
dialog.setInitialSelection(project);
dialog.setValidator(selection -> {
if (selection.length != 1) {
// $NON-NLS-1$
return new Status(IStatus.ERROR, GprofLaunch.PLUGIN_ID, 0, "", null);
}
if (!(selection[0] instanceof IFile)) {
// $NON-NLS-1$
return new Status(IStatus.ERROR, GprofLaunch.PLUGIN_ID, 0, "", null);
}
// $NON-NLS-1$
return new Status(IStatus.OK, GprofLaunch.PLUGIN_ID, 0, "", null);
});
// Open dialogue.
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
// If things were ok, return the gmon path.
return resource.getLocation().toOSString();
} else {
return null;
}
}
use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.
the class OpenGmonDialog method handleBrowseWorkspace.
private void handleBrowseWorkspace(String msg, Text text) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle(msg);
dialog.setMessage(msg);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setAllowMultiple(false);
IContainer c = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(this.gmonFile);
if (c != null) {
dialog.setInitialSelection(c.getProject());
}
dialog.setValidator(selection -> {
if (selection.length != 1) {
// $NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null);
}
if (!(selection[0] instanceof IFile)) {
// $NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null);
}
// $NON-NLS-1$
return new Status(IStatus.OK, Activator.PLUGIN_ID, 0, "", null);
});
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
// $NON-NLS-1$//$NON-NLS-2$
text.setText("${resource_loc:" + resource.getFullPath() + "}");
}
}
use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.
the class ContainerDirectorySelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// page group
Composite composite = (Composite) super.createDialogArea(parent);
createMessageArea(composite);
// Create a fake parent of the root to be the dialog input element.
// Use an empty label so that display of the element's full name
// doesn't include a confusing label
// $NON-NLS-1$
FileSystemElement input = new FileSystemElement("", null, true);
input.addChild(root);
root.setParent(input);
selectionGroup = new ContainerTreeGroup(composite, input, getFolderProvider(), getDynamicFolderProvider(), new WorkbenchLabelProvider(), SWT.NONE, // since this page has no other significantly-sized
SIZING_SELECTION_WIDGET_WIDTH, // widgets we need to hardcode the combined widget's
SIZING_SELECTION_WIDGET_HEIGHT);
// size, otherwise it will open too small
ISelectionChangedListener listener = event -> getOkButton().setEnabled(event.getSelection() != null && !event.getSelection().isEmpty());
WorkbenchViewerComparator comparator = new WorkbenchViewerComparator();
selectionGroup.setTreeComparator(comparator);
selectionGroup.addSelectionChangedListener(listener);
return composite;
}
use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.
the class ContainerFileSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// page group
Composite composite = (Composite) super.createDialogArea(parent);
createMessageArea(composite);
// Create a fake parent of the root to be the dialog input element.
// Use an empty label so that display of the element's full name
// doesn't include a confusing label
// $NON-NLS-1$
FileSystemElement input = new FileSystemElement("", null, true);
input.addChild(root);
root.setParent(input);
selectionGroup = new CheckboxTreeAndListGroup(composite, input, getFolderProvider(), getDynamicFolderProvider(), new WorkbenchLabelProvider(), getFileProvider(), new WorkbenchLabelProvider(), SWT.NONE, // since this page has no other significantly-sized
SIZING_SELECTION_WIDGET_WIDTH, // widgets we need to hardcode the combined widget's
SIZING_SELECTION_WIDGET_HEIGHT);
// size, otherwise it will open too small
ICheckStateListener listener = event -> getOkButton().setEnabled(selectionGroup.getCheckedElementCount() > 0);
WorkbenchViewerComparator comparator = new WorkbenchViewerComparator();
selectionGroup.setTreeComparator(comparator);
selectionGroup.setListComparator(comparator);
selectionGroup.addCheckStateListener(listener);
addSelectionButtons(composite);
return composite;
}
use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.
the class ValgrindOptionsTab method createSuppressionsOption.
private void createSuppressionsOption(Composite top) {
Composite browseTop = new Composite(top, SWT.BORDER);
browseTop.setLayout(new GridLayout(2, false));
GridData browseData = new GridData(GridData.FILL_BOTH);
browseTop.setLayoutData(browseData);
Label suppFileLabel = new Label(browseTop, SWT.NONE);
// $NON-NLS-1$
suppFileLabel.setText(Messages.getString("ValgrindOptionsTab.suppressions_file"));
createVerticalSpacer(browseTop, 1);
suppFileList = new List(browseTop, SWT.BORDER);
suppFileList.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite buttonTop = new Composite(browseTop, SWT.NONE);
GridLayout buttonLayout = new GridLayout();
buttonLayout.marginWidth = buttonLayout.marginHeight = 0;
buttonTop.setLayout(buttonLayout);
buttonTop.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
// $NON-NLS-1$
Button workspaceBrowseButton = createPushButton(buttonTop, Messages.getString("ValgrindOptionsTab.Workspace"), null);
workspaceBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
// $NON-NLS-1$
dialog.setTitle(Messages.getString("ValgrindOptionsTab.Select_a_Resource"));
// $NON-NLS-1$
dialog.setMessage(Messages.getString("ValgrindOptionsTab.Select_a_Suppressions_File"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
String arg = resource.getFullPath().toString();
String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", // $NON-NLS-1$
arg);
suppFileList.add(fileLoc);
updateLaunchConfigurationDialog();
}
}));
// $NON-NLS-1$
Button fileBrowseButton = createPushButton(buttonTop, Messages.getString("ValgrindOptionsTab.File_System"), null);
fileBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String filePath = null;
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
filePath = dialog.open();
if (filePath != null) {
suppFileList.add(filePath);
updateLaunchConfigurationDialog();
}
}));
// $NON-NLS-1$
Button removeButton = createPushButton(buttonTop, Messages.getString("ValgrindOptionsTab.Supp_remove"), null);
removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
int[] selected = suppFileList.getSelectionIndices();
if (selected.length > 0) {
suppFileList.remove(selected);
updateLaunchConfigurationDialog();
}
}));
}
Aggregations