1 11 package org.eclipse.debug.internal.ui.viewers; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.debug.internal.ui.viewers.provisional.IChildrenRequestMonitor; 18 19 28 class ChildrenRequestMonitor extends AsynchronousRequestMonitor implements IChildrenRequestMonitor { 29 30 private boolean fFirstUpdate = true; 31 32 35 private List fChildren = new ArrayList (); 36 37 44 ChildrenRequestMonitor(ModelNode parent, AsynchronousModel model) { 45 super(parent, model); 46 } 47 48 51 public void addChild(Object child) { 52 synchronized (fChildren) { 53 fChildren.add(child); 54 } 55 56 scheduleViewerUpdate(250); 57 } 58 59 62 public void addChildren(Object [] children) { 63 synchronized (fChildren) { 64 for (int i = 0; i < children.length; i++) { 65 fChildren.add(children[i]); 66 } 67 } 68 69 scheduleViewerUpdate(0); 70 } 71 72 75 protected boolean contains(AsynchronousRequestMonitor update) { 76 return (update instanceof ChildrenRequestMonitor) && contains(update.getNode()); 77 } 78 79 82 protected void performUpdate() { 83 synchronized (fChildren) { 84 if (fFirstUpdate) { 85 getModel().setChildren(getNode(), fChildren); 86 fFirstUpdate = false; 87 } else { 88 for (Iterator iter = fChildren.iterator(); iter.hasNext();) { 89 Object child = iter.next(); 90 getModel().add(getNode(), child); 91 } 92 } 93 fChildren.clear(); 94 } 95 } 96 97 } 98 | Popular Tags |