1 11 package org.eclipse.debug.internal.ui.views.variables; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.debug.core.model.IVariable; 17 import org.eclipse.debug.internal.ui.elements.adapters.DeferredVariableLogicalStructure; 18 import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager; 19 import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; 20 import org.eclipse.jface.viewers.ITreeContentProvider; 21 import org.eclipse.ui.IWorkbenchPartSite; 22 import org.eclipse.ui.internal.progress.PendingUpdateAdapter; 23 import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; 24 import org.eclipse.ui.progress.IElementCollector; 25 26 30 public class RemoteVariableContentManager extends RemoteTreeContentManager { 31 32 protected VariablesView fView; 33 private IDeferredWorkbenchAdapter fVariableLogicalStructureAdapter = new DeferredVariableLogicalStructure(); 34 35 private Set fHasChildren = new HashSet (); 36 private Set fNoChildren = new HashSet (); 37 38 41 public class VariableCollector extends RemoteTreeContentManager.Collector { 42 43 public VariableCollector(Object parent) { 44 super(parent); 45 } 46 47 52 public void setHasChildren(Object element, boolean children) { 53 synchronized (fHasChildren) { 54 if (children) { 55 fHasChildren.add(element); 56 fNoChildren.remove(element); 57 } else { 58 fNoChildren.add(element); 59 fHasChildren.remove(element); 60 } 61 } 62 } 63 64 } 65 66 69 public RemoteVariableContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { 70 super(provider, viewer, site); 71 fView = view; 72 } 73 74 77 protected IDeferredWorkbenchAdapter getAdapter(Object element) { 78 if (element instanceof IVariable && fView !=null && fView.isShowLogicalStructure()) { 79 return fVariableLogicalStructureAdapter; 80 } 81 return super.getAdapter(element); 82 } 83 84 87 protected IElementCollector createElementCollector(Object parent, PendingUpdateAdapter placeholder) { 88 return new VariableCollector(parent); 89 } 90 91 94 public boolean mayHaveChildren(Object element) { 95 synchronized (fHasChildren) { 96 if (fHasChildren.contains(element)) { 97 return true; 98 } else if (fNoChildren.contains(element)) { 99 return false; 100 } 101 } 102 return super.mayHaveChildren(element); 103 } 104 105 108 public void clearHasChildrenCache() { 109 synchronized (fHasChildren) { 110 fHasChildren.clear(); 111 fNoChildren.clear(); 112 } 113 } 114 } 115 | Popular Tags |