/** * Return the subset of children that are of interest from the given context. By default, this * method returns those children whose traversals contain a diff in the context. However, it does * not include those model elements that do not exist locally but are within the context (e.g. * locally deleted elements and remotely added elements). Subclasses must override to include * these. * * @param context the context * @param parent the parent of the children * @param children the children * @return the subset of children that are of interest from the given context */ protected Object[] getChildrenInContext( ISynchronizationContext context, Object parent, Object[] children) { if (children.length != 0) children = getChildrenInScope(context.getScope(), parent, children); if (parent instanceof IResource) { IResource resource = (IResource) parent; children = getChildrenWithPhantoms(context, resource, children); } if (children.length == 0) return children; return internalGetChildren(context, parent, children); }
private Object[] internalGetChildren(Object parent, boolean isElement) { Object element = internalGetElement(parent); if (element instanceof ISynchronizationScope) { // If the root is a scope, we want to include all models in the scope ISynchronizationScope rms = (ISynchronizationScope) element; if (rms.getMappings(getModelProviderId()).length > 0) { empty = false; return new Object[] {getModelProvider()}; } empty = true; return new Object[0]; } else if (element instanceof ISynchronizationContext) { ISynchronizationContext context = (ISynchronizationContext) element; // If the root is a context, we want to filter by the context ISynchronizationContext sc = (ISynchronizationContext) element; if (sc.getScope().getMappings(getModelProviderId()).length > 0) { Object root = getModelRoot(); boolean initialized = isInitialized(context); if (!initialized || getChildrenInContext(sc, root, getDelegateChildren(root, isElement)).length > 0) { if (!initialized) requestInitialization(context); empty = false; return new Object[] {getModelProvider()}; } } empty = true; return new Object[0]; } if (element == getModelProvider()) { ISynchronizationContext context = getContext(); if (context != null && !isInitialized(context)) { return new Object[0]; } element = getModelRoot(); if (parent instanceof TreePath) { parent = TreePath.EMPTY.createChildPath(element); } else { parent = element; } } Object[] delegateChildren = getDelegateChildren(parent, isElement); ISynchronizationContext context = getContext(); if (context == null) { ISynchronizationScope scope = getScope(); if (scope == null) { return delegateChildren; } else { return getChildrenInScope(scope, parent, delegateChildren); } } else { return getChildrenInContext(context, parent, delegateChildren); } }