List of usage examples for org.eclipse.jface.viewers AbstractTreeViewer remove
public void remove(final Object parent, final Object... elements)
From source file:ts.eclipse.ide.internal.ui.navigator.TypeScriptNavigatorContentProvider.java
License:Open Source License
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;/*from w w w . ja va 2s.co m*/ } 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); }