org.eclipse.team.core_3.6.0.I20110525-0800

private ResourceMapping findAncestor(ResourceMapping mapping)
  {
    ResourceMapping[] mappings = scope.getMappings(mapping.getModelProviderId());
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping m = mappings[i];
      if (m.contains(mapping)) {
        return m;
      }
    }
    return null;
  }
  
  private ResourceTraversal[] getUncoveredTraversals(ResourceTraversal[] traversals)
  {
    return ((ResourceMappingScope)scope).getCompoundTraversal().getUncoveredTraversals(traversals);
  }
  
  private void addResourcesToScope(ResourceTraversal[] newTraversals, IProgressMonitor monitor)
    throws CoreException
  {
    if (!consultModels) {
      return;
    }
    int count = 0;
    do
    {
      ResourceTraversal[] adjusted = adjustInputTraversals(newTraversals);
      ResourceMapping[] targetMappings = getMappingsFromProviders(adjusted, 
        context, Policy.subMonitorFor(monitor, -1));
      newTraversals = addMappingsToScope(targetMappings, 
        Policy.subMonitorFor(monitor, -1));
    } while ((newTraversals.length != 0) && (count++ < 10));
    if (!scope.hasAdditionalMappings()) {
      setHasAdditionalMappings(scope, internalHasAdditionalMappings());
    }
    if (!scope.hasAdditonalResources()) {
      setHasAdditionalResources(true);
    }
  }
  
  private void fireMappingsChangedEvent(ResourceMapping[] newMappings, ResourceTraversal[] newTraversals)
  {
    ((ResourceMappingScope)scope).fireTraversalsChangedEvent(newTraversals, newMappings);
  }
  
  protected final void setHasAdditionalMappings(ISynchronizationScope scope, boolean hasAdditionalMappings)
  {
    ((ResourceMappingScope)scope).setHasAdditionalMappings(hasAdditionalMappings);
  }
  
  protected final void setHasAdditionalResources(boolean hasAdditionalResources)
  {
    ((ResourceMappingScope)scope).setHasAdditionalResources(hasAdditionalResources);
  }
  
  protected final ISynchronizationScope createScope(ResourceMapping[] inputMappings)
  {
    return new ResourceMappingScope(inputMappings, this);
  }
  
  protected ResourceTraversal[] adjustInputTraversals(ResourceTraversal[] traversals)
  {
    return traversals;
  }
  
  private ResourceTraversal[] addMappingsToScope(ResourceMapping[] targetMappings, IProgressMonitor monitor)
    throws CoreException
  {
    CompoundResourceTraversal result = new CompoundResourceTraversal();
    ResourceMappingContext context = this.context;
    for (int i = 0; i < targetMappings.length; i++)
    {
      ResourceMapping mapping = targetMappings[i];
      if (scope.getTraversals(mapping) == null)
      {
        ResourceTraversal[] traversals = mapping.getTraversals(context, 
          Policy.subMonitorFor(monitor, 100));
        ResourceTraversal[] newOnes = addMappingToScope(mapping, traversals);
        result.addTraversals(newOnes);
      }
      Policy.checkCanceled(monitor);
    }
    return result.asTraversals();
  }
  
  protected final ResourceTraversal[] addMappingToScope(ResourceMapping mapping, ResourceTraversal[] traversals)
  {
    return ((ResourceMappingScope)scope).addMapping(mapping, traversals);
  }
  
  private boolean internalHasAdditionalMappings()
  {
    ResourceMapping[] inputMappings = scope.getInputMappings();
    ResourceMapping[] mappings = scope.getMappings();
    if (inputMappings.length == mappings.length)
    {
      Set testSet = new HashSet();
      for (int i = 0; i < mappings.length; i++)
      {
        ResourceMapping mapping = mappings[i];
        testSet.add(mapping);
      }
      for (int i = 0; i < inputMappings.length; i++)
      {
        ResourceMapping mapping = inputMappings[i];
        if (!testSet.contains(mapping)) {
          return true;
        }
      }
      return false;
    }
    return true;
  }
  
  public ResourceMappingContext getContext()
  {
    return context;
  }
  
  public ISynchronizationScope getScope()
  {
    return scope;
  }
  
  public void dispose()
  {
    if (handler != null) {
      handler.shutdown();
    }
  }
  
  public void refresh(ResourceMapping[] mappings)
  {
    getHandler().refresh(mappings);
  }
  
  private synchronized ScopeManagerEventHandler getHandler()
  {
    if (handler == null) {
      handler = new ScopeManagerEventHandler(this);
    }
    return handler;
  }
  
  public String getName()
  {
    return name;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.mapping.provider.SynchronizationScopeManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import org.eclipse.core.resources.IResource;

public abstract interface ISubscriberChangeEvent
{
  public static final int NO_CHANGE = 0;
  public static final int SYNC_CHANGED = 1;
  public static final int ROOT_ADDED = 2;
  public static final int ROOT_REMOVED = 4;
  
  public abstract int getFlags();
  
  public abstract IResource getResource();
  
  public abstract Subscriber getSubscriber();
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.ISubscriberChangeEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import java.util.EventListener;

public abstract interface ISubscriberChangeListener
  extends EventListener
{
  public abstract void subscriberResourceChanged(ISubscriberChangeEvent[] paramArrayOfISubscriberChangeEvent);
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.ISubscriberChangeListener
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import org.eclipse.core.runtime.ISafeRunnable;

class Subscriber$1
  implements ISafeRunnable
{
  final Subscriber this$0;
  private final ISubscriberChangeListener val$listener;
  private final ISubscriberChangeEvent[] val$deltas;
  
  Subscriber$1(Subscriber paramSubscriber, ISubscriberChangeListener paramISubscriberChangeListener, ISubscriberChangeEvent[] paramArrayOfISubscriberChangeEvent)
  {
    this$0 = paramSubscriber;val$listener = paramISubscriberChangeListener;val$deltas = paramArrayOfISubscriberChangeEvent;
  }
  
  public void handleException(Throwable exception) {}
  
  public void run()
    throws Exception
  {
    val$listener.subscriberResourceChanged(val$deltas);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.Subscriber.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IDiffVisitor;
import org.eclipse.team.core.diff.IThreeWayDiff;

class Subscriber$2
  implements IDiffVisitor
{
  final Subscriber this$0;
  private final int[] val$direction;
  private final int[] val$kind;
  
  Subscriber$2(Subscriber paramSubscriber, int[] paramArrayOfInt1, int[] paramArrayOfInt2)
  {
    this$0 = paramSubscriber;val$direction = paramArrayOfInt1;val$kind = paramArrayOfInt2;
  }
  
  public boolean visit(IDiff diff)
  {
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      val$direction[0] |= twd.getDirection();
    }
    int diffKind = diff.getKind();
    if (val$kind[0] == 0) {
      val$kind[0] = diffKind;
    }
    if (val$kind[0] != diffKind) {
      val$kind[0] = 4;
    }
    return diffKind == 4;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.Subscriber.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamStatus;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IDiffVisitor;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.core.variants.IResourceVariantComparator;
import org.eclipse.team.internal.core.Messages;
import org.eclipse.team.internal.core.Policy;
import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter;

public abstract class Subscriber
{
  private List listeners = new ArrayList(1);
  
  public abstract String getName();
  
  public abstract boolean isSupervised(IResource paramIResource)
    throws TeamException;
  
  public abstract IResource[] members(IResource paramIResource)
    throws TeamException;
  
  public abstract IResource[] roots();
  
  public abstract SyncInfo getSyncInfo(IResource paramIResource)
    throws TeamException;
  
  public abstract IResourceVariantComparator getResourceComparator();
  
  public abstract void refresh(IResource[] paramArrayOfIResource, int paramInt, IProgressMonitor paramIProgressMonitor)
    throws TeamException;
  
  public void addListener(ISubscriberChangeListener listener)
  {
    synchronized (listeners)
    {
      if (!listeners.contains(listener)) {
        listeners.add(listener);
      }
    }
  }
  
  public void removeListener(ISubscriberChangeListener listener)
  {
    synchronized (listeners)
    {
      listeners.remove(listener);
    }
  }
  
  /* Error */
  public void collectOutOfSync(IResource[] resources, int depth, SyncInfoSet set, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload 4
    //   2: aconst_null
    //   3: bipush 100
    //   5: aload_1
    //   6: arraylength
    //   7: imul
    //   8: invokeinterface 271 3 0
    //   13: iconst_0
    //   14: istore 5
    //   16: goto +47 -> 63
    //   19: aload_1
    //   20: iload 5
    //   22: aaload
    //   23: astore 6
    //   25: aload 4
    //   27: bipush 100
    //   29: invokestatic 257	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   32: astore 7
    //   34: aload 7
    //   36: aconst_null
    //   37: iconst_m1
    //   38: invokeinterface 271 3 0
    //   43: aload_0
    //   44: aload 6
    //   46: iload_2
    //   47: aload_3
    //   48: aload 7
    //   50: invokespecial 248	org/eclipse/team/core/subscribers/Subscriber:collect	(Lorg/eclipse/core/resources/IResource;ILorg/eclipse/team/core/synchronize/SyncInfoSet;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   53: aload 7
    //   55: invokeinterface 268 1 0
    //   60: iinc 5 1
    //   63: iload 5
    //   65: aload_1
    //   66: arraylength
    //   67: if_icmplt -48 -> 19
    //   70: goto +15 -> 85
    //   73: astore 8
    //   75: aload 4
    //   77: invokeinterface 268 1 0
    //   82: aload 8
    //   84: athrow
    //   85: aload 4
    //   87: invokeinterface 268 1 0
    //   92: return
    // Line number table:
    //   Java source line #254	-> byte code offset #0
    //   Java source line #255	-> byte code offset #13
    //   Java source line #256	-> byte code offset #19
    //   Java source line #257	-> byte code offset #25
    //   Java source line #258	-> byte code offset #34
    //   Java source line #259	-> byte code offset #43
    //   Java source line #260	-> byte code offset #53
    //   Java source line #255	-> byte code offset #60
    //   Java source line #262	-> byte code offset #73
    //   Java source line #263	-> byte code offset #75
    //   Java source line #264	-> byte code offset #82
    //   Java source line #263	-> byte code offset #85
    //   Java source line #265	-> byte code offset #92
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	93	0	this	Subscriber
    //   0	93	1	resources	IResource[]
    //   0	93	2	depth	int
    //   0	93	3	set	SyncInfoSet
    //   0	93	4	monitor	IProgressMonitor
    //   14	50	5	i	int
    //   23	22	6	resource	IResource
    //   32	22	7	subMonitor	IProgressMonitor
    //   73	10	8	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	73	73	finally
  }
  
  protected void fireTeamResourceChange(ISubscriberChangeEvent[] deltas)
  {
    ISubscriberChangeListener[] allListeners;
    synchronized (listeners)
    {
      allListeners = (ISubscriberChangeListener[])listeners.toArray(new ISubscriberChangeListener[listeners.size()]);
    }
    ISubscriberChangeListener[] allListeners;
    for (int i = 0; i < allListeners.length; i++)
    {
      ISubscriberChangeListener listener = allListeners[i];
      SafeRunner.run(new ISafeRunnable()
      {
        private final ISubscriberChangeListener val$listener;
        private final ISubscriberChangeEvent[] val$deltas;
        
        public void handleException(Throwable exception) {}
        
        public void run()
          throws Exception
        {
          val$listener.subscriberResourceChanged(val$deltas);
        }
      });
    }
  }
  
  private void collect(IResource resource, int depth, SyncInfoSet set, IProgressMonitor monitor)
  {
    Policy.checkCanceled(monitor);
    if ((resource.getType() != 1) && 
      (depth != 0)) {
      try
      {
        IResource[] members = members(resource);
        for (int i = 0; i < members.length; i++) {
          collect(
            members[i], 
            depth == 2 ? 
            2 : 
            0, 
            set, 
            monitor);
        }
      }
      catch (TeamException e)
      {
        set.addError(new TeamStatus(4, "org.eclipse.team.core", 2, NLS.bind(Messages.SubscriberEventHandler_8, new String[] { resource.getFullPath().toString(), e.getMessage() }), e, resource));
      }
    }
    monitor.subTask(NLS.bind(Messages.SubscriberEventHandler_2, new String[] { resource.getFullPath().toString() }));
    try
    {
      SyncInfo info = getSyncInfo(resource);
      if ((info == null) || (info.getKind() == 0)) {
        set.remove(resource);
      } else {
        set.add(info);
      }
    }
    catch (TeamException e)
    {
      set.addError(new TeamStatus(
        4, "org.eclipse.team.core", 1, 
        NLS.bind(Messages.SubscriberEventHandler_9, new String[] { resource.getFullPath().toString(), e.getMessage() }), 
        e, resource));
    }
    monitor.worked(1);
  }
  
  public IDiff getDiff(IResource resource)
    throws CoreException
  {
    SyncInfo info = getSyncInfo(resource);
    if ((info == null) || (info.getKind() == 0)) {
      return null;
    }
    return SyncInfoToDiffConverter.getDefault().getDeltaFor(info);
  }
  
  public void accept(ResourceTraversal[] traversals, IDiffVisitor visitor)
    throws CoreException
  {
    for (int i = 0; i < traversals.length; i++)
    {
      ResourceTraversal traversal = traversals[i];
      accept(traversal.getResources(), traversal.getDepth(), visitor);
    }
  }
  
  public void accept(IResource[] resources, int depth, IDiffVisitor visitor)
    throws CoreException
  {
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      accept(resource, depth, visitor);
    }
  }
  
  private void accept(IResource resource, int depth, IDiffVisitor visitor)
    throws CoreException
  {
    IDiff node = getDiff(resource);
    if ((node != null) && (node.getKind() != 0) && 
      (!visitor.visit(node))) {
      return;
    }
    if (depth != 0)
    {
      IResource[] members = members(resource);
      int newDepth = depth == 2 ? 2 : 0;
      for (int i = 0; i < members.length; i++)
      {
        IResource member = members[i];
        accept(member, newDepth, visitor);
      }
    }
  }
  
  public void refresh(ResourceTraversal[] traversals, IProgressMonitor monitor)
    throws TeamException
  {
    monitor.beginTask(null, 100 * traversals.length);
    for (int i = 0; i < traversals.length; i++)
    {
      ResourceTraversal traversal = traversals[i];
      refresh(traversal.getResources(), traversal.getDepth(), Policy.subMonitorFor(monitor, 100));
    }
    monitor.done();
  }
  
  public int getState(ResourceMapping mapping, int stateMask, IProgressMonitor monitor)
    throws CoreException
  {
    ResourceTraversal[] traversals = mapping.getTraversals(new SubscriberResourceMappingContext(this, true), monitor);
    int[] direction = new int[1];
    int[] kind = new int[1];
    accept(traversals, new IDiffVisitor()
    {
      private final int[] val$direction;
      private final int[] val$kind;
      
      public boolean visit(IDiff diff)
      {
        if ((diff instanceof IThreeWayDiff))
        {
          IThreeWayDiff twd = (IThreeWayDiff)diff;
          val$direction[0] |= twd.getDirection();
        }
        int diffKind = diff.getKind();
        if (val$kind[0] == 0) {
          val$kind[0] = diffKind;
        }
        if (val$kind[0] != diffKind) {
          val$kind[0] = 4;
        }
        return diffKind == 4;
      }
    });
    return (direction[0] | kind[0]) & stateMask;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.Subscriber
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import org.eclipse.core.resources.IResource;

public class SubscriberChangeEvent
  implements ISubscriberChangeEvent
{
  private Subscriber subscriber;
  private int flags;
  private IResource resource;
  
  public SubscriberChangeEvent(Subscriber subscriber, int flags, IResource resource)
  {
    this.subscriber = subscriber;
    this.flags = flags;
    this.resource = resource;
  }
  
  public int getFlags()
  {
    return flags;
  }
  
  public IResource getResource()
  {
    return resource;
  }
  
  public Subscriber getSubscriber()
  {
    return subscriber;
  }
  
  public static SubscriberChangeEvent[] asSyncChangedDeltas(Subscriber subscriber, IResource[] resources)
  {
    SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[resources.length];
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      deltas[i] = new SubscriberChangeEvent(subscriber, 1, resource);
    }
    return deltas;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberChangeEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ProgressMonitorWrapper;
import org.eclipse.team.core.diff.DiffFilter;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.core.mapping.provider.MergeContext;
import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.variants.IResourceVariantComparator;
import org.eclipse.team.internal.core.mapping.GroupProgressMonitor;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;

public abstract class SubscriberMergeContext
  extends MergeContext
{
  private Subscriber subscriber;
  private SubscriberDiffTreeEventHandler handler;
  private final ISynchronizationScopeManager manager;
  
  protected SubscriberMergeContext(Subscriber subscriber, ISynchronizationScopeManager manager)
  {
    super(manager, getType(subscriber), new ResourceDiffTree());
    this.subscriber = subscriber;
    this.manager = manager;
  }
  
  private static int getType(Subscriber subscriber)
  {
    return subscriber.getResourceComparator().isThreeWay() ? 
      3 : 2;
  }
  
  protected void initialize()
  {
    handler = new SubscriberDiffTreeEventHandler(subscriber, manager, (ResourceDiffTree)getDiffTree(), getDiffFilter());
    handler.setJobFamily(this);
    handler.start();
  }
  
  protected DiffFilter getDiffFilter()
  {
    return null;
  }
  
  public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor)
    throws CoreException
  {
    GroupProgressMonitor group = getGroup(monitor);
    if (group != null) {
      handler.setProgressGroupHint(group.getGroup(), group.getTicks());
    }
    handler.initializeIfNeeded();
    subscriber.refresh(traversals, monitor);
  }
  
  private GroupProgressMonitor getGroup(IProgressMonitor monitor)
  {
    if ((monitor instanceof GroupProgressMonitor)) {
      return (GroupProgressMonitor)monitor;
    }
    if ((monitor instanceof ProgressMonitorWrapper))
    {
      ProgressMonitorWrapper wrapper = (ProgressMonitorWrapper)monitor;
      return getGroup(wrapper.getWrappedProgressMonitor());
    }
    return null;
  }
  
  public void dispose()
  {
    handler.shutdown();
    super.dispose();
  }
  
  protected SyncInfo getSyncInfo(IResource resource)
    throws CoreException
  {
    return handler.getSubscriber().getSyncInfo(resource);
  }
  
  public Subscriber getSubscriber()
  {
    return subscriber;
  }
  
  protected void runInBackground(IWorkspaceRunnable runnable)
  {
    handler.run(runnable, false);
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == SubscriberDiffTreeEventHandler.class) {
      return handler;
    }
    return super.getAdapter(adapter);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberMergeContext
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.core.variants.IResourceVariantComparator;
import org.eclipse.team.internal.core.Messages;
import org.eclipse.team.internal.core.Policy;

public class SubscriberResourceMappingContext
  extends RemoteResourceMappingContext
{
  private final Subscriber subscriber;
  private Set shallowRefresh = new HashSet();
  private Set deepRefresh = new HashSet();
  private boolean autoRefresh;
  
  public static RemoteResourceMappingContext createContext(Subscriber subscriber)
  {
    return new SubscriberResourceMappingContext(subscriber, true);
  }
  
  public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh)
  {
    this.subscriber = subscriber;
    this.autoRefresh = autoRefresh;
  }
  
  public final boolean hasRemoteChange(IResource resource, IProgressMonitor monitor)
    throws CoreException
  {
    try
    {
      monitor.beginTask(null, 100);
      ensureRefreshed(resource, 1, 0, monitor);
      SyncInfo syncInfo = subscriber.getSyncInfo(resource);
      validateRemote(resource, syncInfo);
      if (syncInfo == null) {
        return false;
      }
      int direction = SyncInfo.getDirection(syncInfo.getKind());
      return (direction == 8) || (direction == 12);
    }
    finally
    {
      monitor.done();
    }
  }
  
  public boolean hasLocalChange(IResource resource, IProgressMonitor monitor)
    throws CoreException
  {
    SyncInfo syncInfo = subscriber.getSyncInfo(resource);
    if (syncInfo == null) {
      return false;
    }
    int direction = SyncInfo.getDirection(syncInfo.getKind());
    return (direction == 4) || (direction == 12);
  }
  
  public final IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor)
    throws CoreException
  {
    try
    {
      monitor.beginTask(null, 100);
      ensureRefreshed(file, 0, 1, Policy.subMonitorFor(monitor, 10));
      SyncInfo syncInfo = subscriber.getSyncInfo(file);
      IResourceVariant remote = validateRemote(file, syncInfo);
      if (remote == null) {
        return null;
      }
      return remote.getStorage(Policy.subMonitorFor(monitor, 90));
    }
    finally
    {
      monitor.done();
    }
  }
  
  public final IStorage fetchBaseContents(IFile file, IProgressMonitor monitor)
    throws CoreException
  {
    try
    {
      monitor.beginTask(null, 100);
      ensureRefreshed(file, 0, 1, Policy.subMonitorFor(monitor, 10));
      SyncInfo syncInfo = subscriber.getSyncInfo(file);
      IResourceVariant base = validateBase(file, syncInfo);
      if (base == null) {
        return null;
      }
      return base.getStorage(Policy.subMonitorFor(monitor, 90));
    }
    finally
    {
      monitor.done();
    }
  }
  
  public final IResource[] fetchMembers(IContainer container, IProgressMonitor monitor)
    throws CoreException
  {
    try
    {
      monitor.beginTask(null, 100);
      ensureRefreshed(container, 1, 0, Policy.subMonitorFor(monitor, 100));
      SyncInfo syncInfo = subscriber.getSyncInfo(container);
      IResource[] arrayOfIResource;
      if (validateRemote(container, syncInfo) == null) {
        return new IResource[0];
      }
      return subscriber.members(container);
    }
    finally
    {
      monitor.done();
    }
  }
  
  public final void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor)
    throws CoreException
  {
    subscriber.refresh(traversals, monitor);
    for (int i = 0; i < traversals.length; i++)
    {
      ResourceTraversal traversal = traversals[i];
      refreshed(traversal.getResources(), traversal.getDepth());
    }
  }
  
  protected void refresh(IResource[] resources, int depth, int flags, IProgressMonitor monitor)
    throws TeamException
  {
    subscriber.refresh(resources, depth, monitor);
    refreshed(resources, depth);
  }
  
  protected final void refreshed(IResource[] resources, int depth)
  {
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      if ((depth == 1) || (resource.getType() == 1)) {
        shallowRefresh.add(resource);
      } else if (depth == 2) {
        deepRefresh.add(resource);
      }
    }
  }
  
  private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor)
    throws TeamException
  {
    if (autoRefresh)
    {
      if (depth == 2)
      {
        if (wasRefreshedDeeply(resource)) {
          return;
        }
        if ((resource.getType() != 1) || (!wasRefreshedShallow(resource))) {}
      }
      else if (wasRefreshedShallow(resource))
      {
        return;
      }
      refresh(new IResource[] { resource }, depth, flags, monitor);
    }
  }
  
  private boolean wasRefreshedShallow(IResource resource)
  {
    if (shallowRefresh.contains(resource)) {
      return true;
    }
    if ((resource.getType() == 1) && (shallowRefresh.contains(resource.getParent()))) {
      return true;
    }
    if (wasRefreshedDeeply(resource)) {
      return true;
    }
    return false;
  }
  
  private boolean wasRefreshedDeeply(IResource resource)
  {
    if (resource.getType() == 8) {
      return false;
    }
    if (deepRefresh.contains(resource)) {
      return true;
    }
    return wasRefreshedDeeply(resource.getParent());
  }
  
  private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo)
    throws CoreException
  {
    if (syncInfo == null) {
      return null;
    }
    IResourceVariant remote = syncInfo.getRemote();
    if (remote == null) {
      return null;
    }
    return validateRemote(resource, remote);
  }
  
  private IResourceVariant validateRemote(IResource resource, IResourceVariant remote)
    throws CoreException
  {
    boolean containerExpected = resource.getType() != 1;
    if ((remote.isContainer()) && (!containerExpected)) {
      throw new CoreException(new Status(4, "org.eclipse.team.core", 366, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null));
    }
    if ((!remote.isContainer()) && (containerExpected)) {
      throw new CoreException(new Status(4, "org.eclipse.team.core", 366, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null));
    }
    return remote;
  }
  
  private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo)
    throws CoreException
  {
    if (syncInfo == null) {
      return null;
    }
    IResourceVariant base = syncInfo.getBase();
    if (base == null) {
      return null;
    }
    return validateRemote(resource, base);
  }
  
  public void setAutoRefresh(boolean autoRefresh)
  {
    this.autoRefresh = autoRefresh;
  }
  
  public boolean isThreeWay()
  {
    return subscriber.getResourceComparator().isThreeWay();
  }
  
  public boolean contentDiffers(IFile file, IProgressMonitor monitor)
    throws CoreException
  {
    return (hasRemoteChange(file, monitor)) || (hasLocalChange(file, monitor));
  }
  
  public IProject[] getProjects()
  {
    Set projects = new HashSet();
    IResource[] roots = subscriber.roots();
    for (int i = 0; i < roots.length; i++)
    {
      IResource resource = roots[i];
      projects.add(resource.getProject());
    }
    return (IProject[])projects.toArray(new IProject[projects.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberResourceMappingContext
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;

class SubscriberScopeManager$1
  implements IWorkspaceRunnable
{
  final SubscriberScopeManager this$0;
  
  SubscriberScopeManager$1(SubscriberScopeManager paramSubscriberScopeManager)
  {
    this$0 = paramSubscriberScopeManager;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    SubscriberScopeManager.access$0(this$0, monitor);
    this$0.hookupParticipants();
    this$0.getSubscriber().addListener(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberScopeManager.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import java.util.List;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;

class SubscriberScopeManager$2
  implements IWorkspaceRunnable
{
  final SubscriberScopeManager this$0;
  private final List val$result;
  private final ResourceMapping[] val$mappings;
  
  SubscriberScopeManager$2(SubscriberScopeManager paramSubscriberScopeManager, List paramList, ResourceMapping[] paramArrayOfResourceMapping)
  {
    this$0 = paramSubscriberScopeManager;val$result = paramList;val$mappings = paramArrayOfResourceMapping;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    val$result.add(SubscriberScopeManager.access$1(this$0, val$mappings, monitor));
    this$0.hookupParticipants();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberScopeManager.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.team.core.mapping.ISynchronizationScopeParticipant;

class SubscriberScopeManager$3
  implements ISafeRunnable
{
  final SubscriberScopeManager this$0;
  private final ISynchronizationScopeParticipant val$participant;
  private final IResource[] val$resources;
  private final IProject[] val$projects;
  private final Set val$result;
  
  SubscriberScopeManager$3(SubscriberScopeManager paramSubscriberScopeManager, ISynchronizationScopeParticipant paramISynchronizationScopeParticipant, IResource[] paramArrayOfIResource, IProject[] paramArrayOfIProject, Set paramSet)
  {
    this$0 = paramSubscriberScopeManager;val$participant = paramISynchronizationScopeParticipant;val$resources = paramArrayOfIResource;val$projects = paramArrayOfIProject;val$result = paramSet;
  }
  
  public void run()
    throws Exception
  {
    ResourceMapping[] mappings = val$participant.handleContextChange(this$0.getScope(), val$resources, val$projects);
    for (int j = 0; j < mappings.length; j++)
    {
      ResourceMapping mapping = mappings[j];
      val$result.add(mapping);
    }
  }
  
  public void handleException(Throwable exception) {}
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberScopeManager.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.subscribers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.ISynchronizationScopeParticipant;
import org.eclipse.team.core.mapping.ISynchronizationScopeParticipantFactory;
import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;

public class SubscriberScopeManager
  extends SynchronizationScopeManager
  implements ISubscriberChangeListener
{
  private final Subscriber subscriber;
  private Map participants = new HashMap();
  
  public SubscriberScopeManager(String name, ResourceMapping[] inputMappings, Subscriber subscriber, boolean consultModels)
  {
    this(name, inputMappings, subscriber, SubscriberResourceMappingContext.createContext(subscriber), consultModels);
  }
  
  public SubscriberScopeManager(String name, ResourceMapping[] inputMappings, Subscriber subscriber, RemoteResourceMappingContext context, boolean consultModels)
  {
    super(name, inputMappings, context, consultModels);
    this.subscriber = subscriber;
  }
  
  protected Subscriber getSubscriber()
  {
    return subscriber;
  }
  
  public void dispose()
  {
    for (Iterator iter = participants.values().iterator(); iter.hasNext();)
    {
      ISynchronizationScopeParticipant p = (ISynchronizationScopeParticipant)iter.next();
      p.dispose();
    }
    super.dispose();
  }
  
  public void initialize(IProgressMonitor monitor)
    throws CoreException
  {
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable()
    {
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        SubscriberScopeManager.this.initialize(monitor);
        hookupParticipants();
        getSubscriber().addListener(SubscriberScopeManager.this);
      }
    }, getSchedulingRule(), 0, monitor);
  }
  
  public ResourceTraversal[] refresh(ResourceMapping[] mappings, IProgressMonitor monitor)
    throws CoreException
  {
    List result = new ArrayList(1);
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable()
    {
      private final List val$result;
      private final ResourceMapping[] val$mappings;
      
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        val$result.add(SubscriberScopeManager.this.refresh(val$mappings, monitor));
        hookupParticipants();
      }
    }, getSchedulingRule(), 0, monitor);
    if (result.isEmpty()) {
      return new ResourceTraversal[0];
    }
    return (ResourceTraversal[])result.get(0);
  }
  
  void hookupParticipants()
  {
    ModelProvider[] providers = getScope().getModelProviders();
    for (int i = 0; i < providers.length; i++)
    {
      ModelProvider provider = providers[i];
      if (!participants.containsKey(provider))
      {
        ISynchronizationScopeParticipant p = createParticipant(provider);
        if (p != null) {
          participants.put(provider, p);
        }
      }
    }
  }
  
  private ISynchronizationScopeParticipant createParticipant(ModelProvider provider)
  {
    Object factoryObject = provider.getAdapter(ISynchronizationScopeParticipantFactory.class);
    if ((factoryObject instanceof ISynchronizationScopeParticipantFactory))
    {
      ISynchronizationScopeParticipantFactory factory = (ISynchronizationScopeParticipantFactory)factoryObject;
      return factory.createParticipant(provider, getScope());
    }
    return null;
  }
  
  public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas)
  {
    List changedResources = new ArrayList();
    List changedProjects = new ArrayList();
    for (int i = 0; i < deltas.length; i++)
    {
      ISubscriberChangeEvent event = deltas[i];
      if ((event.getFlags() & 0x6) != 0) {
        changedProjects.add(event.getResource().getProject());
      }
      if ((event.getFlags() & 0x1) != 0) {
        changedResources.add(event.getResource());
      }
    }
    fireChange((IResource[])changedResources.toArray(new IResource[changedResources.size()]), (IProject[])changedProjects.toArray(new IProject[changedProjects.size()]));
  }
  
  private void fireChange(IResource[] resources, IProject[] projects)
  {
    Set result = new HashSet();
    ISynchronizationScopeParticipant[] handlers = (ISynchronizationScopeParticipant[])participants.values().toArray(new ISynchronizationScopeParticipant[participants.size()]);
    for (int i = 0; i < handlers.length; i++)
    {
      ISynchronizationScopeParticipant participant = handlers[i];
      SafeRunner.run(new ISafeRunnable()
      {
        private final ISynchronizationScopeParticipant val$participant;
        private final IResource[] val$resources;
        private final IProject[] val$projects;
        private final Set val$result;
        
        public void run()
          throws Exception
        {
          ResourceMapping[] mappings = val$participant.handleContextChange(getScope(), val$resources, val$projects);
          for (int j = 0; j < mappings.length; j++)
          {
            ResourceMapping mapping = mappings[j];
            val$result.add(mapping);
          }
        }
        
        public void handleException(Throwable exception) {}
      });
    }
    if (!result.isEmpty()) {
      refresh((ResourceMapping[])result.toArray(new ResourceMapping[result.size()]));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.subscribers.SubscriberScopeManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.synchronize;

public class FastSyncInfoFilter$AndSyncInfoFilter
  extends FastSyncInfoFilter.CompoundSyncInfoFilter
{
  public FastSyncInfoFilter$AndSyncInfoFilter(FastSyncInfoFilter[] filters)
  {
    super(filters);
  }
  
  public boolean select(SyncInfo info)
  {
    
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd