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

project.getName());
  }
}

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

import java.io.File;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.ProjectSetSerializationContext;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ui.dialogs.IPromptCondition;
import org.eclipse.team.internal.ui.dialogs.PromptingDialog;

public class UIProjectSetSerializationContext
  extends ProjectSetSerializationContext
{
  private final Shell shell;
  
  public UIProjectSetSerializationContext(Shell shell, String filename)
  {
    super(filename);
    Assert.isNotNull(shell);
    this.shell = shell;
  }
  
  public Object getShell()
  {
    return shell;
  }
  
  public IProject[] confirmOverwrite(IProject[] projects)
    throws TeamException
  {
    IPromptCondition prompt = new IPromptCondition()
    {
      List resources;
      
      public boolean needsPrompt(IResource resource)
      {
        if ((resource instanceof IProject))
        {
          IProject project = (IProject)resource;
          return ((project.exists()) || (getTargetFile(project).exists())) && (resources.contains(resource));
        }
        return false;
      }
      
      public String promptMessage(IResource resource)
      {
        if (resource.exists()) {
          return NLS.bind(TeamUIMessages.UIProjectSetSerializationContext_0, new String[] { resource.getName() });
        }
        return NLS.bind(TeamUIMessages.UIProjectSetSerializationContext_2, new String[] { resource.getName(), getTargetFile((IProject)resource).getAbsolutePath() });
      }
      
      public File getTargetFile(IProject project)
      {
        return new File(project.getParent().getLocation().toFile(), project.getName());
      }
    };
    PromptingDialog dialog = 
      new PromptingDialog(
      (Shell)getShell(), 
      projects, 
      prompt, 
      TeamUIMessages.UIProjectSetSerializationContext_1);
    try
    {
      resourcesToOverwrite = dialog.promptForMultiple();
    }
    catch (InterruptedException localInterruptedException)
    {
      IResource[] resourcesToOverwrite;
      return null;
    }
    IResource[] resourcesToOverwrite;
    IProject[] projectsToOverwrite = new IProject[resourcesToOverwrite.length];
    System.arraycopy(resourcesToOverwrite, 0, projectsToOverwrite, 0, resourcesToOverwrite.length);
    return projectsToOverwrite;
  }
}

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

import java.util.Comparator;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;

class Utils$1
  implements Comparator
{
  public boolean equals(Object obj)
  {
    return false;
  }
  
  public int compare(Object o1, Object o2)
  {
    IResource resource0 = (IResource)o1;
    IResource resource1 = (IResource)o2;
    return resource0.getFullPath().toString().compareTo(resource1.getFullPath().toString());
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;

class Utils$2
  implements Runnable
{
  private final IRunnableWithProgress val$runnable;
  private final Exception[] val$holder;
  
  Utils$2(IRunnableWithProgress paramIRunnableWithProgress, Exception[] paramArrayOfException)
  {
    val$runnable = paramIRunnableWithProgress;val$holder = paramArrayOfException;
  }
  
  public void run()
  {
    try
    {
      val$runnable.run(new NullProgressMonitor());
    }
    catch (InvocationTargetException e)
    {
      val$holder[0] = e;
    }
    catch (InterruptedException e)
    {
      val$holder[0] = e;
    }
  }
}

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

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

class Utils$3
  implements Runnable
{
  private final Shell[] val$result;
  
  Utils$3(Shell[] paramArrayOfShell)
  {
    val$result = paramArrayOfShell;
  }
  
  public void run()
  {
    val$result[0] = new Shell(Display.getDefault());
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;

class Utils$4
  implements Runnable
{
  private final Throwable val$exception;
  
  Utils$4(Throwable paramThrowable)
  {
    val$exception = paramThrowable;
  }
  
  public void run()
  {
    IStatus error = null;
    Throwable t = val$exception;
    if ((t instanceof InvocationTargetException)) {
      t = ((InvocationTargetException)t).getTargetException();
    }
    if ((t instanceof CoreException)) {
      error = ((CoreException)t).getStatus();
    } else if ((t instanceof TeamException)) {
      error = ((TeamException)t).getStatus();
    } else {
      error = new Status(4, "org.eclipse.team.ui", 1, TeamUIMessages.simpleInternal, t);
    }
    Shell shell = new Shell(Display.getDefault());
    if (error.getSeverity() == 1) {
      MessageDialog.openInformation(shell, TeamUIMessages.information, error.getMessage());
    } else {
      ErrorDialog.openError(shell, TeamUIMessages.exception, null, error);
    }
    shell.dispose();
    if (!(t instanceof TeamException)) {
      TeamUIPlugin.log(error.getSeverity(), error.getMessage(), t);
    }
  }
}

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

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Control;

class Utils$5
  implements Runnable
{
  private final Control val$ctrl;
  private final Runnable val$r;
  
  Utils$5(Control paramControl, Runnable paramRunnable)
  {
    val$ctrl = paramControl;val$r = paramRunnable;
  }
  
  public void run()
  {
    if (!val$ctrl.isDisposed()) {
      BusyIndicator.showWhile(val$ctrl.getDisplay(), val$r);
    }
  }
}

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

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Control;

class Utils$6
  implements Runnable
{
  private final Control val$ctrl;
  private final Runnable val$r;
  
  Utils$6(Control paramControl, Runnable paramRunnable)
  {
    val$ctrl = paramControl;val$r = paramRunnable;
  }
  
  public void run()
  {
    if (!val$ctrl.isDisposed()) {
      BusyIndicator.showWhile(val$ctrl.getDisplay(), val$r);
    }
  }
}

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

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Control;

class Utils$7
  implements Runnable
{
  private final Control val$ctrl;
  private final Runnable val$r;
  
  Utils$7(Control paramControl, Runnable paramRunnable)
  {
    val$ctrl = paramControl;val$r = paramRunnable;
  }
  
  public void run()
  {
    if (!val$ctrl.isDisposed()) {
      BusyIndicator.showWhile(val$ctrl.getDisplay(), val$r);
    }
  }
}

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

public abstract class Utils$Sorter
{
  public abstract boolean compare(Object paramObject1, Object paramObject2);
  
  private Object[] quickSort(Object[] sortedCollection, int left, int right)
  {
    int originalLeft = left;
    int originalRight = right;
    Object mid = sortedCollection[((left + right) / 2)];
    do
    {
      while (compare(sortedCollection[left], mid)) {
        left++;
      }
      while (compare(mid, sortedCollection[right])) {
        right--;
      }
      if (left <= right)
      {
        Object tmp = sortedCollection[left];
        sortedCollection[left] = sortedCollection[right];
        sortedCollection[right] = tmp;
        left++;
        right--;
      }
    } while (left <= right);
    if (originalLeft < right) {
      sortedCollection = quickSort(sortedCollection, originalLeft, right);
    }
    if (left < originalRight) {
      sortedCollection = quickSort(sortedCollection, left, originalRight);
    }
    return sortedCollection;
  }
  
  public Object[] sort(Object[] unSortedCollection)
  {
    int size = unSortedCollection.length;
    Object[] sortedCollection = new Object[size];
    
    System.arraycopy(unSortedCollection, 0, sortedCollection, 0, size);
    if (size > 1) {
      quickSort(sortedCollection, 0, size - 1);
    }
    return sortedCollection;
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.history.IFileHistoryProvider;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.mapping.IResourceDiff;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.internal.core.mapping.CompoundResourceTraversal;
import org.eclipse.team.internal.ui.history.FileRevisionEditorInput;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
import org.eclipse.team.ui.TeamImages;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor;
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
import org.eclipse.ui.IContributorResourceAdapter;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IContributorResourceAdapter2;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ErrorEditorPart;
import org.eclipse.ui.internal.registry.EditorDescriptor;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
import org.osgi.framework.Bundle;

public class Utils
{
  public static boolean RUNNING_TESTS = false;
  public static boolean TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE = false;
  
  public static abstract class Sorter
  {
    public abstract boolean compare(Object paramObject1, Object paramObject2);
    
    private Object[] quickSort(Object[] sortedCollection, int left, int right)
    {
      int originalLeft = left;
      int originalRight = right;
      Object mid = sortedCollection[((left + right) / 2)];
      do
      {
        while (compare(sortedCollection[left], mid)) {
          left++;
        }
        while (compare(mid, sortedCollection[right])) {
          right--;
        }
        if (left <= right)
        {
          Object tmp = sortedCollection[left];
          sortedCollection[left] = sortedCollection[right];
          sortedCollection[right] = tmp;
          left++;
          right--;
        }
      } while (left <= right);
      if (originalLeft < right) {
        sortedCollection = quickSort(sortedCollection, originalLeft, right);
      }
      if (left < originalRight) {
        sortedCollection = quickSort(sortedCollection, left, originalRight);
      }
      return sortedCollection;
    }
    
    public Object[] sort(Object[] unSortedCollection)
    {
      int size = unSortedCollection.length;
      Object[] sortedCollection = new Object[size];
      
      System.arraycopy(unSortedCollection, 0, sortedCollection, 0, size);
      if (size > 1) {
        quickSort(sortedCollection, 0, size - 1);
      }
      return sortedCollection;
    }
  }
  
  public static final Comparator resourceComparator = new Comparator()
  {
    public boolean equals(Object obj)
    {
      return false;
    }
    
    public int compare(Object o1, Object o2)
    {
      IResource resource0 = (IResource)o1;
      IResource resource1 = (IResource)o2;
      return resource0.getFullPath().toString().compareTo(resource1.getFullPath().toString());
    }
  };
  
  public static void handleError(Shell shell, Exception exception, String title, String message)
  {
    IStatus status = null;
    boolean log = false;
    boolean dialog = false;
    Throwable t = exception;
    if ((exception instanceof TeamException))
    {
      status = ((TeamException)exception).getStatus();
      log = false;
      dialog = true;
    }
    else if ((exception instanceof InvocationTargetException))
    {
      t = ((InvocationTargetException)exception).getTargetException();
      if ((t instanceof TeamException))
      {
        status = ((TeamException)t).getStatus();
        log = false;
        dialog = true;
      }
      else if ((t instanceof CoreException))
      {
        status = ((CoreException)t).getStatus();
        log = true;
        dialog = true;
      }
      else
      {
        if ((t instanceof InterruptedException)) {
          return;
        }
        status = new Status(4, "org.eclipse.team.ui", 1, TeamUIMessages.TeamAction_internal, t);
        log = true;
        dialog = true;
      }
    }
    if (status == null) {
      return;
    }
    if (!status.isOK())
    {
      IStatus toShow = status;
      if (status.isMultiStatus())
      {
        IStatus[] children = status.getChildren();
        if (children.length == 1) {
          toShow = children[0];
        }
      }
      if (title == null) {
        title = status.getMessage();
      }
      if (message == null) {
        message = status.getMessage();
      }
      if ((dialog) && (shell != null)) {
        ErrorDialog.openError(shell, title, message, toShow);
      }
      if ((log) || (shell == null)) {
        TeamUIPlugin.log(toShow.getSeverity(), message, t);
      }
    }
  }
  
  public static void runWithProgress(Shell parent, boolean cancelable, IRunnableWithProgress runnable)
    throws InvocationTargetException, InterruptedException
  {
    boolean createdShell = false;
    try
    {
      if ((parent == null) || (parent.isDisposed()))
      {
        Display display = Display.getCurrent();
        if (display == null)
        {
          runnable.run(new NullProgressMonitor()); return;
        }
        Display display;
        parent = display.getActiveShell();
        if (parent == null)
        {
          parent = new Shell(display);
          createdShell = true;
        }
      }
      Exception[] holder = new Exception[1];
      BusyIndicator.showWhile(parent.getDisplay(), new Runnable()
      {
        private final Exception[] val$holder;
        
        public void run()
        {
          try
          {
            run(new NullProgressMonitor());
          }
          catch (InvocationTargetException e)
          {
            val$holder[0] = e;
          }
          catch (InterruptedException e)
          {
            val$holder[0] = e;
          }
        }
      });
      if (holder[0] != null)
      {
        if ((holder[0] instanceof InvocationTargetException)) {
          throw ((InvocationTargetException)holder[0]);
        }
        throw ((InterruptedException)holder[0]);
      }
    }
    finally
    {
      if (createdShell) {
        parent.dispose();
      }
    }
    if (createdShell) {
      parent.dispose();
    }
  }
  
  public static Shell getShell(IWorkbenchSite site)
  {
    return getShell(site, false);
  }
  
  public static Shell getShell(IWorkbenchSite site, boolean syncIfNecessary)
  {
    if (site != null)
    {
      Shell shell = site.getShell();
      if (!shell.isDisposed()) {
        return shell;
      }
    }
    IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
    if (workbench != null)
    {
      IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
      if (window != null) {
        return window.getShell();
      }
    }
    Display display = Display.getCurrent();
    if (display == null)
    {
      display = Display.getDefault();
      if (display.isDisposed()) {
        return null;
      }
      if (syncIfNecessary)
      {
        Shell[] result = new Shell[1];
        Runnable r = new Runnable()
        {
          public void run()
          {
            Utils.this[0] = new Shell(Display.getDefault());
          }
        };
        display.syncExec(r);
        return result[0];
      }
    }
    if (display.isDisposed()) {
      return null;
    }
    return new Shell(display);
  }
  
  public static void handle(Throwable exception)
  {
    TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        IStatus error = null;
        Throwable t = Utils.this;
        if ((t instanceof InvocationTargetException)) {
          t = ((InvocationTargetException)t).getTargetException();
        }
        if ((t instanceof CoreException)) {
          error = ((CoreException)t).getStatus();
        } else if ((t instanceof TeamException)) {
          error = ((TeamException)t).getStatus();
        } else {
          error = new Status(4, "org.eclipse.team.ui", 1, TeamUIMessages.simpleInternal, t);
        }
        Shell shell = new Shell(Display.getDefault());
        if (error.getSeverity() == 1) {
          MessageDialog.openInformation(shell, TeamUIMessages.information, error.getMessage());
        } else {
          ErrorDialog.openError(shell, TeamUIMessages.exception, null, error);
        }
        shell.dispose();
        if (!(t instanceof TeamException)) {
          TeamUIPlugin.log(error.getSeverity(), error.getMessage(), t);
        }
      }
    });
  }
  
  public static Shell findShell()
  {
    Display display = TeamUIPlugin.getStandardDisplay();
    Shell activeShell = display.getActiveShell();
    if (activeShell != null) {
      return activeShell;
    }
    return new Shell(display);
  }
  
  public static void initAction(IAction a, String prefix)
  {
    initAction(a, prefix, Policy.getActionBundle());
  }
  
  public static void initAction(IAction a, String prefix, ResourceBundle bundle)
  {
    initAction(a, prefix, bundle, null);
  }
  
  public static void updateLabels(SyncInfo sync, CompareConfiguration config, IProgressMonitor monitor)
  {
    IResourceVariant remote = sync.getRemote();
    IResourceVariant base = sync.getBase();
    String baseAuthor = null;
    String remoteAuthor = null;
    String localAuthor = null;
    String localContentId = sync.getLocalContentIdentifier();
    String remoteContentId = remote != null ? remote.getContentIdentifier() : null;
    String baseContentId = base != null ? base.getContentIdentifier() : null;
    if (isShowAuthor())
    {
      baseAuthor = getAuthor(base, monitor);
      if ((baseContentId != null) && (baseContentId.equals(remoteContentId))) {
        remoteAuthor = baseAuthor;
      } else {
        remoteAuthor = getAuthor(remote, monitor);
      }
      if (localContentId != null) {
        if (localContentId.equals(baseContentId)) {
          localAuthor = baseAuthor;
        } else if (localContentId.equals(remoteAuthor)) {
          localAuthor = remoteAuthor;
        } else {
          localAuthor = sync.getLocalAuthor(monitor);
        }
      }
    }
    if (localContentId != null)
    {
      if (localAuthor != null) {
        config.setLeftLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelAuthorExists, new String[] { localContentId, localAuthor }));
      } else {
        config.setLeftLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelExists, new String[] { localContentId }));
      }
    }
    else {
      config.setLeftLabel(TeamUIMessages.SyncInfoCompareInput_localLabel);
    }
    if (remote != null)
    {
      if (remoteAuthor != null) {
        config.setRightLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelAuthorExists, new String[] { remoteContentId, remoteAuthor }));
      } else {
        config.setRightLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelExists, new String[] { remoteContentId }));
      }
    }
    else {
      config.setRightLabel(TeamUIMessages.SyncInfoCompareInput_remoteLabel);
    }
    if (base != null)
    {
      if (baseAuthor != null) {
        config.setAncestorLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelAuthorExists, new String[] { baseContentId, baseAuthor }));
      } else {
        config.setAncestorLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelExists, new String[] { baseContentId }));
      }
    }
    else {
      config.setAncestorLabel(TeamUIMessages.SyncInfoCompareInput_baseLabel);
    }
  }
  
  /**
   * @deprecated
   */
  public static void updateLabels(SyncInfo sync, CompareConfiguration config)
  {
    updateLabels(sync, config, null);
  }
  
  public static boolean isShowAuthor()
  {
    IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
    return store.getBoolean("org.eclipse.team.ui.show_author_in_compare_editor");
  }
  
  private static String getAuthor(IResourceVariant variant, IProgressMonitor monitor)
  {
    String author = null;
    if ((variant instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)variant;
      IFileRevision revision = (IFileRevision)adaptable
        .getAdapter(IFileRevision.class);
      if (revision == null) {
        return null;
      }
      try
      {
        IFileRevision complete = revision.withAllProperties(monitor);
        if (complete != null) {
          author = complete.getAuthor();
        }
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    return author;
  }
  
  public static String getLocalContentId(IDiff diff)
  {
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      diff = twd.getLocalChange();
      if (diff == null) {
        diff = twd.getRemoteChange();
      }
    }
    if ((diff instanceof IResourceDiff))
    {
      IResourceDiff rd = (IResourceDiff)diff;
      IResource resource = rd.getResource();
      IFileHistoryProvider provider = getHistoryProvider(resource);
      if (provider != null)
      {
        IFileRevision revision = provider.getWorkspaceFileRevision(resource);
        if (revision != null) {
          return revision.getContentIdentifier();
        }
      }
    }
    return null;
  }
  
  public static IFileHistoryProvider getHistoryProvider(IResource resource)
  {
    RepositoryProvider rp = RepositoryProvider.getProvider(resource.getProject());
    if (rp != null) {
      return rp.getFileHistoryProvider();
    }
    return null;
  }
  
  public static IFileRevision getBase(IDiff diff)
  {
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IDiff remoteChange = twd.getRemoteChange();
      if ((remoteChange instanceof IResourceDiff))
      {
        IResourceDiff rd = (IResourceDiff)remoteChange;
        return rd.getBeforeState();
      }
      IDiff localChange = twd.getLocalChange();
      if ((localChange instanceof IResourceDiff))
      {
        IResourceDiff ld = (IResourceDiff)localChange;
        return ld.getBeforeState();
      }
    }
    return null;
  }
  
  public static IFileRevision getRemote(IDiff diff)
  {
    if ((diff instanceof IResourceDiff))
    {
      IResourceDiff rd = (IResourceDiff)diff;
      return rd.getAfterState();
    }
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      IDiff remoteChange = twd.getRemoteChange();
      if ((remoteChange instanceof IResourceDiff))
      {
        IResourceDiff rd = (IResourceDiff)remoteChange;
        return rd.getAfterState();
      }
      IDiff localChange = twd.getLocalChange();
      if ((localChange instanceof IResourceDiff))
      {
        IResourceDiff ld = (IResourceDiff)localChange;
        return ld.getBeforeState();
      }
    }
    return null;
  }
  
  public static void initAction(IAction a, String prefix, ResourceBundle bundle, String[] bindings)
  {
    String labelKey = "label";
    String tooltipKey = "tooltip";
    String imageKey = "image";
    String descriptionKey = "description";
    if ((prefix != null) && (prefix.length() > 0))
    {
      labelKey = prefix + labelKey;
      tooltipKey = prefix + tooltipKey;
      imageKey = prefix + imageKey;
      descriptionKey = prefix + descriptionKey;
    }
    String s = null;
    if (bindings != null) {
      s = NLS.bind(getString(labelKey, bundle), bindings);
    } else {
      s = getString(labelKey, bundle);
    }
    if (s != null) {
      a.setText(s);
    }
    s = getString(tooltipKey, bundle);
    if (s != null) {
      a.setToolTipText(s);
    }
    s = getString(descriptionKey, bundle);
    if (s != null) {
      a.setDescription(s);
    }
    String relPath = getString(imageKey, bundle);
    if ((relPath != null) && (!relPath.equals(imageKey)) && (relPath.trim().length() > 0))
    {
      String ePath;
      String dPath;
      String ePath;
      if (relPath.indexOf("/") >= 0)
      {
        String path = relPath.substring(1);
        String dPath = 'd' + path;
        ePath = 'e' + path;
      }
      else
      {
        dPath = "dlcl16/" + relPath;
        ePath = "elcl16/" + relPath;
      }
      ImageDescriptor id = TeamImages.getImageDescriptor(dPath);
      if (id != null) {
        a.setDisabledImageDescriptor(id);
      }
      id = TeamUIPlugin.getImageDescriptor(ePath);
      if (id != null) {
        a.setImageDescriptor(id);
      }
    }
  }
  
  public static String getString(String key, ResourceBundle b)
  {
    try
    {
      return b.getString(key);
    }
    catch (MissingResourceException localMissingResourceException)
    {
      return key;
    }
    catch (NullPointerException localNullPointerException) {}
    return "!" + key + "!";
  }
  
  public static String modeToString(int mode)
  {
    switch (mode)
    {
    case 1: 
      return TeamUIMessages.Utils_22;
    case 2: 
      return TeamUIMessages.Utils_23;
    case 4: 
      return TeamUIMessages.Utils_24;
    case 8: 
      return TeamUIMessages.Utils_25;
    }
    return TeamUIMessages.Utils_26;
  }
  
  private static IResource[] getResources(Object[] elements, List nonResources, boolean isContributed, boolean includeMappingResources)
  {
    List resources = new ArrayList();
    for (int i = 0; i < elements.length; i++)
    {
      Object element = elements[i];
      boolean isResource = false;
      if ((element instanceof IResource))
      {
        resources.add(element);
        isResource = true;
      }
      else if ((element instanceof ISynchronizeModelElement))
      {
        IResource resource = ((ISynchronizeModelElement)element).getResource();
        if (resource != null)
        {
          resources.add(resource);
          isResource = true;
        }
      }
      else if ((element instanceof ResourceMapping))
      {
        if (includeMappingResources)
        {
          isResource = true;
          getResources((ResourceMapping)element, resources);
        }
      }
      else if (element != null)
      {
        Object adapted;
        Object adapted;
        if (isContributed) {
          adapted = getResource(element);
        } else {
          adapted = getAdapter(element, IResource.class);
        }
        if ((adapted instanceof IResource))
        {
          IResource resource = (IResource)adapted;
          isResource = true;
          if (resource.getType() != 8) {
            resources.add(resource);
          }
        }
        else
        {
          if (isContributed) {
            adapted = getResourceMapping(element);
          } else {
            adapted = getAdapter(element, ResourceMapping.class);
          }
          if (((adapted instanceof ResourceMapping)) && (includeMappingResources))
          {
            isResource = true;
            getResources((ResourceMapping)adapted, resources);
          }
        }
      }
      if ((!isResource) && 
        (nonResources != null)) {
        nonResources.add(element);
      }
    }
    return (IResource[])resources.toArray(new IResource[resources.size()]);
  }
  
  private static void getResources(ResourceMapping element, List resources)
  {
    try
    {
      ResourceTraversal[] traversals = element.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
      for (int k = 0; k < traversals.length; k++)
      {
        ResourceTraversal traversal = traversals[k];
        IResource[] resourceArray = traversal.getResources();
        for (int j = 0; j < resourceArray.length; j++)
        {
          IResource resource = resourceArray[j];
          resources.add(resource);
        }
      }
    }
    catch (CoreException e)
    {
      TeamUIPlugin.log(new Status(4, "org.eclipse.team.ui", 0, "Error traversing resource mapping", e));
    }
  }
  
  public static Object[] getNonResources(Object[] elements)
  {
    List nonResources = new ArrayList();
    getResources(elements, nonResources, false, false);
    return nonResources.toArray();
  }
  
  public static IResource[] getResources(Object[] element)
  {
    return getResources(element, null, false, false);
  }
  
  public static IResource[] getContributedResources(Object[] elements)
  {
    return getResources(elements, null, true, true);
  }
  
  public static Object getAdapter(Object element, Class adapterType, boolean load)
  {
    if (adapterType.isInstance(element)) {
      return element;
    }
    if ((element instanceof IAdaptable))
    {
      Object adapted = ((IAdaptable)element).getAdapter(adapterType);
      if (adapterType.isInstance(adapted)) {
        return adapted;
      }
    }
    if (load)
    {
      Object adapted = Platform.getAdapterManager().loadAdapter(element, adapterType.getName());
      if (adapterType.isInstance(adapted)) {
        return adapted;
      }
    }
    else
    {
      Object adapted = Platform.getAdapterManager().getAdapter(element, adapterType);
      if (adapterType.isInstance(adapted)) {
        return adapted;
      }
    }
    return null;
  }
  
  public static Object getAdapter(Object element, Class adapterType)
  {
    return getAdapter(element, adapterType, false);
  }
  
  public static boolean hasMatchingDescendant(IStructuredSelection selection, FastSyncInfoFilter filter)
  {
    for (Iterator iter = selection.iterator(); iter.hasNext();)
    {
      Object o = iter.next();
      if (((o instanceof ISynchronizeModelElement)) && 
        (hasMatchingDescendant((ISynchronizeModelElement)o, filter))) {
        return true;
      }
    }
    return false;
  }
  
  private static boolean hasMatchingDescendant(ISynchronizeModelElement element, FastSyncInfoFilter filter)
  {
    if ((element.getKind() != 0) && ((element instanceof SyncInfoModelElement)))
    {
      SyncInfo info = ((SyncInfoModelElement)element).getSyncInfo();
      if ((info != null) && (filter.select(info))) {
        return true;
      }
    }
    IDiffElement[] children = element.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      IDiffElement child = children[i];
      if (((child instanceof ISynchronizeModelElement)) && 
        (hasMatchingDescendant((ISynchronizeModelElement)child, filter))) {
        return true;
      }
    }
    return false;
  }
  
  public static IDiffElement[] getDiffNodes(Object[] selected)
  {
    Set result = new HashSet();
    for (int i = 0; i < selected.length; i++)
    {
      Object object = selected[i];
      if ((object instanceof IDiffElement)) {
        collectAllNodes((IDiffElement)object, result);
      }
    }
    return (IDiffElement[])result.toArray(new IDiffElement[result.size()]);
  }
  
  private static void collectAllNodes(IDiffElement element, Set nodes)
  {
    if (element.getKind() != 0) {
      nodes.add(element);
    }
    if ((element instanceof IDiffContainer))
    {
      IDiffElement[] children = ((IDiffContainer)element).getChildren();
      for (int i = 0; i < children.length; i++) {
        collectAllNodes(children[i], nodes);
      }
    }
  }
  
  public static void schedule(Job job, IWorkbenchSite site)
  {
    if (site != null)
    {
      IWorkbenchSiteProgressService siteProgress = (IWorkbenchSiteProgressService)site.getAdapter(IWorkbenchSiteProgressService.class);
      if (siteProgress != null)
      {
        siteProgress.schedule(job, 0L, true);
        return;
      }
    }
    job.schedule();
  }
  
  /* Error */
  public static byte[] readBytes(InputStream in)
  {
    // Byte code:
    //   0: new 502	java/io/ByteArrayOutputStream
    //   3: dup
    //   4: invokespecial 1072	java/io/ByteArrayOutputStream:<init>	()V
    //   7: astore_1
    //   8: aload_0
    //   9: invokevirtual 1076	java/io/InputStream:read	()I
    //   12: istore_2
    //   13: iload_2
    //   14: iconst_m1
    //   15: if_icmpne +6 -> 21
    //   18: goto +57 -> 75
    //   21: aload_1
    //   22: iload_2
    //   23: invokevirtual 1075	java/io/ByteArrayOutputStream:write	(I)V
    //   26: goto -18 -> 8
    //   29: pop
    //   30: aload_0
    //   31: ifnull +11 -> 42
    //   34: aload_0
    //   35: invokevirtual 1077	java/io/InputStream:close	()V
    //   38: goto +4 -> 42
    //   41: pop
    //   42: aload_1
    //   43: invokevirtual 1073	java/io/ByteArrayOutputStream:close	()V
    //   46: goto +4 -> 50
    //   49: pop
    //   50: aconst_null
    //   51: areturn
    //   52: astore_3
    //   53: aload_0
    //   54: ifnull +11 -> 65
    //   57: aload_0
    //   58: invokevirtual 1077	java/io/InputStream:close	()V
    //   61: goto +4 -> 65
    //   64: pop
    //   65: aload_1
    //   66: invokevirtual 1073	java/io/ByteArrayOutputStream:close	()V
    //   69: goto +4 -> 73
    //   72: pop
    //   73: aload_3
    //   74: athrow
    //   75: aload_0
    //   76: ifnull +11 -> 87
    //   79: aload_0
    //   80: invokevirtual 1077	java/io/InputStream:close	()V
    //   83: goto +4 -> 87
    //   86: pop
    //   87: aload_1
    //   88: invokevirtual 1073	java/io/ByteArrayOutputStream:close	()V
    //   91: goto +4 -> 95
    //   94: pop
    //   95: aload_1
    //   96: invokevirtual 1074	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   99: areturn
    // Line number table:
    //   Java source line #777	-> byte code offset #0
    //   Java source line #780	-> byte code offset #8
    //   Java source line #781	-> byte code offset #13
    //   Java source line #782	-> byte code offset #18
    //   Java source line #783	-> byte code offset #21
    //   Java source line #779	-> byte code offset #26
    //   Java source line #786	-> byte code offset #29
    //   Java source line #790	-> byte code offset #30
    //   Java source line #792	-> byte code offset #34
    //   Java source line #793	-> byte code offset #41
    //   Java source line #798	-> byte code offset #42
    //   Java source line #799	-> byte code offset #49
    //   Java source line #787	-> byte code offset #50
    //   Java source line #789	-> byte code offset #52
    //   Java source line #790	-> byte code offset #53
    //   Java source line #792	-> byte code offset #57
    //   Java source line #793	-> byte code offset #64
    //   Java source line #798	-> byte code offset #65
    //   Java source line #799	-> byte code offset #72
    //   Java source line #802	-> byte code offset #73
    //   Java source line #790	-> byte code offset #75
    //   Java source line #792	-> byte code offset #79
    //   Java source line #793	-> byte code offset #86
    //   Java source line #798	-> byte code offset #87
    //   Java source line #799	-> byte code offset #94
    //   Java source line #803	-> byte code offset #95
    // Local variable table:
    //   start
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