org.eclipse.jface.viewers.ILazyTreeContentProvider Java Examples

The following examples show how to use org.eclipse.jface.viewers.ILazyTreeContentProvider. 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: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/** 
 * @see org.eclipse.jface.viewers.AbstractTreeViewer#getParentElement(java.lang.Object)
 */
protected Object getParentElement(Object element) {
	boolean oldBusy = isBusy();
	setBusy(true);
	try {
		if (contentProviderIsLazy && !contentProviderIsTreeBased && !(element instanceof TreePath)) {
			ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider();
			return lazyTreeContentProvider.getParent(element);
		}
		if (contentProviderIsLazy && contentProviderIsTreeBased && !(element instanceof TreePath)) {
			ILazyTreePathContentProvider lazyTreePathContentProvider = (ILazyTreePathContentProvider) getContentProvider();
			TreePath[] parents = lazyTreePathContentProvider.getParents(element);
			if (parents != null && parents.length > 0) {
				return parents[0];
			}
		}
		return super.getParentElement(element);
	} finally {
		setBusy(oldBusy);
	}
}
 
Example #2
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Update the widget at index.
 * 
 * @param widget
 * @param index
 */
private void virtualLazyUpdateWidget(Widget widget, int index) {
	boolean oldBusy = isBusy();
	setBusy(false);
	try {
		if (contentProviderIsTreeBased) {
			TreePath treePath;
			if (widget instanceof Item) {
				if (widget.getData() == null) {
					return;
				}
				treePath = getTreePathFromItem((Item) widget);
			} else {
				treePath = TreePath.EMPTY;
			}
			((ILazyTreePathContentProvider) getContentProvider()).updateElement(treePath, index);
		} else {
			((ILazyTreeContentProvider) getContentProvider()).updateElement(widget.getData(), index);
		}
	} finally {
		setBusy(oldBusy);
	}
}
 
Example #3
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Update the child count
 * 
 * @param widget
 * @param currentChildCount
 */
private void virtualLazyUpdateChildCount(Widget widget, int currentChildCount) {
	boolean oldBusy = isBusy();
	setBusy(false);
	try {
		if (contentProviderIsTreeBased) {
			TreePath treePath;
			if (widget instanceof Item) {
				treePath = getTreePathFromItem((Item) widget);
			} else {
				treePath = TreePath.EMPTY;
			}
			((ILazyTreePathContentProvider) getContentProvider()).updateChildCount(treePath, currentChildCount);
		} else {
			((ILazyTreeContentProvider) getContentProvider()).updateChildCount(widget.getData(), currentChildCount);
		}
	} finally {
		setBusy(oldBusy);
	}
}
 
Example #4
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Update the item with the current child count.
 * 
 * @param item
 * @param currentChildCount
 */
private void virtualLazyUpdateHasChildren(Item item, int currentChildCount) {
	boolean oldBusy = isBusy();
	setBusy(false);
	try {
		if (contentProviderIsTreeBased) {
			TreePath treePath;
			treePath = getTreePathFromItem(item);
			if (currentChildCount == 0) {
				// item is not expanded (but may have a plus currently)
				((ILazyTreePathContentProvider) getContentProvider()).updateHasChildren(treePath);
			} else {
				((ILazyTreePathContentProvider) getContentProvider()).updateChildCount(treePath, currentChildCount);
			}
		} else {
			((ILazyTreeContentProvider) getContentProvider()).updateChildCount(item.getData(), currentChildCount);
		}
	} finally {
		setBusy(oldBusy);
	}
}
 
Example #5
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.jface.viewers.AbstractTreeViewer#assertContentProviderType(org.eclipse.jface.viewers.IContentProvider)
 */
protected void assertContentProviderType(IContentProvider provider) {
	if (provider instanceof ILazyTreeContentProvider || provider instanceof ILazyTreePathContentProvider) {
		return;
	}
	super.assertContentProviderType(provider);
}
 
Example #6
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/** 
 * @see org.eclipse.jface.viewers.AbstractTreeViewer#setContentProvider(org.eclipse.jface.viewers.IContentProvider)
 */
public void setContentProvider(IContentProvider provider) {
	contentProviderIsLazy = (provider instanceof ILazyTreeContentProvider) || (provider instanceof ILazyTreePathContentProvider);
	contentProviderIsTreeBased = provider instanceof ILazyTreePathContentProvider;
	super.setContentProvider(provider);
}