/**
  * Return whether the given object is visible in the synchronization page showing this content
  * based on the diffs in the given context. Visibility is determined by obtaining the diffs for
  * the object from the context by calling {@link #getTraversals(ISynchronizationContext, Object)}
  * to get the traversals, then obtaining the diffs from the context's diff tree and then calling
  * {@link #isVisible(IDiff)} for each diff.
  *
  * @param context the synchronization context
  * @param object the object
  * @return whether the given object is visible in the synchronization page showing this content
  */
 protected boolean isVisible(ISynchronizationContext context, Object object) {
   ResourceTraversal[] traversals = getTraversals(context, object);
   IDiff[] deltas = context.getDiffTree().getDiffs(traversals);
   boolean visible = false;
   if (isVisible(deltas)) {
     visible = true;
   }
   return visible;
 }
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.IContentProvider#dispose()
  */
 public void dispose() {
   ICommonContentExtensionSite extensionSite = getExtensionSite();
   if (extensionSite != null) {
     extensionSite.getExtensionStateModel().removePropertyChangeListener(this);
   }
   ISynchronizationContext context = getContext();
   if (context != null) context.getDiffTree().removeDiffChangeListener(this);
   ISynchronizePageConfiguration configuration = getConfiguration();
   if (configuration != null) configuration.removePropertyChangeListener(this);
 }
 private Object[] getChildrenWithPhantoms(
     ISynchronizationContext context, IResource resource, Object[] children) {
   IResource[] setChildren = context.getDiffTree().members(resource);
   if (setChildren.length == 0) return children;
   if (children.length == 0) return setChildren;
   Set result = new HashSet(children.length);
   for (int i = 0; i < children.length; i++) {
     result.add(children[i]);
   }
   for (int i = 0; i < setChildren.length; i++) {
     result.add(setChildren[i]);
   }
   return result.toArray();
 }
 /* (non-Javadoc)
  * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
  */
 public void init(ICommonContentExtensionSite site) {
   // Set the site
   this.site = site;
   // Configure the content provider based on the site and state model
   site.getExtensionStateModel().addPropertyChangeListener(this);
   ISynchronizePageConfiguration configuration = getConfiguration();
   if (configuration != null) configuration.addPropertyChangeListener(this);
   ITreeContentProvider provider = getDelegateContentProvider();
   if (provider instanceof ICommonContentProvider) {
     ((ICommonContentProvider) provider).init(site);
   }
   ISynchronizationContext context = getContext();
   if (context != null) context.getDiffTree().addDiffChangeListener(this);
 }
 /**
  * Return whether the given element has children in the given context. The children may or may not
  * exist locally. By default, this method returns true if the traversals for the element contain
  * any diffs. This could result in false positives. Subclasses can override to provide a more
  * efficient or precise answer.
  *
  * @param element a model element.
  * @return whether the given element has children in the given context
  */
 protected boolean hasChildrenInContext(ISynchronizationContext context, Object element) {
   ResourceTraversal[] traversals = getTraversals(context, element);
   if (traversals == null) return true;
   return context.getDiffTree().getDiffs(traversals).length > 0;
 }