Search in sources :

Example 21 with WorkbenchLabelProvider

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;
    }
}
Also used : ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IFile(org.eclipse.core.resources.IFile) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) IResource(org.eclipse.core.resources.IResource)

Example 22 with WorkbenchLabelProvider

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() + "}");
    }
}
Also used : ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IFile(org.eclipse.core.resources.IFile) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 23 with WorkbenchLabelProvider

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;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) Shell(org.eclipse.swt.widgets.Shell) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) WorkbenchViewerComparator(org.eclipse.ui.model.WorkbenchViewerComparator) SelectionDialog(org.eclipse.ui.dialogs.SelectionDialog) IImportStructureProvider(org.eclipse.ui.wizards.datatransfer.IImportStructureProvider) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Control(org.eclipse.swt.widgets.Control) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) WorkbenchViewerComparator(org.eclipse.ui.model.WorkbenchViewerComparator)

Example 24 with WorkbenchLabelProvider

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;
}
Also used : WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Shell(org.eclipse.swt.widgets.Shell) Iterator(java.util.Iterator) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) WorkbenchViewerComparator(org.eclipse.ui.model.WorkbenchViewerComparator) SelectionDialog(org.eclipse.ui.dialogs.SelectionDialog) IImportStructureProvider(org.eclipse.ui.wizards.datatransfer.IImportStructureProvider) ArrayList(java.util.ArrayList) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) GridData(org.eclipse.swt.layout.GridData) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) WorkbenchViewerComparator(org.eclipse.ui.model.WorkbenchViewerComparator)

Example 25 with WorkbenchLabelProvider

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();
        }
    }));
}
Also used : WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) Arrays(java.util.Arrays) TabFolder(org.eclipse.swt.widgets.TabFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) ConfigUtils(org.eclipse.linuxtools.profiling.launch.ConfigUtils) Image(org.eclipse.swt.graphics.Image) CoreException(org.eclipse.core.runtime.CoreException) Spinner(org.eclipse.swt.widgets.Spinner) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) Point(org.eclipse.swt.graphics.Point) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) IProject(org.eclipse.core.resources.IProject) IPath(org.eclipse.core.runtime.IPath) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) VariablesPlugin(org.eclipse.core.variables.VariablesPlugin) Composite(org.eclipse.swt.widgets.Composite) AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) GridData(org.eclipse.swt.layout.GridData) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) Button(org.eclipse.swt.widgets.Button) NLS(org.eclipse.osgi.util.NLS) FileDialog(org.eclipse.swt.widgets.FileDialog) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) Status(org.eclipse.core.runtime.Status) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Version(org.osgi.framework.Version) Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) IResource(org.eclipse.core.resources.IResource) SWT(org.eclipse.swt.SWT) List(org.eclipse.swt.widgets.List) IValgrindToolPage(org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) List(org.eclipse.swt.widgets.List) FileDialog(org.eclipse.swt.widgets.FileDialog) IResource(org.eclipse.core.resources.IResource)

Aggregations

WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)26 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)16 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)15 IResource (org.eclipse.core.resources.IResource)11 IStatus (org.eclipse.core.runtime.IStatus)10 Status (org.eclipse.core.runtime.Status)10 GridData (org.eclipse.swt.layout.GridData)10 ArrayList (java.util.ArrayList)9 ResourceComparator (org.eclipse.ui.views.navigator.ResourceComparator)9 Composite (org.eclipse.swt.widgets.Composite)8 GridLayout (org.eclipse.swt.layout.GridLayout)7 Button (org.eclipse.swt.widgets.Button)7 IFile (org.eclipse.core.resources.IFile)6 SWT (org.eclipse.swt.SWT)6 List (java.util.List)5 IPath (org.eclipse.core.runtime.IPath)5 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)5 Label (org.eclipse.swt.widgets.Label)5 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4