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

on: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.core.mapping;

import java.util.Date;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.IResourceVariant;

public class LocalResourceVariant
  implements IResourceVariant
{
  private final IResource resource;
  
  public LocalResourceVariant(IResource resource)
  {
    this.resource = resource;
  }
  
  public byte[] asBytes()
  {
    return getContentIdentifier().getBytes();
  }
  
  public String getContentIdentifier()
  {
    return new Date(resource.getLocalTimeStamp()).toString();
  }
  
  public IStorage getStorage(IProgressMonitor monitor)
    throws TeamException
  {
    if (resource.getType() == 1) {
      return (IFile)resource;
    }
    return null;
  }
  
  public boolean isContainer()
  {
    return resource.getType() != 1;
  }
  
  public String getName()
  {
    return resource.getName();
  }
}

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

import java.util.HashSet;
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.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
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.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.core.Policy;
import org.eclipse.team.internal.core.TeamPlugin;

public class ModelProviderResourceMapping
  extends ResourceMapping
{
  ModelProvider provider;
  
  public ModelProviderResourceMapping(ModelProvider provider)
  {
    this.provider = provider;
  }
  
  public Object getModelObject()
  {
    return provider;
  }
  
  public String getModelProviderId()
  {
    return "org.eclipse.core.resources.modelProvider";
  }
  
  public IProject[] getProjects()
  {
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    try
    {
      IResource[] resources = provider.getDescriptor().getMatchingResources(projects);
      Set result = new HashSet();
      for (int i = 0; i < resources.length; i++)
      {
        IResource resource = resources[i];
        if (resource.isAccessible()) {
          result.add(resource.getProject());
        }
      }
      return (IProject[])result.toArray(new IProject[result.size()]);
    }
    catch (CoreException e)
    {
      TeamPlugin.log(e);
    }
    return projects;
  }
  
  public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException
  {
    monitor = Policy.monitorFor(monitor);
    try
    {
      monitor.beginTask(null, 100);
      ResourceMapping[] mappings = provider.getMappings(getProviderResources(context), context, Policy.subMonitorFor(monitor, 50));
      return provider.getTraversals(mappings, context, Policy.subMonitorFor(monitor, 50));
    }
    finally
    {
      monitor.done();
    }
  }
  
  private IResource[] getProviderResources(ResourceMappingContext context)
  {
    try
    {
      if ((context instanceof RemoteResourceMappingContext))
      {
        RemoteResourceMappingContext rrmc = (RemoteResourceMappingContext)context;
        return provider.getDescriptor().getMatchingResources(rrmc.getProjects());
      }
    }
    catch (CoreException e)
    {
      TeamPlugin.log(e);
    }
    return getProjects();
  }
  
  public boolean contains(ResourceMapping mapping)
  {
    return mapping.getModelProviderId().equals(getModelProviderId());
  }
}

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

import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.runtime.IPath;

class PathTree$Node
{
  Object payload;
  Set descendantsWithPayload;
  int flags;
  final PathTree this$0;
  
  PathTree$Node(PathTree paramPathTree)
  {
    this$0 = paramPathTree;
  }
  
  public boolean isEmpty()
  {
    return (payload == null) && ((descendantsWithPayload == null) || (descendantsWithPayload.isEmpty()));
  }
  
  public Object getPayload()
  {
    return payload;
  }
  
  public void setPayload(Object payload)
  {
    this.payload = payload;
  }
  
  public boolean hasDescendants()
  {
    return (descendantsWithPayload != null) && (!descendantsWithPayload.isEmpty());
  }
  
  public boolean hasFlag(int propertyBit)
  {
    return (flags & propertyBit) != 0;
  }
  
  public void setProperty(int propertyBit, boolean value)
  {
    if (value) {
      flags |= propertyBit;
    } else {
      flags ^= propertyBit;
    }
  }
  
  public boolean descendantHasFlag(int property)
  {
    if (hasDescendants()) {
      for (Iterator iter = descendantsWithPayload.iterator(); iter.hasNext();)
      {
        IPath path = (IPath)iter.next();
        Node child = PathTree.access$0(this$0, path);
        if (child.hasFlag(property)) {
          return true;
        }
      }
    }
    return false;
  }
}

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

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.runtime.IPath;

public class PathTree
{
  class Node
  {
    Object payload;
    Set descendantsWithPayload;
    int flags;
    
    Node() {}
    
    public boolean isEmpty()
    {
      return (payload == null) && ((descendantsWithPayload == null) || (descendantsWithPayload.isEmpty()));
    }
    
    public Object getPayload()
    {
      return payload;
    }
    
    public void setPayload(Object payload)
    {
      this.payload = payload;
    }
    
    public boolean hasDescendants()
    {
      return (descendantsWithPayload != null) && (!descendantsWithPayload.isEmpty());
    }
    
    public boolean hasFlag(int propertyBit)
    {
      return (flags & propertyBit) != 0;
    }
    
    public void setProperty(int propertyBit, boolean value)
    {
      if (value) {
        flags |= propertyBit;
      } else {
        flags ^= propertyBit;
      }
    }
    
    public boolean descendantHasFlag(int property)
    {
      if (hasDescendants()) {
        for (Iterator iter = descendantsWithPayload.iterator(); iter.hasNext();)
        {
          IPath path = (IPath)iter.next();
          Node child = PathTree.this.getNode(path);
          if (child.hasFlag(property)) {
            return true;
          }
        }
      }
      return false;
    }
  }
  
  private Map objects = new HashMap();
  
  public synchronized Object get(IPath path)
  {
    Node node = getNode(path);
    if (node == null) {
      return null;
    }
    return node.getPayload();
  }
  
  public synchronized Object put(IPath path, Object object)
  {
    Node node = getNode(path);
    if (node == null) {
      node = addNode(path);
    }
    Object previous = node.getPayload();
    node.setPayload(object);
    if (previous == null) {
      addToParents(path, path);
    }
    return previous;
  }
  
  public synchronized Object remove(IPath path)
  {
    Node node = getNode(path);
    if (node == null) {
      return null;
    }
    Object previous = node.getPayload();
    node.setPayload(null);
    if (previous != null)
    {
      removeFromParents(path, path);
      if (node.isEmpty()) {
        removeNode(path);
      }
    }
    return previous;
  }
  
  public synchronized boolean hasChildren(IPath path)
  {
    if (path.isEmpty()) {
      return !objects.isEmpty();
    }
    Node node = getNode(path);
    if (node == null) {
      return false;
    }
    return node.hasDescendants();
  }
  
  public synchronized IPath[] getChildren(IPath path)
  {
    Set children = new HashSet();
    Node node = getNode(path);
    if (node != null)
    {
      Set possibleChildren = descendantsWithPayload;
      if (possibleChildren != null) {
        for (Iterator it = possibleChildren.iterator(); it.hasNext();)
        {
          Object next = it.next();
          IPath descendantPath = (IPath)next;
          IPath childPath = null;
          if (descendantPath.segmentCount() == path.segmentCount() + 1) {
            childPath = descendantPath;
          } else if (descendantPath.segmentCount() > path.segmentCount()) {
            childPath = descendantPath.removeLastSegments(descendantPath.segmentCount() - path.segmentCount() - 1);
          }
          if (childPath != null) {
            children.add(childPath);
          }
        }
      }
    }
    return (IPath[])children.toArray(new IPath[children.size()]);
  }
  
  private boolean addToParents(IPath path, IPath parent)
  {
    boolean addedParent = false;
    if (path == parent)
    {
      addedParent = true;
    }
    else
    {
      Node node = getNode(parent);
      if (node == null) {
        node = addNode(parent);
      }
      Set children = descendantsWithPayload;
      if (children == null)
      {
        children = new HashSet();
        descendantsWithPayload = children;
        
        addedParent = true;
      }
      children.add(path);
    }
    if ((parent.segmentCount() != 0) && (!addToParents(path, parent.removeLastSegments(1)))) {}
    return addedParent;
  }
  
  private boolean removeFromParents(IPath path, IPath parent)
  {
    boolean removedParent = false;
    Node node = getNode(parent);
    if (node == null)
    {
      removedParent = true;
    }
    else
    {
      Set children = descendantsWithPayload;
      if (children == null)
      {
        removedParent = true;
      }
      else
      {
        children.remove(path);
        if (children.isEmpty())
        {
          descendantsWithPayload = null;
          if (node.isEmpty()) {
            removeNode(parent);
          }
          removedParent = true;
        }
      }
    }
    if ((parent.segmentCount() != 0) && (!removeFromParents(path, parent.removeLastSegments(1)))) {}
    return removedParent;
  }
  
  public synchronized void clear()
  {
    objects.clear();
  }
  
  public synchronized boolean isEmpty()
  {
    return objects.isEmpty();
  }
  
  public synchronized IPath[] getPaths()
  {
    List result = new ArrayList();
    for (Iterator iter = objects.keySet().iterator(); iter.hasNext();)
    {
      IPath path = (IPath)iter.next();
      Node node = getNode(path);
      if (node.getPayload() != null) {
        result.add(path);
      }
    }
    return (IPath[])result.toArray(new IPath[result.size()]);
  }
  
  public synchronized Collection values()
  {
    List result = new ArrayList();
    for (Iterator iter = objects.keySet().iterator(); iter.hasNext();)
    {
      IPath path = (IPath)iter.next();
      Node node = getNode(path);
      if (node.getPayload() != null) {
        result.add(node.getPayload());
      }
    }
    return result;
  }
  
  public int size()
  {
    return values().size();
  }
  
  private Node getNode(IPath path)
  {
    return (Node)objects.get(path);
  }
  
  private Node addNode(IPath path)
  {
    Node node = new Node();
    objects.put(path, node);
    return node;
  }
  
  private Object removeNode(IPath path)
  {
    return objects.remove(path);
  }
  
  public synchronized IPath[] setPropogatedProperty(IPath path, int property, boolean value)
  {
    Set changed = new HashSet();
    internalSetPropertyBit(path, property, value, changed);
    return (IPath[])changed.toArray(new IPath[changed.size()]);
  }
  
  private void internalSetPropertyBit(IPath path, int property, boolean value, Set changed)
  {
    if (path.segmentCount() == 0) {
      return;
    }
    Node node = getNode(path);
    if (node == null) {
      return;
    }
    if (value == node.hasFlag(property)) {
      return;
    }
    if ((!value) && (node.descendantHasFlag(property))) {
      return;
    }
    node.setProperty(property, value);
    changed.add(path);
    internalSetPropertyBit(path.removeLastSegments(1), property, value, changed);
  }
  
  public synchronized boolean getProperty(IPath path, int property)
  {
    if (path.segmentCount() == 0) {
      return false;
    }
    Node node = getNode(path);
    if (node == null) {
      return false;
    }
    return node.hasFlag(property);
  }
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.team.core.mapping.ISynchronizationScope;

public class ResourceMappingInputScope
  extends AbstractResourceMappingScope
{
  ISynchronizationScope wrappedScope;
  
  public ResourceMappingInputScope(ISynchronizationScope wrappedScope)
  {
    this.wrappedScope = wrappedScope;
  }
  
  public ResourceMapping[] getInputMappings()
  {
    return wrappedScope.getInputMappings();
  }
  
  public ResourceMapping[] getMappings()
  {
    return getInputMappings();
  }
  
  public ResourceTraversal[] getTraversals()
  {
    CompoundResourceTraversal result = new CompoundResourceTraversal();
    ResourceMapping[] mappings = getMappings();
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping mapping = mappings[i];
      ResourceTraversal[] traversals = getTraversals(mapping);
      result.addTraversals(traversals);
    }
    return result.asTraversals();
  }
  
  public ResourceTraversal[] getTraversals(ResourceMapping mapping)
  {
    if (!contains(mapping)) {
      return null;
    }
    return wrappedScope.getTraversals(mapping);
  }
  
  private boolean contains(ResourceMapping mapping)
  {
    ResourceMapping[] mappings = getMappings();
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping child = mappings[i];
      if (child.equals(mapping)) {
        return true;
      }
    }
    return false;
  }
  
  public boolean hasAdditionalMappings()
  {
    return false;
  }
  
  public boolean hasAdditonalResources()
  {
    return false;
  }
  
  public ISynchronizationScope asInputScope()
  {
    return this;
  }
  
  public IProject[] getProjects()
  {
    return wrappedScope.getProjects();
  }
  
  public ResourceMappingContext getContext()
  {
    return wrappedScope.getContext();
  }
  
  public void refresh(ResourceMapping[] mappings)
  {
    wrappedScope.refresh(mappings);
  }
}

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

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;

public class ResourceMappingScope
  extends AbstractResourceMappingScope
{
  private ResourceMapping[] inputMappings;
  private final Map mappingsToTraversals = Collections.synchronizedMap(new HashMap());
  private boolean hasAdditionalMappings;
  private boolean hasAdditionalResources;
  private final CompoundResourceTraversal compoundTraversal = new CompoundResourceTraversal();
  private final SynchronizationScopeManager manager;
  
  public ResourceMappingScope(ResourceMapping[] selectedMappings, SynchronizationScopeManager manager)
  {
    inputMappings = selectedMappings;
    this.manager = manager;
  }
  
  public ResourceTraversal[] addMapping(ResourceMapping mapping, ResourceTraversal[] traversals)
  {
    ResourceTraversal[] newTraversals = compoundTraversal.getUncoveredTraversals(traversals);
    mappingsToTraversals.put(mapping, traversals);
    compoundTraversal.addTraversals(traversals);
    return newTraversals;
  }
  
  public ResourceMapping[] getInputMappings()
  {
    return inputMappings;
  }
  
  public ResourceMapping[] getMappings()
  {
    if (mappingsToTraversals.isEmpty()) {
      return inputMappings;
    }
    return (ResourceMapping[])mappingsToTraversals.keySet().toArray(new ResourceMapping[mappingsToTraversals.size()]);
  }
  
  public ResourceTraversal[] getTraversals()
  {
    return compoundTraversal.asTraversals();
  }
  
  public ResourceTraversal[] getTraversals(ResourceMapping mapping)
  {
    return (ResourceTraversal[])mappingsToTraversals.get(mapping);
  }
  
  public boolean hasAdditionalMappings()
  {
    return hasAdditionalMappings;
  }
  
  public void setHasAdditionalMappings(boolean hasAdditionalMappings)
  {
    this.hasAdditionalMappings = hasAdditionalMappings;
  }
  
  public void setHasAdditionalResources(boolean hasAdditionalResources)
  {
    this.hasAdditionalResources = hasAdditionalResources;
  }
  
  public boolean hasAdditonalResources()
  {
    return hasAdditionalResources;
  }
  
  public CompoundResourceTraversal getCompoundTraversal()
  {
    return compoundTraversal;
  }
  
  public ISynchronizationScope asInputScope()
  {
    return new ResourceMappingInputScope(this);
  }
  
  public IProject[] getProjects()
  {
    ResourceMappingContext context = getContext();
    if ((context instanceof RemoteResourceMappingContext))
    {
      RemoteResourceMappingContext rrmc = (RemoteResourceMappingContext)context;
      return rrmc.getProjects();
    }
    return ResourcesPlugin.getWorkspace().getRoot().getProjects();
  }
  
  public ResourceMappingContext getContext()
  {
    return manager.getContext();
  }
  
  public void refresh(ResourceMapping[] mappings)
  {
    manager.refresh(mappings);
  }
  
  public void reset()
  {
    mappingsToTraversals.clear();
    compoundTraversal.clear();
    hasAdditionalMappings = false;
    hasAdditionalResources = false;
  }
}

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

import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.history.provider.FileRevision;
import org.eclipse.team.core.variants.IResourceVariant;

public class ResourceVariantFileRevision
  extends FileRevision
  implements IAdaptable
{
  private final IResourceVariant variant;
  
  public ResourceVariantFileRevision(IResourceVariant variant)
  {
    this.variant = variant;
  }
  
  public IStorage getStorage(IProgressMonitor monitor)
    throws CoreException
  {
    return variant.getStorage(monitor);
  }
  
  public String getName()
  {
    return variant.getName();
  }
  
  public String getContentIdentifier()
  {
    return variant.getContentIdentifier();
  }
  
  public IResourceVariant getVariant()
  {
    return variant;
  }
  
  public boolean isPropertyMissing()
  {
    return false;
  }
  
  public IFileRevision withAllProperties(IProgressMonitor monitor)
    throws CoreException
  {
    return this;
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == IResourceVariant.class) {
      return variant;
    }
    Object object = Platform.getAdapterManager().getAdapter(this, adapter);
    if (object != null) {
      return object;
    }
    if ((variant instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)variant;
      return adaptable.getAdapter(adapter);
    }
    return null;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof ResourceVariantFileRevision))
    {
      ResourceVariantFileRevision fileRevision = (ResourceVariantFileRevision)obj;
      return fileRevision.getVariant().equals(getVariant());
    }
    return false;
  }
  
  public int hashCode()
  {
    return getVariant().hashCode();
  }
}

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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.team.core.mapping.ISynchronizationScope;

public class ScopeChangeEvent
{
  private final ISynchronizationScope scope;
  private final ResourceMapping[] originalMappings;
  private final ResourceTraversal[] originalTraversals;
  private boolean expanded;
  private boolean contracted;
  
  public ScopeChangeEvent(ISynchronizationScope scope)
  {
    this.scope = scope;
    originalMappings = scope.getMappings();
    originalTraversals = scope.getTraversals();
  }
  
  public boolean hasAdditionalMappings()
  {
    return scope.getMappings().length > originalMappings.length;
  }
  
  public ResourceTraversal[] getUncoveredTraversals(CompoundResourceTraversal traversal)
  {
    CompoundResourceTraversal originals = new CompoundResourceTraversal();
    originals.addTraversals(originalTraversals);
    return originals.getUncoveredTraversals(traversal);
  }
  
  public void setExpanded(boolean expanded)
  {
    this.expanded = expanded;
  }
  
  public boolean isExpanded()
  {
    return expanded;
  }
  
  public void setContracted(boolean contracted)
  {
    this.contracted = contracted;
  }
  
  public boolean isContracted()
  {
    return contracted;
  }
  
  public ResourceMapping[] getChangedMappings()
  {
    ResourceMapping[] currentMappings = scope.getMappings();
    ResourceMapping[] changedMappings;
    ResourceMapping[] changedMappings;
    if (currentMappings.length > originalMappings.length)
    {
      Set originalSet = new HashSet();
      List result = new ArrayList();
      for (int i = 0; i < originalMappings.length; i++)
      {
        ResourceMapping mapping = originalMappings[i];
        originalSet.add(mapping);
      }
      for (int i = 0; i < currentMappings.length; i++)
      {
        ResourceMapping mapping = currentMappings[i];
        if (!originalSet.contains(mapping)) {
          result.add(mapping);
        }
      }
      changedMappings = (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
    }
    else
    {
      ResourceMapping[] changedMappings;
      if (isContracted())
      {
        Set finalSet = new HashSet();
        List result = new ArrayList();
        for (int i = 0; i < currentMappings.length; i++)
        {
          ResourceMapping mapping = currentMappings[i];
          finalSet.add(mapping);
        }
        for (int i = 0; i < originalMappings.length; i++)
        {
          ResourceMapping mapping = originalMappings[i];
          if (!finalSet.contains(mapping)) {
            result.add(mapping);
          }
        }
        changedMappings = (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
      }
      else
      {
        changedMappings = new ResourceMapping[0];
      }
    }
    return changedMappings;
  }
  
  public ResourceTraversal[] getChangedTraversals(CompoundResourceTraversal refreshTraversals)
  {
    ResourceTraversal[] changesTraversals;
    ResourceTraversal[] changesTraversals;
    if (isExpanded())
    {
      changesTraversals = getUncoveredTraversals(refreshTraversals);
    }
    else
    {
      ResourceTraversal[] changesTraversals;
      if (isContracted())
      {
        CompoundResourceTraversal finalTraversals = new CompoundResourceTraversal();
        finalTraversals.addTraversals(scope.getTraversals());
        changesTraversals = finalTraversals.getUncoveredTraversals(originalTraversals);
      }
      else
      {
        changesTraversals = new ResourceTraversal[0];
      }
    }
    return changesTraversals;
  }
  
  public boolean shouldFireChange()
  {
    return (isExpanded()) || (isContracted()) || (hasAdditionalMappings());
  }
}

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

import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.team.internal.core.BackgroundEventHandler.Event;

class ScopeManagerEventHandler$ResourceMappingEvent
  extends BackgroundEventHandler.Event
{
  private final ResourceMapping[] mappings;
  final ScopeManagerEventHandler this$0;
  
  public ScopeManagerEventHandler$ResourceMappingEvent(ScopeManagerEventHandler paramScopeManagerEventHandler, ResourceMapping[] mappings)
  {
    super(10);this$0 = paramScopeManagerEventHandler;
    this.mappings = mappings;
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;
import org.eclipse.team.internal.core.BackgroundEventHandler;
import org.eclipse.team.internal.core.BackgroundEventHandler.Event;
import org.eclipse.team.internal.core.Messages;

public class ScopeManagerEventHandler
  extends BackgroundEventHandler
{
  public static final int REFRESH = 10;
  private Set toRefresh = new HashSet();
  private ISynchronizationScopeManager manager;
  
  class ResourceMappingEvent
    extends BackgroundEventHandler.Event
  {
    private final ResourceMapping[] mappings;
    
    public ResourceMappingEvent(ResourceMapping[] mappings)
    {
      super();
      this.mappings = mappings;
    }
  }
  
  public ScopeManagerEventHandler(SynchronizationScopeManager manager)
  {
    super(NLS.bind(Messages.ScopeManagerEventHandler_0, manager.getName()), NLS.bind(Messages.ScopeManagerEventHandler_1, manager.getName()));
    this.manager = manager;
  }
  
  protected boolean doDispatchEvents(IProgressMonitor monitor)
    throws TeamException
  {
    ResourceMapping[] mappings = (ResourceMapping[])toRefresh.toArray(new ResourceMapping[toRefresh.size()]);
    toRefresh.clear();
    if (mappings.length > 0) {
      try
      {
        manager.refresh(mappings, monitor);
      }
      catch (CoreException e)
      {
        throw TeamException.asTeamException(e);
      }
    }
    return mappings.length > 0;
  }
  
  protected void processEvent(BackgroundEventHandler.Event event, IProgressMonitor monitor)
    throws CoreException
  {
    if ((event instanceof ResourceMappingEvent))
    {
      ResourceMappingEvent rme = (ResourceMappingEvent)event;
      for (int i = 0; i < mappings.length; i++)
      {
        ResourceMapping mapping = mappings[i];
        toRefresh.add(mapping);
      }
    }
  }
  
  public void refresh(ResourceMapping[] mappings)
  {
    queueEvent(new ResourceMappingEvent(mappings), false);
  }
  
  protected Object getJobFamiliy()
  {
    return manager;
  }
}

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

import org.eclipse.core.resources.IResource;
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;

class SyncInfoToDiffConverter$PrecalculatedSyncInfo
  extends SyncInfo
{
  public int kind;
  
  public SyncInfoToDiffConverter$PrecalculatedSyncInfo(int kind, IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator)
  {
    super(local, base, remote, comparator);
    this.kind = kind;
  }
  
  protected int calculateKind()
    throws TeamException
  {
    return kind;
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.diff.ITwoWayDiff;
import org.eclipse.team.core.diff.provider.ThreeWayDiff;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.mapping.IResourceDiff;
import org.eclipse.team.core.mapping.provider.ResourceDiff;
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.history.LocalFileRevision;

public class SyncInfoToDiffConverter
{
  private static SyncInfoToDiffConverter instance;
  
  private static class PrecalculatedSyncInfo
    extends SyncInfo
  {
    public int kind;
    
    public PrecalculatedSyncInfo(int kind, IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator)
    {
      super(base, remote, comparator);
      this.kind = kind;
    }
    
    protected int calculateKind()
      throws TeamException
    {
      return kind;
    }
  }
  
  public static String diffKindToString(int kind)
  {
    String label = "";
    if (kind == 0) {
      label = Messages.RemoteSyncElement_insync;
    } else {
      switch (kind)
      {
      case 4: 
        label = Messages.RemoteSyncElement_change; break;
      case 1: 
        label = Messages.RemoteSyncElement_addition; break;
      case 2: 
        label = Messages.RemoteSyncElement_deletion;
      }
    }
    return label;
  }
  
  public static String diffDirectionToString(int direction)
  {
    switch (direction)
    {
    case 768: 
      return Messages.RemoteSyncElement_conflicting;
    case 256: 
      return Messages.RemoteSyncElement_outgoing;
    case 512: 
      return Messages.RemoteSyncElement_incoming;
    }
    return "";
  }
  
  public static String diffStatusToString(int status)
  {
    int kind = status & 0xFF;
    String label = diffKindToString(kind);
    int direction = status & 0x300;
    if (direction != 0) {
      label = NLS.bind(Messages.concatStrings, new String[] { diffDirectionToString(direction), label });
    }
    return label;
  }
  
  public static int asDiffFlags(int syncInfoFlags)
  {
    if (syncInfoFlags == 0) {
      return 0;
    }
    int kind = SyncInfo.getChange(syncInfoFlags);
    int diffFlags = 0;
    switch (kind)
    {
    case 1: 
      diffFlags = 1;
      break;
    case 2: 
      diffFlags = 2;
      break;
    case 3: 
      diffFlags = 4;
    }
    int direction = SyncInfo.getDirection(syncInfoFlags);
    switch (direction)
    {
    case 8: 
      diffFlags |= 0x200;
      break;
    case 4: 
      diffFlags |= 0x100;
      break;
    case 12: 
      diffFlags |= 0x300;
    }
    return diffFlags;
  }
  
  private static int asSyncInfoKind(IThreeWayDiff diff)
  {
    int kind = diff.getKind();
    if (diff.getKind() == 0) {
      return 0;
    }
    int syncKind = 0;
    switch (kind)
    {
    case 1: 
      syncKind = 1;
      break;
    case 2: 
      syncKind = 2;
      break;
    case 4: 
      syncKind = 3;
    }
    int direction = diff.getDirection();
    switch (direction)
    {
    case 512: 
      syncKind |= 0x8;
      break;
    case 256: 
      syncKind |= 0x4;
      break;
    case 768: 
      syncKind |= 0xC;
    }
    return syncKind;
  }
  
  public IDiff getDeltaFor(SyncInfo info)
  {
    if (info.getComparator().isThreeWay())
    {
      ITwoWayDiff local = getLocalDelta(info);
      ITwoWayDiff remote = getRemoteDelta(info);
      return new ThreeWayDiff(local, remote);
    }
    if (info.getKind() != 0)
    {
      IResourceVariant remote = info.getRemote();
      IResource local = info.getLocal();
      int kind;
      int kind;
      if (remote == null)
      {
        kind = 2;
      }
      else
      {
        int kind;
        if (!local.exists()) {
          kind = 1;
        } else {
          kind = 4;
        }
      }
      if (local.getType() == 1)
      {
        IFileRevision after = asFileState(remote);
        IFileRevision before = getFileRevisionFor((IFile)local);
        return new ResourceDiff(info.getLocal(), kind, 0, before, after);
      }
      return new ResourceDiff(info.getLocal(), kind);
    }
    return null;
  }
  
  private ITwoWayDiff getRemoteDelta(SyncInfo info)
  {
    int direction = SyncInfo.getDirection(info.getKind());
    if ((direction == 8) || (direction == 12))
    {
      IResourceVariant ancestor = info.getBase();
      IResourceVariant remote = info.getRemote();
      int kind;
      int kind;
      if (ancestor == null)
      {
        kind = 1;
      }
      else
      {
        int kind;
        if (remote == null) {
          kind = 2;
        } else {
          kind = 4;
        }
      }
      if (info.getLocal().getType() == 1)
      {
        IFileRevision before = asFileState(ancestor);
        IFileRevision after = asFileState(remote);
        return new ResourceDiff(info.getLocal(), kind, 0, before, after);
      }
      return new ResourceDiff(info.getLocal(), kind);
    }
    return null;
  }
  
  private IFileRevision asFileState(IResourceVariant variant)
  {
    if (variant == null) {
      return null;
    }
    return asFileRevision(variant);
  }
  
  private IFileRevision getFileRevisionFor(IFile file)
  {
    return new LocalFileRevision(file);
  }
  
  protected ResourceVariantFileRevision asFileRevision(IResourceVariant variant)
  {
    return new ResourceVariantFileRevision(variant);
  }
  
  private ITwoWayDiff getLocalDelta(SyncInfo info)
  {
    int direction = SyncInfo.getDirection(info.getKind());
    if ((direction == 4) || (direction == 12))
    {
      IResourceVariant ancestor = info.getBase();
      IResource local = info.getLocal();
      int kind;
      int kind;
      if (ancestor == null)
      {
        kind = 1;
      }
      else
      {
        int kind;
        if (!local.exists()) {
          kind = 2;
        } else {
          kind = 4;
        }
      }
      if (local.getType() == 1)
      {
        IFileRevision before = asFileState(ancestor);
        IFileRevision after = getFileRevisionFor((IFile)local);
        return new ResourceDiff(info.getLocal(), kind, 0, before, after);
      }
      return new ResourceDiff(info.getLocal(), kind);
    }
    return null;
  }
  
  public static IResourceVariant getRemoteVariant(IThreeWayDiff twd)
  {
    IFileRevision revision = getRemote(twd);
    if (revision != null) {
      return asResourceVariant(revision);
    }
    return null;
  }
  
  public static IResourceVariant getBaseVariant(IThreeWayDiff twd)
  {
    IResourceDiff diff = (IResourceDiff)twd.getRemoteChange();
    if (diff != null) {
      return asResourceVariant(diff.getBeforeState());
    }
    diff = (IResourceDiff)twd.getLocalChange();
    if (diff != null) {
      return asResourceVariant(diff.getBeforeState());
    }
    return null;
  }
  
  public SyncInfo asSyncInfo(IDiff diff, IResourceVariantComparator comparator)
  {
    if ((diff instanceof ResourceDiff))
    {
      ResourceDiff rd = (ResourceDiff)diff;
      IResource local = rd.getResource();
      IFileRevision afterState = rd.getAfterState();
      IResourceVariant remote = asResourceVariant(afterState);
      int kind;
      int kind;
      if (remote == null)
      {
        kind = 2;
      }
      else
      {
        int kind;
        if (!local.exists()) {
          kind = 1;
        } else {
          kind = 3;
        }
      }
      SyncInfo info = createSyncInfo(comparator, kind, local, null, remote);
      return info;
    }
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IResource local = getLocal(twd);
      if (local != null)
      {
        IResourceVariant remote = getRemoteVariant(twd);
        IResourceVariant base = getBaseVariant(twd);
        int kind = asSyncInfoKind(twd);
        SyncInfo info = createSyncInfo(comparator, kind, local, base, remote);
        return info;
      }
    }
    return null;
  }
  
  protected SyncInfo createSyncInfo(IResourceVariantComparator comparator, int kind, IResource local, IResourceVariant base, IResourceVariant remote)
  {
    PrecalculatedSyncInfo info = new PrecalculatedSyncInfo(kind, local, base, remote, comparator);
    try
    {
      info.init();
    }
    catch (TeamException localTeamException) {}
    return info;
  }
  
  private static IResource getLocal(IThreeWayDiff twd)
  {
    IResourceDiff diff = (IResourceDiff)twd.getRemoteChange();
    if (diff != null) {
      return diff.getResource();
    }
    diff = (IResourceDiff)twd.getLocalChange();
    if (diff != null) {
      return diff.getResource();
    }
    return null;
  }
  
  public static IResourceVariant asResourceVariant(IFileRevision revision)
  {
    if (revision == null) {
      return null;
    }
    if ((revision instanceof ResourceVariantFileRevision))
    {
      ResourceVariantFileRevision rvfr = (ResourceVariantFileRevision)revision;
      return rvfr.getVariant();
    }
    if ((revision instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)revision;
      Object o = adaptable.getAdapter(IResourceVariant.class);
      if ((o instanceof IResourceVariant)) {
        return (IResourceVariant)o;
      }
    }
    return null;
  }
  
  public static IFileRevision getRemote(IDiff diff)
  {
    if ((diff instanceof IResourceDiff))
    {
      IResourceDiff rd = (IResourceDiff)diff;
      return rd.getAfterState();
    }
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      return getRemote(twd);
    }
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