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

lIStatus1;
      if ((fileHistory == null) || (this$0.shutdown)) {
        return status;
      }
      try
      {
        fileHistory.refresh(Policy.subMonitorFor(monitor, 50));
      }
      catch (CoreException ex)
      {
        status = new TeamStatus(ex.getStatus().getSeverity(), "org.eclipse.team.ui", ex.getStatus().getCode(), ex.getMessage(), ex, this$0.file);
      }
      this$0.update(fileHistory.getFileRevisions(), Policy.subMonitorFor(monitor, 50));
      if (status != Status.OK_STATUS)
      {
        setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
        setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);
      }
      if (Policy.DEBUG_HISTORY)
      {
        String time = new SimpleDateFormat("m:ss.SSS").format(new Date(System.currentTimeMillis()));
        System.out.println(time + ": RefreshFileHistoryJob#run finished, status: " + status);
      }
      return status;
    }
    finally
    {
      monitor.done();
    }
  }
}

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

import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.util.Calendar;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.team.core.TeamStatus;
import org.eclipse.team.core.history.IFileHistory;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.internal.core.history.LocalFileHistory;
import org.eclipse.team.internal.core.history.LocalFileRevision;
import org.eclipse.team.internal.ui.Policy;
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.actions.CompareRevisionAction;
import org.eclipse.team.internal.ui.actions.OpenRevisionAction;
import org.eclipse.team.internal.ui.actions.OpenWithMenu;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.ui.history.HistoryPage;
import org.eclipse.team.ui.history.IHistoryCompareAdapter;
import org.eclipse.team.ui.history.IHistoryPageSite;
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.OpenAndLinkWithEditorHelper;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.progress.IProgressConstants;
import org.eclipse.ui.progress.IProgressService;

public class LocalHistoryPage
  extends HistoryPage
  implements IHistoryCompareAdapter
{
  public static final int ON = 1;
  public static final int OFF = 2;
  public static final int ALWAYS = 4;
  IFile file;
  IFileRevision currentFileRevision;
  LocalFileHistory localFileHistory;
  TreeViewer treeViewer;
  boolean shutdown = false;
  private boolean groupingOn = true;
  private int compareMode = 2;
  protected LocalFileHistoryTableProvider historyTableProvider;
  private RefreshFileHistory refreshFileHistoryJob;
  private Composite localComposite;
  private Action groupByDateMode;
  private Action collapseAll;
  private Action compareModeAction;
  private Action getContentsAction;
  private CompareRevisionAction compareAction;
  private OpenRevisionAction openAction;
  private OpenWithMenu openWithMenu;
  private HistoryResourceListener resourceListener;
  private IFileRevision currentSelection;
  static Class class$0;
  
  private final class LocalHistoryContentProvider
    implements ITreeContentProvider
  {
    LocalHistoryContentProvider(LocalHistoryContentProvider paramLocalHistoryContentProvider)
    {
      this();
    }
    
    public Object[] getElements(Object inputElement)
    {
      if ((inputElement instanceof IFileHistory))
      {
        IFileHistory fileHistory = (IFileHistory)inputElement;
        return fileHistory.getFileRevisions();
      }
      if ((inputElement instanceof IFileRevision[])) {
        return (IFileRevision[])inputElement;
      }
      if ((inputElement instanceof AbstractHistoryCategory[])) {
        return (AbstractHistoryCategory[])inputElement;
      }
      return new Object[0];
    }
    
    public Object[] getChildren(Object parentElement)
    {
      if ((parentElement instanceof AbstractHistoryCategory)) {
        return ((AbstractHistoryCategory)parentElement).getRevisions();
      }
      return new Object[0];
    }
    
    public Object getParent(Object element)
    {
      return null;
    }
    
    public boolean hasChildren(Object element)
    {
      if ((element instanceof AbstractHistoryCategory)) {
        return ((AbstractHistoryCategory)element).hasRevisions();
      }
      return false;
    }
    
    private LocalHistoryContentProvider() {}
    
    public void dispose() {}
    
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  }
  
  private class LocalFileHistoryTableProvider
    extends LocalHistoryTableProvider
  {
    LocalFileHistoryTableProvider(LocalFileHistoryTableProvider paramLocalFileHistoryTableProvider)
    {
      this();
    }
    
    protected IFileRevision adaptToFileRevision(Object element)
    {
      IFileRevision entry = null;
      if ((element instanceof IFileRevision))
      {
        entry = (IFileRevision)element;
      }
      else if ((element instanceof IAdaptable))
      {
        Class tmp31_28 = LocalHistoryPage.class$0;
        if (tmp31_28 == null)
        {
          tmp31_28;
          try
          {
            tmpTernaryOp = (LocalHistoryPage.class$0 = Class.forName("org.eclipse.team.core.history.IFileRevision"));
          }
          catch (ClassNotFoundException localClassNotFoundException)
          {
            throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
          }
        }
        entry = (IFileRevision)((IAdaptable)element).getAdapter(tmp31_28);
      }
      else if ((element instanceof AbstractHistoryCategory))
      {
        IFileRevision[] revisions = ((AbstractHistoryCategory)element).getRevisions();
        if (revisions.length > 0) {
          entry = revisions[0];
        }
      }
      return entry;
    }
    
    private long getCurrentRevision()
    {
      if (file != null) {
        return file.getLocalTimeStamp();
      }
      return -1L;
    }
    
    protected long getModificationDate(Object element)
    {
      IFileRevision entry = adaptToFileRevision(element);
      if (entry != null) {
        return entry.getTimestamp();
      }
      return -1L;
    }
    
    protected boolean isCurrentEdition(Object element)
    {
      IFileRevision entry = adaptToFileRevision(element);
      if (entry == null) {
        return false;
      }
      long timestamp = entry.getTimestamp();
      long tempCurrentTimeStamp = getCurrentRevision();
      return (tempCurrentTimeStamp != -1L) && (tempCurrentTimeStamp == timestamp);
    }
    
    protected boolean isDeletedEdition(Object element)
    {
      IFileRevision entry = adaptToFileRevision(element);
      return !entry.exists();
    }
    
    private LocalFileHistoryTableProvider() {}
  }
  
  private class RefreshFileHistory
    extends Job
  {
    public RefreshFileHistory()
    {
      super();
    }
    
    public IStatus run(IProgressMonitor monitor)
    {
      try
      {
        IStatus status = Status.OK_STATUS;
        
        LocalFileHistory fileHistory = localFileHistory;
        IStatus localIStatus1;
        if ((fileHistory == null) || (shutdown)) {
          return status;
        }
        try
        {
          fileHistory.refresh(Policy.subMonitorFor(monitor, 50));
        }
        catch (CoreException ex)
        {
          status = new TeamStatus(ex.getStatus().getSeverity(), "org.eclipse.team.ui", ex.getStatus().getCode(), ex.getMessage(), ex, file);
        }
        update(fileHistory.getFileRevisions(), Policy.subMonitorFor(monitor, 50));
        if (status != Status.OK_STATUS)
        {
          setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
          setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);
        }
        if (Policy.DEBUG_HISTORY)
        {
          String time = new SimpleDateFormat("m:ss.SSS").format(new Date(System.currentTimeMillis()));
          System.out.println(time + ": RefreshFileHistoryJob#run finished, status: " + status);
        }
        return status;
      }
      finally
      {
        monitor.done();
      }
    }
  }
  
  private class HistoryResourceListener
    implements IResourceChangeListener
  {
    HistoryResourceListener(HistoryResourceListener paramHistoryResourceListener)
    {
      this();
    }
    
    public void resourceChanged(IResourceChangeEvent event)
    {
      IResourceDelta root = event.getDelta();
      if (file == null) {
        return;
      }
      IResourceDelta resourceDelta = root.findMember(file.getFullPath());
      if (resourceDelta != null) {
        Display.getDefault().asyncExec(new LocalHistoryPage.1(this));
      }
    }
    
    private HistoryResourceListener() {}
  }
  
  public LocalHistoryPage(int compareMode)
  {
    this.compareMode = compareMode;
  }
  
  public LocalHistoryPage() {}
  
  public boolean inputSet()
  {
    currentFileRevision = null;
    IFile tempFile = getFile();
    file = tempFile;
    if (tempFile == null) {
      return false;
    }
    treeViewer.setInput(null);
    
    localFileHistory = new LocalFileHistory(file, !getHistoryPageSite().isModal());
    if (refreshFileHistoryJob == null) {
      refreshFileHistoryJob = new RefreshFileHistory();
    }
    refreshHistory(true);
    return true;
  }
  
  protected IFile getFile()
  {
    return LocalHistoryPageSource.getFile(getInput());
  }
  
  private void refreshHistory(boolean refetch)
  {
    if (Policy.DEBUG_HISTORY)
    {
      String time = new SimpleDateFormat("m:ss.SSS").format(new Date(System.currentTimeMillis()));
      System.out.println(time + ": LocalHistoryPage#refreshHistory, refetch = " + refetch);
    }
    if (refreshFileHistoryJob.getState() != 0) {
      refreshFileHistoryJob.cancel();
    }
    IHistoryPageSite parentSite = getHistoryPageSite();
    Utils.schedule(refreshFileHistoryJob, getWorkbenchSite(parentSite));
  }
  
  private IWorkbenchPartSite getWorkbenchSite(IHistoryPageSite parentSite)
  {
    IWorkbenchPart part = parentSite.getPart();
    if (part != null) {
      return part.getSite();
    }
    return null;
  }
  
  public void createControl(Composite parent)
  {
    localComposite = new Composite(parent, 0);
    GridLayout layout = new GridLayout();
    marginHeight = 0;
    marginWidth = 0;
    localComposite.setLayout(layout);
    GridData data = new GridData(1808);
    grabExcessVerticalSpace = true;
    localComposite.setLayoutData(data);
    
    treeViewer = createTree(localComposite);
    
    contributeActions();
    
    IHistoryPageSite parentSite = getHistoryPageSite();
    if ((parentSite != null) && ((parentSite instanceof DialogHistoryPageSite)) && (treeViewer != null)) {
      parentSite.setSelectionProvider(treeViewer);
    }
    resourceListener = new HistoryResourceListener(null);
    ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener, 1);
    
    PlatformUI.getWorkbench().getHelpSystem().setHelp(localComposite, "org.eclipse.team.ui.local_history_context");
  }
  
  private void contributeActions()
  {
    IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
    
    groupByDateMode = new Action(TeamUIMessages.LocalHistoryPage_GroupRevisionsByDateAction, TeamUIPlugin.getImageDescriptor("obj/dates.gif"))
    {
      private final IPreferenceStore val$store;
      
      public void run()
      {
        groupingOn = (!groupingOn);
        val$store.setValue("org.eclipse.team.ui.group_bydate_mode", groupingOn);
        LocalHistoryPage.this.refreshHistory(false);
      }
    };
    groupingOn = store.getBoolean("org.eclipse.team.ui.group_bydate_mode");
    groupByDateMode.setChecked(groupingOn);
    groupByDateMode.setToolTipText(TeamUIMessages.LocalHistoryPage_GroupRevisionsByDateTip);
    groupByDateMode.setDisabledImageDescriptor(TeamUIPlugin.getImageDescriptor("obj/dates.gif"));
    groupByDateMode.setHoverImageDescriptor(TeamUIPlugin.getImageDescriptor("obj/dates.gif"));
    
    collapseAll = new Action(TeamUIMessages.LocalHistoryPage_CollapseAllAction, TeamUIPlugin.getImageDescriptor("elcl16/collapseall.gif"))
    {
      public void run()
      {
        treeViewer.collapseAll();
      }
    };
    collapseAll.setToolTipText(TeamUIMessages.LocalHistoryPage_CollapseAllTip);
    collapseAll.setDisabledImageDescriptor(TeamUIPlugin.getImageDescriptor("elcl16/collapseall.gif"));
    collapseAll.setHoverImageDescriptor(TeamUIPlugin.getImageDescriptor("elcl16/collapseall.gif"));
    
    IHistoryPageSite historyPageSite = getHistoryPageSite();
    if (!historyPageSite.isModal())
    {
      if ((compareMode & 0x4) == 0)
      {
        compareModeAction = new Action(TeamUIMessages.LocalHistoryPage_CompareModeAction, TeamUIPlugin.getImageDescriptor("eview16/compare_view.gif"))
        {
          public void run()
          {
            compareMode = (compareMode == 1 ? 2 : 1);
            compareModeAction.setChecked(compareMode == 1);
          }
        };
        compareModeAction.setToolTipText(TeamUIMessages.LocalHistoryPage_CompareModeTip);
        compareModeAction.setDisabledImageDescriptor(TeamUIPlugin.getImageDescriptor("eview16/compare_view.gif"));
        compareModeAction.setHoverImageDescriptor(TeamUIPlugin.getImageDescriptor("eview16/compare_view.gif"));
        compareModeAction.setChecked(compareMode == 1);
        
        getContentsAction = getContextMenuAction(TeamUIMessages.LocalHistoryPage_GetContents, true, new IWorkspaceRunnable()
        {
          /* Error */
          public void run(IProgressMonitor monitor)
            throws CoreException
          {
            // Byte code:
            //   0: aload_1
            //   1: aconst_null
            //   2: bipush 100
            //   4: invokeinterface 84 3 0
            //   9: aload_0
            //   10: getfield 74	org/eclipse/team/internal/ui/history/LocalHistoryPage$5:this$0	Lorg/eclipse/team/internal/ui/history/LocalHistoryPage;
            //   13: invokestatic 79	org/eclipse/team/internal/ui/history/LocalHistoryPage:access$6	(Lorg/eclipse/team/internal/ui/history/LocalHistoryPage;)Z
            //   16: ifeq +85 -> 101
            //   19: aload_0
            //   20: getfield 74	org/eclipse/team/internal/ui/history/LocalHistoryPage$5:this$0	Lorg/eclipse/team/internal/ui/history/LocalHistoryPage;
            //   23: invokestatic 80	org/eclipse/team/internal/ui/history/LocalHistoryPage:access$7	(Lorg/eclipse/team/internal/ui/history/LocalHistoryPage;)Lorg/eclipse/team/core/history/IFileRevision;
            //   26: new 37	org/eclipse/core/runtime/SubProgressMonitor
            //   29: dup
            //   30: aload_1
            //   31: bipush 50
            //   33: invokespecial 77	org/eclipse/core/runtime/SubProgressMonitor:<init>	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
            //   36: invokeinterface 85 2 0
            //   41: astore_2
            //   42: aload_2
            //   43: invokeinterface 82 1 0
            //   48: astore_3
            //   49: aload_0
            //   50: getfield 74	org/eclipse/team/internal/ui/history/LocalHistoryPage$5:this$0	Lorg/eclipse/team/internal/ui/history/LocalHistoryPage;
            //   53: getfield 73	org/eclipse/team/internal/ui/history/LocalHistoryPage:file	Lorg/eclipse/core/resources/IFile;
            //   56: aload_3
            //   57: iconst_0
            //   58: iconst_1
            //   59: new 37	org/eclipse/core/runtime/SubProgressMonitor
            //   62: dup
            //   63: aload_1
            //   64: bipush 50
            //   66: invokespecial 77	org/eclipse/core/runtime/SubProgressMonitor:<init>	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
            //   69: invokeinterface 81 5 0
            //   74: goto +27 -> 101
            //   77: astore_2
            //   78: new 35	org/eclipse/core/runtime/CoreException
            //   81: dup
            //   82: aload_2
            //   83: invokevirtual 78	org/eclipse/team/core/TeamException:getStatus	()Lorg/eclipse/core/runtime/IStatus;
            //   86: invokespecial 76	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
            //   89: athrow
            //   90: astore 4
            //   92: aload_1
            //   93: invokeinterface 83 1 0
            //   98: aload 4
            //   100: athrow
            //   101: aload_1
            //   102: invokeinterface 83 1 0
            //   107: return
            // Line number table:
            //   Java source line #359	-> byte code offset #0
            //   Java source line #361	-> byte code offset #9
            //   Java source line #362	-> byte code offset #19
            //   Java source line #363	-> byte code offset #42
            //   Java source line #364	-> byte code offset #49
            //   Java source line #366	-> byte code offset #77
            //   Java source line #367	-> byte code offset #78
            //   Java source line #368	-> byte code offset #90
            //   Java source line #369	-> byte code offset #92
            //   Java source line #370	-> byte code offset #98
            //   Java source line #369	-> byte code offset #101
            //   Java source line #371	-> byte code offset #107
            // Local variable table:
            //   start	length	slot	name	signature
            //   0	108	0	this	5
            //   0	108	1	monitor	IProgressMonitor
            //   41	2	2	currentStorage	org.eclipse.core.resources.IStorage
            //   77	6	2	e	org.eclipse.team.core.TeamException
            //   48	9	3	in	java.io.InputStream
            //   90	9	4	localObject	Object
            // Exception table:
            //   from	to	target	type
            //   9	74	77	org/eclipse/team/core/TeamException
            //   9	90	90	finally
          }
        });
      }
      compareAction = createCompareAction();
      compareAction.setEnabled(!treeViewer.getSelection().isEmpty());
      treeViewer.getTree().addSelectionListener(new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent e)
        {
          compareAction.setCurrentFileRevision(getCurrentFileRevision());
          compareAction.selectionChanged((IStructuredSelection)treeViewer.getSelection());
        }
      });
      if ((compareMode & 0x5) != 5)
      {
        openAction = new OpenRevisionAction(TeamUIMessages.LocalHistoryPage_OpenAction, this);
        openAction.setEnabled(!treeViewer.getSelection().isEmpty());
        treeViewer.getTree().addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent e)
          {
            openAction.selectionChanged((IStructuredSelection)treeViewer.getSelection());
          }
        });
        openWithMenu = new OpenWithMenu(this);
        treeViewer.getTree().addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent e)
          {
            openWithMenu.selectionChanged((IStructuredSelection)treeViewer.getSelection());
          }
        });
      }
      new OpenAndLinkWithEditorHelper(treeViewer);
      {
        protected void open(ISelection selection, boolean activate)
        {
          if ((getSite() != null) && ((selection instanceof IStructuredSelection)))
          {
            IStructuredSelection structuredSelection = (IStructuredSelection)selection;
            if ((compareMode & 0x1) > 0)
            {
              StructuredSelection sel = new StructuredSelection(new Object[] { getCurrentFileRevision(), structuredSelection.getFirstElement() });
              compareAction.selectionChanged(sel);
              compareAction.run();
            }
            else if (openAction != null)
            {
              openAction.selectionChanged(structuredSelection);
              openAction.run();
            }
          }
        }
        
        /* Error */
        protected void activate(ISelection selection)
        {
          // Byte code:
          //   0: invokestatic 79	org/eclipse/jface/util/OpenStrategy:getOpenMethod	()I
          //   3: istore_2
          //   4: iconst_0
          //   5: invokestatic 80	org/eclipse/jface/util/OpenStrategy:setOpenMethod	(I)V
          //   8: aload_0
          //   9: aload_1
          //   10: iconst_1
          //   11: invokevirtual 91	org/eclipse/team/internal/ui/history/LocalHistoryPage$9:open	(Lorg/eclipse/jface/viewers/ISelection;Z)V
          //   14: goto +10 -> 24
          //   17: astore_3
          //   18: iload_2
          //   19: invokestatic 80	org/eclipse/jface/util/OpenStrategy:setOpenMethod	(I)V
          //   22: aload_3
          //   23: athrow
          //   24: iload_2
          //   25: invokestatic 80	org/eclipse/jface/util/OpenStrategy:setOpenMethod	(I)V
          //   28: return
          // Line number table:
          //   Java source line #426	-> byte code offset #0
          //   Java source line #428	-> byte code offset #4
          //   Java source line #429	-> byte code offset #8
          //   Java source line #430	-> byte code offset #17
          //   Java source line #431	-> byte code offset #18
          //   Java source line #432	-> byte code offset #22
          //   Java source line #431	-> byte code offset #24
          //   Java source line #433	-> byte code offset #28
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	29	0	this	9
          //   0	29	1	selection	ISelection
          //   3	22	2	currentMode	int
          //   17	6	3	localObject	Object
          // Exception table:
          //   from	to	target	type
          //   4	17	17	finally
        }
        
        protected void linkToEditor(ISelection selection) {}
      };
      MenuManager menuMgr = new MenuManager();
      Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
      menuMgr.addMenuListener(new IMenuListener()
      {
        public void menuAboutToShow(IMenuManager menuMgr)
        {
          fillTableMenu(menuMgr);
        }
      });
      menuMgr.setRemoveAllWhenShown(true);
      treeViewer.getTree().setMenu(menu);
      
      IWorkbenchPart part = historyPageSite.getPart();
      if (part != null)
      {
        IWorkbenchPartSite workbenchPartSite = part.getSite();
        workbenchPartSite.registerContextMenu(menuMgr, treeViewer);
      }
      IPageSite pageSite = historyPageSite.getWorkbenchPageSite();
      if (pageSite != null)
      {
        IActionBars actionBars = pageSite.getActionBars();
        
        IMenuManager actionBarsMenu = actionBars.getMenuManager();
        if (actionBarsMenu != null) {
          actionBarsMenu.removeAll();
        }
        actionBars.updateActionBars();
      }
    }
    IToolBarManager tbm = historyPageSite.getToolBarManager();
    if (tbm != null)
    {
      String fileNameQualifier = getFileNameQualifier();
      
      tbm.add(new Separator(fileNameQualifier + "grouping"));
      tbm.appendToGroup(fileNameQualifier + "grouping", groupByDateMode);
      tbm.add(new Separator(fileNameQualifier + "collapse"));
      tbm.appendToGroup(fileNameQualifier + "collapse", collapseAll);
      if (compareModeAction != null) {
        tbm.appendToGroup(fileNameQualifier + "collapse", compareModeAction);
      }
      tbm.update(false);
    }
  }
  
  protected CompareRevisionAction createCompareAction()
  {
    return new CompareRevisionAction(this);
  }
  
  private String getFileNameQualifier()
  {
    if (file != null) {
      return file.getFullPath().toString();
    }
    return "";
  }
  
  protected void fillTableMenu(IMenuManager manager)
  {
    IHistoryPageSite parentSite = getHistoryPageSite();
    manager.add(new Separator("additions"));
    if ((file != null) && (!parentSite.isModal()))
    {
      if (openAction != null) {
        manager.add(openAction);
      }
      if (openWithMenu != null)
      {
        MenuManager openWithSubmenu = new MenuManager(
          TeamUIMessages.LocalHistoryPage_OpenWithMenu);
        openWithSubmenu.add(openWithMenu);
        manager.add(openWithSubmenu);
      }
      if (compareAction != null) {
        manager.add(compareAction);
      }
      if (getContentsAction != null)
      {
        ISelection sel = treeViewer.getSelection();
        if ((!sel.isEmpty()) && 
          ((sel instanceof IStructuredSelection)))
        {
          IStructuredSelection tempSelection = (IStructuredSelection)sel;
          if (tempSelection.size() == 1)
          {
            manager.add(new Separator("getContents"));
            manager.add(getContentsAction);
          }
        }
      }
    }
  }
  
  protected TreeViewer createTree(Composite parent)
  {
    historyTableProvider = new LocalFileHistoryTableProvider(null);
    TreeViewer viewer = historyTableProvider.createTree(parent);
    viewer.setContentProvider(new LocalHistoryContentProvider(null));
    return viewer;
  }
  
  public Control getControl()
  {
    return localComposite;
  }
  
  public void setFocus()
  {
    localComposite.setFocus();
  }
  
  public String getDescription()
  {
    if (getFile() != null) {
      return getFile().getFullPath().toString();
    }
    return null;
  }
  
  public String getName()
  {
    if (getFile() != null) {
      return getFile().getName();
    }
    return "";
  }
  
  public boolean isValidInput(Object object)
  {
    return object instanceof IFile;
  }
  
  public void refresh()
  {
    refreshHistory(true);
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == IHistoryCompareAdapter.class) {
      return this;
    }
    return null;
  }
  
  public void dispose()
  {
    shutdown = true;
    if (resourceListener != null)
    {
      ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceListener);
      resourceListener = null;
    }
    if ((refreshFileHistoryJob != null) && 
      (refreshFileHistoryJob.getState() != 0)) {
      refreshFileHistoryJob.cancel();
    }
  }
  
  public IFileRevision getCurrentFileRevision()
  {
    if (currentFileRevision != null) {
      return currentFileRevision;
    }
    if (file != null) {
      currentFileRevision = new LocalFileRevision(file);
    }
    return currentFileRevision;
  }
  
  private Action getContextMenuAction(String title, boolean needsProgressDialog, IWorkspaceRunnable action)
  {
    new Action(title)
    {
      private final boolean val$needsProgressDialog;
      private final IWorkspaceRunnable val$action;
      
      public void run()
      {
        try
        {
          if (file == null) {
            return;
          }
          ISelection selection = treeViewer.getSelection();
          if (!(selection instanceof IStructuredSelection)) {
            return;
          }
          IStructuredSelection ss = (IStructuredSelection)selection;
          Object o = ss.getFirstElement();
          if ((o instanceof AbstractHistoryCategory)) {
            return;
          }
          currentSelection = ((IFileRevision)o);
          if (val$needsProgressDialog) {
            PlatformUI.getWorkbench().getProgressService().run(true, true, new LocalHistoryPage.12(this, val$action));
          } else {
            try
            {
              val$action.run(null);
            }
            catch (CoreException e)
            {
              throw new InvocationTargetException(e);
            }
          }
          IHistoryPageSite parentSite;
          return;
        }
        catch (InvocationTargetException e)
        {
          parentSite = getHistoryPageSite();
          Utils.handleError(parentSite.getShell(), e, null, null);
        }
        catch (InterruptedException localInterruptedException) {}
      }
      
      public boolean isEnabled()
      {
        ISelection selection = treeViewer.getSelection();
        if (!(selection instanceof IStructuredSelection)) {
          return false;
        }
        IStructuredSelection ss = (IStructuredSelection)selection;
        if (ss.size() != 1) {
          return false;
        }
        return true;
      }
    };
  }
  
  private boolean confirmOverwrite()
  {
    if ((file != null) && (file.exists()))
    {
      String title = TeamUIMessages.LocalHistoryPage_OverwriteTitle;
      String msg = TeamUIMessages.LocalHistoryPage_OverwriteMessage;
      IHistoryPageSite parentSite = getHistoryPageSite();
      MessageDialog dialog = new MessageDialog(parentSite.getShell(), title, null, msg, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
      int[] result = new int[1];
      parentSite.getShell().getDisplay().syncExec(new Runnable()
      {
        private final int[] val$result;
        private final MessageDialog val$dialog;
        
        public void run()
        {
          val$result[0] = val$dialog.open();
        }
      });
      if (result[0] != 0) {
        return false;
      }
    }
    return true;
  }
  
  public void setClickAction(boolean compare)
  {
    compareMode = (compare ? 1 : 2);
    if (compareModeAction != null) {
      compareModeAction.setChecked(compareMode == 1);
    }
  }
  
  public ICompareInput getCompareInput(Object object)
  {
    if ((object instanceof IFileRevision))
    {
      IFileRevision selectedFileRevision = (IFileRevision)object;
      ITypedElement fileElement = SaveableCompareEditorInput.createFileElement(file);
      FileRevisionTypedElement right = new FileRevisionTypedElement(selectedFileRevision);
      DiffNode node = new DiffNode(fileElement, right);
      return node;
    }
    return null;
  }
  
  public void prepareInput(ICompareInput input, CompareConfiguration configuration, IProgressMonitor monitor)
  {
    Object right = input.getRight();
    if (right != null)
    {
      String label = getLabel(right);
      if (label != null) {
        configuration.setRightLabel(label);
      }
      Image image = getImage(right);
      if (image != null) {
        configuration.setRightImage(image);
      }
    }
    Object left = input.getLeft();
    if (left != null)
    {
      String label = getLabel(left);
      if (label != null) {
        configuration.setLeftLabel(label);
      }
      Image image = getImage(left);
      if (image != null) {
        configuration.setLeftImage(image);
      }
    }
  }
  
  protected Image getImage(Object right)
  {
    if (((right instanceof FileRevisionTypedElement)) || ((right instanceof LocalFileRevision)) || ((right instanceof IFileRevision))) {
      return historyTableProvider.getRevisionImage();
    }
    if ((right instanceof ITypedElement))
    {
      ITypedElement te = (ITypedElement)right;
      return te.getImage();
    }
    return null;
  }
  
  protected String getLabel(Object object)
  {
    if ((object instanceof IFileRevision))
    {
      IFileRevision revision = (IFileRevision)object;
      long timestamp = revision.getTimestamp();
      if (timestamp > 0L) {
        return NLS.bind(TeamUIMessages.LocalHistoryPage_0, historyTableProvider.getDateFormat().format(new Date(timestamp)));
      }
    }
    if ((object instanceof FileRevisionTypedElement))
    {
      FileRevisionTypedElement e = (FileRevisionTypedElement)object;
      return getLabel(e.getRevision());
    }
    if ((object instanceof LocalResourceTypedElement)) {
      return TeamUIMessages.LocalHistoryPage_1;
    }
    return null;
  }
  
  protected void update(IFileRevision[] revisions, IProgressMonitor monitor)
  {
    AbstractHistoryCategory[] categories = groupRevisions(revisions, monitor);
    
    Utils.asyncExec(new Runnable()
    {
      private final AbstractHistoryCategory[] val$categories;
      private final IFileRevision[] val$revisions;
      
      public void run()
      {
        if (Policy.DEBUG_HISTORY)
        {
          String time = new SimpleDateFormat("m:ss.SSS").format(new Date(System.currentTimeMillis()));
          System.out.println(time + ": LocalHistoryPage#update, the tree is being updated in the UI thread");
        }
        if (val$categories != null)
        {
          Object[] elementsToExpand = LocalHistoryPage.this.mapExpandedElements(val$categories, treeViewer.getExpandedElements());
          treeViewer.getTree().setRedraw(false);
          treeViewer.setInput(val$categories);
          if (elementsToExpand.length > 0)
          {
            treeViewer.setExpandedElements(elementsToExpand);
          }
          else
          {
            treeViewer.expandAll();
            Object[] el = treeViewer.getExpandedElements();
            if ((el != null) && (el.length > 0))
            {
              treeViewer.setSelection(new StructuredSelection(el[0]));
              treeViewer.getTree().deselectAll();
            }
          }
          treeViewer.getTree().setRedraw(true);
        }
        else if (val$revisions.length > 0)
        {
          treeViewer.setInput(val$revisions);
        }
        else
        {
          treeViewer.setInput(new AbstractHistoryCategory[] { LocalHistoryPage.this.getErrorMessage() });
        }
      }
    }, treeViewer);
  }
  
  private AbstractHistoryCategory[] groupRevisions(IFileRevision[] revisions, IProgressMonitor monitor)
  {
    if (groupingOn) {
      return sortRevisions(revisions, monitor);
    }
    return null;
  }
  
  private Object[] mapExpandedElements(AbstractHistoryCategory[] categories, Object[] expandedElements)
  {
    HashMap elementMap = new HashMap();
    for (int i = 0; i < expandedElements.length; i++) {
      elementMap.put(((DateHistoryCategory)expandedElements[i]).getName(), null);
    }
    ArrayList expandable = new ArrayList();
    for (int i = 0; i < categories.length; i++) {
      if (elementMap.containsKey(categories[i].getName())) {
        expandable.add(categories[i]);
      }
    }
    return expandable.toArray(new Object[expandable.size()]);
  }
  
  private AbstractHistoryCategory[] sortRevisions(IFileRevision[] revisions, IProgressMonitor monitor)
  {
    try
    {
      monitor.beginTask(null, 100);
      
      DateHistoryCategory[] tempCategories = new DateHistoryCategory[4];
      
      Calendar currentCal = Calendar.getInstance();
      tempCategories[0] = new DateHistoryCategory(TeamUIMessages.HistoryPage_Today, currentCal, null);
      
      Calendar yesterdayCal = Calendar.getInstance();
      yesterdayCal.roll(6, -1);
      tempCategories[1] = new DateHistoryCategory(TeamUIMessages.HistoryPage_Yesterday, yesterdayCal, null);
      
      Calendar monthCal = Calendar.getInstance();
      monthCal.set(5, 1);
      tempCategories[2] = new DateHistoryCategory(TeamUIMessages.HistoryPage_ThisMonth, monthCal, yesterdayCal);
      
      tempCategories[3] = new DateHistoryCategory(TeamUIMessages.HistoryPage_Previous, null, monthCal);
      
      ArrayList finalCategories = new ArrayList();
      for (int i = 0; i < tempCategories.length; i++)
      {
        tempCategories[i].collectFileRevisions(revisions, false);
        if (tempCategories[i].hasRevisions()) {
          finalCategories.add(tempCategories[i]);
        }
      }
      if (finalCategories.size() == 0) {
        finalCategories.add(getErrorMessage());
      }
      return (AbstractHistoryCategory[])finalCategories.toArray(new AbstractHistoryCategory[finalCategories.size()]);
    }
    finally
    {
      monitor.done();
    }
  }
  
  private MessageHistoryCategory getErrorMessage()
  {
    MessageHistoryCategory messageCategory = new MessageHistoryCategory(getNoChangesMessage());
    return messageCategory;
  }
  
  protected String getNoChangesMessage()
  {
    return TeamUIMessages.LocalHistoryPage_NoRevisionsFound;
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.history.HistoryPageSource;
import org.eclipse.team.ui.history.IHistoryPageSource;
import org.eclipse.ui.part.Page;

public class LocalHistoryPageSource
  extends HistoryPageSource
{
  private static LocalHistoryPageSource instance;
  
  public static IFile getFile(Object object)
  {
    IResource resource = Utils.getResource(object);
    if ((resource instanceof IFile)) {
      return (IFile)resource;
    }
    return null;
  }
  
  public boolean canShowHistoryFor(Object object)
  {
    return getFile(object) != null;
  }
  
  public Page createPage(Object object)
  {
    LocalHistoryPage page = new LocalHistoryPage();
    return page;
  }
  
  public static synchronized IHistoryPageSource getInstance()
  {
    if (instance == null) {
      instance = new LocalHistoryPageSource();
    }
    return instance;
  }
}

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

import org.eclipse.jface.util.
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