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

e;

public class CompareFileRevisionEditorInput
  extends SaveableCompareEditorInput
{
  private ITypedElement left;
  private ITypedElement right;
  CompareInputChangeNotifier notifier = new CompareInputChangeNotifier()
  {
    protected IResource[] getResources(ICompareInput input)
    {
      IResource resource = CompareFileRevisionEditorInput.this.getResource(input);
      if (resource == null) {
        return new IResource[0];
      }
      return new IResource[] { resource };
    }
  };
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if ((obj instanceof CompareFileRevisionEditorInput))
    {
      CompareFileRevisionEditorInput other = (CompareFileRevisionEditorInput)obj;
      
      return (other.getLeft().equals(left)) && (other.getRightRevision().equals(right));
    }
    return false;
  }
  
  public class MyDiffNode
    extends AbstractCompareInput
  {
    public MyDiffNode(ITypedElement left, ITypedElement right)
    {
      super(null, left, right);
    }
    
    public void fireChange()
    {
      super.fireChange();
    }
    
    protected CompareInputChangeNotifier getChangeNotifier()
    {
      return notifier;
    }
    
    public boolean needsUpdate()
    {
      return false;
    }
    
    public void update()
    {
      fireChange();
    }
  }
  
  public CompareFileRevisionEditorInput(ITypedElement left, ITypedElement right, IWorkbenchPage page)
  {
    super(new CompareConfiguration(), page);
    this.left = left;
    this.right = right;
    setTitle(NLS.bind(TeamUIMessages.SyncInfoCompareInput_title, new String[] { left.getName() }));
  }
  
  protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    ICompareInput input = createCompareInput();
    getCompareConfiguration().setLeftEditable(isLeftEditable(input));
    getCompareConfiguration().setRightEditable(false);
    ensureContentsCached(getLeftRevision(), getRightRevision(), monitor);
    initLabels(input);
    return input;
  }
  
  protected FileRevisionTypedElement getRightRevision()
  {
    if ((right instanceof FileRevisionTypedElement)) {
      return (FileRevisionTypedElement)right;
    }
    return null;
  }
  
  protected FileRevisionTypedElement getLeftRevision()
  {
    if ((left instanceof FileRevisionTypedElement)) {
      return (FileRevisionTypedElement)left;
    }
    return null;
  }
  
  private static void ensureContentsCached(FileRevisionTypedElement left, FileRevisionTypedElement right, IProgressMonitor monitor)
  {
    if (left != null) {
      try
      {
        left.cacheContents(monitor);
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    if (right != null) {
      try
      {
        right.cacheContents(monitor);
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
  }
  
  private boolean isLeftEditable(ICompareInput input)
  {
    Object left = input.getLeft();
    if ((left instanceof IEditableContent)) {
      return ((IEditableContent)left).isEditable();
    }
    return false;
  }
  
  private IResource getResource(ICompareInput input)
  {
    if ((getLocalElement() instanceof IResourceProvider)) {
      return getLocalElement().getResource();
    }
    return null;
  }
  
  private ICompareInput createCompareInput()
  {
    MyDiffNode input = new MyDiffNode(left, right);
    return input;
  }
  
  private void initLabels(ICompareInput input)
  {
    CompareConfiguration cc = getCompareConfiguration();
    if (getLeftRevision() != null)
    {
      String leftLabel = getFileRevisionLabel(getLeftRevision());
      cc.setLeftLabel(leftLabel);
    }
    else if ((left instanceof LocalResourceTypedElement))
    {
      String name = TextProcessor.process(input.getLeft().getName());
      String leftLabel = getLocalResourceRevisionLabel((LocalResourceTypedElement)left, name);
      cc.setLeftLabel(leftLabel);
    }
    else if (getResource(input) != null)
    {
      String leftLabel = NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_workspace, new Object[] { TextProcessor.process(input.getLeft().getName()) });
      cc.setLeftLabel(leftLabel);
    }
    if (getRightRevision() != null)
    {
      String rightLabel = getFileRevisionLabel(getRightRevision());
      cc.setRightLabel(rightLabel);
    }
  }
  
  private String getLocalResourceRevisionLabel(LocalResourceTypedElement localElement, String name)
  {
    if (Utils.isShowAuthor())
    {
      String author = localElement.getAuthor();
      if (author == null)
      {
        try
        {
          localElement.fetchAuthor(null);
        }
        catch (CoreException e)
        {
          TeamUIPlugin.log(e);
        }
        author = localElement.getAuthor();
      }
      if (author != null) {
        return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_workspace_authorExists, new Object[] { name, author });
      }
    }
    return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_workspace, new Object[] { name });
  }
  
  private String getFileRevisionLabel(FileRevisionTypedElement element)
  {
    Object fileObject = element.getFileRevision();
    if ((fileObject instanceof LocalFileRevision))
    {
      IFileState state = ((LocalFileRevision)fileObject).getState();
      if (state != null) {
        return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_localRevision, new Object[] { TextProcessor.process(element.getName()), element.getTimestamp() });
      }
    }
    else
    {
      if (Utils.isShowAuthor()) {
        return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_repository, new Object[] { element.getName(), element.getContentIdentifier(), element.getAuthor() });
      }
      return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_repositoryWithoutAuthor, new Object[] { element.getName(), element.getContentIdentifier() });
    }
    return "";
  }
  
  public String getToolTipText()
  {
    Object[] titleObject = new Object[3];
    titleObject[0] = getLongName(left);
    titleObject[1] = getContentIdentifier(getLeftRevision());
    titleObject[2] = getContentIdentifier(getRightRevision());
    return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_compareResourceAndVersions, titleObject);
  }
  
  public String getTitle()
  {
    Object[] titleObject = new Object[3];
    titleObject[0] = getShortName(left);
    titleObject[1] = getContentIdentifier(getLeftRevision());
    titleObject[2] = getContentIdentifier(getRightRevision());
    return NLS.bind(TeamUIMessages.CompareFileRevisionEditorInput_compareResourceAndVersions, titleObject);
  }
  
  public Object getAdapter(Class adapter)
  {
    if ((adapter == IFile.class) || (adapter == IResource.class))
    {
      if (getLocalElement() != null) {
        return getLocalElement().getResource();
      }
      return null;
    }
    return super.getAdapter(adapter);
  }
  
  private String getShortName(ITypedElement element)
  {
    if ((element instanceof FileRevisionTypedElement))
    {
      FileRevisionTypedElement fileRevisionElement = (FileRevisionTypedElement)element;
      return fileRevisionElement.getName();
    }
    if ((element instanceof LocalResourceTypedElement))
    {
      LocalResourceTypedElement typedContent = (LocalResourceTypedElement)element;
      return typedContent.getResource().getName();
    }
    return element.getName();
  }
  
  private String getLongName(ITypedElement element)
  {
    if ((element instanceof FileRevisionTypedElement))
    {
      FileRevisionTypedElement fileRevisionElement = (FileRevisionTypedElement)element;
      return fileRevisionElement.getPath();
    }
    if ((element instanceof LocalResourceTypedElement))
    {
      LocalResourceTypedElement typedContent = (LocalResourceTypedElement)element;
      return typedContent.getResource().getFullPath().toString();
    }
    return element.getName();
  }
  
  private String getContentIdentifier(ITypedElement element)
  {
    if ((element instanceof FileRevisionTypedElement))
    {
      FileRevisionTypedElement fileRevisionElement = (FileRevisionTypedElement)element;
      Object fileObject = fileRevisionElement.getFileRevision();
      if ((fileObject instanceof LocalFileRevision)) {
        try
        {
          IStorage storage = ((LocalFileRevision)fileObject).getStorage(new NullProgressMonitor());
          if (Utils.getAdapter(storage, IFileState.class) != null) {
            return TeamUIMessages.CompareFileRevisionEditorInput_0;
          }
          if (Utils.getAdapter(storage, IFile.class) == null) {
            break label139;
          }
          return TeamUIMessages.CompareFileRevisionEditorInput_1;
        }
        catch (CoreException localCoreException) {}
      }
      return fileRevisionElement.getContentIdentifier();
    }
    label139:
    return TeamUIMessages.CompareFileRevisionEditorInput_2;
  }
  
  protected void fireInputChange()
  {
    ((MyDiffNode)getCompareResult()).fireChange();
  }
  
  protected void contentsCreated()
  {
    super.contentsCreated();
    notifier.initialize();
  }
  
  protected void handleDispose()
  {
    super.handleDispose();
    notifier.dispose();
    if (getLocalElement() != null) {
      getLocalElement().discardBuffer();
    }
  }
  
  public LocalResourceTypedElement getLocalElement()
  {
    if ((left instanceof LocalResourceTypedElement)) {
      return (LocalResourceTypedElement)left;
    }
    return null;
  }
  
  public ITypedElement getLeft()
  {
    return left;
  }
}

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

import org.eclipse.team.internal.ui.TeamUIMessages;

public class CompareLocalHistory
  extends ShowLocalHistory
{
  protected boolean isCompare()
  {
    return true;
  }
  
  protected String getPromptTitle()
  {
    return TeamUIMessages.CompareLocalHistory_0;
  }
}

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

import com.ibm.icu.util.Calendar;
import java.util.ArrayList;
import org.eclipse.team.core.history.IFileRevision;

public class DateHistoryCategory
  extends AbstractHistoryCategory
{
  private String name;
  private Calendar fromDate;
  private Calendar toDate;
  private IFileRevision[] revisions;
  
  public DateHistoryCategory(String name, Calendar fromDate, Calendar toDate)
  {
    this.name = name;
    this.fromDate = fromDate;
    this.toDate = toDate;
  }
  
  public String getName()
  {
    return name;
  }
  
  public boolean collectFileRevisions(IFileRevision[] fileRevisions, boolean shouldRemove)
  {
    ArrayList pertinentRevisions = new ArrayList();
    ArrayList nonPertinentRevisions = new ArrayList();
    for (int i = 0; i < fileRevisions.length; i++)
    {
      Calendar fileRevDate = Calendar.getInstance();
      fileRevDate.setTimeInMillis(fileRevisions[i].getTimestamp());
      
      int fileRevDay = fileRevDate.get(6);
      int fileRevYear = fileRevDate.get(1);
      if (fromDate == null)
      {
        if (((fileRevDay < toDate.get(6)) && (fileRevYear == toDate.get(1))) || 
          (fileRevYear < toDate.get(1))) {
          pertinentRevisions.add(fileRevisions[i]);
        } else {
          nonPertinentRevisions.add(fileRevisions[i]);
        }
      }
      else if (toDate == null)
      {
        if ((fileRevDay == fromDate.get(6)) && 
          (fileRevYear == fromDate.get(1))) {
          pertinentRevisions.add(fileRevisions[i]);
        } else {
          nonPertinentRevisions.add(fileRevisions[i]);
        }
      }
      else if ((fileRevYear >= fromDate.get(1)) && 
        (fileRevYear <= toDate.get(1)) && 
        (fileRevDay >= fromDate.get(6)) && 
        (fileRevDay < toDate.get(6))) {
        pertinentRevisions.add(fileRevisions[i]);
      } else {
        nonPertinentRevisions.add(fileRevisions[i]);
      }
    }
    if (pertinentRevisions.size() > 0)
    {
      IFileRevision[] tempRevision = (IFileRevision[])pertinentRevisions.toArray(new IFileRevision[pertinentRevisions.size()]);
      revisions = new IFileRevision[tempRevision.length];
      System.arraycopy(tempRevision, 0, revisions, 0, tempRevision.length);
      return true;
    }
    return false;
  }
  
  public IFileRevision[] getRevisions()
  {
    return revisions;
  }
  
  public boolean hasRevisions()
  {
    if ((revisions != null) && (revisions.length > 0)) {
      return true;
    }
    return false;
  }
}

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

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.ui.history.IHistoryPageSite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.IPageSite;

public class DialogHistoryPageSite
  implements IHistoryPageSite
{
  private ISelectionProvider selectionProvider;
  private final Shell shell;
  private IToolBarManager toolBarManager;
  
  public DialogHistoryPageSite(Shell shell)
  {
    this.shell = shell;
  }
  
  public IPageSite getWorkbenchPageSite()
  {
    return null;
  }
  
  public IWorkbenchPart getPart()
  {
    return null;
  }
  
  public Shell getShell()
  {
    return shell;
  }
  
  public ISelectionProvider getSelectionProvider()
  {
    return selectionProvider;
  }
  
  public void setSelectionProvider(ISelectionProvider provider)
  {
    selectionProvider = provider;
  }
  
  public void setFocus() {}
  
  public void setToolBarManager(IToolBarManager toolBarManager)
  {
    this.toolBarManager = toolBarManager;
  }
  
  public boolean isModal()
  {
    return true;
  }
  
  public IToolBarManager getToolBarManager()
  {
    return toolBarManager;
  }
}

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

import java.util.Comparator;
import org.eclipse.team.core.history.IFileRevision;

class EditionHistoryPage$1
  implements Comparator
{
  public int compare(Object o1, Object o2)
  {
    IFileRevision d1 = (IFileRevision)o1;
    IFileRevision d2 = (IFileRevision)o2;
    long d = d2.getTimestamp() - d1.getTimestamp();
    if (d < 0L) {
      return -1;
    }
    if (d > 0L) {
      return 1;
    }
    return 0;
  }
}

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

import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.team.internal.ui.actions.CompareRevisionAction;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.ui.history.HistoryPage;
import org.eclipse.ui.IWorkbenchPage;

class EditionHistoryPage$CompareEditionAction
  extends CompareRevisionAction
{
  final EditionHistoryPage this$0;
  
  public EditionHistoryPage$CompareEditionAction(EditionHistoryPage paramEditionHistoryPage, HistoryPage page)
  {
    super(page);
    this$0 = paramEditionHistoryPage;
  }
  
  protected ITypedElement getElementFor(IResource resource)
  {
    if (resource.equals(EditionHistoryPage.access$0(this$0))) {
      return EditionHistoryPage.access$1(this$0);
    }
    return super.getElementFor(resource);
  }
  
  protected CompareFileRevisionEditorInput createCompareEditorInput(ITypedElement left, ITypedElement right, IWorkbenchPage page)
  {
    ITypedElement leftEdition = getEdition(left);
    boolean leftIsLocal = false;
    if ((leftEdition == null) && ((left instanceof LocalResourceTypedElement)))
    {
      leftEdition = EditionHistoryPage.access$4(EditionHistoryPage.access$2(this$0), EditionHistoryPage.access$1(this$0), EditionHistoryPage.access$3(this$0));
      leftIsLocal = true;
    }
    ITypedElement rightEdition = getEdition(right);
    return new EditionHistoryPage.CompareEditionsEditorInput(EditionHistoryPage.access$2(this$0), left, right, leftEdition, rightEdition, leftIsLocal, page);
  }
  
  private ITypedElement getEdition(ITypedElement input)
  {
    if ((input instanceof FileRevisionTypedElement))
    {
      FileRevisionTypedElement te = (FileRevisionTypedElement)input;
      return this$0.getEditionFor(te.getRevision());
    }
    return null;
  }
}

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

import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.IStructureCreator;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.ui.IWorkbenchPage;

class EditionHistoryPage$CompareEditionsEditorInput
  extends CompareFileRevisionEditorInput
{
  private final ITypedElement leftRevision;
  private final ITypedElement rightRevision;
  private final boolean leftIsLocal;
  private IStructureCreator structureCreator;
  
  public EditionHistoryPage$CompareEditionsEditorInput(IStructureCreator structureCreator, ITypedElement left, ITypedElement right, ITypedElement leftEdition, ITypedElement rightEdition, boolean leftIsLocal, IWorkbenchPage page)
  {
    super(leftEdition, rightEdition, page);
    this.structureCreator = structureCreator;
    leftRevision = left;
    rightRevision = right;
    this.leftIsLocal = leftIsLocal;
  }
  
  public LocalResourceTypedElement getLocalElement()
  {
    if ((leftRevision instanceof LocalResourceTypedElement)) {
      return (LocalResourceTypedElement)leftRevision;
    }
    return super.getLocalElement();
  }
  
  protected FileRevisionTypedElement getRightRevision()
  {
    if ((rightRevision instanceof FileRevisionTypedElement)) {
      return (FileRevisionTypedElement)rightRevision;
    }
    return null;
  }
  
  protected FileRevisionTypedElement getLeftRevision()
  {
    if ((leftRevision instanceof FileRevisionTypedElement)) {
      return (FileRevisionTypedElement)leftRevision;
    }
    return null;
  }
  
  public Object getAdapter(Class adapter)
  {
    Class tmp4_1 = EditionHistoryPage.class$0;
    if (tmp4_1 == null)
    {
      tmp4_1;
      try
      {
        tmpTernaryOp = (EditionHistoryPage.class$0 = Class.forName("org.eclipse.core.resources.IFile"));
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
      }
    }
    if (adapter == tmp4_1) {
      return null;
    }
    return super.getAdapter(adapter);
  }
  
  protected void handleDispose()
  {
    if ((leftIsLocal) && (structureCreator != null)) {
      EditionHistoryPage.access$5(structureCreator, getLeft());
    }
    structureCreator = null;
    super.handleDispose();
  }
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.compare.structuremergeviewer.IStructureCreator;
import org.eclipse.compare.structuremergeviewer.IStructureCreator2;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.internal.core.history.LocalFileHistory;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.actions.CompareRevisionAction;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.ui.history.HistoryPage;
import org.eclipse.team.ui.history.IHistoryPageSite;
import org.eclipse.ui.IWorkbenchPage;

public class EditionHistoryPage
  extends LocalHistoryPage
{
  private final IFile file;
  private final Object element;
  private final LocalResourceTypedElement localFileElement;
  private IStructureCreator structureCreator;
  private Map editions = new HashMap();
  private ITypedElement localEdition;
  private String name;
  static Class class$0;
  
  class CompareEditionAction
    extends CompareRevisionAction
  {
    public CompareEditionAction(HistoryPage page)
    {
      super();
    }
    
    protected ITypedElement getElementFor(IResource resource)
    {
      if (resource.equals(file)) {
        return localFileElement;
      }
      return super.getElementFor(resource);
    }
    
    protected CompareFileRevisionEditorInput createCompareEditorInput(ITypedElement left, ITypedElement right, IWorkbenchPage page)
    {
      ITypedElement leftEdition = getEdition(left);
      boolean leftIsLocal = false;
      if ((leftEdition == null) && ((left instanceof LocalResourceTypedElement)))
      {
        leftEdition = EditionHistoryPage.createLocalEdition(structureCreator, localFileElement, element);
        leftIsLocal = true;
      }
      ITypedElement rightEdition = getEdition(right);
      return new EditionHistoryPage.CompareEditionsEditorInput(structureCreator, left, right, leftEdition, rightEdition, leftIsLocal, page);
    }
    
    private ITypedElement getEdition(ITypedElement input)
    {
      if ((input instanceof FileRevisionTypedElement))
      {
        FileRevisionTypedElement te = (FileRevisionTypedElement)input;
        return getEditionFor(te.getRevision());
      }
      return null;
    }
  }
  
  static class CompareEditionsEditorInput
    extends CompareFileRevisionEditorInput
  {
    private final ITypedElement leftRevision;
    private final ITypedElement rightRevision;
    private final boolean leftIsLocal;
    private IStructureCreator structureCreator;
    
    public CompareEditionsEditorInput(IStructureCreator structureCreator, ITypedElement left, ITypedElement right, ITypedElement leftEdition, ITypedElement rightEdition, boolean leftIsLocal, IWorkbenchPage page)
    {
      super(rightEdition, page);
      this.structureCreator = structureCreator;
      leftRevision = left;
      rightRevision = right;
      this.leftIsLocal = leftIsLocal;
    }
    
    public LocalResourceTypedElement getLocalElement()
    {
      if ((leftRevision instanceof LocalResourceTypedElement)) {
        return (LocalResourceTypedElement)leftRevision;
      }
      return super.getLocalElement();
    }
    
    protected FileRevisionTypedElement getRightRevision()
    {
      if ((rightRevision instanceof FileRevisionTypedElement)) {
        return (FileRevisionTypedElement)rightRevision;
      }
      return null;
    }
    
    protected FileRevisionTypedElement getLeftRevision()
    {
      if ((leftRevision instanceof FileRevisionTypedElement)) {
        return (FileRevisionTypedElement)leftRevision;
      }
      return null;
    }
    
    public Object getAdapter(Class adapter)
    {
      Class tmp4_1 = EditionHistoryPage.class$0;
      if (tmp4_1 == null)
      {
        tmp4_1;
        try
        {
          tmpTernaryOp = (EditionHistoryPage.class$0 = Class.forName("org.eclipse.core.resources.IFile"));
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
        }
      }
      if (adapter == tmp4_1) {
        return null;
      }
      return super.getAdapter(adapter);
    }
    
    protected void handleDispose()
    {
      if ((leftIsLocal) && (structureCreator != null)) {
        EditionHistoryPage.internalDestroy(structureCreator, getLeft());
      }
      structureCreator = null;
      super.handleDispose();
    }
  }
  
  public static ITypedElement getPreviousState(IFile file, Object element)
    throws TeamException
  {
    LocalResourceTypedElement localFileElement = new LocalResourceTypedElement(file);
    IStructureCreator structureCreator = CompareUI.createStructureCreator(localFileElement);
    if (structureCreator == null) {
      return null;
    }
    LocalFileHistory history = new LocalFileHistory(file, false);
    history.refresh(new NullProgressMonitor());
    IFileRevision[] revisions = history.getFileRevisions();
    if (revisions.length == 0) {
      return null;
    }
    sortDescending(revisions);
    ITypedElement localEdition = null;
    try
    {
      localEdition = createLocalEdition(structureCreator, localFileElement, element);
      int i;
      for (int i = 0; i < revisions.length; i++)
      {
        IFileRevision revision = revisions[i];
        ITypedElement edition = createEdition(structureCreator, element, new FileRevisionTypedElement(revision));
        if ((edition != null) && (!contentsEqual(structureCreator, localEdition, edition))) {
          return edition;
        }
      }
    }
    finally
    {
      if (localEdition != null) {
        destroyLocalEdition(structureCreator, localFileElement, localEdition);
      }
    }
    if (localEdition != null) {
      destroyLocalEdition(structureCreator, localFileElement, localEdition);
    }
    return null;
  }
  
  public EditionHistoryPage(IFile file, Object element)
  {
    super(5);
    Assert.isNotNull(file);
    Assert.isNotNull(element);
    this.file = file;
    this.element = element;
    localFileElement = new LocalResourceTypedElement(getFile());
    structureCreator = CompareUI.createStructureCreator(localFileElement);
  }
  
  public void setSite(IHistoryPageSite site)
  {
    super.setSite(site);
    if (site.isModal()) {
      localEdition = createLocalEdition(structureCreator, localFileElement, element);
    }
  }
  
  protected IFile getFile()
  {
    return file;
  }
  
  /* Error */
  protected void update(IFileRevision[] revisions, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: aconst_null
    //   2: bipush 100
    //   4: invokeinterface 371 3 0
    //   9: aconst_null
    //   10: astore_3
    //   11: aload_0
    //   12: getfield 307	org/eclipse/team/internal/ui/history/EditionHistoryPage:localEdition	Lorg/eclipse/compare/ITypedElement;
    //   15: ifnonnull +22 -> 37
    //   18: aload_0
    //   19: getfield 308	org/eclipse/team/internal/ui/history/EditionHistoryPage:structureCreator	Lorg/eclipse/compare/structuremergeviewer/IStructureCreator;
    //   22: aload_0
    //   23: getfield 310	org/eclipse/team/internal/ui/history/EditionHistoryPage:localFileElement	Lorg/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement;
    //   26: aload_0
    //   27: getfield 304	org/eclipse/team/internal/ui/history/EditionHistoryPage:element	Ljava/lang/Object;
    //   30: invokestatic 338	org/eclipse/team/internal/ui/history/EditionHistoryPage:createLocalEdition	(Lorg/eclipse/compare/structuremergeviewer/IStructureCreator;Lorg/eclipse/compare/ITypedElement;Ljava/lang/Object;)Lorg/eclipse/compare/ITypedElement;
    //   33: astore_3
    //   34: goto +8 -> 42
    //   37: aload_0
    //   38: getfield 307	org/eclipse/team/internal/ui/history/EditionHistoryPage:localEdition	Lorg/eclipse/compare/ITypedElement;
    //   41: astore_3
    //   42: aload_3
    //   43: ifnull +110 -> 153
    //   46: aload_0
    //   47: invokevirtual 328	org/eclipse/team/internal/ui/history/EditionHistoryPage:getName	()Ljava/lang/String;
    //   50: astore 4
    //   52: aload_0
    //   53: invokevirtual 327	org/eclipse/team/internal/ui/history/EditionHistoryPage:getDescription	()Ljava/lang/String;
    //   56: astore 5
    //   58: aload_0
    //   59: aload_3
    //   60: invokeinterface 364 1 0
    //   65: putfield 305	org/eclipse/team/internal/ui/history/EditionHistoryPage:name	Ljava/lang/String;
    //   68: aload_0
    //   69: aload_3
    //   70: aload_1
    //   71: aload_2
    //   72: bipush 75
    //   74: invokestatic 324	org/eclipse/team/internal/ui/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   77: invokespecial 340	org/eclipse/team/internal/ui/history/EditionHistoryPage:filterRevisions	(Lorg/eclipse/compare/ITypedElement;[Lorg/eclipse/team/core/history/IFileRevision;Lorg/eclipse/core/runtime/IProgressMonitor;)[Lorg/eclipse/team/core/history/IFileRevision;
    //   80: astore 6
    //   82: aload_0
    //   83: aload 6
    //   85: aload_2
    //   86: bipush 25
    //   88: invokestatic 324	org/eclipse/team/internal/ui/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   91: invokespecial 350	org/eclipse/team/internal/ui/history/LocalHistoryPage:update	([Lorg/eclipse/team/core/history/IFileRevision;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   94: aload_0
    //   95: aload_0
    //   96: ldc 2
    //   98: aload 4
    //   100: aload_0
    //   101: invokevirtual 328	org/eclipse/team/internal/ui/history/EditionHistoryPage:getName	()Ljava/lang/String;
    //   104: invokevirtual 337	org/eclipse/team/internal/ui/history/EditionHistoryPage:firePropertyChange	(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
    //   107: aload_0
    //   108: aload_0
    //   109: ldc 1
    //   111: aload 5
    //   113: aload_0
    //   114: invokevirtual 327	org/eclipse/team/internal/ui/history/EditionHistoryPage:getDescription	()Ljava/lang/String;
    //   117: invokevirtual 337	org/eclipse/team/internal/ui/history/EditionHistoryPage:firePropertyChange	(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
    //   120: goto +33 -> 153
    //   123: astore 7
    //   125: aload_0
    //   126: getfield 307	org/eclipse/team/internal/ui/history/EditionHistoryPage:localEdition	Lorg/eclipse/compare/ITypedElement;
    //   129: ifnonnull +15 -> 144
    //   132: aload_3
    //   133: ifnull +11 -> 144
    //   136: aload_0
    //   137: getfield 308	org/eclipse/team/internal/ui/history/EditionHistoryPage:structureCreator	Lorg/eclipse/compare/structuremergeviewer/IStructureCreator;
    //   140: aload_3
    //   141: invokestatic 334	org/eclipse/team/internal/ui/history/EditionHistoryPage:internalDestroy	(Lorg/eclipse/compare/structuremergeviewer/IStructureCreator;Lorg/eclipse/compare/ITypedElement;)V
    //   144: aload_2
    //   145: invokeinterface 370 1 0
    //   150: aload 7
    //   152: athrow
    //   153: aload_0
    //   154: getfield 307	org/eclipse/team/internal/ui/history/EditionHistoryPage:localEdition	Lorg/eclipse/compare/ITypedElement;
    //   157: ifnonnull +15 -> 172
    //   160: aload_3
    //   161: ifnull +11 -> 172
    //   164: aload_0
    //   165: getfield 308	org/eclipse/team/internal/ui/history/EditionHistoryPage:structureCreator	Lorg/eclipse/compare/structuremergeviewer/IStructureCreator;
    //   168: aload_3
    //   169: invokestatic 334	org/eclipse/team/internal/ui/history/EditionHistoryPage:internalDestroy	(Lorg/eclipse/compare/structuremergeviewer/IStructureCreator;Lorg/eclipse/compare/ITypedElement;)V
    //   172: aload_2
    //   173: invokeinterface 370 1 0
    //   178: return
    // Line number table:
    //   Java source line #190	-> byte code offset #0
    //   Java source line #191	-> byte code offset #9
    //   Java source line #193	-> byte code offset #11
    //   Java source line #194	-> byte code offset #18
    //   Java source line #196	-> byte code offset #37
    //   Java source line #198	-> byte code offset #42
    //   Java source line #199	-> byte code offset #46
    //   Java source line #200	-> byte code offset #52
    //   Java source line #201	-> byte code offset #58
    //   Java source line #202	-> byte code offset #68
    //   Java source line #203	-> byte code offset #82
    //   Java source line #204	-> byte code offset #94
    //   Java source line #205	-> byte code offset #107
    //   Java source line #207	-> byte code offset #123
    //   Java source line #208	-> byte code offset #125
    //   Java source line #209	-> byte code offset #136
    //   Java source line #210	-> byte code offset #144
    //   Java source line #211	-> byte code offset #150
    //   Java source line #208	-> byte code offset #153
    //   Java source line #209	-> byte code offset #164
    //   Java source line #210	-> byte code offset #172
    //   Java source line #212	-> byte code offset #178
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	179	0	this	EditionHistoryPage
    //   0	179	1	revisions	IFileRevision[]
    //   0	179	2	monitor	IProgressMonitor
    //   10	159	3	te	ITypedElement
    //   50	49	4	oldValue	String
    //   56	56	5	oldDesc	String
    //   80	4	6	filtered	IFileRevision[]
    //   123	28	7	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   11	123	123	finally
  }
  
  private IFileRevision[] filterRevisions(ITypedElement localEdition, IFileRevision[] revisions, IProgressMonitor monitor)
  {
    ITypedElement previousEdition = localEdition;
    List result = new ArrayList();
    sortDescending(revisions);
    editions.clear();
    for (int i = 0; i < revisions.length; i++)
    {
      IFileRevision revision = revisions[i];
      ITypedElement edition = createEdition(new FileRevisionTypedElement(revision));
      if ((edition != null) && (!contentsEqual(structureCreator, previousEdition, edition)))
      {
        editions.put(revision, edition);
        previousEdition = edition;
        result.add(revision);
      }
    }
    return (IFileRevision[])result.toArray(new IFileRevision[result.size()]);
  }
  
  private static void sortDescending(IFileRevision[] revisions)
  {
    Arrays.sort(revisions, new Comparator()
    {
      public int compare(Object o1, Object o2)
      {
        IFileRevision d1 = (IFileRevision)o1;
        IFileRevision d2 = (IFileRevision)o2;
        long d = d2.getTimestamp() - d1.getTimestamp();
        if (d < 0L) {
          return -1;
        }
        if (d > 0L) {
          return 1;
        }
        return 0;
      }
    });
  }
  
  private static boolean contentsEqual(IStructureCreator creator, ITypedElement previousEdition, ITypedElement edition)
  {
    if ((previousEdition == null) || (creator == null) || (edition == null)) {
      return false;
    }
    String contents1 = creator.getContents(previousEdition, false);
    String contents2 = creator.getContents(edition, false);
    return (contents1 != null) && (contents2 != null) && (contents1.equals(contents2));
  }
  
  public ICompareInput getCompareInput(Object object)
  {
    ITypedElement edition = getEditionFor(object);
    if ((edition != null) && (localEdition != null)) {
      return new DiffNode(localEdition, edition);
    }
    return null;
  }
  
  public ITypedElement getEditionFor(Object object)
  {
    return (ITypedElement)editions.get(object);
  }
  
  private static ITypedElement createLocalEdition(IStructureCreator creator, ITypedElement input, Object element)
  {
    if (creator == null) {
      return null;
    }
    ITypedElement result = null;
    if ((creator instanceof IStructureCreator2))
    {
      IStructureCreator2 sc2 = (IStructureCreator2)creator;
      try
      {
        result = sc2.createElement(element, input, null);
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    if (result == null) {
      result = createEdition(creator, element, input);
    }
    return result;
  }
  
  private ITypedElement createEdition(ITypedElement input)
  {
    return createEdition(structureCreator, element, input);
  }
  
  private static ITypedElement createEdition(IStructureCreator creator, Object element, ITypedElement input)
  {
    if (creator == null) {
      return null;
    }
    IStructureComparator edition = creator.locate(element, input);
    if ((edition instanceof ITypedElement)) {
      return (ITypedElement)edition;
    }
    return null;
  }
  
  public boolean isValidInput(Object object)
  {
    return object.equals(element);
  }
  
  /* Error */
  public void dispose()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 326	org/eclipse/team/internal/ui/history/EditionHistoryPage:disconnect	()V
    //   4: goto +10 -> 14
    //   7: astore_1
    //   8: aload_0
    //   9: invokespecial 344	org/eclipse/team/internal/ui/history/LocalHistoryPage:dispose	()V
    //   12: aload_1
    //   13: athrow
    //   14: aload_0
    //   15: invokespecial 344	org/eclipse/team/internal/ui/history/LocalHistoryPage:dispose	()V
    //   18: return
    // Line number table:
    //   Java source line #314	-> byte code offset #0
    //   Java source line #315	-> byte code offset #7
    //   Java source line #316	-> byte code offset #8
    //   Java source line #317	-> byte code offset #12
    //   Java source line #316	-> byte code offset #14
    //   Java source line #318	-> byte code offset #18
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	19	0	this	EditionHistoryPage
    //   7	6	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	7	7	finally
  }
  
  private void disconnect()
  {
    if (localFileElement != null) {
      localFileElement.discardBuffer();
    }
    internalDestroy(structureCreator, localEdition);
    localEdition = null;
    structureCreator = null;
  }
  
  private static void internalDestroy(IStructureCreator creator, ITypedElement te)
  {
    if ((te != null) && ((creator instanceof IStructureCreator2)))
    {
      IStructureCreator2 sc2 = (IStructureCreator2)creator;
      sc2.destroy(te);
    }
  }
  
  private static void destroyLocalEdition(IStructureCreator structureCreator, LocalResourceTypedElement localFileElement, ITypedElement localEdition)
  {
    if (localFileElement != null) {
      localFileElement.discardBuffer();
    }
    if ((localEdition != null) && ((structureCreator instanceof IStructureCreator2)))
    {
      IStructureCreator2 sc2 = (IStructureCreator2)structureCreator;
      sc2.destroy(localEdition);
    }
  }
  
  protected String getNoChangesMessage()
  {
    if (name != null) {
      return NLS.bind(TeamUIMessages.EditionHistoryPage_0, name);
    }
    return TeamUIMessages.EditionHistoryPage_1;
  }
  
  protected Image getImage(Object object)
  {
    if (object == localEdition) {
      return localEdition.getImage();
    }
    Object revision = getRevisionFor(object);
    if (revision != null) {
      return super.getImage(revision);
    }
    return super.getImage(object);
  }
  
  protected String getLabel(Object object)
  {
    Object revision = getRevisionFor(object);
    if (revision != null) {
      return super.getLabel(revision);
    }
    return super.getLabel(object);
  }
  
  private Object getRevisionFor(Object object)
  {
    if (object
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