Search in sources :

Example 56 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project bndtools by bndtools.

the class PackageListWizardPage method createControl.

@SuppressWarnings("unused")
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    setControl(composite);
    composite.setLayout(new GridLayout(3, false));
    Label lblAvailablePackages = new Label(composite, SWT.NONE);
    lblAvailablePackages.setText("Available Packages:");
    new Label(composite, SWT.NONE);
    Label lblSelectedPackages = new Label(composite, SWT.NONE);
    lblSelectedPackages.setText("Selected Packages:");
    tblAvailable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblAvailable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    availableViewer = new TableViewer(tblAvailable);
    availableViewer.setContentProvider(ArrayContentProvider.getInstance());
    availableViewer.setLabelProvider(new PackageNameLabelProvider());
    availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateUI();
        }
    });
    availableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            doAddSelection();
        }
    });
    Composite composite_1 = new Composite(composite, SWT.NONE);
    GridLayout gl_composite_1 = new GridLayout(1, false);
    gl_composite_1.marginWidth = 0;
    gl_composite_1.marginHeight = 0;
    composite_1.setLayout(gl_composite_1);
    btnAdd = new Button(composite_1, SWT.NONE);
    btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAdd.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddSelection();
        }
    });
    btnAdd.setText("Add ->");
    btnAdd.setEnabled(false);
    btnAddAll = new Button(composite_1, SWT.NONE);
    btnAddAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAddAll.setText("Add All ->");
    btnAddAll.setEnabled(false);
    btnAddAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddAll();
        }
    });
    btnRemove = new Button(composite_1, SWT.NONE);
    btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnRemove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemoveSelection();
        }
    });
    btnRemove.setText("<- Remove");
    btnRemove.setEnabled(false);
    btnRemoveAll = new Button(composite_1, SWT.NONE);
    btnRemoveAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnRemoveAll.setText("<- Remove All");
    btnRemoveAll.setEnabled(false);
    btnRemoveAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemoveAll();
        }
    });
    tblSelected = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblSelected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    selectedViewer = new TableViewer(tblSelected);
    selectedViewer.setContentProvider(ArrayContentProvider.getInstance());
    selectedViewer.setLabelProvider(new PackageNameLabelProvider());
    selectedViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateUI();
        }
    });
    selectedViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            doRemoveSelection();
        }
    });
    Composite composite_2 = new Composite(composite, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));
    composite_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Label lblNewLabel = new Label(composite_2, SWT.NONE);
    lblNewLabel.setText("Project Name:");
    txtProjectName = new Text(composite_2, SWT.BORDER);
    txtProjectName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtProjectName.setText(projectName != null ? projectName : "");
    txtProjectName.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (!programmaticChange) {
                try {
                    uiChange = true;
                    setProjectName(txtProjectName.getText());
                } finally {
                    uiChange = false;
                }
            }
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) PackageNameLabelProvider(bndtools.internal.pkgselection.PackageNameLabelProvider) 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)

Example 57 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project eclipse.platform.text by eclipse.

the class AbstractTemplatesPage method createTreeViewer.

/**
 * Create the tree viewer and setup the providers.
 *
 * @param templatesTree the tree used to show the templates
 */
private void createTreeViewer(Tree templatesTree) {
    fTreeViewer = new TreeViewer(fTemplatesTree);
    fTreeViewer.setLabelProvider(new TemplateLabelProvider());
    fTreeViewer.setContentProvider(new TemplatesContentProvider());
    fTreeViewer.setComparator(new TemplateViewerComparator());
    fTreeViewer.setInput(getTemplatePreferenceStore());
    fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent e) {
            updateSelectedItems();
            TemplatePersistenceData[] selectedTemplates = getSelectedTemplates();
            if (selectedTemplates.length > 0)
                insertTemplate(selectedTemplates[0].getTemplate());
        }
    });
    fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent e) {
            updateSelectedItems();
            updateButtons();
        }
    });
    fTreeViewer.expandAll();
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 58 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project linuxtools by eclipse.

the class DoubleClickTest method doDoubleClick.

private void doDoubleClick() {
    MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    MassifTreeViewer treeViewer = view.getTreeViewer();
    MassifSnapshot[] snapshots = view.getSnapshots();
    // first detailed
    node = snapshots[1].getRoot();
    TreePath path = new TreePath(new Object[] { node });
    while (node.getChildren().length > 0 && !node.hasSourceFile()) {
        node = node.getChildren()[0];
        path = path.createChildPath(node);
    }
    assertTrue(node.hasSourceFile());
    treeViewer.getViewer().expandToLevel(node, AbstractTreeViewer.ALL_LEVELS);
    TreeSelection selection = new TreeSelection(path);
    // do double click
    IDoubleClickListener listener = treeViewer.getDoubleClickListener();
    listener.doubleClick(new DoubleClickEvent(treeViewer.getViewer(), selection));
}
Also used : MassifTreeViewer(org.eclipse.linuxtools.internal.valgrind.massif.MassifTreeViewer) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart)

Example 59 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project linuxtools by eclipse.

the class DoubleClickTest method doDoubleClick.

private void doDoubleClick() {
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    CoreMessagesViewer viewer = view.getMessagesViewer();
    // get first leaf
    IValgrindMessage[] elements = (IValgrindMessage[]) viewer.getTreeViewer().getInput();
    IValgrindMessage element = elements[0];
    TreePath path = new TreePath(new Object[] { element });
    frame = null;
    while (element.getChildren().length > 0) {
        element = element.getChildren()[0];
        path = path.createChildPath(element);
        if (element instanceof ValgrindStackFrame) {
            frame = (ValgrindStackFrame) element;
        }
    }
    assertNotNull(frame);
    viewer.getTreeViewer().expandToLevel(frame, AbstractTreeViewer.ALL_LEVELS);
    TreeSelection selection = new TreeSelection(path);
    // do double click
    IDoubleClickListener listener = viewer.getDoubleClickListener();
    listener.doubleClick(new DoubleClickEvent(viewer.getTreeViewer(), selection));
}
Also used : ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ValgrindStackFrame(org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CoreMessagesViewer(org.eclipse.linuxtools.internal.valgrind.ui.CoreMessagesViewer)

Example 60 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project knime-core by knime.

the class AbstractRepositoryView method hookDoubleClickAction.

private void hookDoubleClickAction() {
    m_viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(final DoubleClickEvent event) {
            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (o instanceof NodeTemplate) {
                NodeTemplate tmplt = (NodeTemplate) o;
                NodeFactory<? extends NodeModel> nodeFact;
                try {
                    nodeFact = tmplt.createFactoryInstance();
                } catch (Exception e) {
                    LOGGER.error("Unable to instantiate the selected node " + tmplt.getFactory().getName(), e);
                    return;
                }
                boolean added = NodeProvider.INSTANCE.addNode(nodeFact);
                if (added) {
                    NodeUsageRegistry.addNode(tmplt);
                }
            } else if (o instanceof MetaNodeTemplate) {
                MetaNodeTemplate mnt = (MetaNodeTemplate) o;
                NodeID metaNode = mnt.getManager().getID();
                NodeProvider.INSTANCE.addMetaNode(WorkflowManager.META_NODE_ROOT, metaNode);
            } else if (o instanceof Category) {
                m_viewer.setExpandedState(o, !m_viewer.getExpandedState(o));
            }
        }
    });
}
Also used : NodeModel(org.knime.core.node.NodeModel) NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) Category(org.knime.workbench.repository.model.Category) NodeFactory(org.knime.core.node.NodeFactory) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) NodeID(org.knime.core.node.workflow.NodeID) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) AbstractRepositoryObject(org.knime.workbench.repository.model.AbstractRepositoryObject) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject) IContainerObject(org.knime.workbench.repository.model.IContainerObject) PartInitException(org.eclipse.ui.PartInitException) ConcurrentModificationException(java.util.ConcurrentModificationException)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)67 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)67 GridData (org.eclipse.swt.layout.GridData)40 TableViewer (org.eclipse.jface.viewers.TableViewer)37 Composite (org.eclipse.swt.widgets.Composite)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)28 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 GridLayout (org.eclipse.swt.layout.GridLayout)21 Table (org.eclipse.swt.widgets.Table)16 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)15 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 Button (org.eclipse.swt.widgets.Button)13 Label (org.eclipse.swt.widgets.Label)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 ISelection (org.eclipse.jface.viewers.ISelection)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 FillLayout (org.eclipse.swt.layout.FillLayout)10