org.eclipse.team.cvs.core_3.3.400.I20110510-0800

16:47:55.093 INFO  jd.cli.Main - Decompiling org.eclipse.team.cvs.core_3.3.400.I20110510-0800.jar
package org.eclipse.team.internal.ccvs.core;

import org.eclipse.osgi.util.NLS;

public class CVSAnnotateBlock
{
  String revision = "";
  String user = "";
  int startLine = 0;
  int endLine = 0;
  int sourceOffset = 0;
  boolean valid = false;
  
  public boolean isValid()
  {
    return valid;
  }
  
  public int getSourceOffset()
  {
    return sourceOffset;
  }
  
  public int getEndLine()
  {
    return endLine;
  }
  
  public void setEndLine(int line)
  {
    endLine = line;
  }
  
  public String getRevision()
  {
    return revision;
  }
  
  public int getStartLine()
  {
    return startLine;
  }
  
  public CVSAnnotateBlock(String line, int lineNumber)
  {
    startLine = lineNumber;
    endLine = lineNumber;
    
    int index = line.indexOf(' ');
    if (index == -1) {
      return;
    }
    revision = line.substring(0, index);
    
    index = line.indexOf("(", index);
    if (index == -1) {
      return;
    }
    int index2 = line.indexOf(' ', index);
    if (index2 == -1) {
      return;
    }
    user = line.substring(index + 1, index2);
    
    index = line.indexOf(":", index2);
    if (index == -1) {
      return;
    }
    sourceOffset = (index + 2);
    valid = true;
  }
  
  public String toString()
  {
    int delta = endLine - startLine + 1;
    String line = CVSMessages.CVSAnnotateBlock_4;
    if (delta == 1) {
      line = CVSMessages.CVSAnnotateBlock_5;
    }
    return NLS.bind(CVSMessages.CVSAnnotateBlock_6, new Object[] {
      user, 
      revision, 
      String.valueOf(delta), 
      line });
  }
  
  public boolean contains(int i)
  {
    return (i >= startLine) && (i <= endLine);
  }
}

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

import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree;

class CVSCompareSubscriber$1
  implements ICVSResourceVisitor
{
  final CVSCompareSubscriber this$0;
  
  CVSCompareSubscriber$1(CVSCompareSubscriber paramCVSCompareSubscriber)
  {
    this$0 = paramCVSCompareSubscriber;
  }
  
  public void visitFile(ICVSFile file)
    throws CVSException
  {
    byte[] bytes = file.getSyncBytes();
    if (bytes != null) {
      try
      {
        CVSCompareSubscriber.access$0(this$0).getByteStore().setBytes(file.getIResource(), bytes);
      }
      catch (TeamException e)
      {
        throw CVSException.wrapException(e);
      }
    }
  }
  
  public void visitFolder(ICVSFolder folder)
    throws CVSException
  {
    folder.acceptChildren(this);
  }
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.ISubscriberChangeEvent;
import org.eclipse.team.core.subscribers.ISubscriberChangeListener;
import org.eclipse.team.core.subscribers.SubscriberChangeEvent;
import org.eclipse.team.core.variants.IResourceVariantTree;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.core.variants.SessionResourceVariantByteStore;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree;
import org.eclipse.team.internal.ccvs.core.syncinfo.MultiTagResourceVariantTree;

public class CVSCompareSubscriber
  extends CVSSyncTreeSubscriber
  implements ISubscriberChangeListener
{
  public static final String ID = "org.eclipse.team.cvs.ui.compare-participant";
  public static final String ID_MODAL = "org.eclipse.team.cvs.ui.compare-participant-modal";
  public static final String QUALIFIED_NAME = "org.eclipse.team.cvs.core.compare";
  private static final String UNIQUE_ID_PREFIX = "compare-";
  private IResource[] resources;
  private CVSResourceVariantTree tree;
  
  public CVSCompareSubscriber(IResource[] resources, CVSTag tag)
  {
    super(getUniqueId(), NLS.bind(CVSMessages.CVSCompareSubscriber_2, new String[] { tag.getName() }));
    this.resources = resources;
    tree = new CVSResourceVariantTree(new SessionResourceVariantByteStore(), tag, getCacheFileContentsHint());
    initialize();
  }
  
  public CVSCompareSubscriber(IResource[] resources, CVSTag[] tags, String name)
  {
    super(getUniqueId(), NLS.bind(CVSMessages.CVSCompareSubscriber_2, new String[] { name }));
    resetRoots(resources, tags);
    initialize();
  }
  
  public void resetRoots(IResource[] resources, CVSTag[] tags)
  {
    if (this.resources != null)
    {
      List removed = new ArrayList();
      for (int i = 0; i < this.resources.length; i++)
      {
        IResource resource = this.resources[i];
        removed.add(new SubscriberChangeEvent(this, 4, resource));
      }
      this.resources = new IResource[0];
      fireTeamResourceChange((ISubscriberChangeEvent[])removed.toArray(new ISubscriberChangeEvent[removed.size()]));
      if (tree != null)
      {
        tree.dispose();
        tree = null;
      }
    }
    this.resources = resources;
    MultiTagResourceVariantTree multiTree = new MultiTagResourceVariantTree(new SessionResourceVariantByteStore(), getCacheFileContentsHint());
    for (int i = 0; i < tags.length; i++) {
      multiTree.addResource(resources[i], tags[i]);
    }
    tree = multiTree;
  }
  
  private void initialize()
  {
    CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this);
  }
  
  public void dispose()
  {
    CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().removeListener(this);
    tree.dispose();
  }
  
  private static QualifiedName getUniqueId()
  {
    String uniqueId = Long.toString(System.currentTimeMillis());
    return new QualifiedName("org.eclipse.team.cvs.core.compare", "compare-" + uniqueId);
  }
  
  protected IResourceVariantTree getBaseTree()
  {
    return null;
  }
  
  protected IResourceVariantTree getRemoteTree()
  {
    return tree;
  }
  
  public boolean isThreeWay()
  {
    return false;
  }
  
  public IResource[] roots()
  {
    return resources;
  }
  
  public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas)
  {
    List outgoingDeltas = new ArrayList(deltas.length);
    for (int i = 0; i < deltas.length; i++)
    {
      ISubscriberChangeEvent delta = deltas[i];
      if ((delta.getFlags() & 0x4) != 0)
      {
        IResource resource = delta.getResource();
        outgoingDeltas.addAll(Arrays.asList(handleRemovedRoot(resource)));
      }
      else if ((delta.getFlags() & 0x1) != 0)
      {
        IResource resource = delta.getResource();
        try
        {
          if (isSupervised(resource)) {
            outgoingDeltas.add(new SubscriberChangeEvent(this, delta.getFlags(), resource));
          }
        }
        catch (TeamException e)
        {
          CVSProviderPlugin.log(e);
        }
      }
    }
    fireTeamResourceChange((SubscriberChangeEvent[])outgoingDeltas.toArray(new SubscriberChangeEvent[outgoingDeltas.size()]));
  }
  
  private SubscriberChangeEvent[] handleRemovedRoot(IResource removedRoot)
  {
    List removals = new ArrayList(resources.length);
    for (int j = 0; j < resources.length; j++)
    {
      IResource root = resources[j];
      if (removedRoot.getFullPath().isPrefixOf(root.getFullPath()))
      {
        removals.add(root);
        try
        {
          tree.flushVariants(root, 2);
        }
        catch (TeamException e)
        {
          CVSProviderPlugin.log(e);
        }
      }
    }
    if (removals.isEmpty()) {
      return new SubscriberChangeEvent[0];
    }
    List newRoots = new ArrayList(resources.length);
    newRoots.addAll(Arrays.asList(resources));
    newRoots.removeAll(removals);
    resources = ((IResource[])newRoots.toArray(new IResource[newRoots.size()]));
    
    SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[removals.size()];
    for (int i = 0; i < deltas.length; i++) {
      deltas[i] = new SubscriberChangeEvent(this, 4, (IResource)removals.get(i));
    }
    return deltas;
  }
  
  public boolean isSupervised(IResource resource)
    throws TeamException
  {
    if (super.isSupervised(resource))
    {
      if ((!resource.exists()) && (!getRemoteTree().hasResourceVariant(resource))) {
        return false;
      }
      if (resources != null) {
        for (int i = 0; i < resources.length; i++)
        {
          IResource root = resources[i];
          if (root.getFullPath().isPrefixOf(resource.getFullPath())) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  protected boolean getCacheFileContentsHint()
  {
    return true;
  }
  
  public CVSTag getTag()
  {
    return tree.getTag(ResourcesPlugin.getWorkspace().getRoot());
  }
  
  public boolean equals(Object other)
  {
    if (this == other) {
      return true;
    }
    if (!(other instanceof CVSCompareSubscriber)) {
      return false;
    }
    CVSCompareSubscriber s = (CVSCompareSubscriber)other;
    CVSResourceVariantTree tree1 = (CVSResourceVariantTree)getRemoteTree();
    CVSResourceVariantTree tree2 = (CVSResourceVariantTree)s.getRemoteTree();
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    CVSTag tag1 = tree1.getTag(root);
    CVSTag tag2 = tree2.getTag(root);
    if ((tag1 == null) || (tag2 == null)) {
      return false;
    }
    return (tag1.equals(tag2)) && (rootsEqual(s));
  }
  
  public void primeRemoteTree()
    throws CVSException
  {
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
      cvsResource.accept(new ICVSResourceVisitor()
      {
        public void visitFile(ICVSFile file)
          throws CVSException
        {
          byte[] bytes = file.getSyncBytes();
          if (bytes != null) {
            try
            {
              tree.getByteStore().setBytes(file.getIResource(), bytes);
            }
            catch (TeamException e)
            {
              throw CVSException.wrapException(e);
            }
          }
        }
        
        public void visitFolder(ICVSFolder folder)
          throws CVSException
        {
          folder.acceptChildren(this);
        }
      });
    }
  }
  
  public CVSTag getTag(IResource root)
  {
    return tree.getTag(root);
  }
  
  public boolean isMultipleTagComparison()
  {
    return getTag() == null;
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

class CVSCoreFileModificationValidator$1
  extends Job
{
  final CVSCoreFileModificationValidator this$0;
  private final IFile[] val$readOnlyFiles;
  
  CVSCoreFileModificationValidator$1(CVSCoreFileModificationValidator paramCVSCoreFileModificationValidator, String $anonymous0, IFile[] paramArrayOfIFile)
  {
    super($anonymous0);this$0 = paramCVSCoreFileModificationValidator;val$readOnlyFiles = paramArrayOfIFile;
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    try
    {
      this$0.performEdit(val$readOnlyFiles, monitor);
    }
    catch (CVSException e)
    {
      return e.getStatus();
    }
    return Status.OK_STATUS;
  }
}

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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourceAttributes;
import org.eclipse.core.resources.team.FileModificationValidationContext;
import org.eclipse.core.resources.team.FileModificationValidator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;

public class CVSCoreFileModificationValidator
  extends FileModificationValidator
  implements ICVSFileModificationValidator
{
  FileModificationValidator uiValidator;
  
  public IStatus validateEdit(IFile[] files, FileModificationValidationContext context)
  {
    IFile[] unmanagedReadOnlyFiles = getUnmanagedReadOnlyFiles(files);
    if (unmanagedReadOnlyFiles.length > 0)
    {
      IStatus status = setWritable(unmanagedReadOnlyFiles);
      if (!status.isOK()) {
        return status;
      }
    }
    IFile[] readOnlyFiles = getManagedReadOnlyFiles(files);
    if (readOnlyFiles.length == 0) {
      return Status.OK_STATUS;
    }
    return edit(readOnlyFiles, context);
  }
  
  public IStatus validateSave(IFile file)
  {
    if (!needsCheckout(file))
    {
      if (file.isReadOnly()) {
        setWritable(new IFile[] { file });
      }
      return Status.OK_STATUS;
    }
    return edit(new IFile[] { file }, null);
  }
  
  protected IStatus edit(IFile[] readOnlyFiles, FileModificationValidationContext context)
  {
    FileModificationValidator override = getUIValidator();
    if (override != null) {
      return override.validateEdit(readOnlyFiles, context);
    }
    performEdit(readOnlyFiles);
    return Status.OK_STATUS;
  }
  
  private FileModificationValidator getUIValidator()
  {
    synchronized (this)
    {
      if (uiValidator == null) {
        uiValidator = getPluggedInValidator();
      }
    }
    return uiValidator;
  }
  
  public IStatus validateMoveDelete(IFile[] files, IProgressMonitor monitor)
  {
    IFile[] readOnlyFiles = getManagedReadOnlyFiles(files);
    if (readOnlyFiles.length == 0) {
      return Status.OK_STATUS;
    }
    performEdit(readOnlyFiles);
    return Status.OK_STATUS;
  }
  
  protected void performEdit(IFile[] readOnlyFiles)
  {
    setWritable(readOnlyFiles);
    Job job = new Job(CVSMessages.CVSCoreFileModificationValidator_editJob)
    {
      private final IFile[] val$readOnlyFiles;
      
      protected IStatus run(IProgressMonitor monitor)
      {
        try
        {
          performEdit(val$readOnlyFiles, monitor);
        }
        catch (CVSException e)
        {
          return e.getStatus();
        }
        return Status.OK_STATUS;
      }
    };
    scheduleEditJob(job);
  }
  
  protected void scheduleEditJob(Job job)
  {
    job.schedule();
  }
  
  protected CVSTeamProvider getProvider(IFile[] files)
  {
    CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(files[0].getProject(), CVSProviderPlugin.getTypeId());
    return provider;
  }
  
  protected void performEdit(IFile[] files, IProgressMonitor monitor)
    throws CVSException
  {
    getProvider(files).edit(files, false, true, true, 0, monitor);
  }
  
  private boolean needsCheckout(IFile file)
  {
    try
    {
      if (file.isReadOnly())
      {
        ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
        return cvsFile.isManaged();
      }
    }
    catch (CVSException e)
    {
      CVSProviderPlugin.log(e);
    }
    return false;
  }
  
  protected IStatus setWritable(IFile[] files)
  {
    for (int i = 0; i < files.length; i++)
    {
      IFile file = files[i];
      ResourceAttributes attributes = file.getResourceAttributes();
      if (attributes != null) {
        attributes.setReadOnly(false);
      }
      try
      {
        file.setResourceAttributes(attributes);
      }
      catch (CoreException e)
      {
        return CVSException.wrapException(e).getStatus();
      }
    }
    return Status.OK_STATUS;
  }
  
  private IFile[] getManagedReadOnlyFiles(IFile[] files)
  {
    List readOnlys = new ArrayList();
    for (int i = 0; i < files.length; i++)
    {
      IFile iFile = files[i];
      if (needsCheckout(iFile)) {
        readOnlys.add(iFile);
      }
    }
    return (IFile[])readOnlys.toArray(new IFile[readOnlys.size()]);
  }
  
  protected IFile[] getUnmanagedReadOnlyFiles(IFile[] files)
  {
    List readOnlys = new ArrayList();
    for (int i = 0; i < files.length; i++)
    {
      IFile iFile = files[i];
      if ((iFile.isReadOnly()) && (!needsCheckout(iFile))) {
        readOnlys.add(iFile);
      }
    }
    return (IFile[])readOnlys.toArray(new IFile[readOnlys.size()]);
  }
  
  private static FileModificationValidator getPluggedInValidator()
  {
    IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.team.cvs.core", "filemodificationvalidator").getExtensions();
    if (extensions.length == 0) {
      return null;
    }
    IExtension extension = extensions[0];
    IConfigurationElement[] configs = extension.getConfigurationElements();
    if (configs.length == 0)
    {
      CVSProviderPlugin.log(4, NLS.bind("The CVS file modification validator is missing from extension {0}", new Object[] { extension.getUniqueIdentifier() }), null);
      return null;
    }
    try
    {
      IConfigurationElement config = configs[0];
      return (FileModificationValidator)config.createExecutableExtension("run");
    }
    catch (CoreException ex)
    {
      CVSProviderPlugin.log(4, NLS.bind("The CVS file modification validator registered as ID {0} could not be instantiated", new Object[] { extension.getUniqueIdentifier() }), ex);
    }
    return null;
  }
  
  public ISchedulingRule validateEditRule(CVSResourceRuleFactory factory, IResource[] resources)
  {
    FileModificationValidator override = getUIValidator();
    if (((override instanceof CVSCoreFileModificationValidator)) && (override != this))
    {
      CVSCoreFileModificationValidator ui = (CVSCoreFileModificationValidator)override;
      return ui.validateEditRule(factory, resources);
    }
    return internalValidateEditRule(factory, resources);
  }
  
  protected final ISchedulingRule internalValidateEditRule(CVSResourceRuleFactory factory, IResource[] resources)
  {
    if (resources.length == 0) {
      return null;
    }
    if (resources.length == 1) {
      return isReadOnly(resources[0]) ? factory.getParent(resources[0]) : null;
    }
    HashSet rules = new HashSet();
    for (int i = 0; i < resources.length; i++) {
      if (isReadOnly(resources[i])) {
        rules.add(factory.getParent(resources[i]));
      }
    }
    return createSchedulingRule(rules);
  }
  
  protected ISchedulingRule createSchedulingRule(Set rules)
  {
    if (rules.isEmpty()) {
      return null;
    }
    if (rules.size() == 1) {
      return (ISchedulingRule)rules.iterator().next();
    }
    ISchedulingRule[] ruleArray = (ISchedulingRule[])rules
      .toArray(new ISchedulingRule[rules.size()]);
    return new MultiRule(ruleArray);
  }
  
  protected final boolean isReadOnly(IResource resource)
  {
    ResourceAttributes a = resource.getResourceAttributes();
    if (a != null) {
      return a.isReadOnly();
    }
    return false;
  }
}

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

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.core.TeamException;

public class CVSException
  extends TeamException
{
  private static final long serialVersionUID = 1L;
  
  public CVSException(CoreException e)
  {
    super(e);
  }
  
  public CVSException(String message)
  {
    this(new CVSStatus(4, message));
  }
  
  public CVSException(IStatus status)
  {
    super(status);
  }
  
  public static CVSException wrapException(IResource resource, String message, IOException e)
  {
    return new CVSException(new CVSStatus(4, -4, message, e, resource));
  }
  
  public static CVSException wrapException(IResource resource, String message, CoreException e)
  {
    return new CVSException(new CVSStatus(4, e.getStatus().getCode(), message, e, resource));
  }
  
  public static CVSException wrapException(Exception e)
  {
    Throwable t = e;
    if ((e instanceof InvocationTargetException))
    {
      Throwable target = ((InvocationTargetException)e).getTargetException();
      if ((target instanceof CVSException)) {
        return (CVSException)target;
      }
      t = target;
    }
    return new CVSException(new CVSStatus(4, -6, t.getMessage() != null ? t.getMessage() : "", t, null));
  }
  
  public static CVSException wrapException(CoreException e)
  {
    if ((e instanceof CVSException)) {
      return (CVSException)e;
    }
    return new CVSException(e);
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree;

class CVSMergeSubscriber$1
  extends CVSResourceVariantTree
{
  final CVSMergeSubscriber this$0;
  
  CVSMergeSubscriber$1(CVSMergeSubscriber paramCVSMergeSubscriber, ResourceVariantByteStore $anonymous0, CVSTag $anonymous1, boolean $anonymous2)
  {
    super($anonymous0, $anonymous1, $anonymous2);this$0 = paramCVSMergeSubscriber;
  }
  
  public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    monitor.beginTask(null, 100);
    try
    {
      IResource[] refreshed = super.refresh(resources, depth, monitor);
      CVSMergeSubscriber.access$0(this$0, refreshed, Policy.subMonitorFor(monitor, 50));
      return refreshed;
    }
    finally
    {
      monitor.done();
    }
  }
}

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

import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.core.RepositoryProvider;

class CVSMergeSubscriber$2
  implements IResourceDeltaVisitor
{
  final CVSMergeSubscriber this$0;
  
  CVSMergeSubscriber$2(CVSMergeSubscriber paramCVSMergeSubscriber)
  {
    this$0 = paramCVSMergeSubscriber;
  }
  
  public boolean visit(IResourceDelta delta)
    throws CoreException
  {
    IResource resource = delta.getResource();
    if (resource.getType() == 4)
    {
      IProject project = (IProject)resource;
      if (!project.isAccessible()) {
        return false;
      }
      if ((delta.getFlags() & 0x4000) != 0) {
        return false;
      }
      if (RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) == null) {
        return false;
      }
    }
    if (CVSMergeSubscriber.access$1(this$0).contains(resource))
    {
      if ((delta.getKind() == 2) || (delta.getKind() == 8192)) {
        this$0.cancel();
      }
      return false;
    }
    return true;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.core.variants.PersistantResourceVariantByteStore;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree;
import org.eclipse.team.internal.ccvs.core.util.Util;

final class CVSMergeSubscriber$MergeBaseTree
  extends CVSResourceVariantTree
{
  private PersistantResourceVariantByteStore mergedSynchronizer;
  final CVSMergeSubscriber this$0;
  
  CVSMergeSubscriber$MergeBaseTree(CVSMergeSubscriber paramCVSMergeSubscriber, ResourceVariantByteStore paramResourceVariantByteStore, CVSTag paramCVSTag, boolean paramBoolean, String paramString, MergeBaseTree paramMergeBaseTree)
  {
    this(paramCVSMergeSubscriber, paramResourceVariantByteStore, paramCVSTag, paramBoolean, paramString);
  }
  
  private CVSMergeSubscriber$MergeBaseTree(CVSMergeSubscriber paramCVSMergeSubscriber, ResourceVariantByteStore cache, CVSTag tag, boolean cacheFileContentsHint, String syncKeyPrefix)
  {
    super(cache, tag, cacheFileContentsHint);this$0 = paramCVSMergeSubscriber;
    mergedSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName("org.eclipse.team.cvs", syncKeyPrefix + "0merged"));
  }
  
  public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    List unrefreshed = new ArrayList();
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      if (!hasResourceVariant(resource)) {
        unrefreshed.add(resource);
      }
    }
    if (unrefreshed.isEmpty())
    {
      monitor.done();
      return new IResource[0];
    }
    IResource[] refreshed = super.refresh((IResource[])unrefreshed.toArray(new IResource[unrefreshed.size()]), depth, monitor);
    return refreshed;
  }
  
  public IResourceVariant getResourceVariant(IResource resource)
    throws TeamException
  {
    byte[] mergedBytes = mergedSynchronizer.getBytes(resource);
    if (mergedBytes != null)
    {
      byte[] parentBytes = getByteStore().getBytes(resource.getParent());
      if (parentBytes != null) {
        return RemoteFile.fromBytes(resource, mergedBytes, parentBytes);
      }
    }
    return super.getResourceVariant(resource);
  }
  
  public void merged(IResource resource, byte[] remoteBytes)
    throws TeamException
  {
    if (remoteBytes == null) {
      getByteStore().deleteBytes(resource);
    } else {
      getByteStore().setBytes(resource, remoteBytes);
    }
  }
  
  public boolean isMerged(IResource resource, byte[] remoteBytes)
    throws TeamException
  {
    byte[] mergedBytes = getByteStore().getBytes(resource);
    return Util.equals(mergedBytes, remoteBytes);
  }
  
  public void dispose()
  {
    mergedSynchronizer.dispose();
    super.dispose();
  }
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.ISubscriberChangeEvent;
import org.eclipse.team.core.subscribers.ISubscriberChangeListener;
import org.eclipse.team.core.subscribers.SubscriberChangeEvent;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.core.variants.IResourceVariantTree;
import org.eclipse.team.core.variants.PersistantResourceVariantByteStore;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;

public class CVSMergeSubscriber
  extends CVSSyncTreeSubscriber
  implements IResourceChangeListener, ISubscriberChangeListener
{
  public static final String ID = "org.eclipse.team.cvs.ui.cvsmerge-participant";
  public static final String ID_MODAL = "org.eclipse.team.cvs.ui.cvsmerge-participant-modal";
  private static final String UNIQUE_ID_PREFIX = "merge-";
  private CVSTag start;
  private CVSTag end;
  private List roots;
  private CVSResourceVariantTree remoteTree;
  private MergeBaseTree baseTree;
  private boolean isModelSync;
  
  private final class MergeBaseTree
    extends CVSResourceVariantTree
  {
    private PersistantResourceVariantByteStore mergedSynchronizer;
    
    MergeBaseTree(ResourceVariantByteStore paramResourceVariantByteStore, CVSTag paramCVSTag, boolean paramBoolean, String paramString, MergeBaseTree paramMergeBaseTree)
    {
      this(paramResourceVariantByteStore, paramCVSTag, paramBoolean, paramString);
    }
    
    private MergeBaseTree(ResourceVariantByteStore cache, CVSTag tag, boolean cacheFileContentsHint, String syncKeyPrefix)
    {
      super(tag, cacheFileContentsHint);
      mergedSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName("org.eclipse.team.cvs", syncKeyPrefix + "0merged"));
    }
    
    public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor)
      throws TeamException
    {
      List unrefreshed = new ArrayList();
      for (int i = 0; i < resources.length; i++)
      {
        IResource resource = resources[i];
        if (!hasResourceVariant(resource)) {
          unrefreshed.add(resource);
        }
      }
      if (unrefreshed.isEmpty())
      {
        monitor.done();
        return new IResource[0];
      }
      IResource[] refreshed = super.refresh((IResource[])unrefreshed.toArray(new IResource[unrefreshed.size()]), depth, monitor);
      return refreshed;
    }
    
    public IResourceVariant getResourceVariant(IResource resource)
      throws TeamException
    {
      byte[] mergedBytes = mergedSynchronizer.getBytes(resource);
      if (mergedBytes != null)
      {
        byte[] parentBytes = getByteStore().getBytes(resource.getParent());
        if (parentBytes != null) {
          return RemoteFile.fromBytes(resource, mergedBytes, parentBytes);
        }
      }
      return super.getResourceVariant(resource);
    }
    
    public void merged(IResource resource, byte[] remoteBytes)
      throws TeamException
    {
      if (remoteBytes == null) {
        getByteStore().deleteBytes(resource);
      } else {
        getByteStore().setBytes(resource, remoteBytes);
      }
    }
    
    public boolean isMerged(IResource resource, byte[] remoteBytes)
      throws TeamException
    {
      byte[] mergedBytes = getByteStore().getBytes(resource);
      return Util.equals(mergedBytes, remoteBytes);
    }
    
    public void dispose()
    {
      mergedSynchronizer.dispose();
      super.dispose();
    }
  }
  
  public CVSMergeSubscriber(IResource[] roots, CVSTag start, CVSTag end, boolean isModelSync)
  {
    this(getUniqueId(), roots, start, end);
    this.isModelSync = isModelSync;
  }
  
  private static QualifiedName getUniqueId()
  {
    String uniqueId = Long.toString(System.currentTimeMillis());
    return new QualifiedName("org.eclipse.team.cvs.ui.cvsmerge-participant", "CVSmerge-" + uniqueId);
  }
  
  public CVSMergeSubscriber(QualifiedName id, IResource[] roots, CVSTag start, CVSTag end)
  {
    super(id, NLS.bind(CVSMessages.CVSMergeSubscriber_2, new String[] { start.getName(), end.getName() }));
    this.start = start;
    this.end = end;
    this.roots = new ArrayList(Arrays.asList(roots));
    initialize();
  }
  
  private void initialize()
  {
    QualifiedName id = getId();
    String syncKeyPrefix = id.getLocalName();
    PersistantResourceVariantByteStore remoteSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName("org.eclipse.team.cvs", syncKeyPrefix + end.getName()));
    remoteTree = new CVSResourceVariantTree(remoteSynchronizer, getEndTag(), getCacheFileContentsHint())
    {
      public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor)
        throws TeamException
      {
        monitor.beginTask(null, 100);
        try
        {
          IResource[] refreshed = super.refresh(resources, depth, monitor);
          CVSMergeSubscriber.this.compareWithRemote(refreshed, Policy.subMonitorFor(monitor, 50));
          return refreshed;
        }
        finally
        {
          monitor.done();
        }
      }
    };
    PersistantResourceVariantByteStore baseSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName("org.eclipse.team.cvs", syncKeyPrefix + start.getName()));
    baseTree = new MergeBaseTree(baseSynchronizer, getStartTag(), getCacheFileContentsHint(), syncKeyPrefix, null);
    
    ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
    CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this);
  }
  
  protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote)
    throws TeamException
  {
    CVSMergeSyncInfo info = new CVSMergeSyncInfo(local, base, remote, this);
    info.init();
    return info;
  }
  
  public void merged(IResource[] resources)
    throws TeamException
  {
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      internalMerged(resource);
    }
    fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, resources));
  }
  
  private void internalMerged(IResource resource)
    throws TeamException
  {
    byte[] remoteBytes = getRemoteByteStore().getBytes(resource);
    baseTree.merged(resource, remoteBytes);
  }
  
  public void cancel()
  {
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    remoteTree.dispose();
    baseTree.dispose();
  }
  
  public IResource[] roots()
  {
    return (IResource[])roots.toArray(new IResource[roots.size()]);
  }
  
  public boolean isSupervised(IResource resource)
    throws TeamException
  {
    return (getBaseTree().hasResourceVariant(resource)) || (getRemoteTree().hasResourceVariant(resource));
  }
  
  public CVSTag getStartTag()
  {
    return start;
  }
  
  public CVSTag getEndTag()
  {
    return end;
  }
  
  boolean isModelSync()
  {
    return isModelSync;
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    try
    {
      IResourceDelta delta = event.getDelta();
      if (delta != null) {
        delta.accept(new IResourceDeltaVisitor()
        {
          public boolean visit(IResourceDelta delta)
            throws CoreException
          {
            IResource resource = delta.getResource();
            if (resource.getType() == 4)
            {
              IProject project = (IProject)resource;
              if (!project.isAccessible()) {
                return false;
              }
              if ((delta.getFlags() & 0x4000) != 0) {
                return false;
              }
              if (RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) == null) {
                return false;
              }
            }
            if (roots.contains(resource))
            {
              if ((delta.getKind() == 2) || (delta.getKind() == 8192)) {
                cancel();
              }
              return false;
            }
            return true;
          }
        });
      }
    }
    catch (CoreException e)
    {
      CVSProviderPlugin.log(e.getStatus());
    }
  }
  
  public boolean isMerged(IResource resource)
    throws TeamException
  {
    byte[] remoteBytes = getRemoteByteStore().getBytes(resource);
    return baseTree.isMerged(resource, remoteBytes);
  }
  
  public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas)
  {
    for (int i = 0; i < deltas.length; i++)
    {
      ISubscriberChangeEvent delta = deltas[i];
      switch (delta.getFlags())
      {
      case 4: 
        IResource resource = delta.getResource();
        if (roots.remove(resource)) {
          fireTeamResourceChange(new ISubscriberChangeEvent[] { delta });
        }
        break;
      }
    }
  }
  
  protected IResourceVariantTree getBaseTree()
  {
    return baseTree;
  }
  
  protected IResourceVariantTree getRemoteTree()
  {
    return remoteTree;
  }
  
  protected boolean getCacheFileContentsHint()
  {
    return true;
  }
  
  private void compareWithRemote(IResource[] refreshed, IProgressMonitor monitor)
    throws CVSException, TeamException
  {
    if (refreshed.length == 0) {
      return;
    }
    SyncInfoFilter.ContentComparisonSyncInfoFilter contentFilter = 
      new SyncInfoFilter.ContentComparisonSyncInfoFilter();
    monitor.beginTask(null, refreshed.length * 100);
    for (int i = 0; i < refreshed.length; i++)
    {
      IResource resource = refreshed[i];
      if (resource.getType() == 1)
      {
        ICVSFile local = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
        byte[] localBytes = local.getSyncBytes();
        byte[] remoteBytes = getRemoteByteStore().getBytes(resource);
        if ((remoteBytes != null) && 
          (localBytes != null) && 
          (local.exists()) && 
          (!ResourceSyncInfo.getRevision(remoteBytes).equals(ResourceSyncInfo.getRevision(localBytes))) && 
          (contentFilter.select(getSyncInfo(resource), Policy.subMonitorFor(monitor, 100)))) {
          internalMerged(resource);
        }
      }
    }
    monitor.done();
  }
  
  private PersistantResourceVariantByteStore getRemoteByteStore()
  {
    return (PersistantResourceVariantByteStore)((CVSResourceVariantTree)getRemoteTree()).getByteStore();
  }
  
  public boolean equals(Object other)
  {
    if
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 27 28 29 30 31 32 33 34 35 36

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