/** * Delete elements from existing container that doesn't exist in the reference container. * * @param container the existing container to delete the removed elements. * @param refContainer the reference container to compare elements that are removed. * @param containerDelta the delta of the existing container. */ private void deleteRemovedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) { Object[] children = container.getChildren(); Object[] refChildren = refContainer.getChildren(); // if a child of container doesn't exist in refContainer, than remove it from container for (int i = 0; i < children.length; ++i) { Object element = getElement(refChildren, children[i]); if (element == null) { if (children[i] instanceof BreakpointContainer) { BreakpointContainer.removeAll((BreakpointContainer) children[i], containerDelta); } else { BreakpointContainer.removeBreakpoint(container, (IBreakpoint) children[i], containerDelta); } } else if (element instanceof BreakpointContainer){ ModelDelta childDelta = containerDelta.addNode(children[i], IModelDelta.STATE); deleteRemovedElements((BreakpointContainer) children[i], (BreakpointContainer) element, childDelta); } } }
void updateContainers() { IBreakpoint[] breakpoints = filterBreakpoints( fInput, getSelectionFilter(fInput, getDebugContext()), fBpManager.getBreakpoints()); synchronized(this) { ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); // create a reference container, use for deleting elements and adding elements ModelDelta dummyDelta = new ModelDelta(null, IModelDelta.NO_CHANGE); BreakpointContainer refContainer = createRootContainer(dummyDelta, fInput, fOrganizers, breakpoints); // delete the removed elements deleteRemovedElements(fContainer, refContainer, delta); // adjust the old organizer with the reference organizer BreakpointContainer.copyOrganizers(fContainer, refContainer); // insert the added elements IBreakpoint newBreakpoint = insertAddedElements(fContainer, refContainer, delta); delta.setChildCount(fContainer.getChildren().length); // select the new breakpoint if (newBreakpoint != null) { appendModelDeltaToElement(delta, newBreakpoint, IModelDelta.SELECT); } if (DebugUIPlugin.DEBUG_BREAKPOINT_DELTAS) { DebugUIPlugin.trace("POST BREAKPOINT DELTA (setOrganizers)\n"); //$NON-NLS-1$ } postModelChanged(delta, false); } }