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

n hasChildren(ISynchronizationContext context, Object elementOrPath)
  {
    Object element = internalGetElement(elementOrPath);
    if ((element instanceof IContainer))
    {
      IContainer container = (IContainer)element;
      if (context != null)
      {
        int depth = getLayoutDepth(container, internalGetPath(elementOrPath));
        if (depth == 0) {
          return false;
        }
        IResourceDiffTree tree = context.getDiffTree();
        IResource[] members = tree.members(container);
        if (members.length > 0)
        {
          if (depth == 2) {
            return true;
          }
          for (int i = 0; i < members.length; i++)
          {
            IResource resource = members[i];
            if (resource.getType() == 1) {
              return true;
            }
          }
        }
      }
    }
    return false;
  }
  
  public TreePath getParentPath(ISynchronizationContext context, ModelProvider provider, Object element)
  {
    if ((element instanceof IResource))
    {
      IResource resource = (IResource)element;
      TreePath treePath = getProviderRootPath(context, provider);
      if (resource.getType() == 8) {
        return null;
      }
      if (resource.getType() == 4) {
        return treePath;
      }
      if (getLayout().equals("org.eclipse.team.ui.flay_layout")) {
        return treePath.createChildPath(resource.getProject());
      }
      if ((getLayout().equals("org.eclipse.team.ui.compressed_layout")) && (resource.getType() == 2)) {
        return treePath.createChildPath(resource.getProject());
      }
      if ((getLayout().equals("org.eclipse.team.ui.compressed_layout")) && (resource.getType() == 1))
      {
        if (resource.getParent().getType() == 4) {
          return treePath.createChildPath(resource.getProject());
        }
        return treePath.createChildPath(resource.getProject()).createChildPath(resource.getParent());
      }
      IResource parent = resource.getParent();
      IResource[] resourcePath = new IResource[parent.getFullPath().segmentCount()];
      for (int i = resourcePath.length - 1; i >= 0; i--)
      {
        resourcePath[i] = parent;
        parent = parent.getParent();
      }
      for (int i = 0; i < resourcePath.length; i++)
      {
        IResource r = resourcePath[i];
        treePath = treePath.createChildPath(r);
      }
      return treePath;
    }
    return null;
  }
  
  private TreePath getProviderRootPath(ISynchronizationContext context, ModelProvider provider)
  {
    if (context == null) {
      return TreePath.EMPTY.createChildPath(provider);
    }
    return TreePath.EMPTY;
  }
  
  private boolean isFlatPageLayout()
  {
    if (configuration != null)
    {
      String p = (String)configuration.getProperty("org.eclipse.team.ui.pageLayout");
      return (p != null) && (p.equals("org.eclipse.team.ui.flatLayout"));
    }
    return false;
  }
  
  public static synchronized ResourceModelTraversalCalculator getDefault()
  {
    if (instance == null) {
      instance = new ResourceModelTraversalCalculator();
    }
    return instance;
  }
  
  public static synchronized ResourceModelTraversalCalculator getTraversalCalculator(ISynchronizePageConfiguration configuration)
  {
    if (configuration == null) {
      return getDefault();
    }
    ResourceModelTraversalCalculator tc = (ResourceModelTraversalCalculator)configuration.getProperty("org.eclipse.team.ui.resourceModelTraversalCalculator");
    if (tc == null)
    {
      tc = new ResourceModelTraversalCalculator(configuration);
      configuration.setProperty("org.eclipse.team.ui.resourceModelTraversalCalculator", tc);
    }
    return tc;
  }
}

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

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.subscribers.SubscriberMergeContext;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public class RestoreRemovedItemsAction
  extends ResourceModelParticipantAction
{
  public RestoreRemovedItemsAction(ISynchronizePageConfiguration configuration)
  {
    super(null, configuration);
    Utils.initAction(this, "action.restoreRemovedFromView.");
  }
  
  public void run()
  {
    ISynchronizationContext context = getSynchronizationContext();
    if ((context instanceof SubscriberMergeContext))
    {
      SubscriberMergeContext smc = (SubscriberMergeContext)context;
      SubscriberDiffTreeEventHandler handler = (SubscriberDiffTreeEventHandler)smc.getAdapter(SubscriberDiffTreeEventHandler.class);
      handler.reset();
    }
    super.run();
  }
  
  protected boolean isEnabledForSelection(IStructuredSelection selection)
  {
    return true;
  }
}

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

import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.jface.action.Action;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
import org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchModelSynchronizeParticipant;
import org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSubscriber;
import org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSubscriberMergeContext;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;

public class ReversePatchAction
  extends Action
{
  private ISynchronizePageConfiguration configuration;
  private ApplyPatchModelSynchronizeParticipant participant;
  private ApplyPatchSubscriberMergeContext context;
  private ApplyPatchSubscriber subscriber;
  
  public ReversePatchAction(ISynchronizePageConfiguration configuration)
  {
    super("", 2);
    this.configuration = configuration;
    participant = 
      ((ApplyPatchModelSynchronizeParticipant)configuration.getParticipant());
    context = ((ApplyPatchSubscriberMergeContext)participant.getContext());
    subscriber = ((ApplyPatchSubscriber)context.getSubscriber());
  }
  
  public boolean isChecked()
  {
    return subscriber.getPatcher().isReversed();
  }
  
  public void run()
  {
    boolean oldValue = subscriber.getPatcher().isReversed();
    subscriber.getPatcher().setReversed(!oldValue);
    
    SubscriberDiffTreeEventHandler handler = (SubscriberDiffTreeEventHandler)context
      .getAdapter(SubscriberDiffTreeEventHandler.class);
    handler.reset();
    participant.refresh(configuration.getSite().getWorkbenchSite(), context
      .getScope().getMappings());
    
    firePropertyChange("checked", new Boolean(oldValue), new Boolean(
      !oldValue));
  }
}

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

import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public class ShowModelProviderAction
  extends Action
{
  private final ISynchronizePageConfiguration configuration;
  private final ModelProvider provider;
  
  public ShowModelProviderAction(ISynchronizePageConfiguration configuration, ModelProvider provider)
  {
    super(Utils.getLabel(provider), 8);
    this.configuration = configuration;
    this.provider = provider;
    setImageDescriptor(getImageDescriptor(provider));
  }
  
  private ImageDescriptor getImageDescriptor(ModelProvider provider)
  {
    ITeamContentProviderManager manager = TeamUI.getTeamContentProviderManager();
    ITeamContentProviderDescriptor desc = manager.getDescriptor(provider.getId());
    return desc.getImageDescriptor();
  }
  
  public void run()
  {
    configuration.setProperty(
      "org.eclipse.team.ui.activeModelProvider", 
      provider.getDescriptor().getId());
  }
  
  public String getProviderId()
  {
    return provider.getDescriptor().getId();
  }
}

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

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.compare.IStreamMerger;
import org.eclipse.core.resources.IEncodedStorage;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.mapping.IStorageMerger;
import org.eclipse.team.internal.ui.TeamUIPlugin;

public class StorageStreamMerger
  implements IStorageMerger
{
  private IStreamMerger merger;
  
  public StorageStreamMerger(IStreamMerger merger)
  {
    this.merger = merger;
  }
  
  public IStatus merge(OutputStream output, String outputEncoding, IStorage ancestorStorage, IStorage targetStorage, IStorage otherStorage, IProgressMonitor monitor)
    throws CoreException
  {
    InputStream ancestorStream = null;
    InputStream remoteStream = null;
    InputStream targetStream = null;
    try
    {
      ancestorStream = new BufferedInputStream(ancestorStorage.getContents());
      remoteStream = new BufferedInputStream(otherStorage.getContents());
      targetStream = new BufferedInputStream(targetStorage.getContents());
      IStatus status = merger.merge(output, outputEncoding, 
        ancestorStream, getEncoding(ancestorStorage, outputEncoding), 
        targetStream, getEncoding(targetStorage, outputEncoding), 
        remoteStream, getEncoding(otherStorage, outputEncoding), 
        monitor);
      Object localObject2;
      if (status.isOK()) {
        return status;
      }
      IStatus status;
      if (status.getCode() == 1) {
        return new Status(status.getSeverity(), status.getPlugin(), 1, status.getMessage(), status.getException());
      }
      IStatus status;
      return status;
    }
    finally
    {
      try
      {
        if (ancestorStream != null) {
          ancestorStream.close();
        }
      }
      catch (IOException localIOException10) {}
      try
      {
        if (remoteStream != null) {
          remoteStream.close();
        }
      }
      catch (IOException localIOException11) {}
      try
      {
        if (targetStream != null) {
          targetStream.close();
        }
      }
      catch (IOException localIOException12) {}
    }
  }
  
  private String getEncoding(IStorage ancestorStorage, String outputEncoding)
  {
    if ((ancestorStorage instanceof IEncodedStorage))
    {
      IEncodedStorage es = (IEncodedStorage)ancestorStorage;
      try
      {
        String charSet = es.getCharset();
        if (charSet != null) {
          return charSet;
        }
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    return outputEncoding;
  }
  
  public boolean canMergeWithoutAncestor()
  {
    return false;
  }
}

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

import org.eclipse.compare.CompareUI;
import org.eclipse.compare.IStreamMerger;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.team.core.mapping.DelegatingStorageMerger;
import org.eclipse.team.core.mapping.IStorageMerger;
import org.eclipse.team.internal.core.TeamPlugin;
import org.eclipse.team.internal.core.mapping.IStreamMergerDelegate;
import org.eclipse.team.internal.ui.TeamUIPlugin;

public class StreamMergerDelegate
  implements IStreamMergerDelegate
{
  public static void start()
  {
    TeamPlugin.getPlugin().setMergerDelegate(new StreamMergerDelegate());
  }
  
  public IStorageMerger findMerger(IStorage target)
  {
    try
    {
      IContentType type = DelegatingStorageMerger.getContentType(target);
      if (type != null)
      {
        IStreamMerger merger = CompareUI.createStreamMerger(type);
        if (merger != null) {
          return new StorageStreamMerger(merger);
        }
      }
    }
    catch (CoreException e)
    {
      TeamUIPlugin.log(e);
      
      IStreamMerger merger = CompareUI.createStreamMerger(DelegatingStorageMerger.getExtension(target.getName()));
      if (merger != null) {
        return new StorageStreamMerger(merger);
      }
    }
    return null;
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.mapping.IResourceDiff;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;

public final class SynchronizationResourceMappingContext
  extends RemoteResourceMappingContext
{
  private final ISynchronizationContext context;
  
  public SynchronizationResourceMappingContext(ISynchronizationContext context)
  {
    this.context = context;
  }
  
  public boolean isThreeWay()
  {
    return context.getType() == 3;
  }
  
  public boolean hasRemoteChange(IResource resource, IProgressMonitor monitor)
    throws CoreException
  {
    IDiff diff = context.getDiffTree().getDiff(resource);
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IDiff remote = twd.getRemoteChange();
      return (remote != null) && (remote.getKind() != 0);
    }
    return (diff != null) && (diff.getKind() != 0);
  }
  
  public boolean hasLocalChange(IResource resource, IProgressMonitor monitor)
    throws CoreException
  {
    IDiff diff = context.getDiffTree().getDiff(resource);
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IDiff local = twd.getLocalChange();
      return (local != null) && (local.getKind() != 0);
    }
    return false;
  }
  
  public IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor)
    throws CoreException
  {
    IDiff diff = context.getDiffTree().getDiff(file);
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IDiff remote = twd.getRemoteChange();
      if ((remote instanceof IResourceDiff))
      {
        IResourceDiff rd = (IResourceDiff)remote;
        return rd.getAfterState().getStorage(monitor);
      }
    }
    else if ((diff instanceof IResourceDiff))
    {
      IResourceDiff rd = (IResourceDiff)diff;
      return rd.getAfterState().getStorage(monitor);
    }
    return file;
  }
  
  public IStorage fetchBaseContents(IFile file, IProgressMonitor monitor)
    throws CoreException
  {
    IDiff diff = context.getDiffTree().getDiff(file);
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IDiff remote = twd.getRemoteChange();
      if ((remote instanceof IResourceDiff))
      {
        IResourceDiff rd = (IResourceDiff)remote;
        return rd.getBeforeState().getStorage(monitor);
      }
      IDiff local = twd.getLocalChange();
      if ((local instanceof IResourceDiff))
      {
        IResourceDiff rd = (IResourceDiff)local;
        return rd.getBeforeState().getStorage(monitor);
      }
    }
    return null;
  }
  
  public IResource[] fetchMembers(IContainer container, IProgressMonitor monitor)
    throws CoreException
  {
    Set result = new HashSet();
    IResource[] children = container.members();
    for (int i = 0; i < children.length; i++)
    {
      IResource resource = children[i];
      result.add(resource);
    }
    IPath[] childPaths = context.getDiffTree().getChildren(container.getFullPath());
    for (int i = 0; i < childPaths.length; i++)
    {
      IPath path = childPaths[i];
      IDiff delta = context.getDiffTree().getDiff(path);
      IResource child;
      IResource child;
      if (delta == null)
      {
        IResource child;
        if (path.segmentCount() == 1) {
          child = ((IWorkspaceRoot)container).getProject(path.lastSegment());
        } else {
          child = container.getFolder(new Path(path.lastSegment()));
        }
      }
      else
      {
        child = context.getDiffTree().getResource(delta);
      }
      result.add(child);
    }
    return (IResource[])result.toArray(new IResource[result.size()]);
  }
  
  public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor)
    throws CoreException
  {}
  
  public ISynchronizationContext getSynchronizationContext()
  {
    return context;
  }
  
  public IProject[] getProjects()
  {
    Set projects = new HashSet();
    IResource[] roots = context.getScope().getRoots();
    for (int i = 0; i < roots.length; i++)
    {
      IResource resource = roots[i];
      projects.add(resource.getProject());
    }
    return (IProject[])projects.toArray(new IProject[projects.size()]);
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreePathViewerSorter;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.navigator.CommonViewerSorter;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class TeamViewerSorter
  extends TreePathViewerSorter
{
  private CommonViewerSorter sorter;
  private ResourceComparator resourceComparator;
  
  public TeamViewerSorter(CommonViewerSorter sorter)
  {
    this.sorter = sorter;
    resourceComparator = new ResourceComparator(1);
  }
  
  public int category(Object element)
  {
    if ((element instanceof ModelProvider)) {
      return 2;
    }
    IResource resource = Utils.getResource(element);
    if ((resource != null) && (resource.getType() == 4)) {
      return 1;
    }
    return super.category(element);
  }
  
  public int compare(Viewer viewer, TreePath parentPath, Object e1, Object e2)
  {
    if ((parentPath == null) || (parentPath.getSegmentCount() == 0))
    {
      int cat1 = category(e1);
      int cat2 = category(e2);
      if (cat1 != cat2) {
        return cat1 - cat2;
      }
      if (((e1 instanceof ModelProvider)) && ((e2 instanceof ModelProvider)))
      {
        ModelProvider mp1 = (ModelProvider)e1;
        ModelProvider mp2 = (ModelProvider)e2;
        if (isExtends(mp1, mp2.getDescriptor())) {
          return 1;
        }
        if (isExtends(mp2, mp1.getDescriptor())) {
          return -1;
        }
        return mp1.getDescriptor().getLabel().compareTo(mp2.getDescriptor().getLabel());
      }
      IResource r1 = Utils.getResource(e1);
      IResource r2 = Utils.getResource(e2);
      if ((r1 != null) && (r2 != null)) {
        return resourceComparator.compare(viewer, r1, r2);
      }
    }
    return sorter.compare(viewer, parentPath, e1, e2);
  }
  
  private boolean isExtends(ModelProvider mp1, IModelProviderDescriptor desc)
  {
    String[] extended = mp1.getDescriptor().getExtendedModels();
    for (int i = 0; i < extended.length; i++)
    {
      String id = extended[i];
      if (id.equals(desc.getId())) {
        return true;
      }
    }
    for (int i = 0; i < extended.length; i++)
    {
      String id = extended[i];
      IModelProviderDescriptor desc2 = ModelProvider.getModelProviderDescriptor(id);
      if (isExtends(mp1, desc2)) {
        return true;
      }
    }
    return false;
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import org.eclipse.compare.rangedifferencer.RangeDifference;
import org.eclipse.compare.rangedifferencer.RangeDifferencer;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.mapping.IStorageMerger;
import org.eclipse.team.internal.ui.TeamUIMessages;

public class TextStorageMerger
  implements IStorageMerger
{
  public IStatus merge(OutputStream output, String outputEncoding, IStorage ancestor, IStorage target, IStorage other, IProgressMonitor monitor)
    throws CoreException
  {
    try
    {
      LineComparator a = LineComparator.create(ancestor, outputEncoding);
      LineComparator t = LineComparator.create(target, outputEncoding);
      o = LineComparator.create(other, outputEncoding);
    }
    catch (UnsupportedEncodingException e)
    {
      LineComparator o;
      throw new CoreException(new Status(4, "org.eclipse.compare", 3, TeamUIMessages.TextAutoMerge_inputEncodingError, e));
    }
    catch (IOException e)
    {
      throw new CoreException(new Status(4, "org.eclipse.compare", 2, e.getMessage(), e));
    }
    try
    {
      LineComparator o;
      LineComparator t;
      LineComparator a;
      boolean firstLine = true;
      String lineSeparator = System.getProperty("line.separator");
      if (lineSeparator == null) {
        lineSeparator = "\n";
      }
      RangeDifference[] diffs = RangeDifferencer.findRanges(monitor, a, t, o);
      for (int i = 0; i < diffs.length; i++)
      {
        RangeDifference rd = diffs[i];
        switch (rd.kind())
        {
        case 0: 
        case 2: 
        case 4: 
          for (int j = rd.rightStart(); j < rd.rightEnd(); j++)
          {
            String s = o.getLine(j);
            if (!firstLine) {
              output.write(lineSeparator.getBytes(outputEncoding));
            }
            output.write(s.getBytes(outputEncoding));
            firstLine = false;
          }
          break;
        case 3: 
          for (int j = rd.leftStart(); j < rd.leftEnd(); j++)
          {
            String s = t.getLine(j);
            if (!firstLine) {
              output.write(lineSeparator.getBytes(outputEncoding));
            }
            output.write(s.getBytes(outputEncoding));
            firstLine = false;
          }
          break;
        case 1: 
          return new Status(2, "org.eclipse.compare", 1, TeamUIMessages.TextAutoMerge_conflict, null);
        }
      }
    }
    catch (UnsupportedEncodingException e)
    {
      throw new CoreException(new Status(4, "org.eclipse.compare", 3, TeamUIMessages.TextAutoMerge_outputEncodingError, e));
    }
    catch (IOException e)
    {
      return new Status(4, "org.eclipse.compare", 2, TeamUIMessages.TextAutoMerge_outputIOError, e);
    }
    return Status.OK_STATUS;
  }
  
  public boolean canMergeWithoutAncestor()
  {
    return false;
  }
}

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

import java.util.HashMap;
import java.util.Map;
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.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.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.RepositoryProviderType;
import org.eclipse.team.internal.core.IRepositoryProviderListener;
import org.eclipse.team.internal.core.RepositoryProviderManager;
import org.eclipse.team.internal.core.TeamPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.mapping.ITeamStateChangeEvent;
import org.eclipse.team.ui.mapping.ITeamStateChangeListener;
import org.eclipse.team.ui.mapping.ITeamStateDescription;
import org.eclipse.team.ui.mapping.ITeamStateProvider;
import org.eclipse.team.ui.synchronize.TeamStateProvider;

public class WorkspaceTeamStateProvider
  extends TeamStateProvider
  implements ITeamStateChangeListener, IRepositoryProviderListener, IResourceChangeListener
{
  private Map providers = new HashMap();
  
  public WorkspaceTeamStateProvider()
  {
    RepositoryProviderManager.getInstance().addListener(this);
    ResourcesPlugin.getWorkspace().addResourceChangeListener(this, 
      1);
    IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot()
      .getProjects();
    for (int i = 0; i < allProjects.length; i++)
    {
      IProject project = allProjects[i];
      handleProject(project);
    }
  }
  
  public void dispose()
  {
    RepositoryProviderManager.getInstance().removeListener(this);
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
  }
  
  public final boolean isDecorationEnabled(Object element)
  {
    ITeamStateProvider provider = getDecoratedStateProvider(element);
    if (provider != null) {
      return provider.isDecorationEnabled(element);
    }
    return false;
  }
  
  public boolean hasDecoratedState(Object element)
    throws CoreException
  {
    ITeamStateProvider provider = getDecoratedStateProvider(element);
    if (provider != null) {
      provider.hasDecoratedState(element);
    }
    return false;
  }
  
  public final int getDecoratedStateMask(Object element)
  {
    ITeamStateProvider provider = getDecoratedStateProvider(element);
    if (provider != null) {
      return provider.getDecoratedStateMask(element);
    }
    return 0;
  }
  
  public String[] getDecoratedProperties(Object element)
  {
    ITeamStateProvider provider = getDecoratedStateProvider(element);
    if (provider != null) {
      return provider.getDecoratedProperties(element);
    }
    return new String[0];
  }
  
  public ITeamStateDescription getStateDescription(Object element, int stateMask, String[] properties, IProgressMonitor monitor)
    throws CoreException
  {
    ITeamStateProvider provider = getDecoratedStateProvider(element);
    if (provider != null) {
      return provider.getStateDescription(element, stateMask, properties, monitor);
    }
    return null;
  }
  
  public ResourceMappingContext getResourceMappingContext(Object element)
  {
    ITeamStateProvider provider = getDecoratedStateProvider(element);
    if (provider != null) {
      return provider.getResourceMappingContext(element);
    }
    return ResourceMappingContext.LOCAL_CONTEXT;
  }
  
  private ITeamStateProvider getDecoratedStateProvider(Object element)
  {
    RepositoryProviderType type = getProviderType(element);
    if (type != null) {
      return (ITeamStateProvider)Utils.getAdapter(type, 
        ITeamStateProvider.class);
    }
    return null;
  }
  
  private ITeamStateProvider getDecoratedStateProviderForId(String id)
  {
    RepositoryProviderType type = getProviderTypeForId(id);
    if (type != null) {
      return (ITeamStateProvider)Utils.getAdapter(type, 
        ITeamStateProvider.class, true);
    }
    return null;
  }
  
  private RepositoryProviderType getProviderType(Object element)
  {
    ResourceMapping mapping = Utils.getResourceMapping(element);
    if (mapping != null)
    {
      String providerId = getProviderId(mapping.getProjects());
      if (providerId != null) {
        return getProviderTypeForId(providerId);
      }
    }
    return null;
  }
  
  private String getProviderId(IProject[] projects)
  {
    String id = null;
    for (int i = 0; i < projects.length; i++)
    {
      IProject project = projects[i];
      String nextId = getProviderId(project);
      if (id == null) {
        id = nextId;
      } else if ((nextId != null) && (!id.equals(nextId))) {
        return null;
      }
    }
    return id;
  }
  
  private String getProviderId(IProject project)
  {
    RepositoryProvider provider = RepositoryProvider.getProvider(project);
    if (provider != null) {
      return provider.getID();
    }
    return null;
  }
  
  private RepositoryProviderType getProviderTypeForId(String providerId)
  {
    return RepositoryProviderType.getProviderType(providerId);
  }
  
  private void handleProject(IProject project)
  {
    if (RepositoryProvider.isShared(project)) {
      try
      {
        String currentId = project
          .getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY);
        if (currentId != null) {
          listenerForStateChangesForId(currentId);
        }
      }
      catch (CoreException e)
      {
        TeamPlugin.log(e);
      }
    }
  }
  
  private void listenerForStateChangesForId(String id)
  {
    if (!providers.containsKey(id))
    {
      ITeamStateProvider provider = getDecoratedStateProviderForId(id);
      if (provider != null)
      {
        providers.put(id, provider);
        provider.addDecoratedStateChangeListener(this);
      }
    }
  }
  
  public void teamStateChanged(ITeamStateChangeEvent event)
  {
    fireStateChangeEvent(event);
  }
  
  public void providerUnmapped(IProject project) {}
  
  public void providerMapped(RepositoryProvider provider)
  {
    String id = provider.getID();
    listenerForStateChangesForId(id);
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    IResourceDelta delta = event.getDelta();
    IResourceDelta[] projectDeltas = delta
      .getAffectedChildren(5);
    for (int i = 0; i < projectDeltas.length; i++)
    {
      IResourceDelta projectDelta = projectDeltas[i];
      IResource resource = projectDelta.getResource();
      if (((projectDelta.getFlags() & 0x4000) != 0) && 
        (resource.getType() == 4))
      {
        IProject project = (IProject)resource;
        if (project.isAccessible()) {
          handleProject(project);
        }
      }
    }
  }
}

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

public class FileTypeTable$Extension
  extends FileTypeTable.Item
{
  public FileTypeTable$Extension(String name, boolean contributed)
  {
    super(name, contributed);
  }
}

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

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;

final class FileTypeTable$FileTypeComparator
  extends ViewerComparator
{
  private int getCategory(Object element)
  {
    if ((element instanceof FileTypeTable.Extension)) {
      return 0;
    }
    if ((element instanceof FileTypeTable.Name)) {
      return 1;
    }
    return 2;
  }
  
  public int compare(Viewer viewer, Object e1, Object e2)
  {
    int compare = getCategory(e1) - getCategory(e2);
    if (compare != 0) {
      return compare;
    }
    return super.compare(viewer, name, name);
  }
}

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

public abstract class FileTypeTable$Item
  implements Comparable
{
  public final String name;
  public boolean save;
  public int mode;
  public boolean contributed;
  
  public FileTypeTable$Item(String name, boolean contributed)
  {
    this.name = name;this.contributed = contributed;save = true;mode = 2;
  }
  
  public int compareTo(Object o)
  {
    return name.compareTo(name);
  }
}

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

public class FileTypeTable$Name
  extends FileTypeTable.Item
{
  public FileTypeTable$Name(String name, boolean contributed)
  {
    super(name, contributed);
  }
}

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

import java.util.Collection;
import java.util.List;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.util.TextProcessor;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.team.internal.ui.PixelConverter;
import org.eclipse.team.internal.ui.SWTUtils;
import org.eclipse.team.internal.ui.TeamUIMessages;

public class FileTypeTable
  implements ICellModifier, IStructuredContentProvider, ITableLabelProvider
{
  private static final int COMBO_INDEX_BINARY = 0;
  private static final int COMBO_INDEX_TEXT = 1;
  private static final String[] MODES_TEXT = { TeamUIMessages.FileTypeTable_0, TeamUIMessages.FileTypeTable_1 };
  private static final int COMBO_INDEX_SAVE = 0;
  private static final int COMBO_INDEX_DONT_SAVE = 1;
  private static final String[] SAVE_TEXT = { TeamUIMessages.FileTypeTable_2, TeamUIMessages.FileTypeTable_3 };
  private static final int COLUMN_PADDING = 5;
  protected static final String ITEM = "item";
  protected static final String PROPERTY_MODE = "mode";
  protected static final String PROPERTY_SAVE = "save";
  private final TableViewer fTableViewer;
  private final List fItems;
  private final boolean fShowSaveColumn;
  
  private static final class FileTypeComparator
    extends ViewerComparator
  {
    private int getCategory(Object element)
    {
      if ((element instanceof FileTypeTable.Extension)) {
        return 0;
      }
      if ((element instanceof FileTypeTable.Name)) {
        return 1;
      }
      return 2;
    }
    
    public int compare(Viewer viewer, Object e1, Object e2)
    {
      int compare = getCategory(e1) - getCategory(e2);
      if (compare != 0) {
        return compare;
      }
      return super.compare(viewer, name, name);
    }
  }
  
  public static abstract class Item
    implements Comparable
  {
    public final String name;
    public boolean save;
    public int mode;
    public boolean contributed;
    
    public Item(String name, boolean contributed)
    {
      this.name = name;this.contributed = contributed;save = true;mode = 2;
    }
    
    public int compareTo(Object o)
    {
      return name.compareTo(name);
    }
  }
  
  public static class Extension
    extends FileTypeTable.Item
  {
    public Extension(String name, boolean contributed)
    {
      super(contributed);
    }
  }
  
  public static class Name
    extends FileTypeTable.Item
  {
    public Name(String name, boolean contributed)
    {
      super(contributed);
    }
  }
  
  public FileTypeTable(Composite composite, List items, boolean showSaveColumn)
  {
    fShowSaveColumn = showSaveColumn;
    fItems = items;
    
    Table table = new Table(composite, 68098);
    table.setLayoutData(SWTUtils.createHVFillGridData());
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    
    PixelConverter converter = SWTUtils.createDialogPixelConverter(composite);
    
    TableColumn fileColumn = new TableColumn(table, 0, 0);
    fileColumn.setWidth(converter.convertWidthInCharsToPixels(TeamUIMessages.FileTypeTable_4.length() + 5));
    fileColumn.setText(TeamUIMessages.FileTypeTable_4);
    
    TableColumn modeColumn = new TableColumn(table, 0, 1);
    int length;
    try
    {
      int length = TeamUIMessages.FileTypeTable_5.length();
      length = Math.max(length, TeamUIMessages.FileTypeTable_0.length());
      length = Math.max(length, TeamUIMessages.FileTypeTable_1.length());
    }
    catch (RuntimeException localRuntimeException)
    {
      length = 15;
    }
    modeColumn.setWidth(converter.convertWidthInCharsToPixels(length + 5));
    modeColumn.setText(TeamUIMessages.FileTypeTable_5);
    if (fShowSaveColumn)
    {
      TableColumn saveColumn = new TableColumn(table, 0, 2);
      saveColumn.setWidth(converter.convertWidthInCharsToPixels(TeamUIMessages.FileTypeTable_6.length() + 5));
      saveColumn.setText(TeamUIMessages.FileTypeTable_6);
    }
    fTableViewer = new TableViewer(table);
    fTableViewer.setContentProvider(this);
    fTableViewer.setLabelProvider(this);
    fTableViewer.setComparator(new FileTypeComparator());
    
    new TableEditor(table);
    
    CellEditor modeEditor = new ComboBoxCellEditor(table, MODES_TEXT, 8);
    CellEditor saveEditor = new ComboBoxCellEditor(table, SAVE_TEXT, 8);
    if (fShowSaveColumn)
    {
      fTableViewer.setCellEditors(new CellEditor[] { 0, modeEditor, saveEditor });
      fTableViewer.setColumnProperties(new String[] { "item", "mode", "save" });
    }
    else
    {
      fTableViewer.setCellEditors(new CellEditor[] { 0, modeEditor });
      fTableViewer.setColumnProperties(new String[] { "item", "mode" });
    }
    fTableViewer.setCellModifier(this);
    
    fTableViewer.setInput(fItems);
  }
  
  public Object getValue(Objec
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