Java Code Examples for org.eclipse.jface.viewers.StructuredViewer#getContentProvider()

The following examples show how to use org.eclipse.jface.viewers.StructuredViewer#getContentProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiTreePatternFilter.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected boolean isLeafMatch(Viewer viewer, Object element) {
    Object node = element;
    StructuredViewer structuredViewer = (StructuredViewer) viewer;
    ITableLabelProvider labelProvider = (ITableLabelProvider) structuredViewer.getLabelProvider();
    ITreeContentProvider treeContentProvider = (ITreeContentProvider) structuredViewer.getContentProvider();

    // Ensure the tree element and its parent(s) match the filter text
    for (Predicate<String> p : fPredicates) {
        // Retrieve tree element text and make verification. Text is at column 0
        String labelText = labelProvider.getColumnText(node, 0);
        if (labelText == null || !p.test(labelText)) {
            return false;
        }

        // Retrieve parent element
        node = treeContentProvider.getParent(node);
    }
    return true;
}
 
Example 2
Source File: LabItemTreeSelectionComposite.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean select(Viewer viewer, Object parentElement, Object element){
	if (searchString == null || searchString.length() == 0) {
		return true;
	}
	
	StructuredViewer sviewer = (StructuredViewer) viewer;
	ITreeContentProvider provider = (ITreeContentProvider) sviewer.getContentProvider();
	Object[] children = provider.getChildren(element);
	if (children != null && children.length > 0) {
		for (Object child : children) {
			if (select(viewer, element, child)) {
				return true;
			}
		}
	}
	return isSelect(element);
}
 
Example 3
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Precondition here: the viewer must be showing a tree with a LevelContentProvider.
 *
 * @param grouping the grouping which must be one of the <code>LEVEL_*</code> constants from
 *            {@link LevelTreeContentProvider}
 */
void setGrouping(int grouping) {
	fCurrentGrouping= grouping;
	StructuredViewer viewer= getViewer();
	LevelTreeContentProvider cp= (LevelTreeContentProvider) viewer.getContentProvider();
	cp.setLevel(grouping);
	updateGroupingActions();
	getSettings().put(KEY_GROUPING, fCurrentGrouping);
	getViewPart().updateLabel();
}
 
Example 4
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int getFilteredMatchCount() {
	StructuredViewer viewer= getViewer();
	if (viewer instanceof TreeViewer) {
		ITreeContentProvider tp= (ITreeContentProvider) viewer.getContentProvider();
		return getMatchCount(tp, getRootElements((TreeViewer) getViewer()));
	} else {
		return getMatchCount((TableViewer) viewer);
	}
}
 
Example 5
Source File: NonEssentialElementsFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Object[] getRawChildren(StructuredViewer viewer, IPackageFragment fragment) {
	IStructuredContentProvider provider = (IStructuredContentProvider) viewer.getContentProvider();
	if (provider instanceof ITreeContentProvider) {
		return ((ITreeContentProvider)provider).getChildren(fragment);
	}
	return provider.getElements(fragment);
}
 
Example 6
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void updateGroupWith(StructuredViewer viewer) {
    if (viewer != null) {
        IContentProvider contentProvider = viewer.getContentProvider();
        if (contentProvider instanceof ISearchIndexContentProvider) {
            ISearchIndexContentProvider searchIndexTreeContentProvider = (ISearchIndexContentProvider) contentProvider;
            searchIndexTreeContentProvider.setGroupWith(groupWithConfiguration);
        }
    }
}
 
Example 7
Source File: DocumentsView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean select(Viewer viewer, Object parentElement, Object element){
	
	if (searchTitle != null && !searchTitle.isEmpty()) {
		String searchText = searchTitle.toLowerCase();
		
		if (element instanceof ICategory) {
			StructuredViewer sviewer = (StructuredViewer) viewer;
			ITreeContentProvider provider =
				(ITreeContentProvider) sviewer.getContentProvider();
			for (Object child : provider.getChildren(element)) {
				if (select(viewer, element, child))
					return true;
			}
			return false;
		}
		if (element instanceof IDocument) {
			IDocument iDocument = (IDocument) element;
			if (iDocument.getCategory().getName().toLowerCase().startsWith(searchText)) {
				return true;
			}
			if (iDocument.getTitle().toLowerCase().contains(searchText)) {
				return true;
			}
			if (iDocument.getKeywords() != null && iDocument.getKeywords().toLowerCase()
				.contains(searchText.toLowerCase())) {
				return true;
			}
		}
		return false;
	}
	return true;
}
 
Example 8
Source File: ContributionCutoff.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void setCutoff(StructuredViewer viewer, double value) {
	IContentProvider cp = viewer.getContentProvider();
	if (!(cp instanceof CutoffContentProvider)) {
		Logger log = LoggerFactory.getLogger(getClass());
		log.error("Content provider of viewer with cutoff spinner should "
				+ "implement CutoffContentProvider");
		return;
	}
	CutoffContentProvider provider = (CutoffContentProvider) cp;
	provider.setCutoff(value);
	viewer.refresh();
}