Search in sources :

Example 1 with WorkbenchLabelProvider

use of org.eclipse.ui.model.WorkbenchLabelProvider in project xtext-eclipse by eclipse.

the class ProjectSelectionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Font font = parent.getFont();
    composite.setFont(font);
    createMessageArea(composite);
    tableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
        }
    });
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    tableViewer.getTable().setLayoutData(data);
    tableViewer.setContentProvider(new WorkbenchContentProvider());
    tableViewer.setLabelProvider(new WorkbenchLabelProvider());
    tableViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
    tableViewer.getControl().setFont(font);
    Button checkbox = new Button(composite, SWT.CHECK);
    checkbox.setText(Messages.ProjectSelectionDialog_filter);
    checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    checkbox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateFilter(((Button) e.widget).getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            updateFilter(((Button) e.widget).getSelection());
        }
    });
    boolean doFilter = !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !projectsWithSpecifics.isEmpty();
    checkbox.setSelection(doFilter);
    updateFilter(doFilter);
    tableViewer.setInput(ResourcesPlugin.getWorkspace());
    doSelectionChanged(new Object[0]);
    Dialog.applyDialogFont(composite);
    return composite;
}
Also used : ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) Font(org.eclipse.swt.graphics.Font) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with WorkbenchLabelProvider

use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.

the class BuildDockerImageLaunchConfigurationMainTab method onBrowseWorkspace.

/**
 * Opens a dialog to browse the workspace
 *
 * @return
 */
private SelectionListener onBrowseWorkspace(final Text pathText, final Class<?> expectedType) {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setTitle(LaunchMessages.getString(BROWSE_WORKSPACE_DIALOG_TITLE));
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
        dialog.setAllowMultiple(false);
        dialog.setValidator(selection -> {
            if (selection.length == 1 && expectedType.isAssignableFrom(selection[0].getClass())) {
                return new Status(IStatus.OK, Activator.PLUGIN_ID, null);
            }
            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, null);
        });
        if (dialog.open() == IDialogConstants.OK_ID) {
            final IResource selection = (IResource) dialog.getFirstResult();
            pathText.setText(selection.getFullPath().toOSString());
            buildContextPathWorkspaceRelative = true;
        }
    });
}
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) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) IResource(org.eclipse.core.resources.IResource)

Example 3 with WorkbenchLabelProvider

use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.

the class DockerComposeUpLaunchConfigurationMainTab method onBrowseWorkspace.

/**
 * Opens a dialog to browse the workspace
 *
 * @return
 */
private SelectionListener onBrowseWorkspace(final Text pathText, final Class<?> expectedType) {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setTitle(LaunchMessages.getString(// $NON-NLS-1$
        "DockerComposeUpLaunchConfigurationMainTab.dockerComposePath.browseworkspace.dialog.title"));
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
        dialog.setAllowMultiple(false);
        dialog.setValidator(selection -> {
            if (selection.length == 1 && expectedType.isAssignableFrom(selection[0].getClass())) {
                return new Status(IStatus.OK, Activator.PLUGIN_ID, null);
            }
            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, null);
        });
        if (dialog.open() == IDialogConstants.OK_ID) {
            final IResource selection = (IResource) dialog.getFirstResult();
            pathText.setText(selection.getFullPath().toOSString());
            dockerComposeFilePathWorkspaceRelative = true;
        }
    });
}
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) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) IResource(org.eclipse.core.resources.IResource)

Example 4 with WorkbenchLabelProvider

use of org.eclipse.ui.model.WorkbenchLabelProvider in project linuxtools by eclipse.

the class LaunchWizard method promptForInputs.

private void promptForInputs() {
    InputDialog id = new // $NON-NLS-1$
    InputDialog(// $NON-NLS-1$
    new Shell(), // $NON-NLS-1$
    Messages.getString("LaunchWizard.WelcomeWizard"), // $NON-NLS-1$
    Messages.getString("LaunchWizard.Text1") + // $NON-NLS-1$
    Messages.getString("LaunchWizard.Text2") + // $NON-NLS-1$
    Messages.getString("LaunchWizard.Text3"), getLaunchManager().generateLaunchConfigurationName(Messages.getString("LaunchWizard.NamePrefix")), // $NON-NLS-1$
    null);
    id.open();
    if (id.getReturnCode() == Window.CANCEL) {
        return;
    }
    name = id.getValue();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IPath location = root.getLocation();
    workspacePath = location.toString();
    sh = new Shell();
    sh.setSize(WIDTH, HEIGHT);
    sh.setLayout(new GridLayout(1, false));
    sh.setText(name);
    // $NON-NLS-1$
    Image img = new Image(sh.getDisplay(), PluginConstants.getPluginLocation() + "systemtapbanner.png");
    Composite imageCmp = new Composite(sh, SWT.BORDER);
    imageCmp.setLayout(new FillLayout());
    GridData imageData = new GridData(650, 157);
    imageData.horizontalAlignment = SWT.CENTER;
    imageCmp.setLayoutData(imageData);
    imageCmp.setBackgroundImage(img);
    Composite fileComp = new Composite(sh, SWT.NONE);
    fileComp.setLayout(new GridLayout(2, false));
    fileComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridDataFactory labelData = GridDataFactory.fillDefaults().grab(true, false).span(2, 1);
    Label scriptLabel = new Label(fileComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    scriptLabel.setText(Messages.getString("LaunchWizard.Script"));
    labelData.applyTo(scriptLabel);
    GridDataFactory textData = GridDataFactory.fillDefaults().grab(true, false).hint(WIDTH, SWT.DEFAULT);
    scriptLocation = new Text(fileComp, SWT.SINGLE | SWT.BORDER);
    textData.applyTo(scriptLocation);
    Button scriptButton = new Button(fileComp, SWT.PUSH);
    // $NON-NLS-1$
    scriptButton.setText(Messages.getString("SystemTapOptionsTab.BrowseFiles"));
    scriptButton.setLayoutData(new GridData());
    scriptButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        String filePath = scriptLocation.getText();
        FileDialog dialog = new FileDialog(sh, SWT.SAVE);
        filePath = dialog.open();
        if (filePath != null) {
            scriptLocation.setText(filePath);
        }
    }));
    GridData gd2 = new GridData();
    gd2.horizontalSpan = 3;
    Label binaryLabel = new Label(fileComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    binaryLabel.setText(Messages.getString("LaunchWizard.BinFile"));
    labelData.applyTo(binaryLabel);
    binaryLocation = new Text(fileComp, SWT.SINGLE | SWT.BORDER);
    textData.applyTo(binaryLocation);
    Button binaryButton = new Button(fileComp, SWT.PUSH);
    // $NON-NLS-1$
    binaryButton.setText(Messages.getString("SystemTapOptionsTab.WorkspaceButton2"));
    binaryButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(sh, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        // $NON-NLS-1$
        dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource"));
        // $NON-NLS-1$
        dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions"));
        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();
            binaryLocation.setText(workspacePath + arg);
        }
    }));
    Composite argumentsComp = new Composite(sh, SWT.BORDER_DASH);
    argumentsComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    argumentsComp.setLayout(new GridLayout(2, false));
    Label argumentsLabel = new Label(argumentsComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    argumentsLabel.setText(Messages.getString("LaunchWizard.Args"));
    labelData.applyTo(argumentsLabel);
    argumentsLocation = new Text(argumentsComp, SWT.MULTI | SWT.WRAP | SWT.BORDER);
    GridData gd3 = new GridData(GridData.FILL_HORIZONTAL);
    gd3.heightHint = 200;
    argumentsLocation.setLayoutData(gd3);
    Button argumentsButton = new Button(argumentsComp, SWT.PUSH);
    // $NON-NLS-1$
    argumentsButton.setText(Messages.getString("LaunchWizard.Func"));
    argumentsButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> argumentsLocation.setText(// $NON-NLS-1$
    argumentsLocation.getText() + " process(\"" + binaryLocation.getText() + // $NON-NLS-1$
    "\").function(\"\")")));
    // TODO: Don't use blank labels to move button to the right column :P
    Label blankLabel2 = new Label(argumentsComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    blankLabel2.setText("");
    Button launch = new Button(sh, SWT.PUSH);
    launch.setLayoutData(new GridData(GridData.CENTER, GridData.BEGINNING, false, false));
    // $NON-NLS-1$
    launch.setText(Messages.getString("LaunchWizard.Launch"));
    launch.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        scriptPath = scriptLocation.getText();
        binaryPath = binaryLocation.getText();
        arguments = argumentsLocation.getText();
        ILaunchConfigurationWorkingCopy wc = createConfiguration(null, name);
        try {
            // $NON-NLS-1$
            finishLaunch(scriptPath + ": " + binName, mode, wc);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        sh.dispose();
    }));
    // TODO: Verify that this works
    Display.getCurrent().asyncExec(() -> sh.open());
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Image(org.eclipse.swt.graphics.Image) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) IPath(org.eclipse.core.runtime.IPath) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) IEditorPart(org.eclipse.ui.IEditorPart) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) FileDialog(org.eclipse.swt.widgets.FileDialog) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) Display(org.eclipse.swt.widgets.Display) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Window(org.eclipse.jface.window.Window) IResource(org.eclipse.core.resources.IResource) SWT(org.eclipse.swt.SWT) ISelection(org.eclipse.jface.viewers.ISelection) Label(org.eclipse.swt.widgets.Label) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) PluginConstants(org.eclipse.linuxtools.internal.callgraph.core.PluginConstants) 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) InputDialog(org.eclipse.jface.dialogs.InputDialog) IPath(org.eclipse.core.runtime.IPath) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Image(org.eclipse.swt.graphics.Image) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) Button(org.eclipse.swt.widgets.Button) IWorkspace(org.eclipse.core.resources.IWorkspace) GridData(org.eclipse.swt.layout.GridData) FileDialog(org.eclipse.swt.widgets.FileDialog) IResource(org.eclipse.core.resources.IResource)

Example 5 with WorkbenchLabelProvider

use of org.eclipse.ui.model.WorkbenchLabelProvider in project yamcs-studio by yamcs.

the class ScriptsInputDialog method createScriptsTableViewer.

/**
 * Creates and configures a {@link TableViewer}.
 *
 * @param parent
 *            The parent for the table
 * @return The {@link TableViewer}
 */
private TableViewer createScriptsTableViewer(final Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
    viewer.setContentProvider(new BaseWorkbenchContentProvider() {

        @SuppressWarnings("unchecked")
        @Override
        public Object[] getElements(final Object element) {
            return (((List<ScriptData>) element).toArray());
        }
    });
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            refreshGUIOnSelection();
        }
    });
    viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    return viewer;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) List(java.util.List) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)93 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)44 GridData (org.eclipse.swt.layout.GridData)36 Composite (org.eclipse.swt.widgets.Composite)36 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)36 GridLayout (org.eclipse.swt.layout.GridLayout)30 IResource (org.eclipse.core.resources.IResource)24 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)22 Button (org.eclipse.swt.widgets.Button)22 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)20 IFile (org.eclipse.core.resources.IFile)19 TableViewer (org.eclipse.jface.viewers.TableViewer)19 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)19 ResourceComparator (org.eclipse.ui.views.navigator.ResourceComparator)19 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)17 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)16 SelectionListener (org.eclipse.swt.events.SelectionListener)16 Label (org.eclipse.swt.widgets.Label)16 ArrayList (java.util.ArrayList)14