本文整理汇总了Java中org.eclipse.jface.viewers.AbstractTreeViewer.remove方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractTreeViewer.remove方法的具体用法?Java AbstractTreeViewer.remove怎么用?Java AbstractTreeViewer.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.AbstractTreeViewer
的用法示例。
在下文中一共展示了AbstractTreeViewer.remove方法的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());
}
}
示例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);
}