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

urces/IFile;Ljava/io/OutputStream;)V
        //   351: aload_1
        //   352: invokeinterface 188 1 0
        //   357: return
        // Line number table:
        //   Java source line #189	-> byte code offset #0
        //   Java source line #190	-> byte code offset #9
        //   Java source line #191	-> byte code offset #22
        //   Java source line #192	-> byte code offset #35
        //   Java source line #193	-> byte code offset #79
        //   Java source line #194	-> byte code offset #84
        //   Java source line #195	-> byte code offset #89
        //   Java source line #196	-> byte code offset #100
        //   Java source line #197	-> byte code offset #124
        //   Java source line #198	-> byte code offset #133
        //   Java source line #199	-> byte code offset #141
        //   Java source line #201	-> byte code offset #149
        //   Java source line #202	-> byte code offset #154
        //   Java source line #204	-> byte code offset #172
        //   Java source line #205	-> byte code offset #175
        //   Java source line #206	-> byte code offset #190
        //   Java source line #208	-> byte code offset #201
        //   Java source line #209	-> byte code offset #226
        //   Java source line #210	-> byte code offset #236
        //   Java source line #211	-> byte code offset #261
        //   Java source line #213	-> byte code offset #281
        //   Java source line #215	-> byte code offset #313
        //   Java source line #216	-> byte code offset #324
        //   Java source line #217	-> byte code offset #326
        //   Java source line #218	-> byte code offset #337
        //   Java source line #217	-> byte code offset #340
        //   Java source line #219	-> byte code offset #351
        //   Java source line #220	-> byte code offset #357
        // Local variable table:
        //   start	length	slot	name	signature
        //   0	358	0	this	4
        //   0	358	1	monitor	IProgressMonitor
        //   21	113	2	localDiff	IResourceDiff
        //   34	108	3	remoteDiff	IResourceDiff
        //   77	125	4	merger	IStorageMerger
        //   98	247	5	file	IFile
        //   131	75	6	osEncoding	String
        //   139	16	7	ancestorState	IFileRevision
        //   147	29	8	remoteState	IFileRevision
        //   167	3	9	ancestorStorage	org.eclipse.core.resources.IStorage
        //   173	35	9	ancestorStorage	org.eclipse.core.resources.IStorage
        //   188	24	10	remoteStorage	org.eclipse.core.resources.IStorage
        //   199	148	11	os	OutputStream
        //   224	95	12	status	IStatus
        //   324	14	13	localObject	Object
        //   59	1	15	localClassNotFoundException	ClassNotFoundException
        // Exception table:
        //   from	to	target	type
        //   47	52	59	java/lang/ClassNotFoundException
        //   201	324	324	finally
      }
    }, getMergeRule(diff), 1, monitor);
    return result[0];
  }
  
  private void disposeTempOutputStream(IFile file, OutputStream output)
  {
    if ((output instanceof ByteArrayOutputStream)) {
      return;
    }
    try
    {
      if (output != null) {
        output.close();
      }
    }
    catch (IOException localIOException) {}
    File tmpFile = getTempFile(file);
    if (tmpFile.exists()) {
      tmpFile.delete();
    }
  }
  
  private OutputStream getTempOutputStream(IFile file)
    throws CoreException
  {
    File tmpFile = getTempFile(file);
    if (tmpFile.exists()) {
      tmpFile.delete();
    }
    File parent = tmpFile.getParentFile();
    if (!parent.exists()) {
      parent.mkdirs();
    }
    try
    {
      return new BufferedOutputStream(new FileOutputStream(tmpFile));
    }
    catch (FileNotFoundException e)
    {
      TeamPlugin.log(4, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e);
    }
    return new ByteArrayOutputStream();
  }
  
  private InputStream getTempInputStream(IFile file, OutputStream output)
    throws CoreException
  {
    if ((output instanceof ByteArrayOutputStream))
    {
      ByteArrayOutputStream baos = (ByteArrayOutputStream)output;
      return new ByteArrayInputStream(baos.toByteArray());
    }
    try
    {
      if (output != null) {
        output.close();
      }
    }
    catch (IOException localIOException) {}
    File tmpFile = getTempFile(file);
    try
    {
      return new BufferedInputStream(new FileInputStream(tmpFile));
    }
    catch (FileNotFoundException e)
    {
      throw new CoreException(new Status(4, "org.eclipse.team.core", 2, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e));
    }
  }
  
  private File getTempFile(IFile file)
  {
    return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile();
  }
  
  private IFile getLocalFile(IDiff delta)
  {
    return ResourcesPlugin.getWorkspace().getRoot().getFile(delta.getPath());
  }
  
  protected void performReplace(IDiff diff, IProgressMonitor monitor)
    throws CoreException
  {
    IFile file = getLocalFile(diff);
    IFileRevision remote = null;
    IResourceDiff d;
    if ((diff instanceof IResourceDiff))
    {
      IResourceDiff d = (IResourceDiff)diff;
      remote = d.getAfterState();
    }
    else
    {
      d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange();
      if (d != null) {
        remote = d.getAfterState();
      }
    }
    if (d == null)
    {
      d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange();
      if (d != null) {
        remote = d.getBeforeState();
      }
    }
    if (d != null) {
      performReplace(diff, file, remote, monitor);
    }
  }
  
  protected abstract void makeInSync(IDiff paramIDiff, IProgressMonitor paramIProgressMonitor)
    throws CoreException;
  
  private void performReplace(IDiff diff, IFile file, IFileRevision remote, IProgressMonitor monitor)
    throws CoreException
  {
    run(new IWorkspaceRunnable()
    {
      private final IFile val$file;
      private final IFileRevision val$remote;
      private final IDiff val$diff;
      
      /* Error */
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        // Byte code:
        //   0: aload_1
        //   1: aconst_null
        //   2: bipush 100
        //   4: invokeinterface 130 3 0
        //   9: aload_1
        //   10: getstatic 113	org/eclipse/team/internal/core/Messages:MergeContext_6	Ljava/lang/String;
        //   13: aload_0
        //   14: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   17: invokeinterface 122 1 0
        //   22: invokeinterface 127 1 0
        //   27: invokestatic 117	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
        //   30: invokeinterface 129 2 0
        //   35: aload_0
        //   36: getfield 111	org/eclipse/team/core/mapping/provider/MergeContext$5:val$remote	Lorg/eclipse/team/core/history/IFileRevision;
        //   39: ifnull +15 -> 54
        //   42: aload_0
        //   43: getfield 111	org/eclipse/team/core/mapping/provider/MergeContext$5:val$remote	Lorg/eclipse/team/core/history/IFileRevision;
        //   46: invokeinterface 131 1 0
        //   51: ifne +35 -> 86
        //   54: aload_0
        //   55: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   58: invokeinterface 121 1 0
        //   63: ifeq +23 -> 86
        //   66: aload_0
        //   67: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   70: iconst_0
        //   71: iconst_1
        //   72: aload_1
        //   73: bipush 95
        //   75: invokestatic 120	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
        //   78: invokeinterface 123 4 0
        //   83: goto +119 -> 202
        //   86: aload_0
        //   87: getfield 111	org/eclipse/team/core/mapping/provider/MergeContext$5:val$remote	Lorg/eclipse/team/core/history/IFileRevision;
        //   90: ifnull +112 -> 202
        //   93: aload_0
        //   94: getfield 112	org/eclipse/team/core/mapping/provider/MergeContext$5:this$0	Lorg/eclipse/team/core/mapping/provider/MergeContext;
        //   97: aload_0
        //   98: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   101: aload_1
        //   102: invokevirtual 118	org/eclipse/team/core/mapping/provider/MergeContext:ensureParentsExist	(Lorg/eclipse/core/resources/IResource;Lorg/eclipse/core/runtime/IProgressMonitor;)V
        //   105: aload_0
        //   106: getfield 111	org/eclipse/team/core/mapping/provider/MergeContext$5:val$remote	Lorg/eclipse/team/core/history/IFileRevision;
        //   109: aload_1
        //   110: invokeinterface 132 2 0
        //   115: invokeinterface 126 1 0
        //   120: astore_2
        //   121: new 46	java/io/BufferedInputStream
        //   124: dup
        //   125: aload_2
        //   126: invokespecial 114	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
        //   129: astore_2
        //   130: aload_0
        //   131: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   134: invokeinterface 121 1 0
        //   139: ifeq +24 -> 163
        //   142: aload_0
        //   143: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   146: aload_2
        //   147: iconst_0
        //   148: iconst_1
        //   149: aload_1
        //   150: bipush 95
        //   152: invokestatic 120	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
        //   155: invokeinterface 125 5 0
        //   160: goto +34 -> 194
        //   163: aload_0
        //   164: getfield 109	org/eclipse/team/core/mapping/provider/MergeContext$5:val$file	Lorg/eclipse/core/resources/IFile;
        //   167: aload_2
        //   168: iconst_0
        //   169: aload_1
        //   170: bipush 95
        //   172: invokestatic 120	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
        //   175: invokeinterface 124 4 0
        //   180: goto +14 -> 194
        //   183: astore_3
        //   184: aload_2
        //   185: invokevirtual 115	java/io/InputStream:close	()V
        //   188: goto +4 -> 192
        //   191: pop
        //   192: aload_3
        //   193: athrow
        //   194: aload_2
        //   195: invokevirtual 115	java/io/InputStream:close	()V
        //   198: goto +4 -> 202
        //   201: pop
        //   202: aload_0
        //   203: getfield 112	org/eclipse/team/core/mapping/provider/MergeContext$5:this$0	Lorg/eclipse/team/core/mapping/provider/MergeContext;
        //   206: aload_0
        //   207: getfield 110	org/eclipse/team/core/mapping/provider/MergeContext$5:val$diff	Lorg/eclipse/team/core/diff/IDiff;
        //   210: aload_1
        //   211: iconst_5
        //   212: invokestatic 120	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
        //   215: invokevirtual 119	org/eclipse/team/core/mapping/provider/MergeContext:makeInSync	(Lorg/eclipse/team/core/diff/IDiff;Lorg/eclipse/core/runtime/IProgressMonitor;)V
        //   218: goto +14 -> 232
        //   221: astore 4
        //   223: aload_1
        //   224: invokeinterface 128 1 0
        //   229: aload 4
        //   231: athrow
        //   232: aload_1
        //   233: invokeinterface 128 1 0
        //   238: return
        // Line number table:
        //   Java source line #348	-> byte code offset #0
        //   Java source line #349	-> byte code offset #9
        //   Java source line #350	-> byte code offset #35
        //   Java source line #351	-> byte code offset #66
        //   Java source line #352	-> byte code offset #86
        //   Java source line #353	-> byte code offset #93
        //   Java source line #354	-> byte code offset #105
        //   Java source line #355	-> byte code offset #121
        //   Java source line #357	-> byte code offset #130
        //   Java source line #358	-> byte code offset #142
        //   Java source line #360	-> byte code offset #163
        //   Java source line #362	-> byte code offset #183
        //   Java source line #364	-> byte code offset #184
        //   Java source line #365	-> byte code offset #191
        //   Java source line #368	-> byte code offset #192
        //   Java source line #364	-> byte code offset #194
        //   Java source line #365	-> byte code offset #201
        //   Java source line #371	-> byte code offset #202
        //   Java source line #372	-> byte code offset #221
        //   Java source line #373	-> byte code offset #223
        //   Java source line #374	-> byte code offset #229
        //   Java source line #373	-> byte code offset #232
        //   Java source line #375	-> byte code offset #238
        // Local variable table:
        //   start	length	slot	name	signature
        //   0	239	0	this	5
        //   0	239	1	monitor	IProgressMonitor
        //   120	75	2	stream	InputStream
        //   183	10	3	localObject1	Object
        //   221	9	4	localObject2	Object
        //   191	1	5	localIOException1	IOException
        //   201	1	6	localIOException2	IOException
        // Exception table:
        //   from	to	target	type
        //   130	183	183	finally
        //   184	188	191	java/io/IOException
        //   194	198	201	java/io/IOException
        //   0	221	221	finally
      }
    }, getMergeRule(diff), 1, monitor);
  }
  
  protected void ensureParentsExist(IResource resource, IProgressMonitor monitor)
    throws CoreException
  {
    IContainer parent = resource.getParent();
    if (parent.getType() != 2) {
      return;
    }
    if (!parent.exists())
    {
      ensureParentsExist(parent, monitor);
      ((IFolder)parent).create(false, true, monitor);
    }
  }
  
  public void run(IWorkspaceRunnable runnable, ISchedulingRule rule, int flags, IProgressMonitor monitor)
    throws CoreException
  {
    ResourcesPlugin.getWorkspace().run(runnable, rule, flags, monitor);
  }
  
  public ISchedulingRule getMergeRule(IDiff diff)
  {
    IResource resource = getDiffTree().getResource(diff);
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule rule;
    ISchedulingRule rule;
    if (!resource.exists())
    {
      rule = ruleFactory.createRule(resource);
    }
    else
    {
      ISchedulingRule rule;
      if (SyncInfoToDiffConverter.getRemote(diff) == null) {
        rule = ruleFactory.deleteRule(resource);
      } else {
        rule = ruleFactory.modifyRule(resource);
      }
    }
    return rule;
  }
  
  public ISchedulingRule getMergeRule(IDiff[] deltas)
  {
    ISchedulingRule result = null;
    for (int i = 0; i < deltas.length; i++)
    {
      IDiff node = deltas[i];
      ISchedulingRule rule = getMergeRule(node);
      if (result == null) {
        result = rule;
      } else {
        result = MultiRule.combine(result, rule);
      }
    }
    return result;
  }
  
  public int getMergeType()
  {
    return getType();
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == IStorageMerger.class) {
      return DelegatingStorageMerger.getInstance();
    }
    return super.getAdapter(adapter);
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.mapping.IMergeStatus;

public class MergeStatus
  extends Status
  implements IMergeStatus
{
  private ResourceMapping[] conflictingMappings;
  private IFile[] conflictingFiles;
  
  public MergeStatus(String pluginId, String message, ResourceMapping[] conflictingMappings)
  {
    super(4, pluginId, 1, message, null);
    this.conflictingMappings = conflictingMappings;
  }
  
  public MergeStatus(String pluginId, String message, IFile[] files)
  {
    super(4, pluginId, 1, message, null);
    conflictingFiles = files;
  }
  
  public ResourceMapping[] getConflictingMappings()
  {
    return conflictingMappings;
  }
  
  public IFile[] getConflictingFiles()
  {
    return conflictingFiles;
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.team.core.diff.provider.TwoWayDiff;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.mapping.IResourceDiff;

public class ResourceDiff
  extends TwoWayDiff
  implements IResourceDiff
{
  private final IFileRevision before;
  private final IFileRevision after;
  private final IResource resource;
  
  public ResourceDiff(IResource resource, int kind, int flags, IFileRevision before, IFileRevision after)
  {
    super(resource.getFullPath(), kind, flags);
    this.resource = resource;
    this.before = before;
    this.after = after;
  }
  
  public ResourceDiff(IResource resource, int kind)
  {
    this(resource, kind, 0, null, null);
    Assert.isTrue(resource.getType() != 1);
  }
  
  public IFileRevision getBeforeState()
  {
    return before;
  }
  
  public IFileRevision getAfterState()
  {
    return after;
  }
  
  public IResource getResource()
  {
    return resource;
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if ((super.equals(obj)) && 
      ((obj instanceof ResourceDiff)))
    {
      ResourceDiff other = (ResourceDiff)obj;
      
      return (getResource().equals(getResource())) && (revisionsEqual(getBeforeState(), other.getBeforeState())) && (revisionsEqual(getAfterState(), other.getAfterState()));
    }
    return false;
  }
  
  private boolean revisionsEqual(IFileRevision revision, IFileRevision revision2)
  {
    if (revision == null) {
      return revision2 == null;
    }
    if (revision2 == null) {
      return false;
    }
    return revision.equals(revision2);
  }
}

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

import java.util.Set;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IDiffVisitor;

class ResourceDiffTree$1
  implements IDiffVisitor
{
  final ResourceDiffTree this$0;
  private final Set val$result;
  
  ResourceDiffTree$1(ResourceDiffTree paramResourceDiffTree, Set paramSet)
  {
    this$0 = paramResourceDiffTree;val$result = paramSet;
  }
  
  public boolean visit(IDiff diff)
  {
    return val$result.add(diff);
  }
}

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

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

class ResourceDiffTree$2
  implements IDiffVisitor
{
  final ResourceDiffTree this$0;
  private final FastDiffFilter val$filter;
  private final RuntimeException val$found;
  
  ResourceDiffTree$2(ResourceDiffTree paramResourceDiffTree, FastDiffFilter paramFastDiffFilter, RuntimeException paramRuntimeException)
  {
    this$0 = paramResourceDiffTree;val$filter = paramFastDiffFilter;val$found = paramRuntimeException;
  }
  
  public boolean visit(IDiff delta)
  {
    if (val$filter.select(delta)) {
      throw val$found;
    }
    return false;
  }
}

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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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.ResourceTraversal;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.team.core.diff.FastDiffFilter;
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.diff.provider.DiffTree;
import org.eclipse.team.core.mapping.IResourceDiff;
import org.eclipse.team.core.mapping.IResourceDiffTree;

public class ResourceDiffTree
  extends DiffTree
  implements IResourceDiffTree
{
  public static IResource getResourceFor(IDiff node)
  {
    if ((node instanceof IResourceDiff))
    {
      IResourceDiff rd = (IResourceDiff)node;
      return rd.getResource();
    }
    if ((node instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)node;
      IDiff child = twd.getLocalChange();
      if (child != null) {
        return getResourceFor(child);
      }
      child = twd.getRemoteChange();
      if (child != null) {
        return getResourceFor(child);
      }
    }
    Assert.isLegal(false);
    return null;
  }
  
  public IDiff getDiff(IResource resource)
  {
    return getDiff(resource.getFullPath());
  }
  
  public IResource getResource(IDiff diff)
  {
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IResourceDiff localChange = (IResourceDiff)twd.getLocalChange();
      if (localChange != null) {
        return localChange.getResource();
      }
      return ((IResourceDiff)twd.getRemoteChange()).getResource();
    }
    return ((IResourceDiff)diff).getResource();
  }
  
  public void accept(ResourceTraversal[] traversals, IDiffVisitor visitor)
  {
    for (int i = 0; i < traversals.length; i++)
    {
      ResourceTraversal traversal = traversals[i];
      IResource[] resources = traversal.getResources();
      for (int j = 0; j < resources.length; j++)
      {
        IResource resource = resources[j];
        accept(resource.getFullPath(), visitor, traversal.getDepth());
      }
    }
  }
  
  public IDiff[] getDiffs(ResourceTraversal[] traversals)
  {
    Set result = new HashSet();
    for (int i = 0; i < traversals.length; i++)
    {
      ResourceTraversal traversal = traversals[i];
      IResource[] resources = traversal.getResources();
      for (int j = 0; j < resources.length; j++)
      {
        IResource resource = resources[j];
        internalGetDiffs(resource, traversal.getDepth(), result);
      }
    }
    return (IDiff[])result.toArray(new IDiff[result.size()]);
  }
  
  public IDiff[] getDiffs(IResource resource, int depth)
  {
    Set result = new HashSet();
    internalGetDiffs(resource, depth, result);
    return (IDiff[])result.toArray(new IDiff[result.size()]);
  }
  
  private void internalGetDiffs(IResource resource, int depth, Set result)
  {
    accept(resource.getFullPath(), new IDiffVisitor()
    {
      private final Set val$result;
      
      public boolean visit(IDiff diff)
      {
        return val$result.add(diff);
      }
    }, depth);
  }
  
  private IResource internalGetResource(IPath fullPath, boolean container)
  {
    if (container)
    {
      if (fullPath.segmentCount() == 1) {
        return ResourcesPlugin.getWorkspace().getRoot().getProject(fullPath.segment(0));
      }
      return ResourcesPlugin.getWorkspace().getRoot().getFolder(fullPath);
    }
    return ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
  }
  
  public IResource[] members(IResource resource)
  {
    List result = new ArrayList();
    IPath[] paths = getChildren(resource.getFullPath());
    for (int i = 0; i < paths.length; i++)
    {
      IPath path = paths[i];
      IDiff node = getDiff(path);
      if (node == null) {
        result.add(internalGetResource(path, true));
      } else {
        result.add(getResource(node));
      }
    }
    return (IResource[])result.toArray(new IResource[result.size()]);
  }
  
  public IResource[] getAffectedResources()
  {
    List result = new ArrayList();
    IDiff[] nodes = getDiffs();
    for (int i = 0; i < nodes.length; i++)
    {
      IDiff node = nodes[i];
      result.add(getResource(node));
    }
    return (IResource[])result.toArray(new IResource[result.size()]);
  }
  
  public void add(IDiff delta)
  {
    Assert.isTrue(((delta instanceof IResourceDiff)) || ((delta instanceof IThreeWayDiff)));
    super.add(delta);
  }
  
  public void remove(IResource resource)
  {
    remove(resource.getFullPath());
  }
  
  public boolean hasMatchingDiffs(ResourceTraversal[] traversals, FastDiffFilter filter)
  {
    RuntimeException found = new RuntimeException();
    try
    {
      accept(traversals, new IDiffVisitor()
      {
        private final FastDiffFilter val$filter;
        private final RuntimeException val$found;
        
        public boolean visit(IDiff delta)
        {
          if (val$filter.select(delta)) {
            throw val$found;
          }
          return false;
        }
      });
    }
    catch (RuntimeException e)
    {
      if (e == found) {
        return true;
      }
      throw e;
    }
    return false;
  }
}

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

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.PlatformObject;
import org.eclipse.team.core.ICache;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.internal.core.Cache;
import org.eclipse.team.internal.core.Policy;

public abstract class SynchronizationContext
  extends PlatformObject
  implements ISynchronizationContext
{
  private final int type;
  private final IResourceDiffTree diffTree;
  private Cache cache;
  private final ISynchronizationScopeManager manager;
  
  protected SynchronizationContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree diffTree)
  {
    this.manager = manager;
    this.type = type;
    this.diffTree = diffTree;
  }
  
  public ISynchronizationScope getScope()
  {
    return getScopeManager().getScope();
  }
  
  public ISynchronizationScopeManager getScopeManager()
  {
    return manager;
  }
  
  public int getType()
  {
    return type;
  }
  
  public void dispose()
  {
    if (cache != null) {
      cache.dispose();
    }
    manager.dispose();
  }
  
  public synchronized ICache getCache()
  {
    if (cache == null) {
      cache = new Cache();
    }
    return cache;
  }
  
  public IResourceDiffTree getDiffTree()
  {
    return diffTree;
  }
  
  public void refresh(ResourceMapping[] mappings, IProgressMonitor monitor)
    throws CoreException
  {
    monitor.beginTask(null, 100);
    ISynchronizationScopeManager manager = getScopeManager();
    if (manager == null)
    {
      refresh(getScope().getTraversals(), 0, Policy.subMonitorFor(monitor, 50));
    }
    else
    {
      ResourceTraversal[] traversals = manager.refresh(mappings, Policy.subMonitorFor(monitor, 50));
      if (traversals.length > 0) {
        refresh(traversals, 0, Policy.subMonitorFor(monitor, 50));
      }
    }
    monitor.done();
  }
}

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

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

class SynchronizationScopeManager$1
  implements IWorkspaceRunnable
{
  final SynchronizationScopeManager this$0;
  
  SynchronizationScopeManager$1(SynchronizationScopeManager paramSynchronizationScopeManager)
  {
    this$0 = paramSynchronizationScopeManager;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    SynchronizationScopeManager.access$0(this$0, monitor);
  }
}

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

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

class SynchronizationScopeManager$2
  implements IWorkspaceRunnable
{
  final SynchronizationScopeManager this$0;
  private final ResourceTraversal[][] val$traversals;
  private final ResourceMapping[] val$mappings;
  
  SynchronizationScopeManager$2(SynchronizationScopeManager paramSynchronizationScopeManager, ResourceTraversal[][] paramArrayOfResourceTraversal, ResourceMapping[] paramArrayOfResourceMapping)
  {
    this$0 = paramSynchronizationScopeManager;val$traversals = paramArrayOfResourceTraversal;val$mappings = paramArrayOfResourceMapping;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    val$traversals[0] = SynchronizationScopeManager.access$1(this$0, val$mappings, true, monitor);
  }
}

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

import java.util.Arrays;
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.IWorkspaceRunnable;
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.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.core.runtime.PlatformObject;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.internal.core.Policy;
import org.eclipse.team.internal.core.mapping.CompoundResourceTraversal;
import org.eclipse.team.internal.core.mapping.ResourceMappingScope;
import org.eclipse.team.internal.core.mapping.ScopeChangeEvent;
import org.eclipse.team.internal.core.mapping.ScopeManagerEventHandler;

public class SynchronizationScopeManager
  extends PlatformObject
  implements ISynchronizationScopeManager
{
  private static final int MAX_ITERATION = 10;
  private final ResourceMappingContext context;
  private final boolean consultModels;
  private ISynchronizationScope scope;
  private boolean initialized;
  private ScopeManagerEventHandler handler;
  private final String name;
  
  public static ResourceMapping[] getMappingsFromProviders(ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException
  {
    Set result = new HashSet();
    IModelProviderDescriptor[] descriptors = 
      ModelProvider.getModelProviderDescriptors();
    for (int i = 0; i < descriptors.length; i++)
    {
      IModelProviderDescriptor descriptor = descriptors[i];
      ResourceMapping[] mappings = getMappings(descriptor, traversals, 
        context, monitor);
      result.addAll(Arrays.asList(mappings));
      Policy.checkCanceled(monitor);
    }
    return (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
  }
  
  private static ResourceMapping[] getMappings(IModelProviderDescriptor descriptor, ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException
  {
    ResourceTraversal[] matchingTraversals = descriptor.getMatchingTraversals(
      traversals);
    return descriptor.getModelProvider().getMappings(matchingTraversals, 
      context, monitor);
  }
  
  public SynchronizationScopeManager(String name, ResourceMapping[] inputMappings, ResourceMappingContext resourceMappingContext, boolean consultModels)
  {
    this.name = name;
    context = resourceMappingContext;
    this.consultModels = consultModels;
    scope = createScope(inputMappings);
  }
  
  public boolean isInitialized()
  {
    return initialized;
  }
  
  public ISchedulingRule getSchedulingRule()
  {
    Set projects = new HashSet();
    ResourceMapping[] mappings = scope.getInputMappings();
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping mapping = mappings[i];
      Object modelObject = mapping.getModelObject();
      if ((modelObject instanceof IResource))
      {
        IResource resource = (IResource)modelObject;
        if (resource.getType() == 8) {
          return ResourcesPlugin.getWorkspace().getRoot();
        }
        projects.add(resource.getProject());
      }
      else
      {
        return ResourcesPlugin.getWorkspace().getRoot();
      }
    }
    return MultiRule.combine((IProject[])projects.toArray(new IProject[projects.size()]));
  }
  
  public void initialize(IProgressMonitor monitor)
    throws CoreException
  {
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable()
    {
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        SynchronizationScopeManager.this.internalPrepareContext(monitor);
      }
    }, getSchedulingRule(), 0, monitor);
  }
  
  public ResourceTraversal[] refresh(ResourceMapping[] mappings, IProgressMonitor monitor)
    throws CoreException
  {
    ResourceTraversal[][] traversals = { new ResourceTraversal[0] };
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    workspace.run(new IWorkspaceRunnable()
    {
      private final ResourceTraversal[][] val$traversals;
      private final ResourceMapping[] val$mappings;
      
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        val$traversals[0] = SynchronizationScopeManager.this.internalRefreshScope(val$mappings, true, monitor);
      }
    }, getSchedulingRule(), 0, monitor);
    return traversals[0];
  }
  
  private void internalPrepareContext(IProgressMonitor monitor)
    throws CoreException
  {
    if (initialized) {
      return;
    }
    monitor.beginTask(null, -1);
    
    ((ResourceMappingScope)scope).reset();
    ResourceMapping[] targetMappings = scope.getInputMappings();
    
    boolean firstTime = true;
    boolean hasAdditionalResources = false;
    int count = 0;
    ResourceTraversal[] newTraversals;
    do
    {
      Policy.checkCanceled(monitor);
      newTraversals = addMappingsToScope(targetMappings, 
        Policy.subMonitorFor(monitor, -1));
      if ((newTraversals.length > 0) && (consultModels))
      {
        ResourceTraversal[] adjusted = adjustInputTraversals(newTraversals);
        targetMappings = getMappingsFromProviders(adjusted, 
          context, 
          Policy.subMonitorFor(monitor, -1));
        if (firstTime) {
          firstTime = false;
        } else if (!hasAdditionalResources) {
          hasAdditionalResources = newTraversals.length != 0;
        }
      }
    } while (((consultModels & newTraversals.length != 0)) && (count++ < 10));
    setHasAdditionalMappings(scope, (consultModels) && (internalHasAdditionalMappings()));
    setHasAdditionalResources((consultModels) && (hasAdditionalResources));
    monitor.done();
    initialized = true;
    fireMappingsChangedEvent(scope.getMappings(), scope.getTraversals());
  }
  
  private ResourceTraversal[] internalRefreshScope(ResourceMapping[] mappings, boolean checkForContraction, IProgressMonitor monitor)
    throws CoreException
  {
    monitor.beginTask(null, 100 * mappings.length + 100);
    ScopeChangeEvent change = new ScopeChangeEvent(scope);
    CompoundResourceTraversal refreshTraversals = new CompoundResourceTraversal();
    CompoundResourceTraversal removedTraversals = new CompoundResourceTraversal();
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping mapping = mappings[i];
      ResourceTraversal[] previousTraversals = scope.getTraversals(mapping);
      ResourceTraversal[] mappingTraversals = mapping.getTraversals(
        context, Policy.subMonitorFor(monitor, 100));
      refreshTraversals.addTraversals(mappingTraversals);
      ResourceTraversal[] uncovered = getUncoveredTraversals(mappingTraversals);
      if ((checkForContraction) && (previousTraversals != null) && (previousTraversals.length > 0))
      {
        ResourceTraversal[] removed = getUncoveredTraversals(mappingTraversals, previousTraversals);
        removedTraversals.addTraversals(removed);
      }
      if (uncovered.length > 0)
      {
        change.setExpanded(true);
        ResourceTraversal[] result = performExpandScope(mapping, mappingTraversals, uncovered, monitor);
        refreshTraversals.addTraversals(result);
      }
    }
    if ((checkForContraction) && (removedTraversals.getRoots().length > 0))
    {
      ((ResourceMappingScope)scope).reset();
      internalRefreshScope(scope.getInputMappings(), false, monitor);
      change.setContracted(true);
    }
    if (change.shouldFireChange()) {
      fireMappingsChangedEvent(change.getChangedMappings(), change.getChangedTraversals(refreshTraversals));
    }
    monitor.done();
    return refreshTraversals.asTraversals();
  }
  
  private ResourceTraversal[] getUncoveredTraversals(ResourceTraversal[] newTraversals, ResourceTraversal[] previousTraversals)
  {
    CompoundResourceTraversal t = new CompoundResourceTraversal();
    t.addTraversals(newTraversals);
    return t.getUncoveredTraversals(previousTraversals);
  }
  
  private ResourceTraversal[] performExpandScope(ResourceMapping mapping, ResourceTraversal[] mappingTraversals, ResourceTraversal[] uncovered, IProgressMonitor monitor)
    throws CoreException
  {
    ResourceMapping ancestor = findAncestor(mapping);
    if (ancestor == null)
    {
      uncovered = addMappingToScope(mapping, mappingTraversals);
      addResourcesToScope(uncovered, monitor);
      return mappingTraversals;
    }
    ResourceTraversal[] ancestorTraversals = ancestor.getTraversals(
      context, Policy.subMonitorFor(monitor, 100));
    uncovered = addMappingToScope(ancestor, ancestorTraversals);
    addResourcesToScope(uncovered, monitor);
    return ancestorTraversals;
  }
  
  
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