Search in sources :

Example 36 with ISelectionProvider

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

the class RevisionSelectionProvider method install.

/**
 * Installs the selection provider on the viewer.
 *
 * @param viewer the viewer on which we listen to for post selection events
 */
void install(ITextViewer viewer) {
    uninstall();
    fViewer = viewer;
    if (fViewer != null) {
        ISelectionProvider provider = fViewer.getSelectionProvider();
        if (provider instanceof IPostSelectionProvider) {
            IPostSelectionProvider postProvider = (IPostSelectionProvider) provider;
            fSelectionListener = new PostSelectionListener(postProvider);
        }
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 37 with ISelectionProvider

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

the class PaintManager method addListeners.

/**
 * Installs our listener set on the text viewer and the text widget,
 * respectively.
 */
private void addListeners() {
    ISelectionProvider provider = fTextViewer.getSelectionProvider();
    provider.addSelectionChangedListener(this);
    fTextViewer.addTextListener(this);
    StyledText text = fTextViewer.getTextWidget();
    text.addKeyListener(this);
    text.addMouseListener(this);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 38 with ISelectionProvider

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

the class WorkflowEditor method onF2Pressed.

/**
 * Opens editor for (node) annotation (given that a single node or
 * annotation is selected).
 */
private void onF2Pressed() {
    ISelectionProvider provider = getEditorSite().getSelectionProvider();
    if (provider == null) {
        return;
    }
    ISelection sel = provider.getSelection();
    if (!(sel instanceof IStructuredSelection)) {
        return;
    }
    Set<AnnotationEditPart> selectedAnnoParts = new HashSet<AnnotationEditPart>();
    @SuppressWarnings("rawtypes") Iterator selIter = ((IStructuredSelection) sel).iterator();
    while (selIter.hasNext()) {
        Object next = selIter.next();
        if (next instanceof AnnotationEditPart) {
            selectedAnnoParts.add((AnnotationEditPart) next);
        } else if (next instanceof NodeContainerEditPart) {
            NodeAnnotationEditPart nodeAnnoPart = ((NodeContainerEditPart) next).getNodeAnnotationEditPart();
            if (nodeAnnoPart != null) {
                selectedAnnoParts.add(nodeAnnoPart);
            }
        } else {
            // unknown type selected
            return;
        }
    }
    if (selectedAnnoParts.size() == 1) {
        AnnotationEditPart next = selectedAnnoParts.iterator().next();
        next.performEdit();
    }
}
Also used : NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) EventObject(java.util.EventObject) ContentObject(org.knime.workbench.explorer.view.ContentObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart) HashSet(java.util.HashSet)

Example 39 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by dbeaver.

the class CompileHandler method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    List<OracleSourceObject> objects = new ArrayList<>();
    IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
    if (partSite != null) {
        final ISelectionProvider selectionProvider = partSite.getSelectionProvider();
        if (selectionProvider != null) {
            ISelection selection = selectionProvider.getSelection();
            if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
                for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
                    final Object item = iter.next();
                    final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(item, OracleSourceObject.class);
                    if (sourceObject != null) {
                        objects.add(sourceObject);
                    }
                }
            }
        }
        if (objects.isEmpty()) {
            final IWorkbenchPart activePart = partSite.getPart();
            final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(activePart, OracleSourceObject.class);
            if (sourceObject != null) {
                objects.add(sourceObject);
            }
        }
    }
    if (!objects.isEmpty()) {
        if (objects.size() > 1) {
            element.setText("Compile " + objects.size() + " objects");
        } else {
            final OracleSourceObject sourceObject = objects.get(0);
            String objectType = TextUtils.formatWord(sourceObject.getSourceType().name());
            element.setText("Compile " + objectType);
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ArrayList(java.util.ArrayList) ISelection(org.eclipse.jface.viewers.ISelection) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject)

Example 40 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by dbeaver.

the class AggregateColumnsPanel method refresh.

@Override
public void refresh(boolean force) {
    aggregateTable.setRedraw(false);
    try {
        aggregateTable.removeAll();
        if (this.presentation instanceof ISelectionProvider) {
            ISelection selection = ((ISelectionProvider) presentation).getSelection();
            if (selection instanceof IResultSetSelection) {
                aggregateSelection((IResultSetSelection) selection);
            }
        }
        UIUtils.packColumns(aggregateTable, true, null);
    } finally {
        aggregateTable.setRedraw(true);
    }
    saveSettings();
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection)

Aggregations

ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)170 ISelection (org.eclipse.jface.viewers.ISelection)61 TreeViewer (org.eclipse.jface.viewers.TreeViewer)40 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 ITextSelection (org.eclipse.jface.text.ITextSelection)26 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)24 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)23 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)21 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)17 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)15 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)13 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)13 IPostSelectionProvider (org.eclipse.jface.viewers.IPostSelectionProvider)13 IEditorPart (org.eclipse.ui.IEditorPart)13 Shell (org.eclipse.swt.widgets.Shell)12 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)10 IDocument (org.eclipse.jface.text.IDocument)9