Example usage for org.eclipse.jface.viewers ContentViewer getInput

List of usage examples for org.eclipse.jface.viewers ContentViewer getInput

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ContentViewer getInput.

Prototype

@Override
public Object getInput() 

Source Link

Document

The ContentViewer implementation of this IInputProvider method returns the current input of this viewer, or null if none.

Usage

From source file:org.eclipse.emf.compare.ui.viewer.structure.ModelStructureMergeViewerService.java

License:Open Source License

/**
 * Returns all visible {@link DiffElement}s from the given compare in and compare configuration in the
 * given viewer.//w ww. j  a  va 2 s.  com
 * 
 * @param input
 *            The compare input of the editor.
 * @param parent
 *            The parent composite.
 * @param configuration
 *            The compare configuration.
 * @return Returns all visible {@link DiffElement}s from the given compare in and compare configuration in
 *         the given viewer
 * @deprecated
 */
@Deprecated
public static List<DiffElement> getvisibleDiffElements(ICompareInput input, Composite parent,
        CompareConfiguration configuration) {
    final List<DiffElement> ret = new ArrayList<DiffElement>();

    final ContentViewer contentViewer = (ContentViewer) CompareUI.findStructureViewer(null, input, parent,
            configuration);
    final ITreeContentProvider contentProvider = (ITreeContentProvider) contentViewer.getContentProvider();

    final Object[] elements = contentProvider.getElements(contentViewer.getInput());
    for (Object object : elements) {
        if (object instanceof DiffElement) {
            ret.add((DiffElement) object);
        }
        ret.addAll(allChildren(object, contentProvider));
    }
    return ret;
}

From source file:org.eclipse.emf.compare.ui.viewer.structure.ModelStructureMergeViewerService.java

License:Open Source License

/**
 * Returns all visible elements from the given compare in and compare configuration in the given viewer
 * grouped by selected groups./*from w  w w  . j  a  v a 2s  .c  o m*/
 * 
 * @param input
 *            The compare input of the editor.
 * @param parent
 *            The parent composite.
 * @param configuration
 *            The compare configuration.
 * @return all visible elements from the given compare in and compare configuration in the given viewer
 *         grouped by selected groups.
 * @deprecated
 */
@Deprecated
public static Map<UIDifferenceGroup, List<DiffElement>> getGroupedDiffElements(ICompareInput input,
        Composite parent, CompareConfiguration configuration) {
    final Map<UIDifferenceGroup, List<DiffElement>> ret = new HashMap<UIDifferenceGroup, List<DiffElement>>();

    final ContentViewer contentViewer = (ContentViewer) CompareUI.findStructureViewer(null, input, parent,
            configuration);
    final ITreeContentProvider contentProvider = (ITreeContentProvider) contentViewer.getContentProvider();

    final Object[] elements = contentProvider.getElements(contentViewer.getInput());
    for (Object object : elements) {
        if (object instanceof UIDifferenceGroup) {
            final UIDifferenceGroup diffGroup = (UIDifferenceGroup) object;
            ret.put(diffGroup, allChildren(object, contentProvider));
        }

    }

    return ret;
}

From source file:org.eclipse.emf.eson.ui.editor.tree.XtextMultiEObjectSearchDialog.java

License:Open Source License

@SuppressWarnings("unchecked")
private List<IEObjectDescription> getInputList(ContentViewer tableViewer) {
    Object input = tableViewer.getInput();
    List<IEObjectDescription> list = new ArrayList<IEObjectDescription>();
    if (input != null) {
        if (input instanceof IStructuredSelection) {
            list.addAll(((IStructuredSelection) input).toList());
        } else if (input instanceof Collection) {
            list.addAll((Collection<IEObjectDescription>) input);
        } else {/*from   w w  w  .  j  a v a 2s  .c  o m*/
            // Undefined input given to TableViewer
        }
        input = new ArrayList<IEObjectDescription>();
    }
    return list;
}

From source file:org.kalypso.contribs.eclipse.jface.viewers.ViewerUtilities.java

License:Open Source License

/**
 * Sets the selection of this viewer to its first input-element.
 * <p>/*from w w w . jav a2 s.co m*/
 * The content provider must be a {@link IStructuredContentProvider}.
 * </p>
 */
public static void selectFirstElement(final ContentViewer viewer) {
    final IContentProvider contentProvider = viewer.getContentProvider();
    if (contentProvider instanceof IStructuredContentProvider) {
        final IStructuredContentProvider provider = (IStructuredContentProvider) contentProvider;
        final Object[] elements = provider.getElements(viewer.getInput());
        if (elements != null && elements.length > 0)
            viewer.setSelection(new StructuredSelection(elements[0]), true);
    }
}