当前位置: 首页>>代码示例>>Java>>正文


Java AbstractTreeViewer.add方法代码示例

本文整理汇总了Java中org.eclipse.jface.viewers.AbstractTreeViewer.add方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractTreeViewer.add方法的具体用法?Java AbstractTreeViewer.add怎么用?Java AbstractTreeViewer.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.viewers.AbstractTreeViewer的用法示例。


在下文中一共展示了AbstractTreeViewer.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: elementsChanged

import org.eclipse.jface.viewers.AbstractTreeViewer; //导入方法依赖的package包/类
@Override
public synchronized void elementsChanged(Object[] updatedElements) {
	if (getSearchResult() == null)
		return;

	AbstractTreeViewer viewer= (AbstractTreeViewer) getPage().getViewer();

	Set<Object> toRemove= new HashSet<Object>();
	Set<Object> toUpdate= new HashSet<Object>();
	Map<Object, Set<Object>> toAdd= new HashMap<Object, Set<Object>>();
	for (int i= 0; i < updatedElements.length; i++) {
		if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0)
			insert(toAdd, toUpdate, updatedElements[i]);
		else
			remove(toRemove, toUpdate, updatedElements[i]);
	}

	viewer.remove(toRemove.toArray());
	for (Iterator<Object> iter= toAdd.keySet().iterator(); iter.hasNext();) {
		Object parent= iter.next();
		HashSet<Object> children= (HashSet<Object>) toAdd.get(parent);
		viewer.add(parent, children.toArray());
	}
	for (Iterator<Object> elementsToUpdate= toUpdate.iterator(); elementsToUpdate.hasNext();) {
		viewer.refresh(elementsToUpdate.next());
	}

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:LevelTreeContentProvider.java

示例2: processChanged

import org.eclipse.jface.viewers.AbstractTreeViewer; //导入方法依赖的package包/类
private void processChanged(final IIDETypeScriptProject tsProject, final ITypeScriptBuildPath oldBuildPath,
		final ITypeScriptBuildPath newBuildPath, Collection<Runnable> runnables) {
	// he widget may have been destroyed
	// by the time this is run. Check for this and do nothing if so.
	Control ctrl = viewer.getControl();
	if (ctrl == null || ctrl.isDisposed()) {
		return;
	}

	final IProject project = tsProject.getProject();
	Runnable addAndRemove = new Runnable() {
		public void run() {
			if (viewer instanceof AbstractTreeViewer) {
				AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer;
				// Disable redraw until the operation is finished so we
				// don't
				// get a flash of both the new and old item (in the case of
				// rename)
				// Only do this if we're both adding and removing files (the
				// rename case)
				/*
				 * if (hasRename) {
				 * treeViewer.getControl().setRedraw(false); }
				 */
				try {
					/*
					 * if (oldBuildPath != null) { treeViewer.remove(new
					 * Object[] { oldBuildPath }); } if (newBuildPath !=
					 * null && newBuildPath.getContainers().size() > 0) {
					 * treeViewer.add(project, new Object[] { newBuildPath
					 * }); }
					 */
					if (!hasBuildPath(newBuildPath)) {
						treeViewer.remove(project, new Object[] { tsProject });
					} else {
						if (!hasBuildPath(oldBuildPath)) {
							treeViewer.add(project, new Object[] { tsProject });
						} else {
							treeViewer.refresh(tsProject);
						}
					}
				} finally {
					/*
					 * if (hasRename) {
					 * treeViewer.getControl().setRedraw(true); }
					 */
				}
			} else {
				((StructuredViewer) viewer).refresh(project);
			}
		}

		private boolean hasBuildPath(final ITypeScriptBuildPath buildPath) {
			return buildPath != null && buildPath.hasRootContainers();
		}
	};
	runnables.add(addAndRemove);
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:59,代码来源:TypeScriptNavigatorContentProvider.java


注:本文中的org.eclipse.jface.viewers.AbstractTreeViewer.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。