Example usage for org.eclipse.jface.viewers StructuredSelection EMPTY

List of usage examples for org.eclipse.jface.viewers StructuredSelection EMPTY

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredSelection EMPTY.

Prototype

StructuredSelection EMPTY

To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.

Click Source Link

Document

The canonical empty selection.

Usage

From source file:net.certiv.fluentmark.outline.FluentOutlinePage.java

License:Open Source License

public void select(ISourceReference reference) {
    if (viewer != null) {
        ISelection sel = viewer.getSelection();
        if (sel instanceof IStructuredSelection) {
            IStructuredSelection ssel = (IStructuredSelection) sel;
            List<?> elements = ssel.toList();
            if (!elements.contains(reference)) {
                sel = reference == null ? StructuredSelection.EMPTY : new StructuredSelection(reference);
                viewer.setSelection(sel, true);
            }//from   www  . java  2 s.c  o m
        }
    }
}

From source file:net.enilink.commons.ui.editor.EditorPartBook.java

License:Open Source License

@Override
public void setInput(Object input) {
    if (input != null) {
        selectionChanged(new StructuredSelection(input));
    } else {//from w w w.ja v  a2 s.  c om
        selectionChanged(StructuredSelection.EMPTY);
    }
}

From source file:net.enilink.commons.ui.jface.table.CComboBoxCellEditor.java

License:Open Source License

/**
 * The <code>ComboBoxCellEditor</code> implementation of this
 * <code>CellEditor</code> framework method accepts a zero-based index of
 * a selection./*  w  ww . ja  v  a 2 s . c om*/
 * 
 * @param value
 *            the zero-based index of the selection wrapped as an
 *            <code>Integer</code>
 */
protected void doSetValue(Object value) {
    Assert.isTrue(viewer != null);
    if (value != null) {
        viewer.setSelection(new StructuredSelection(value), true);
    } else {
        viewer.setSelection(StructuredSelection.EMPTY);
    }
    selection = value;
}

From source file:net.enilink.komma.edit.ui.action.AbstractActionDelegate.java

License:Open Source License

/**
 * Retrieves the current selection./*  ww w.  j a v a2  s . c om*/
 * 
 * @return The current selection.
 */
protected ISelection getSelection() {
    ISelection selection = null;
    IWorkbenchPart wbp = getWorkbenchPart();
    if (wbp != null) {
        IWorkbenchPartSite wbps = wbp.getSite();
        if (wbps != null) {
            ISelectionProvider selectionProvider = wbps.getSelectionProvider();
            if (selectionProvider != null) {
                selection = selectionProvider.getSelection();
                if (selection != null)
                    return selection;
            }
        }
    }
    return StructuredSelection.EMPTY;
}

From source file:net.enilink.komma.edit.ui.action.AbstractActionDelegate.java

License:Open Source License

/**
 * Retrieves the current structured selection.
 * //from   w  ww  .  j a  va2s  .c o  m
 * @return The current structured selection.
 */
protected IStructuredSelection getStructuredSelection() {
    IStructuredSelection selection = null;
    IWorkbenchPart wbp = getWorkbenchPart();
    if (wbp != null) {
        ISelectionProvider selectionProvider = wbp.getSite().getSelectionProvider();
        if (selectionProvider != null && selectionProvider.getSelection() instanceof IStructuredSelection) {
            selection = (IStructuredSelection) selectionProvider.getSelection();
            if (selection != null)
                return selection;
        }
    }
    return StructuredSelection.EMPTY;
}

From source file:net.enilink.komma.edit.ui.action.AbstractActionHandler.java

License:Open Source License

/**
 * Retrieves the current selection./*from w  ww . ja  v a2  s.  co m*/
 * 
 * @return The current selection.
 */
protected ISelection getSelection() {
    if (this.selection != null) {
        return this.selection;
    }

    ISelection selection = null;
    ISelectionService selectionService = null;
    if (getWorkbenchPart() != null && getWorkbenchPart().getSite().getWorkbenchWindow() != null) {
        selectionService = getWorkbenchPart().getSite().getWorkbenchWindow().getSelectionService();
    }

    if (selectionService != null) {
        selection = selectionService.getSelection();
    }

    return (selection != null) ? selection : StructuredSelection.EMPTY;
}

From source file:net.enilink.komma.edit.ui.action.AbstractActionHandler.java

License:Open Source License

/**
 * Retrieves the current structured selection.
 * /* www.j a  v  a  2 s.c  o  m*/
 * @return The current structured selection.
 */
protected IStructuredSelection getStructuredSelection() {
    ISelection selection = getSelection();
    return (selection instanceof StructuredSelection) ? (StructuredSelection) selection
            : StructuredSelection.EMPTY;
}

From source file:net.enilink.komma.edit.ui.action.AbstractContributionItem.java

License:Open Source License

/**
 * Retrieves the current selection.// w w  w . ja  va  2s .co m
 * 
 * @return The current selection.
 */
protected ISelection getSelection() {
    ISelection selection = null;
    ISelectionProvider selectionProvider = getWorkbenchPart().getSite().getSelectionProvider();

    if (selectionProvider != null) {
        selection = selectionProvider.getSelection();
    }

    return (selection != null) ? selection : StructuredSelection.EMPTY;
}

From source file:net.enilink.komma.edit.ui.action.AbstractContributionItem.java

License:Open Source License

/**
 * Retrieves the current structured selection.
 * //w  ww  .ja v  a 2  s . co  m
 * @return <code>IStructuredSelection</code> for current selection
 */
protected IStructuredSelection getStructuredSelection() {
    IStructuredSelection selection = null;
    ISelectionProvider selectionProvider = getWorkbenchPart().getSite().getSelectionProvider();

    if (selectionProvider != null && selectionProvider.getSelection() instanceof IStructuredSelection) {
        selection = (IStructuredSelection) selectionProvider.getSelection();
    }
    return (selection != null) ? selection : StructuredSelection.EMPTY;
}

From source file:net.enilink.komma.edit.ui.commands.AbstractHandler.java

License:Open Source License

/**
 * Retrieves the current selection./* ww  w . ja va 2s  .  c om*/
 * 
 * @return The current selection.
 */
protected ISelection getSelection(ExecutionEvent event) {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        return (IStructuredSelection) selection;
    }
    return StructuredSelection.EMPTY;
}