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

	length	slot	name	signature
    //   0	100	0	in	InputStream
    //   7	89	1	bos	java.io.ByteArrayOutputStream
    //   12	11	2	c	int
    //   52	22	3	localObject	Object
    //   29	1	4	localIOException1	IOException
    //   41	1	5	localIOException2	IOException
    //   49	1	6	localIOException3	IOException
    //   64	1	7	localIOException4	IOException
    //   72	1	8	localIOException5	IOException
    //   86	1	9	localIOException6	IOException
    //   94	1	10	localIOException7	IOException
    // Exception table:
    //   from	to	target	type
    //   8	29	29	java/io/IOException
    //   34	38	41	java/io/IOException
    //   42	46	49	java/io/IOException
    //   8	30	52	finally
    //   57	61	64	java/io/IOException
    //   65	69	72	java/io/IOException
    //   79	83	86	java/io/IOException
    //   87	91	94	java/io/IOException
  }
  
  public static boolean equalObject(Object o1, Object o2)
  {
    if ((o1 == null) && (o2 == null)) {
      return true;
    }
    if ((o1 == null) || (o2 == null)) {
      return false;
    }
    return o1.equals(o2);
  }
  
  public static String getKey(String id, String secondaryId)
  {
    return id + '/' + secondaryId;
  }
  
  public static String convertSelection(IResource[] resources)
  {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      if (i > 0) {
        buffer.append(", ");
      }
      buffer.append(resource.getFullPath());
    }
    return buffer.toString();
  }
  
  public static String shortenText(int maxWidth, String textValue)
  {
    int length = textValue.length();
    if (length < maxWidth) {
      return textValue;
    }
    String ellipsis = "...";
    int subStrLen = (maxWidth - ellipsis.length()) / 2;
    int addtl = (maxWidth - ellipsis.length()) % 2;
    
    StringBuffer sb = new StringBuffer();
    sb.append(textValue.substring(0, subStrLen));
    sb.append(ellipsis);
    sb.append(textValue.substring(length - subStrLen - addtl));
    return sb.toString();
  }
  
  public static String getTypeName(ISynchronizeParticipant participant)
  {
    ISynchronizeManager manager = TeamUI.getSynchronizeManager();
    return manager.getParticipantDescriptor(participant.getId()).getName();
  }
  
  public static boolean canUpdateViewer(StructuredViewer viewer)
  {
    if ((viewer == null) || (viewer.getControl().isDisposed())) {
      return false;
    }
    Display display = viewer.getControl().getDisplay();
    if (display == null) {
      return false;
    }
    if (display.getThread() != Thread.currentThread()) {
      return false;
    }
    return true;
  }
  
  public static void asyncExec(Runnable r, StructuredViewer v)
  {
    if (v == null) {
      return;
    }
    Control ctrl = v.getControl();
    if ((ctrl != null) && (!ctrl.isDisposed())) {
      ctrl.getDisplay().asyncExec(new Runnable()
      {
        private final Runnable val$r;
        
        public void run()
        {
          if (!isDisposed()) {
            BusyIndicator.showWhile(getDisplay(), val$r);
          }
        }
      });
    }
  }
  
  public static void syncExec(Runnable r, StructuredViewer v)
  {
    if (v == null) {
      return;
    }
    Control ctrl = v.getControl();
    syncExec(r, ctrl);
  }
  
  public static void syncExec(Runnable r, Control ctrl)
  {
    if ((ctrl != null) && (!ctrl.isDisposed())) {
      ctrl.getDisplay().syncExec(new Runnable()
      {
        private final Runnable val$r;
        
        public void run()
        {
          if (!isDisposed()) {
            BusyIndicator.showWhile(getDisplay(), val$r);
          }
        }
      });
    }
  }
  
  public static void asyncExec(Runnable r, Control ctrl)
  {
    if ((ctrl != null) && (!ctrl.isDisposed())) {
      ctrl.getDisplay().asyncExec(new Runnable()
      {
        private final Runnable val$r;
        
        public void run()
        {
          if (!isDisposed()) {
            BusyIndicator.showWhile(getDisplay(), val$r);
          }
        }
      });
    }
  }
  
  public static SyncInfo getSyncInfo(ISynchronizeModelElement node)
  {
    if ((node instanceof IAdaptable)) {
      return (SyncInfo)((IAdaptable)node).getAdapter(SyncInfo.class);
    }
    return null;
  }
  
  public static ISynchronizationCompareAdapter getCompareAdapter(Object element)
  {
    ModelProvider provider = getModelProvider(element);
    if (provider != null)
    {
      Object o = provider.getAdapter(ISynchronizationCompareAdapter.class);
      if ((o instanceof ISynchronizationCompareAdapter)) {
        return (ISynchronizationCompareAdapter)o;
      }
    }
    return null;
  }
  
  public static ModelProvider getModelProvider(Object o)
  {
    if ((o instanceof ModelProvider)) {
      return (ModelProvider)o;
    }
    ResourceMapping mapping = getResourceMapping(o);
    if (mapping != null) {
      return mapping.getModelProvider();
    }
    return null;
  }
  
  public static IResource getResource(Object o)
  {
    IResource resource = null;
    if ((o instanceof IResource))
    {
      resource = (IResource)o;
    }
    else if ((o instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)o;
      resource = (IResource)adaptable.getAdapter(IResource.class);
      if (resource == null)
      {
        IContributorResourceAdapter adapter = (IContributorResourceAdapter)adaptable.getAdapter(IContributorResourceAdapter.class);
        if (adapter != null) {
          resource = adapter.getAdaptedResource(adaptable);
        }
      }
    }
    return resource;
  }
  
  public static ResourceMapping getResourceMapping(Object o)
  {
    if ((o instanceof ResourceMapping)) {
      return (ResourceMapping)o;
    }
    if ((o instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)o;
      Object adapted = adaptable.getAdapter(ResourceMapping.class);
      if ((adapted instanceof ResourceMapping)) {
        return (ResourceMapping)adapted;
      }
      adapted = adaptable.getAdapter(IContributorResourceAdapter.class);
      if ((adapted instanceof IContributorResourceAdapter2))
      {
        IContributorResourceAdapter2 cra = (IContributorResourceAdapter2)adapted;
        return cra.getAdaptedResourceMapping(adaptable);
      }
    }
    else
    {
      Object adapted = Platform.getAdapterManager().getAdapter(o, ResourceMapping.class);
      if ((adapted instanceof ResourceMapping)) {
        return (ResourceMapping)adapted;
      }
    }
    return null;
  }
  
  public static ResourceMapping[] getResourceMappings(Object[] objects)
  {
    List result = new ArrayList();
    for (int i = 0; i < objects.length; i++)
    {
      Object object = objects[i];
      ResourceMapping mapping = getResourceMapping(object);
      if (mapping != null) {
        result.add(mapping);
      }
    }
    return (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
  }
  
  public static String getLabel(ResourceMapping mapping)
  {
    ModelProvider provider = mapping.getModelProvider();
    ISynchronizationCompareAdapter adapter = getCompareAdapter(provider);
    if (adapter == null) {
      return "";
    }
    String pathString = adapter.getPathString(mapping);
    if ((pathString == null) || (pathString.length() == 0)) {
      return adapter.getName(mapping);
    }
    return pathString;
  }
  
  public static String getLabel(ModelProvider provider)
  {
    ResourceMapping mapping = getResourceMapping(provider);
    if (mapping != null)
    {
      String base = getLabel(mapping);
      if ((base != null) && (base.length() > 0)) {
        return base;
      }
    }
    return provider.getDescriptor().getLabel();
  }
  
  public static String getScopeDescription(ISynchronizationScope scope)
  {
    ResourceMapping[] mappings = scope.getInputMappings();
    if (mappings.length == 1)
    {
      String label = getLabel(mappings[0]);
      if (label == null) {
        return TeamUIMessages.Utils_19;
      }
      return label;
    }
    String desc = convertSelection(mappings);
    if (desc.length() > 0) {
      return shortenText(30, desc);
    }
    return NLS.bind(TeamUIMessages.Utils_18, new Integer(mappings.length));
  }
  
  public static String convertSelection(ResourceMapping[] mappings)
  {
    StringBuffer buffer = new StringBuffer();
    boolean hadOne = false;
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping resourceMapping = mappings[i];
      String label = getLabel(resourceMapping);
      if (label != null)
      {
        if (hadOne) {
          buffer.append(", ");
        }
        hadOne = true;
        buffer.append(label);
      }
    }
    return buffer.toString();
  }
  
  public static ResourceTraversal[] getTraversals(Object[] elements)
    throws CoreException
  {
    CompoundResourceTraversal traversal = new CompoundResourceTraversal();
    for (int i = 0; i < elements.length; i++)
    {
      Object object = elements[i];
      ResourceMapping mapping = getResourceMapping(object);
      if (mapping != null) {
        traversal.addTraversals(mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null));
      }
    }
    return traversal.asTraversals();
  }
  
  public static boolean isTextEditor(IEditorDescriptor descriptor)
    throws CoreException
  {
    if (!(descriptor instanceof EditorDescriptor)) {
      return false;
    }
    EditorDescriptor desc = (EditorDescriptor)descriptor;
    String className = desc.getClassName();
    String contributor = desc.getPluginId();
    if ((className == null) || (contributor == null)) {
      return false;
    }
    try
    {
      Bundle bundle = Platform.getBundle(contributor);
      if (bundle != null)
      {
        Class clazz = bundle.loadClass(className);
        return AbstractDecoratedTextEditor.class.isAssignableFrom(clazz);
      }
    }
    catch (ClassNotFoundException localClassNotFoundException2)
    {
      IEditorPart editor = desc.createEditor();
      editor.dispose();
      return editor instanceof AbstractDecoratedTextEditor;
    }
  }
  
  public static IEditorPart openEditor(IWorkbenchPage page, IFileRevision revision, IProgressMonitor monitor)
    throws CoreException
  {
    IStorage file = revision.getStorage(monitor);
    if ((file instanceof IFile)) {
      return IDE.openEditor(page, (IFile)file, OpenStrategy.activateOnOpen());
    }
    FileRevisionEditorInput fileRevEditorInput = FileRevisionEditorInput.createEditorInputFor(revision, monitor);
    IEditorPart part = openEditor(page, fileRevEditorInput);
    return part;
  }
  
  public static IEditorPart openEditor(IWorkbenchPage page, FileRevisionEditorInput editorInput)
    throws PartInitException
  {
    String id = getEditorId(editorInput);
    return openEditor(page, editorInput, id);
  }
  
  public static IEditorPart openEditor(IWorkbenchPage page, FileRevisionEditorInput editorInput, String editorId)
    throws PartInitException
  {
    try
    {
      IEditorPart part = page.openEditor(editorInput, editorId, 
        OpenStrategy.activateOnOpen());
      if ((part instanceof ErrorEditorPart))
      {
        page.closeEditor(part, false);
        part = null;
      }
      if (part == null) {
        throw new PartInitException(NLS.bind(TeamUIMessages.Utils_17, 
          editorId));
      }
      return part;
    }
    catch (PartInitException e)
    {
      if (editorId.equals("org.eclipse.ui.DefaultTextEditor")) {
        throw e;
      }
    }
    return page.openEditor(editorInput, 
      "org.eclipse.ui.DefaultTextEditor");
  }
  
  public static IEditorDescriptor[] getEditors(IFileRevision revision)
  {
    IEditorRegistry registry = PlatformUI.getWorkbench()
      .getEditorRegistry();
    
    return registry.getEditors(revision.getName());
  }
  
  public static IEditorDescriptor getDefaultEditor(IFileRevision revision)
  {
    IEditorRegistry registry = PlatformUI.getWorkbench()
      .getEditorRegistry();
    return registry.getDefaultEditor(revision.getName());
  }
  
  private static String getEditorId(FileRevisionEditorInput editorInput)
  {
    String id = getEditorId(editorInput.getFileRevision().getName(), getContentType(editorInput));
    return id;
  }
  
  /* Error */
  private static IContentType getContentType(FileRevisionEditorInput editorInput)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aload_0
    //   3: invokevirtual 1196	org/eclipse/team/internal/ui/history/FileRevisionEditorInput:getStorage	()Lorg/eclipse/core/resources/IStorage;
    //   6: invokeinterface 1222 1 0
    //   11: astore_2
    //   12: aload_0
    //   13: invokevirtual 1197	org/eclipse/team/internal/ui/history/FileRevisionEditorInput:getFileRevision	()Lorg/eclipse/team/core/history/IFileRevision;
    //   16: invokeinterface 1247 1 0
    //   21: aload_2
    //   22: invokestatic 1184	org/eclipse/team/internal/ui/Utils:getContentType	(Ljava/lang/String;Ljava/io/InputStream;)Lorg/eclipse/core/runtime/content/IContentType;
    //   25: astore_1
    //   26: goto +14 -> 40
    //   29: astore_3
    //   30: aload_2
    //   31: invokevirtual 1077	java/io/InputStream:close	()V
    //   34: goto +4 -> 38
    //   37: pop
    //   38: aload_3
    //   39: athrow
    //   40: aload_2
    //   41: invokevirtual 1077	java/io/InputStream:close	()V
    //   44: goto +30 -> 74
    //   47: pop
    //   48: goto +26 -> 74
    //   51: astore_2
    //   52: iconst_4
    //   53: ldc_w 480
    //   56: iconst_1
    //   57: anewarray 513	java/lang/String
    //   60: dup
    //   61: iconst_0
    //   62: aload_0
    //   63: invokevirtual 1195	org/eclipse/team/internal/ui/history/FileRevisionEditorInput:getName	()Ljava/lang/String;
    //   66: aastore
    //   67: invokestatic 1125	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   70: aload_2
    //   71: invokestatic 1158	org/eclipse/team/internal/ui/TeamUIPlugin:log	(ILjava/lang/String;Ljava/lang/Throwable;)V
    //   74: aload_1
    //   75: areturn
    // Line number table:
    //   Java source line #1154	-> byte code offset #0
    //   Java source line #1156	-> byte code offset #2
    //   Java source line #1158	-> byte code offset #12
    //   Java source line #1159	-> byte code offset #29
    //   Java source line #1161	-> byte code offset #30
    //   Java source line #1162	-> byte code offset #37
    //   Java source line #1165	-> byte code offset #38
    //   Java source line #1161	-> byte code offset #40
    //   Java source line #1162	-> byte code offset #47
    //   Java source line #1166	-> byte code offset #51
    //   Java source line #1167	-> byte code offset #52
    //   Java source line #1169	-> byte code offset #74
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	76	0	editorInput	FileRevisionEditorInput
    //   1	74	1	type	IContentType
    //   11	30	2	contents	InputStream
    //   51	20	2	e	CoreException
    //   29	10	3	localObject	Object
    //   37	1	5	localIOException1	IOException
    //   47	1	6	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   12	29	29	finally
    //   30	34	37	java/io/IOException
    //   40	44	47	java/io/IOException
    //   2	48	51	org/eclipse/core/runtime/CoreException
  }
  
  private static IContentType getContentType(String fileName, InputStream contents)
  {
    IContentType type = null;
    if (contents != null) {
      try
      {
        type = Platform.getContentTypeManager().findContentTypeFor(contents, fileName);
      }
      catch (IOException e)
      {
        TeamUIPlugin.log(4, NLS.bind("An error occurred reading the contents of file {0}", fileName), e);
      }
    }
    if (type == null) {
      type = Platform.getContentTypeManager().findContentTypeFor(fileName);
    }
    return type;
  }
  
  private static String getEditorId(String fileName, IContentType type)
  {
    IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
    IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type);
    String id;
    String id;
    if ((descriptor == null) || (descriptor.isOpenExternal())) {
      id = "org.eclipse.ui.DefaultTextEditor";
    } else {
      id = descriptor.getId();
    }
    return id;
  }
  
  public static IEditorPart findReusableCompareEditor(CompareEditorInput input, IWorkbenchPage page, Class[] editorInputClasses)
  {
    IEditorReference[] editorRefs = page.getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++)
    {
      IEditorPart part = editorRefs[i].getEditor(false);
      if ((part != null) && ((part instanceof IReusableEditor))) {
        for (int j = 0; j < editorInputClasses.length; j++) {
          if ((editorInputClasses[j].isInstance(part.getEditorInput())) && 
            (part.getEditorInput().equals(input))) {
            return part;
          }
        }
      }
    }
    if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean("org.eclipse.team.ui.reuse_open_compare_editors")) {
      for (int i = 0; i < editorRefs.length; i++)
      {
        IEditorPart part = editorRefs[i].getEditor(false);
        if ((part != null) && 
          ((part.getEditorInput() instanceof SaveableCompareEditorInput)) && 
          ((part instanceof IReusableEditor)) && (!part.isDirty())) {
          return part;
        }
      }
    }
    return null;
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchOperation;

public class ApplyPatchAction
  extends TeamAction
{
  public boolean isEnabled()
  {
    return true;
  }
  
  protected void execute(IAction action)
    throws InvocationTargetException, InterruptedException
  {
    IResource[] resources = getSelectedResources();
    IResource resource = null;
    if (resources.length > 0) {
      resource = resources[0];
    }
    boolean isPatch = false;
    if ((resource instanceof IFile)) {
      try
      {
        isPatch = ApplyPatchOperation.isPatch((IFile)resource);
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    ApplyPatchOperation op;
    ApplyPatchOperation op;
    if (isPatch) {
      op = new ApplyPatchOperation(getTargetPart(), (IFile)resource, null, new CompareConfiguration());
    } else {
      op = new ApplyPatchOperation(getTargetPart(), resource);
    }
    BusyIndicator.showWhile(Display.getDefault(), op);
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;

class CompareAction$1
  extends SelectionAdapter
{
  final CompareAction.SelectAncestorDialog this$1;
  
  CompareAction$1(CompareAction.SelectAncestorDialog paramSelectAncestorDialog)
  {
    this$1 = paramSelectAncestorDialog;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    Button selectedButton = (Button)widget;
    if (!selectedButton.getSelection()) {
      return;
    }
    for (int i = 0; i < 3; i++) {
      if (selectedButton == CompareAction.SelectAncestorDialog.access$0(this$1)[i]) {
        CompareAction.SelectAncestorDialog.access$1(this$1, i);
      }
    }
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.TeamUIMessages;

class CompareAction$SelectAncestorDialog
  extends MessageDialog
{
  private IResource[] theResources;
  IResource ancestorResource;
  IResource leftResource;
  IResource rightResource;
  private Button[] buttons;
  private SelectionListener selectionListener;
  final CompareAction this$0;
  
  public CompareAction$SelectAncestorDialog(CompareAction paramCompareAction, Shell parentShell, IResource[] theResources)
  {
    super(parentShell, TeamUIMessages.SelectAncestorDialog_title, null, TeamUIMessages.SelectAncestorDialog_message, 3, new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);this$0 = paramCompareAction;
    
    selectionListener = new CompareAction.1(this);this.theResources = theResources;
  }
  
  protected Control createCustomArea(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout());
    buttons = new Button[3];
    for (int i = 0; i < 3; i++)
    {
      buttons[i] = new Button(composite, 16);
      buttons[i].addSelectionListener(selectionListener);
      buttons[i].setText(NLS.bind(
        TeamUIMessages.SelectAncestorDialog_option, 
        theResources[i].getFullPath().toPortableString()));
      buttons[i].setFont(parent.getFont());
      
      buttons[i].setSelection(i == 0);
    }
    pickAncestor(0);
    return composite;
  }
  
  private void pickAncestor(int i)
  {
    ancestorResource = theResources[i];
    leftResource = theResources[0];
    rightResource = theResources[2];
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.history.CompareFileRevisionEditorInput;
import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbenchPage;

public class CompareAction
  extends TeamAction
{
  protected void execute(IAction action)
    throws InvocationTargetException, InterruptedException
  {
    IResource[] selectedResources = getSelectedResources();
    
    ITypedElement ancestor = null;
    ITypedElement left = null;
    ITypedElement right = null;
    if (selectedResources.length == 2)
    {
      if (selectedResources[0] != null) {
        left = getElementFor(selectedResources[0]);
      }
      if (selectedResources[1] != null) {
        right = getElementFor(selectedResources[1]);
      }
    }
    else if (selectedResources.length == 3)
    {
      SelectAncestorDialog dialog = new SelectAncestorDialog(getShell(), 
        selectedResources);
      int code = dialog.open();
      if (code != 0) {
        return;
      }
      ancestor = getElementFor(ancestorResource);
      left = getElementFor(leftResource);
      right = getElementFor(rightResource);
    }
    else
    {
      return;
    }
    openInCompare(ancestor, left, right);
  }
  
  private void openInCompare(ITypedElement ancestor, ITypedElement left, ITypedElement right)
  {
    IWorkbenchPage workBenchPage = getTargetPage();
    CompareEditorInput input = new SaveablesCompareEditorInput(ancestor, 
      left, right, workBenchPage);
    IEditorPart editor = Utils.findReusableCompareEditor(input, 
      workBenchPage, 
      new Class[] { CompareFileRevisionEditorInput.class });
    if (editor != null)
    {
      IEditorInput otherInput = editor.getEditorInput();
      if (otherInput.equals(input))
      {
        workBenchPage.activate(editor);
      }
      else
      {
        CompareUI.reuseCompareEditor(input, (IReusableEditor)editor);
        workBenchPage.activate(editor);
      }
    }
    else
    {
      CompareUI.openCompareEditor(input);
    }
  }
  
  public boolean isEnabled()
  {
    int l = getSelectedResources().length;
    return (l == 2) || (l == 3);
  }
  
  private ITypedElement getElementFor(IResource resource)
  {
    return SaveablesCompareEditorInput.createFileElement((IFile)resource);
  }
  
  private class SelectAncestorDialog
    extends MessageDialog
  {
    private IResource[] theResources;
    IResource ancestorResource;
    IResource leftResource;
    IResource rightResource;
    private Button[] buttons;
    
    public SelectAncestorDialog(Shell parentShell, IResource[] theResources)
    {
      super(TeamUIMessages.SelectAncestorDialog_title, null, TeamUIMessages.SelectAncestorDialog_message, 3, new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
      this.theResources = theResources;
    }
    
    protected Control createCustomArea(Composite parent)
    {
      Composite composite = new Composite(parent, 0);
      composite.setLayout(new GridLayout());
      buttons = new Button[3];
      for (int i = 0; i < 3; i++)
      {
        buttons[i] = new Button(composite, 16);
        buttons[i].addSelectionListener(selectionListener);
        buttons[i].setText(NLS.bind(
          TeamUIMessages.SelectAncestorDialog_option, 
          theResources[i].getFullPath().toPortableString()));
        buttons[i].setFont(parent.getFont());
        
        buttons[i].setSelection(i == 0);
      }
      pickAncestor(0);
      return composite;
    }
    
    private void pickAncestor(int i)
    {
      ancestorResource = theResources[i];
      leftResource = theResources[0];
      rightResource = theResources[2];
    }
    
    private SelectionListener selectionListener = new CompareAction.1(this);
  }
}

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

import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.history.provider.FileRevision;
import org.eclipse.team.internal.core.history.LocalFileRevision;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.history.AbstractHistoryCategory;
import org.eclipse.team.internal.ui.history.CompareFileRevisionEditorInput;
import org.eclipse.team.internal.ui.history.FileRevisionTypedElement;
import org.eclipse.team.ui.history.HistoryPage;
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.eclipse.ui.part.IPageSite;

public class CompareRevisionAction
  extends BaseSelectionListenerAction
{
  HistoryPage page;
  IStructuredSelection selection;
  IFileRevision currentFileRevision;
  
  public CompareRevisionAction(String text, HistoryPage page)
  {
    super(text);
    this.page = page;
  }
  
  public CompareRevisionAction(HistoryPage page)
  {
    this(TeamUIMessages.LocalHistoryPage_CompareAction, page);
  }
  
  public void run()
  {
    IStructuredSelection structSel = selection;
    if (structSel == null) {
      return;
    }
    Object[] objArray = structSel.toArray();
    
    IFileRevision file1 = null;
    IFileRevision file2 = null;
    switch (structSel.size())
    {
    case 1: 
      file1 = getCurrentFileRevision();
      Object tempRevision = objArray[0];
      if ((tempRevision instanceof IFileRevision)) {
        file2 = (IFileRevision)tempRevision;
      } else {
        return;
      }
      break;
    case 2: 
      Object tempRevision2 = objArray[0];
      Object tempRevision3 = objArray[1];
      if (((tempRevision2 instanceof IFileRevision)) && 
        ((tempRevision3 instanceof IFileRevision)))
      {
        file1 = (IFileRevision)objArray[0];
        file2 = (IFileRevision)objArray[1];
      }
      else
      {
        return;
      }
      break;
    }
    if ((file1 == null) || (file2 == null) || 
      (!file1.exists()) || (!file2.exists()))
    {
      MessageDialog.openError(page.getSite().getShell(), TeamUIMessages.OpenRevisionAction_DeletedRevTitle, TeamUIMessages.CompareRevisionAction_DeleteCompareMessage);
      return;
    }
    IResource resource = getResource(file2);
    if (resource != null)
    {
      IFileRevision temp = file1;
      file1 = file2;
      file2 = temp;
    }
    resource = getResource(file1);
    ITypedElement left;
    ITypedElement left;
    if (resource != null) {
      left = getElementFor(resource);
    } else {
      left = new FileRevisionTypedElement(file1, getLocalEncoding());
    }
    ITypedElement right = new FileRevisionTypedElement(file2, getLocalEncoding());
    
    openInCompare(left, right);
  }
  
  private String getLocalEncoding()
  {
    IResource resource = getResource(getCurrentFileRevision());
    if ((resource instanceof IFile))
    {
      IFile file = (IFile)resource;
      try
      {
        return file.getCharset();
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    return null;
  }
  
  protected ITypedElement getElementFor(IResource resource)
  {
    return SaveableCompareEditorInput.createFileElement((IFile)resource);
  }
  
  private void openInCompare(ITypedElement left, ITypedElement right)
  {
    CompareEditorInput input = createCompareEditorInput(left, right, page.getSite().getPage());
    IWorkbenchPage workBenchPage = page.getSite().getPage();
    IEditorPart editor = Utils.findReusableCompareEditor(input, 
      workBenchPage, 
      new Class[] { CompareFileRevisionEditorInput.class });
    if (editor != null)
    {
      IEditorInput otherInput = editor.getEditorInput();
      if (otherInput.equals(input))
      {
        if (OpenStrategy.activateOnOpen()) {
          workBenchPage.activate(editor);
        } else {
          workBenchPage.bringToTop(editor);
        }
      }
      else
      {
        CompareUI.reuseCompareEditor(input, (IReusableEditor)editor);
        if (OpenStrategy.activateOnOpen()) {
          workBenchPage.activate(editor);
        } else {
          workBenchPage.bringToTop(editor);
        }
      }
    }
    else
    {
      CompareUI.openCompareEditor(input, OpenStrategy.activateOnOpen());
    }
  }
  
  protected CompareFileRevisionEditorInput createCompareEditorInput(ITypedElement left, ITypedElement right, IWorkbenchPage page)
  {
    return new CompareFileRevisionEditorInput(left, 
      right, page);
  }
  
  private IResource getResource(IFileRevision revision)
  {
    if ((revision instanceof LocalFileRevision))
    {
      LocalFileRevision local = (LocalFileRevision)revision;
      return local.getFile();
    }
    return null;
  }
  
  private IFileRevision getCurrentFileRevision()
  {
    return currentFileRevision;
  }
  
  public void setCurrentFileRevision(IFileRevision fileRevision)
  {
    currentFileRevision = fileRevision;
  }
  
  /**
   * @deprecated
   */
  public static IEditorPart findReusableCompareEditor(IWorkbenchPage workbenchPage)
  {
    return Utils.findReusableCompareEditor(null, workbenchPage, 
      new Class[] { CompareFileRevisionEditorInput.class });
  }
  
  protected boolean updateSelection(IStructuredSelection selection)
  {
    this.selection = selection;
    if (selection.size() == 1)
    {
      Object el = selection.getFirstElement();
      if ((el instanceof LocalFileRevision))
      {
        setText(TeamUIMessages.CompareRevisionAction_Local);
      }
      else if ((el instanceof FileRevision))
      {
        FileRevision tempFileRevision = (FileRevision)el;
        setText(NLS.bind(TeamUIMessages.CompareRevisionAction_Revision, new String[] { tempFileRevision.getContentIdentifier() }));
      }
      else
      {
        setText(TeamUIMessages.CompareRevisionAction_CompareWithCurrent);
      }
      return shouldShow();
    }
    if (selection.size() == 2)
    {
      setText(TeamUIMessages.CompareRevisionAction_CompareWithOther);
      return shouldShow();
    }
    return false;
  }
  
  private boolean shouldShow()
  {
    IStructuredSelection structSel = selection;
    Object[] objArray = structSel.toArray();
    if (objArray.length == 0) {
      return false;
    }
    for (int i = 0; i < objArray.length; i++)
    {
      if ((objArray[i] instanceof AbstractHistoryCategory)) {
        return false;
      }
      IFileRevision revision = (IFileRevision)objArray[i];
      if ((revision != null) && (!revision.exists())) {
        return false;
      }
    }
    return true;
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;

class ConfigureProjectAction$1
  implements IRunnableWithProgress
{
  final ConfigureProjectAction this$0;
  
  ConfigureProjectAction$1(ConfigureProjectAction paramConfigureProjectAction)
  {
    this$0 = paramConfigureProjectAction;
  }
  
  public void run(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    try
    {
      if (!this$0.isEnabled()) {
        return;
      }
      IProject[] projects = this$0.getSelectedProjects();
      ConfigureProjectWizard.shareProjects(this$0.getShell(), projects);
    }
    catch (Exception e)
    {
      throw new InvocationTargetException(e);
    }
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;

public class ConfigureProjectAction
  extends TeamAction
{
  protected void execute(IAction action)
    throws InvocationTargetException, InterruptedException
  {
    run(new IRunnableWithProgress()
    {
      public void run(IProgressMonitor monitor)
        throws InvocationTargetException, InterruptedException
      {
        try
        {
          if (!isEnabled()) {
            return;
          }
          IProject[] projects = getSelectedProjects();
          ConfigureProjectWizard.shareProjects(getShell(), projects);
        }
        catch (Exception e)
        {
          throw new InvocationTargetException(e);
        }
      }
    }, TeamUIMessages.ConfigureProjectAction_configureProject, 2);
  }
  
  public boolean isEnabled()
  {
    IProject[] selectedProjects = getSelectedProjects();
    for (int i = 0; i < selectedProjects.length; i++)
    {
      IProject project = selectedProjects[i];
      if (!project.isAccessible()) {
        return false;
      }
      if (RepositoryProvider.isShared(project)) {
        return false;
      }
    }
    return selectedProjects.length > 0;
  }
}

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

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

public abstract interface ITeamRunnableContext
{
  public abstract void run(IRunnableWithProgress paramIRunnableWithProgress)
    throws InvocationTargetException, InterruptedException;
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.ProjectSetImporter;
import org.eclipse.team.internal.ui.wizards.ImportProjectSetOperation;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

class ImportProjectSetAction$1
  extends WorkspaceModifyOperation
{
  final ImportProjectSetAction this$0;
  private final Shell val$shell;
  
  ImportProjectSetAction$1(ImportProjectSetAction paramImportProjectSetAction, ISchedulingRule $anonymous0, Shell paramShell)
  {
    super($anonymous0);this$0 = paramImportProjectSetAction;val$shell = paramShell;
  }
  
  protected void execute(IProgressMonitor monitor)
    throws CoreException, InvocationTargetException, InterruptedException
  {
    Iterator iterator = ImportProjectSetAction.access$0(this$0).iterator();
    while (iterator.hasNext())
    {
      IFile file = (IFile)iterator.next();
      if (ImportProjectSetAction.access$1())
      {
        ImportProjectSetOperation op = new ImportProjectSetOperation(null, file.getLocation().toString(), new IWorkingSet[0]);
        op.run();
      }
      else
      {
        ProjectSetImporter.importProjectSet(file.getLocation().toString(), val$shell, monitor);
      }
    }
  }
}

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

import java.lang.refl
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