org.eclipse.team.ui_3.6.101.R37x_v20111109-0800

Result(((PatchedFileVariant)getRemote()).getDiff()).containsProblems())) {
      kind |= 0xC;
    }
    return kind;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSubscriber.ApplyPatchSyncInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.core.patch.Hunk;
import org.eclipse.compare.internal.patch.PatchProjectDiffNode;
import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.compare.patch.IHunk;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IContainer;
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.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberChangeEvent;
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.mapping.LocalResourceVariant;

public class ApplyPatchSubscriber
  extends Subscriber
{
  private WorkspacePatcher patcher;
  private IResourceVariantComparator comparator;
  
  private class ApplyPatchSyncInfo
    extends SyncInfo
  {
    ApplyPatchSyncInfo(IResource paramIResource, IResourceVariant paramIResourceVariant1, IResourceVariant paramIResourceVariant2, IResourceVariantComparator paramIResourceVariantComparator, ApplyPatchSyncInfo paramApplyPatchSyncInfo)
    {
      this(paramIResource, paramIResourceVariant1, paramIResourceVariant2, paramIResourceVariantComparator);
    }
    
    private ApplyPatchSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator)
    {
      super(base, remote, comparator);
    }
    
    protected int calculateKind()
      throws TeamException
    {
      if (!getPatcher().isEnabled(PatchModelProvider.getPatchObject(getLocal(), patcher))) {
        return 0;
      }
      if (getRemote() != null)
      {
        FilePatch2 filePatch2 = ((PatchedFileVariant)getRemote()).getDiff();
        IHunk[] hunks = filePatch2.getHunks();
        for (int i = 0; i < hunks.length; i++) {
          if (patcher.isManuallyMerged((Hunk)hunks[i])) {
            return 0;
          }
        }
      }
      else
      {
        Object patchObject = PatchModelProvider.getPatchObject(getLocal(), patcher);
        if ((patchObject instanceof FilePatch2))
        {
          FilePatch2 filePatch2 = (FilePatch2)patchObject;
          IHunk[] hunks = filePatch2.getHunks();
          for (int i = 0; i < hunks.length; i++) {
            if (patcher.isManuallyMerged((Hunk)hunks[i])) {
              return 0;
            }
          }
        }
      }
      int kind = super.calculateKind();
      if ((getRemote() != null) && 
        (getPatcher().getDiffResult(((PatchedFileVariant)getRemote()).getDiff()).containsProblems())) {
        kind |= 0xC;
      }
      return kind;
    }
  }
  
  public ApplyPatchSubscriber(WorkspacePatcher patcher)
  {
    this.patcher = patcher;
    comparator = new PatchedFileVariantComparator();
    getPatcher().refresh();
  }
  
  public String getName()
  {
    return "Apply Patch Subscriber";
  }
  
  public IResourceVariantComparator getResourceComparator()
  {
    return comparator;
  }
  
  public SyncInfo getSyncInfo(IResource resource)
    throws TeamException
  {
    if (!isSupervised(resource)) {
      return null;
    }
    refresh(new IResource[] { resource }, 0, null);
    try
    {
      FilePatch2 diff = (FilePatch2)PatchModelProvider.getPatchObject(resource, getPatcher());
      
      IResourceVariant remote = null;
      if (diff.getDiffType(patcher.isReversed()) != 2) {
        remote = new PatchedFileVariant(getPatcher(), diff);
      }
      IResourceVariant base = null;
      if (diff.getDiffType(patcher.isReversed()) != 1) {
        base = new LocalResourceVariant(resource);
      }
      SyncInfo info = new ApplyPatchSyncInfo(resource, base, remote, getResourceComparator(), null);
      info.init();
      return info;
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
  
  public boolean isSupervised(IResource resource)
    throws TeamException
  {
    return (resource.getType() == 1) && (PatchModelProvider.getPatchObject(resource, getPatcher()) != null);
  }
  
  public IResource[] members(IResource resource)
    throws TeamException
  {
    try
    {
      if (resource.getType() == 1) {
        return new IResource[0];
      }
      IContainer container = (IContainer)resource;
      
      List existingChildren = new ArrayList();
      if (container.isAccessible()) {
        existingChildren.addAll(Arrays.asList(container.members()));
      }
      FilePatch2[] diffs = getPatcher().getDiffs();
      for (int i = 0; i < diffs.length; i++)
      {
        IResource file = PatchModelProvider.getFile(diffs[i], getPatcher());
        if (container.getFullPath().isPrefixOf(file.getFullPath())) {
          if (!container.exists(file.getProjectRelativePath())) {
            existingChildren.add(file);
          }
        }
      }
      return (IResource[])existingChildren.toArray(new IResource[existingChildren.size()]);
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
  
  public void refresh(IResource[] resources, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    Set diffs = new HashSet();
    for (int i = 0; i < resources.length; i++)
    {
      Object object = PatchModelProvider.getPatchObject(resources[i], 
        getPatcher());
      if ((object instanceof FilePatch2))
      {
        FilePatch2 filePatch = (FilePatch2)object;
        diffs.add(filePatch);
      }
    }
    getPatcher().refresh((FilePatch2[])diffs.toArray(new FilePatch2[0]));
  }
  
  public IResource[] roots()
  {
    Set roots = new HashSet();
    if (getPatcher().isWorkspacePatch())
    {
      IDiffElement[] children = PatchModelProvider.getPatchWorkspace(this).getChildren();
      for (int i = 0; i < children.length; i++)
      {
        DiffProject diffProject = ((PatchProjectDiffNode)children[i]).getDiffProject();
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(diffProject.getName());
        if (project.isAccessible()) {
          roots.add(project);
        }
      }
    }
    else
    {
      roots.add(getPatcher().getTarget());
    }
    return (IResource[])roots.toArray(new IResource[0]);
  }
  
  public WorkspacePatcher getPatcher()
  {
    return patcher;
  }
  
  public void merged(IResource[] resources)
  {
    fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, resources));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSubscriber
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.core.patch.FileDiffResult;
import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.core.patch.HunkResult;
import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceRuleFactory;
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.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberMergeContext;

public class ApplyPatchSubscriberMergeContext
  extends SubscriberMergeContext
{
  protected ApplyPatchSubscriberMergeContext(Subscriber subscriber, ISynchronizationScopeManager manager)
  {
    super(subscriber, manager);
  }
  
  public static ApplyPatchSubscriberMergeContext createContext(Subscriber subscriber, ISynchronizationScopeManager manager)
  {
    ApplyPatchSubscriberMergeContext mergeContext = new ApplyPatchSubscriberMergeContext(
      subscriber, manager);
    
    mergeContext.initialize();
    return mergeContext;
  }
  
  protected void makeInSync(IDiff diff, IProgressMonitor monitor)
    throws CoreException
  {
    markAsMerged(diff, true, monitor);
  }
  
  public void markAsMerged(IDiff node, boolean inSyncHint, IProgressMonitor monitor)
    throws CoreException
  {
    IResource resource = getDiffTree().getResource(node);
    WorkspacePatcher patcher = ((ApplyPatchSubscriber)getSubscriber()).getPatcher();
    Object object = PatchModelProvider.getPatchObject(resource, patcher);
    if ((object instanceof FilePatch2))
    {
      HunkResult[] hunkResults = patcher.getDiffResult((FilePatch2)object).getHunkResults();
      for (int i = 0; i < hunkResults.length; i++) {
        if (inSyncHint)
        {
          if (hunkResults[i].isOK()) {
            patcher.setEnabled(hunkResults[i].getHunk(), false);
          }
        }
        else {
          patcher.setManuallyMerged(hunkResults[i].getHunk(), true);
        }
      }
    }
    else
    {
      patcher.setEnabled(object, false);
    }
    ((ApplyPatchSubscriber)getSubscriber()).merged(new IResource[] { resource });
  }
  
  protected IStatus performThreeWayMerge(IThreeWayDiff diff, IProgressMonitor monitor)
    throws CoreException
  {
    IStatus status = super.performThreeWayMerge(diff, monitor);
    if (status.isOK())
    {
      IResource resource = getDiffTree().getResource(diff);
      WorkspacePatcher patcher = ((ApplyPatchSubscriber)getSubscriber()).getPatcher();
      Object object = PatchModelProvider.getPatchObject(resource, patcher);
      if ((object instanceof FilePatch2))
      {
        HunkResult[] hunkResults = patcher.getDiffResult((FilePatch2)object).getHunkResults();
        for (int i = 0; i < hunkResults.length; i++) {
          if (patcher.isManuallyMerged(hunkResults[i].getHunk()))
          {
            patcher.setManuallyMerged(hunkResults[i].getHunk(), false);
            if (hunkResults[i].isOK()) {
              patcher.setEnabled(hunkResults[i].getHunk(), false);
            }
          }
        }
      }
    }
    return status;
  }
  
  public void reject(IDiff diff, IProgressMonitor monitor)
    throws CoreException
  {}
  
  public ISchedulingRule getMergeRule(IDiff diff)
  {
    IResource resource = getDiffTree().getResource(diff);
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace()
      .getRuleFactory();
    if (!resource.exists())
    {
      IContainer parent = resource.getParent();
      while (!parent.exists())
      {
        resource = parent;
        parent = parent.getParent();
      }
      return ruleFactory.createRule(resource);
    }
    return super.getMergeRule(diff);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSubscriberMergeContext
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.patch.HunkDiffNode;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.internal.ui.mapping.ResourceMergeHandler;
import org.eclipse.team.ui.mapping.SynchronizationOperation;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class ApplyPatchSynchronizationActionProvider$1
  extends ResourceMergeHandler
{
  final ApplyPatchSynchronizationActionProvider this$0;
  
  ApplyPatchSynchronizationActionProvider$1(ApplyPatchSynchronizationActionProvider paramApplyPatchSynchronizationActionProvider, ISynchronizePageConfiguration $anonymous0, boolean $anonymous1)
  {
    super($anonymous0, $anonymous1);this$0 = paramApplyPatchSynchronizationActionProvider;
  }
  
  public void updateEnablement(IStructuredSelection selection)
  {
    super.updateEnablement(selection);
    
    Object[] elements = getOperation().getElements();
    for (int i = 0; i < elements.length; i++) {
      if ((elements[i] instanceof HunkDiffNode))
      {
        setEnabled(false);
        return;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationActionProvider.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.patch.HunkDiffNode;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.internal.ui.mapping.ResourceMarkAsMergedHandler;
import org.eclipse.team.ui.mapping.SynchronizationOperation;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class ApplyPatchSynchronizationActionProvider$2
  extends ResourceMarkAsMergedHandler
{
  final ApplyPatchSynchronizationActionProvider this$0;
  
  ApplyPatchSynchronizationActionProvider$2(ApplyPatchSynchronizationActionProvider paramApplyPatchSynchronizationActionProvider, ISynchronizePageConfiguration $anonymous0)
  {
    super($anonymous0);this$0 = paramApplyPatchSynchronizationActionProvider;
  }
  
  public void updateEnablement(IStructuredSelection selection)
  {
    super.updateEnablement(selection);
    
    Object[] elements = getOperation().getElements();
    for (int i = 0; i < elements.length; i++) {
      if ((elements[i] instanceof HunkDiffNode))
      {
        setEnabled(false);
        return;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationActionProvider.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.patch.HunkDiffNode;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.internal.ui.mapping.ResourceMarkAsMergedHandler;
import org.eclipse.team.internal.ui.mapping.ResourceMergeHandler;
import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
import org.eclipse.team.ui.mapping.SynchronizationOperation;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public class ApplyPatchSynchronizationActionProvider
  extends SynchronizationActionProvider
{
  protected void initialize()
  {
    super.initialize();
    ISynchronizePageConfiguration configuration = getSynchronizePageConfiguration();
    
    registerHandler("org.eclipse.team.ui.mergeAction", new ResourceMergeHandler(
      configuration, false)
      {
        public void updateEnablement(IStructuredSelection selection)
        {
          super.updateEnablement(selection);
          
          Object[] elements = getOperation().getElements();
          for (int i = 0; i < elements.length; i++) {
            if ((elements[i] instanceof HunkDiffNode))
            {
              setEnabled(false);
              return;
            }
          }
        }
      });
    registerHandler("org.eclipse.team.ui.markAsMergeAction", 
      new ResourceMarkAsMergedHandler(configuration)
      {
        public void updateEnablement(IStructuredSelection selection)
        {
          super.updateEnablement(selection);
          
          Object[] elements = getOperation().getElements();
          for (int i = 0; i < elements.length; i++) {
            if ((elements[i] instanceof HunkDiffNode))
            {
              setEnabled(false);
              return;
            }
          }
        }
      });
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationActionProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.patch.PatchTargetPage;
import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.jface.wizard.IWizardPage;

class ApplyPatchSynchronizationWizard$1
  extends PatchTargetPage
{
  final ApplyPatchSynchronizationWizard this$0;
  
  ApplyPatchSynchronizationWizard$1(ApplyPatchSynchronizationWizard paramApplyPatchSynchronizationWizard, WorkspacePatcher $anonymous0)
  {
    super($anonymous0);this$0 = paramApplyPatchSynchronizationWizard;
  }
  
  public IWizardPage getNextPage()
  {
    IWizardPage nextPage = super.getNextPage();
    if ((!ApplyPatchSynchronizationWizard.access$0(this$0)) && (nextPage != this)) {
      return nextPage.getNextPage();
    }
    return nextPage;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationWizard.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.team.internal.ui.TeamUIMessages;

class ApplyPatchSynchronizationWizard$2
  extends Job
{
  final ApplyPatchSynchronizationWizard this$0;
  private final IProject[] val$projects;
  
  ApplyPatchSynchronizationWizard$2(ApplyPatchSynchronizationWizard paramApplyPatchSynchronizationWizard, String $anonymous0, IProject[] paramArrayOfIProject)
  {
    super($anonymous0);this$0 = paramApplyPatchSynchronizationWizard;val$projects = paramArrayOfIProject;
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    monitor.beginTask(
      TeamUIMessages.PatchInaccessibleProjectsPage_openingProjects, 
      val$projects.length);
    MultiStatus errorStatus = new MultiStatus(
      "org.eclipse.team.ui", 
      4, 
      TeamUIMessages.PatchInaccessibleProjectsPage_openingProjects, 
      null);
    for (int i = 0; i < val$projects.length; i++)
    {
      IProject project = val$projects[i];
      try
      {
        project.open(new SubProgressMonitor(monitor, 1));
      }
      catch (CoreException e)
      {
        errorStatus.add(e.getStatus());
      }
    }
    monitor.done();
    return errorStatus;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationWizard.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.patch.InputPatchPage;
import org.eclipse.compare.internal.patch.PatchTargetPage;
import org.eclipse.compare.internal.patch.PatchWizard;
import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.team.core.subscribers.SubscriberMergeContext;
import org.eclipse.team.core.subscribers.SubscriberScopeManager;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.wizards.PatchInaccessibleProjectsPage;
import org.eclipse.team.ui.IConfigurationWizard;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
import org.eclipse.ui.IWorkbench;

public class ApplyPatchSynchronizationWizard
  extends PatchWizard
  implements IConfigurationWizard
{
  private PatchInaccessibleProjectsPage fPatchInaccessibleProjectsPage;
  
  public ApplyPatchSynchronizationWizard()
  {
    this(null, null, new CompareConfiguration());
  }
  
  public ApplyPatchSynchronizationWizard(IStorage patch, IResource target, CompareConfiguration configuration)
  {
    super(patch, target, configuration);
    setNeedsProgressMonitor(true);
  }
  
  public boolean performFinish()
  {
    if (fPatchInaccessibleProjectsPage != null)
    {
      IProject[] projects = fPatchInaccessibleProjectsPage
        .getSelectedProjects();
      if ((projects != null) && (projects.length != 0)) {
        openSelectedProjects(projects);
      }
    }
    ApplyPatchSubscriber subscriber = new ApplyPatchSubscriber(getPatcher());
    
    ResourceMapping[] inputMappings = Utils.getResourceMappings(subscriber
      .roots());
    
    SubscriberScopeManager scopeManager = new SubscriberScopeManager(
      subscriber.getName(), inputMappings, subscriber, true);
    
    SubscriberMergeContext mergeContext = 
      ApplyPatchSubscriberMergeContext.createContext(subscriber, scopeManager);
    
    ModelSynchronizeParticipant participant = new ApplyPatchModelSynchronizeParticipant(
      mergeContext);
    TeamUI.getSynchronizeManager().addSynchronizeParticipants(
      new ISynchronizeParticipant[] { participant });
    
    participant.run(null);
    return true;
  }
  
  public void init(IWorkbench workbench, IProject project) {}
  
  public void addPages()
  {
    if (getPatch() == null) {
      addPage(fPatchWizardPage = new InputPatchPage(this));
    }
    if ((getPatch() == null) || (!getPatcher().isWorkspacePatch())) {
      addPage( = new PatchTargetPage(getPatcher())
      {
        public IWizardPage getNextPage()
        {
          IWizardPage nextPage = super.getNextPage();
          if ((!ApplyPatchSynchronizationWizard.this.isTargetingInaccessibleProjects()) && (nextPage != this)) {
            return nextPage.getNextPage();
          }
          return nextPage;
        }
      });
    }
    if ((getPatch() == null) || (isTargetingInaccessibleProjects())) {
      addPage(fPatchInaccessibleProjectsPage = new PatchInaccessibleProjectsPage(
        getPatcher()));
    }
    addPage(new PatchParsedPage());
  }
  
  public boolean isComplete()
  {
    if ((getPatch() == null) || (!getPatcher().isWorkspacePatch()) || 
      (isTargetingInaccessibleProjects())) {
      return false;
    }
    return true;
  }
  
  private boolean isTargetingInaccessibleProjects()
  {
    DiffProject[] diffProjects = getPatcher().getDiffProjects();
    if (diffProjects != null) {
      for (int i = 0; i < diffProjects.length; i++)
      {
        IProject project = ResourcesPlugin.getWorkspace().getRoot()
          .getProject(diffProjects[i].getName());
        if (!project.isAccessible()) {
          return true;
        }
      }
    }
    return false;
  }
  
  public boolean canFinish()
  {
    IWizardPage currentPage = getContainer().getCurrentPage();
    if (currentPage.getName().equals(
      "PatchInaccessibleProjectsPage")) {
      return currentPage.isPageComplete();
    }
    if (currentPage.getName().equals("PatchParsedPage")) {
      return currentPage.isPageComplete();
    }
    return super.canFinish();
  }
  
  public WorkspacePatcher getPatcher()
  {
    return super.getPatcher();
  }
  
  private void openSelectedProjects(IProject[] projects)
  {
    Job openProjectsJob = new Job(
      TeamUIMessages.PatchInaccessibleProjectsPage_openingProjects)
      {
        private final IProject[] val$projects;
        
        protected IStatus run(IProgressMonitor monitor)
        {
          monitor.beginTask(
            TeamUIMessages.PatchInaccessibleProjectsPage_openingProjects, 
            val$projects.length);
          MultiStatus errorStatus = new MultiStatus(
            "org.eclipse.team.ui", 
            4, 
            TeamUIMessages.PatchInaccessibleProjectsPage_openingProjects, 
            null);
          for (int i = 0; i < val$projects.length; i++)
          {
            IProject project = val$projects[i];
            try
            {
              project.open(new SubProgressMonitor(monitor, 1));
            }
            catch (CoreException e)
            {
              errorStatus.add(e.getStatus());
            }
          }
          monitor.done();
          return errorStatus;
        }
      };
      openProjectsJob.setUser(true);
      openProjectsJob.schedule();
    }
  }

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationWizard
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.core.patch.Hunk;
import org.eclipse.compare.internal.core.patch.HunkResult;
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.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.IPath;
import org.eclipse.core.runtime.IProgressMonitor;

public class DiffProjectResourceMapping
  extends ResourceMapping
{
  private final DiffProject object;
  
  public DiffProjectResourceMapping(DiffProject adaptableObject)
  {
    object = adaptableObject;
  }
  
  public Object getModelObject()
  {
    return object;
  }
  
  public String getModelProviderId()
  {
    return "org.eclipse.team.ui.patchModelProvider";
  }
  
  public IProject[] getProjects()
  {
    IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
      object.getName());
    return new IProject[] { p };
  }
  
  public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException
  {
    return new ResourceTraversal[] { new ResourceTraversal(
      new IResource[] { getResource() }, 2, 
      0) };
  }
  
  private IResource getResource()
  {
    return getProjects()[0];
  }
  
  public boolean contains(ResourceMapping mapping)
  {
    if ((mapping instanceof DiffProjectResourceMapping))
    {
      DiffProject diffProject = (DiffProject)mapping.getModelObject();
      return diffProject.getName().equals(object.getName());
    }
    if ((mapping instanceof FilePatchResourceMapping))
    {
      FileDiffResult filePatch = (FileDiffResult)mapping
        .getModelObject();
      FilePatch2[] filePatches = object.getFileDiffs();
      for (int i = 0; i < filePatches.length; i++) {
        if (filePatches[i].getPath(false).equals(
          filePatch.getTargetPath())) {
          return true;
        }
      }
    }
    else if ((mapping instanceof HunkResourceMapping))
    {
      HunkResult hunk = (HunkResult)mapping.getModelObject();
      DiffProject diffProject = hunk.getHunk().getParent().getProject();
      return diffProject.getName().equals(object.getName());
    }
    return super.contains(mapping);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.DiffProjectResourceMapping
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.patch.WorkspaceFileDiffResult;
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.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;

public class FilePatchResourceMapping
  extends ResourceMapping
{
  private final FileDiffResult object;
  
  public FilePatchResourceMapping(FileDiffResult fileDiffResult)
  {
    object = fileDiffResult;
  }
  
  public Object getModelObject()
  {
    return object;
  }
  
  public String getModelProviderId()
  {
    return "org.eclipse.team.ui.patchModelProvider";
  }
  
  public IProject[] getProjects()
  {
    DiffProject dp = object.getDiff().getProject();
    IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
      dp.getName());
    return new IProject[] { p };
  }
  
  public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException
  {
    return new ResourceTraversal[] { new ResourceTraversal(
      new IResource[] { getResource() }, 2, 
      0) };
  }
  
  private IResource getResource()
  {
    return ((WorkspaceFileDiffResult)object).getTargetFile();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.FilePatchResourceMapping
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.core.patch.Hunk;
import org.eclipse.compare.internal.core.patch.HunkResult;
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.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.IPath;
import org.eclipse.core.runtime.IProgressMonitor;

public class HunkResourceMapping
  extends ResourceMapping
{
  private final HunkResult object;
  
  public HunkResourceMapping(HunkResult hunkResult)
  {
    object = hunkResult;
  }
  
  public Object getModelObject()
  {
    return object;
  }
  
  public String getModelProviderId()
  {
    return "org.eclipse.team.ui.patchModelProvider";
  }
  
  public IProject[] getProjects()
  {
    DiffProject dp = object.getHunk().getParent()
      .getProject();
    IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
      dp.getName());
    return new IProject[] { p };
  }
  
  private IResource getResource()
  {
    IPath path = object.getHunk().getParent().getPath(false);
    return getProjects()[0].getFile(path);
  }
  
  public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor)
    throws CoreException
  {
    return new ResourceTraversal[] { new ResourceTraversal(
      new IResource[] { getResource() }, 0, 
      0) };
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.HunkResourceMapping
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.patch.PatchFileDiffNode;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.internal.ui.mapping.DiffTreeChangesSection.ITraversalFactory;
import org.eclipse.team.ui.mapping.SynchronizationCompareAdapter;
import org.eclipse.ui.IMemento;

public class PatchCompareAdapter
  extends SynchronizationCompareAdapter
  implements DiffTreeChangesSection.ITraversalFactory
{
  public ICompareInput asCompareInput(ISynchronizationContext context, Object o)
  {
    if ((o instanceof PatchFileDiffNode)) {
      return super.asCompareInput(context, ((PatchFileDiffNode)o)
        .getResource());
    }
    if ((o instanceof ICompareInput)) {
      return (ICompareInput)o;
    }
    return super.asCompareInput(context, o);
  }
  
  public void save(ResourceMapping[] mappings, IMemento memento) {}
  
  public ResourceMapping[] restore(IMemento memento)
  {
    return null;
  }
  
  public ResourceTraversal[] getTraversals(ISynchronizationScope scope)
  {
    return scope.getTraversals("org.eclipse.core.resources.modelProvider");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.PatchCompareAdapter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.patch.HunkDiffNode;
import org.eclipse.compare.internal.patch.PatchDiffNode;
import org.eclipse.compare.internal.patch.PatchFileDiffNode;
import org.eclipse.compare.internal.patch.PatchProjectDiffNode;
import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.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.ResourceMapping;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.internal.core.TeamPlugin;

public class PatchModelProvider
  extends ModelProvider
{
  public static final String ID = "org.eclipse.team.ui.patchModelProvider";
  private static PatchModelProvider provider;
  
  public static PatchModelProvider getProvider()
  {
    if (provider == null) {
      try
      {
        provider = (PatchModelProvider)
          ModelProvider.getModelProviderDescriptor("org.eclipse.team.ui.patchModelProvider")
          .getModelProvider();
      }
      catch (CoreException e)
      {
        TeamPlugin.log(e);
      }
    }
    return provider;
  }
  
  static ResourceMapping getResourceMapping(IDiffElement object)
  {
    if ((object instanceof PatchProjectDiffNode)) {
      return new DiffProjectResourceMapping(
        ((PatchProjectDiffNode)object).getDiffProject());
    }
    if ((object instanceof PatchFileDiffNode)) {
      return new FilePatchResourceMapping(((PatchFileDiffNode)object)
        .getDiffResult());
    }
    if ((object instanceof HunkDiffNode)) {
      return new HunkResourceMapping(((HunkDiffNode)object)
        .getHunkResult());
    }
    return null;
  }
  
  static IResource getResource(PatchDiffNode element)
  {
    IResource resource = null;
    if ((element instanceof PatchProjectDiffNode)) {
      return ((PatchProjectDiffNode)element).getResource();
    }
    if ((element instanceof PatchFileDiffNode)) {
      return ((PatchFileDiffNode)element).getResource();
    }
    if ((element instanceof HunkDiffNode)) {
      return ((HunkDiffNode)element).getResource();
    }
    return resource;
  }
  
  static Object getPatchObject(IResource resource, WorkspacePatcher patcher)
  {
    if (resource.getType() == 4)
    {
      if (patcher.isWorkspacePatch())
      {
        DiffProject[] diffProjects = patcher.getDiffProjects();
        for (int i = 0; i < diffProjects.length; i++) {
          if (diffProjects[i].getName().equals(resource.getName())) {
            return diffProjects[i];
          }
        }
      }
    }
    else if (resource.getType() == 1)
    {
      FilePatch2[] diffs = patcher.getDiffs();
      for (int i = 0; i < diffs.length; i++) {
        if (resource.equals(getFile(diffs[i], patcher))) {
          return diffs[i];
        }
      }
    }
    return null;
  }
  
  static IFile getFile(FilePatch2 diff, WorkspacePatcher patcher)
  {
    IProject project = null;
    if (patcher.isWorkspacePatch())
    {
      DiffProject diffProject = diff.getProject();
      project = ResourcesPlugin.getWorkspace().getRoot().getProject(
        diffProject.getName());
      return project.getFile(diff.getPath(patcher.isReversed()));
    }
    IResource target = patcher.getTarget();
    if ((target.getType() == 4) || 
      (target.getType() == 2))
    {
      IContainer container = (IContainer)target;
      return container.getFile(diff.getStrippedPath(patcher
        .getStripPrefixSegments(), patcher.isReversed()));
    }
    IContainer container = target.getParent();
    return container.getFile(diff.getStrippedPath(patcher
      .getStripPrefixSegments(), patcher.isReversed()));
  }
  
  public static PatchWorkspace getPatchWorkspace(Subscriber subscriber)
  {
    if ((subscriber instanceof ApplyPatchSubscriber))
    {
      ApplyPatchSubscriber aps = (ApplyPatchSubscriber)subscriber;
      return new PatchWorkspace(aps.getPatcher());
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.patch.PatchModelProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.patch;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.team.internal.ui.TeamUIMessages;

public class PatchParsedPage
  extends WizardPage
{
  public static final String PATCH_PARSED_PAGE_NAME = "PatchParsedPage";
  private Label messageLabel;
  
  public PatchParsedPage()
  {
    super("PatchParsedPage", TeamUIMessages.PatchParsedPage_title, null);
    setDescription(TeamUIMessages.PatchParsedPage_description);
  }
  
  public void createControl(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(272));
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

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-2019. Infinite Loop Ltd