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

team.ui.mapping.SynchronizationActionProvider;
import org.eclipse.team.ui.synchronize.ISynchronizePage;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.eclipse.ui.navigator.IExtensionStateModel;
import org.eclipse.ui.navigator.INavigatorContentService;

public class ResourceModelActionProvider
  extends SynchronizationActionProvider
{
  private RefactorActionGroup refactorActions;
  
  protected void initialize()
  {
    super.initialize();
    
    ResourceMergeHandler mergeHandler = new ResourceMergeHandler(
      (ISynchronizePageConfiguration)getExtensionStateModel().getProperty("org.eclipse.team.ui.synchronizationPageConfiguration"), 
      false);
    registerHandler("org.eclipse.team.ui.mergeAction", mergeHandler);
    ResourceMergeHandler overwriteHandler = new ResourceMergeHandler(
      (ISynchronizePageConfiguration)getExtensionStateModel().getProperty("org.eclipse.team.ui.synchronizationPageConfiguration"), 
      true);
    registerHandler("org.eclipse.team.ui.overwriteAction", overwriteHandler);
    ResourceMarkAsMergedHandler markAsMergedHandler = new ResourceMarkAsMergedHandler(
      (ISynchronizePageConfiguration)getExtensionStateModel().getProperty("org.eclipse.team.ui.synchronizationPageConfiguration"));
    registerHandler("org.eclipse.team.ui.markAsMergeAction", markAsMergedHandler);
    
    ICommonViewerSite cvs = getActionSite().getViewSite();
    ISynchronizePageConfiguration configuration = getSynchronizePageConfiguration();
    if (((cvs instanceof ICommonViewerWorkbenchSite)) && (configuration != null))
    {
      ICommonViewerWorkbenchSite cvws = (ICommonViewerWorkbenchSite)cvs;
      IWorkbenchPartSite wps = cvws.getSite();
      if ((wps instanceof IViewSite)) {
        refactorActions = new RefactorActionGroup(configuration.getSite(), getNavigatorContentService(configuration));
      }
    }
  }
  
  private INavigatorContentService getNavigatorContentService(ISynchronizePageConfiguration configuration)
  {
    Viewer v = configuration.getPage().getViewer();
    if ((v instanceof CommonViewer))
    {
      CommonViewer cv = (CommonViewer)v;
      return cv.getNavigatorContentService();
    }
    return null;
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    super.fillActionBars(actionBars);
    if (refactorActions != null) {
      refactorActions.fillActionBars(actionBars);
    }
  }
  
  public void fillContextMenu(IMenuManager menu)
  {
    super.fillContextMenu(menu);
    IContributionItem editGroup = menu.find("edit");
    if ((refactorActions != null) && (editGroup != null)) {
      refactorActions.fillContextMenu(menu, editGroup.getId());
    }
  }
  
  public void updateActionBars()
  {
    super.updateActionBars();
    if (refactorActions != null) {
      refactorActions.updateActionBars();
    }
  }
  
  public void dispose()
  {
    super.dispose();
    if (refactorActions != null) {
      refactorActions.dispose();
    }
  }
  
  public void setContext(ActionContext context)
  {
    super.setContext(context);
    if (refactorActions != null) {
      refactorActions.setContext(context);
    }
  }
}

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

import org.eclipse.core.runtime.IPath;
import org.eclipse.team.core.mapping.ISynchronizationContext;

class ResourceModelContentProvider$1
  implements Runnable
{
  final ResourceModelContentProvider this$0;
  private final IPath[] val$paths;
  
  ResourceModelContentProvider$1(ResourceModelContentProvider paramResourceModelContentProvider, IPath[] paramArrayOfIPath)
  {
    this$0 = paramResourceModelContentProvider;val$paths = paramArrayOfIPath;
  }
  
  public void run()
  {
    ISynchronizationContext context = ResourceModelContentProvider.access$0(this$0);
    if (context != null) {
      this$0.updateLabels(context, val$paths);
    }
  }
}

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

import org.eclipse.jface.viewers.TreeViewer;

class ResourceModelContentProvider$2
  implements Runnable
{
  final ResourceModelContentProvider this$0;
  
  ResourceModelContentProvider$2(ResourceModelContentProvider paramResourceModelContentProvider)
  {
    this$0 = paramResourceModelContentProvider;
  }
  
  public void run()
  {
    TreeViewer treeViewer = (TreeViewer)ResourceModelContentProvider.access$1(this$0);
    treeViewer.refresh();
  }
}

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

import org.eclipse.team.core.diff.IDiffChangeEvent;

class ResourceModelContentProvider$3
  implements Runnable
{
  final ResourceModelContentProvider this$0;
  private final IDiffChangeEvent val$event;
  
  ResourceModelContentProvider$3(ResourceModelContentProvider paramResourceModelContentProvider, IDiffChangeEvent paramIDiffChangeEvent)
  {
    this$0 = paramResourceModelContentProvider;val$event = paramIDiffChangeEvent;
  }
  
  public void run()
  {
    ResourceModelContentProvider.access$2(this$0, val$event);
  }
}

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

import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;

class ResourceModelContentProvider$4
  extends FastDiffFilter
{
  final ResourceModelContentProvider this$0;
  
  ResourceModelContentProvider$4(ResourceModelContentProvider paramResourceModelContentProvider)
  {
    this$0 = paramResourceModelContentProvider;
  }
  
  public boolean select(IDiff diff)
  {
    return this$0.isVisible(diff);
  }
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreePathContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IDiffChangeEvent;
import org.eclipse.team.core.diff.IDiffTree;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.mapping.SynchronizationContentProvider;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;

public class ResourceModelContentProvider
  extends SynchronizationContentProvider
  implements ITreePathContentProvider
{
  private WorkbenchContentProvider provider;
  
  protected ITreeContentProvider getDelegateContentProvider()
  {
    if (provider == null) {
      provider = new WorkbenchContentProvider();
    }
    return provider;
  }
  
  protected String getModelProviderId()
  {
    return "org.eclipse.core.resources.modelProvider";
  }
  
  protected Object getModelRoot()
  {
    return ResourcesPlugin.getWorkspace().getRoot();
  }
  
  protected boolean isInScope(ISynchronizationScope scope, Object parent, Object elementOrPath)
  {
    Object object = internalGetElement(elementOrPath);
    if ((object instanceof IResource))
    {
      IResource resource = (IResource)object;
      if (!resource.getProject().isAccessible()) {
        return false;
      }
      if (scope.contains(resource)) {
        return true;
      }
      if (hasChildrenInScope(scope, object, resource)) {
        return true;
      }
    }
    return false;
  }
  
  private boolean hasChildrenInScope(ISynchronizationScope scope, Object object, IResource resource)
  {
    if (!resource.isAccessible()) {
      return false;
    }
    IResource[] roots = scope.getRoots();
    for (int i = 0; i < roots.length; i++)
    {
      IResource root = roots[i];
      if (resource.getFullPath().isPrefixOf(root.getFullPath())) {
        return true;
      }
    }
    return false;
  }
  
  public void init(ICommonContentExtensionSite site)
  {
    super.init(site);
    TeamUIPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(this);
  }
  
  public void dispose()
  {
    if (provider != null) {
      provider.dispose();
    }
    super.dispose();
    TeamUIPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(this);
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("org.eclipse.team.ui.default_layout")) {
      refresh();
    }
    super.propertyChange(event);
  }
  
  protected Object[] getChildrenInContext(ISynchronizationContext context, Object parentOrPath, Object[] children)
  {
    Object parent = internalGetElement(parentOrPath);
    if ((parent instanceof IResource))
    {
      IResource resource = (IResource)parent;
      if ((resource.getType() == 4) && (!resource.getProject().isAccessible())) {
        return new Object[0];
      }
      IResourceDiffTree diffTree = context.getDiffTree();
      
      children = getTraversalCalculator().filterChildren(diffTree, resource, parentOrPath, children);
      if (children.length != 0) {
        children = getChildrenInScope(context.getScope(), parentOrPath, children);
      }
      if (children.length != 0) {
        children = internalGetChildren(context, parentOrPath, children);
      }
      return children;
    }
    return super.getChildrenInContext(context, parentOrPath, children);
  }
  
  private Object[] internalGetChildren(ISynchronizationContext context, Object parent, Object[] children)
  {
    List result = new ArrayList(children.length);
    for (int i = 0; i < children.length; i++)
    {
      Object object = children[i];
      if ((parent instanceof TreePath))
      {
        TreePath tp = (TreePath)parent;
        object = tp.createChildPath(object);
      }
      if (isVisible(context, object)) {
        result.add(internalGetElement(object));
      }
    }
    return result.toArray(new Object[result.size()]);
  }
  
  protected ResourceTraversal[] getTraversals(ISynchronizationContext context, Object elementOrPath)
  {
    Object object = internalGetElement(elementOrPath);
    ISynchronizationScope scope = context.getScope();
    
    ResourceMapping mapping = scope.getMapping(object);
    if (mapping != null)
    {
      ResourceTraversal[] traversals = scope.getTraversals(mapping);
      if (traversals == null) {
        return new ResourceTraversal[0];
      }
      return traversals;
    }
    if ((object instanceof IResource))
    {
      IResource resource = (IResource)object;
      if (scope.contains(resource))
      {
        List result = new ArrayList();
        ResourceTraversal[] traversals = scope.getTraversals();
        for (int i = 0; i < traversals.length; i++)
        {
          ResourceTraversal traversal = traversals[i];
          if (traversal.contains(resource))
          {
            boolean include = false;
            int depth = traversal.getDepth();
            if (depth == 2)
            {
              include = true;
            }
            else
            {
              IResource[] roots = traversal.getResources();
              for (int j = 0; j < roots.length; j++)
              {
                IResource root = roots[j];
                if (root.equals(resource))
                {
                  include = true;
                  break;
                }
                if ((root.getFullPath().equals(resource.getFullPath().removeLastSegments(1))) && (depth == 1))
                {
                  include = true;
                  depth = 0;
                  break;
                }
              }
            }
            if (include)
            {
              int layoutDepth = getTraversalCalculator().getLayoutDepth(resource, internalGetPath(elementOrPath));
              result.add(new ResourceTraversal(new IResource[] { resource }, Math.min(depth, layoutDepth), 0));
            }
          }
        }
        return (ResourceTraversal[])result.toArray(new ResourceTraversal[result.size()]);
      }
      ResourceMapping[] mappings = scope.getMappings("org.eclipse.core.resources.modelProvider");
      List result = new ArrayList();
      for (int i = 0; i < mappings.length; i++)
      {
        ResourceMapping resourceMapping = mappings[i];
        Object element = resourceMapping.getModelObject();
        IResource root = getResource(element);
        if ((root != null) && 
          (resource.getFullPath().isPrefixOf(root.getFullPath())))
        {
          mapping = scope.getMapping(element);
          if (mapping != null)
          {
            ResourceTraversal[] traversals = scope.getTraversals(mapping);
            result.addAll(Arrays.asList(traversals));
          }
        }
      }
      return (ResourceTraversal[])result.toArray(new ResourceTraversal[result.size()]);
    }
    return new ResourceTraversal[0];
  }
  
  private IResource getResource(Object element)
  {
    if ((element instanceof IResource)) {
      return (IResource)element;
    }
    return Utils.getResource(element);
  }
  
  protected boolean hasChildrenInContext(ISynchronizationContext context, Object elementOrPath)
  {
    return getTraversalCalculator().hasChildren(context, elementOrPath);
  }
  
  public void propertyChanged(IDiffTree tree, int property, IPath[] paths)
  {
    Utils.syncExec(new Runnable()
    {
      private final IPath[] val$paths;
      
      public void run()
      {
        ISynchronizationContext context = getContext();
        if (context != null) {
          updateLabels(context, val$paths);
        }
      }
    }, (StructuredViewer)getViewer());
  }
  
  private IResource[] getResources(ISynchronizationContext context, IPath[] paths)
  {
    List resources = new ArrayList();
    for (int i = 0; i < paths.length; i++)
    {
      IPath path = paths[i];
      IResource resource = getResource(context, path);
      if (resource != null) {
        resources.add(resource);
      }
    }
    return (IResource[])resources.toArray(new IResource[resources.size()]);
  }
  
  private IResource getResource(ISynchronizationContext context, IPath path)
  {
    IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
    if (resource != null) {
      return resource;
    }
    if (context != null)
    {
      IResourceDiffTree diffTree = context.getDiffTree();
      
      IDiff node = diffTree.getDiff(path);
      if (node != null) {
        return diffTree.getResource(node);
      }
      if (diffTree.getChildren(path).length > 0)
      {
        if (path.segmentCount() == 1) {
          return ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
        }
        if (path.segmentCount() > 1) {
          return ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
        }
      }
    }
    return null;
  }
  
  protected StructuredViewer getStructuredViewer()
  {
    return (StructuredViewer)getViewer();
  }
  
  public Object[] getChildren(Object parent)
  {
    if ((parent instanceof ISynchronizationContext)) {
      parent = getModelRoot();
    }
    return super.getChildren(parent);
  }
  
  public boolean hasChildren(Object element)
  {
    if ((element instanceof ISynchronizationContext)) {
      element = getModelRoot();
    }
    return super.hasChildren(element);
  }
  
  public Object[] getElements(Object parent)
  {
    if ((parent instanceof ISynchronizationContext)) {
      parent = getModelRoot();
    }
    return super.getElements(parent);
  }
  
  public Object getParent(Object elementOrPath)
  {
    Object element = internalGetElement(elementOrPath);
    if ((element instanceof IProject))
    {
      ISynchronizationContext context = getContext();
      if (context != null) {
        return context;
      }
    }
    return super.getParent(elementOrPath);
  }
  
  protected void refresh()
  {
    Utils.syncExec(new Runnable()
    {
      public void run()
      {
        TreeViewer treeViewer = (TreeViewer)getViewer();
        treeViewer.refresh();
      }
    }, getViewer().getControl());
  }
  
  protected void updateLabels(ISynchronizationContext context, IPath[] paths)
  {
    IResource[] resources = getResources(context, paths);
    if (resources.length > 0) {
      ((AbstractTreeViewer)getViewer()).update(resources, null);
    }
  }
  
  protected ResourceModelTraversalCalculator getTraversalCalculator()
  {
    return ResourceModelTraversalCalculator.getTraversalCalculator(getConfiguration());
  }
  
  protected boolean isVisible(IDiff diff)
  {
    return super.isVisible(diff);
  }
  
  public Object[] getChildren(TreePath parentPath)
  {
    return getChildren(parentPath);
  }
  
  public boolean hasChildren(TreePath path)
  {
    return hasChildren(path);
  }
  
  public TreePath[] getParents(Object element)
  {
    TreePath path = getTraversalCalculator().getParentPath(getContext(), getModelProvider(), element);
    if (path != null) {
      return new TreePath[] { path };
    }
    return new TreePath[0];
  }
  
  private Object internalGetElement(Object elementOrPath)
  {
    if ((elementOrPath instanceof TreePath))
    {
      TreePath tp = (TreePath)elementOrPath;
      return tp.getLastSegment();
    }
    return elementOrPath;
  }
  
  private TreePath internalGetPath(Object elementOrPath)
  {
    if ((elementOrPath instanceof TreePath)) {
      return (TreePath)elementOrPath;
    }
    return null;
  }
  
  public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor)
  {
    Utils.syncExec(new Runnable()
    {
      private final IDiffChangeEvent val$event;
      
      public void run()
      {
        ResourceModelContentProvider.this.handleChange(val$event);
      }
    }, (StructuredViewer)getViewer());
  }
  
  /* Error */
  private void handleChange(IDiffChangeEvent event)
  {
    // Byte code:
    //   0: new 226	java/util/ArrayList
    //   3: dup
    //   4: invokespecial 496	java/util/ArrayList:<init>	()V
    //   7: astore_2
    //   8: new 226	java/util/ArrayList
    //   11: dup
    //   12: invokespecial 496	java/util/ArrayList:<init>	()V
    //   15: astore_3
    //   16: new 226	java/util/ArrayList
    //   19: dup
    //   20: invokespecial 496	java/util/ArrayList:<init>	()V
    //   23: astore 4
    //   25: aload_0
    //   26: invokespecial 526	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:isFlatPresentation	()Z
    //   29: ifeq +124 -> 153
    //   32: aload_0
    //   33: invokespecial 530	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:getVisibleResources	()Ljava/util/Set;
    //   36: astore 5
    //   38: aload_0
    //   39: aload_1
    //   40: aload 5
    //   42: invokespecial 545	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:getChangedResources	(Lorg/eclipse/team/core/diff/IDiffChangeEvent;Ljava/util/Set;)[Lorg/eclipse/core/resources/IResource;
    //   45: astore 6
    //   47: iconst_0
    //   48: istore 7
    //   50: goto +92 -> 142
    //   53: aload 6
    //   55: iload 7
    //   57: aaload
    //   58: astore 8
    //   60: aload_1
    //   61: invokeinterface 605 1 0
    //   66: aload 8
    //   68: invokeinterface 590 1 0
    //   73: invokeinterface 607 2 0
    //   78: ifnull +39 -> 117
    //   81: aload 5
    //   83: aload 8
    //   85: invokeinterface 582 2 0
    //   90: ifeq +15 -> 105
    //   93: aload_2
    //   94: aload 8
    //   96: invokeinterface 576 2 0
    //   101: pop
    //   102: goto +37 -> 139
    //   105: aload_3
    //   106: aload 8
    //   108: invokeinterface 576 2 0
    //   113: pop
    //   114: goto +25 -> 139
    //   117: aload 5
    //   119: aload 8
    //   121: invokeinterface 582 2 0
    //   126: ifeq +13 -> 139
    //   129: aload 4
    //   131: aload 8
    //   133: invokeinterface 576 2 0
    //   138: pop
    //   139: iinc 7 1
    //   142: iload 7
    //   144: aload 6
    //   146: arraylength
    //   147: if_icmplt -94 -> 53
    //   150: goto +113 -> 263
    //   153: aload_0
    //   154: aload_1
    //   155: invokespecial 540	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:getChangedProjects	(Lorg/eclipse/team/core/diff/IDiffChangeEvent;)[Lorg/eclipse/core/resources/IProject;
    //   158: astore 5
    //   160: aload_0
    //   161: invokespecial 529	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:getVisibleProjects	()Ljava/util/Set;
    //   164: astore 6
    //   166: iconst_0
    //   167: istore 7
    //   169: goto +86 -> 255
    //   172: aload 5
    //   174: iload 7
    //   176: aaload
    //   177: astore 8
    //   179: aload_0
    //   180: aload_1
    //   181: invokeinterface 605 1 0
    //   186: aload 8
    //   188: invokespecial 542	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:hasVisibleChanges	(Lorg/eclipse/team/core/diff/IDiffTree;Lorg/eclipse/core/resources/IResource;)Z
    //   191: ifeq +39 -> 230
    //   194: aload 6
    //   196: aload 8
    //   198: invokeinterface 582 2 0
    //   203: ifeq +15 -> 218
    //   206: aload_2
    //   207: aload 8
    //   209: invokeinterface 576 2 0
    //   214: pop
    //   215: goto +37 -> 252
    //   218: aload_3
    //   219: aload 8
    //   221: invokeinterface 576 2 0
    //   226: pop
    //   227: goto +25 -> 252
    //   230: aload 6
    //   232: aload 8
    //   234: invokeinterface 582 2 0
    //   239: ifeq +13 -> 252
    //   242: aload 4
    //   244: aload 8
    //   246: invokeinterface 576 2 0
    //   251: pop
    //   252: iinc 7 1
    //   255: iload 7
    //   257: aload 5
    //   259: arraylength
    //   260: if_icmplt -88 -> 172
    //   263: aload 4
    //   265: invokeinterface 574 1 0
    //   270: ifeq +21 -> 291
    //   273: aload_3
    //   274: invokeinterface 574 1 0
    //   279: ifeq +12 -> 291
    //   282: aload_2
    //   283: invokeinterface 574 1 0
    //   288: ifne +143 -> 431
    //   291: aload_0
    //   292: invokevirtual 532	org/eclipse/team/internal/ui/mapping/ResourceModelContentProvider:getViewer	()Lorg/eclipse/jface/viewers/Viewer;
    //   295: checkcast 246	org/eclipse/jface/viewers/TreeViewer
    //   298: astore 5
    //   300: aload 5
    //   302: invokevirtual 512	org/eclipse/jface/viewers/TreeViewer:getTree	()Lorg/eclipse/swt/widgets/Tree;
    //   305: astore 6
    //   307: aload 6
    //   309: iconst_0
    //   310: invokevirtual 516	org/eclipse/swt/widgets/Tree:setRedraw	(Z)V
    //   313: aload_3
    //   314: invokeinterface 574 1 0
    //   319: ifne +19 -> 338
    //   322: aload 5
    //   324: aload 5
    //   326: invokevirtual 510	org/eclipse/jface/viewers/TreeViewer:getInput	()Ljava/lang/Object;
    //   329: aload_3
    //   330: invokeinterface 575 1 0
    //   335: invokevirtual 513	org/eclipse/jface/viewers/TreeViewer:add	(Ljava/lang/Object;[Ljava/lang/Object;)V
    //   338: aload 4
    //   340: invokeinterface 574 1 0
    //   345: ifne +20 -> 365
    //   348: aload 5
    //   350: aload 5
    //   352: invokevirtual 510	org/eclipse/jface/viewers/TreeViewer:getInput	()Ljava/lang/Object;
    //   355: aload 4
    //   357: invokeinterface 575 1 0
    //   362: invokevirtual 514	org/eclipse/jface/viewers/TreeViewer:remove	(Ljava/lang/Object;[Ljava/lang/Object;)V
    //   365: aload_2
    //   366: invokeinterface 574 1 0
    //   371: ifne +54 -> 425
    //   374: aload_2
    //   375: invokeinterface 578 1 0
    //   380: astore 7
    //   382: goto +19 -> 401
    //   385: aload 7
    //   387: invokeinterface 572 1 0
    //   392: astore 8
    //   394: aload 5
    //   396: aload 8
    //   398: invokevirtual 511	org/eclipse/jface/viewers/TreeViewer:refresh	(Ljava/lang/Object;)V
    //   401: aload 7
    //   403: invokeinterface 571 1 0
    //   408: ifne -23 -> 385
    //   411: goto +14 -> 425
    //   414: astore 9
    //   416: aload 6
    //   418: iconst_1
    //   419: invokevirtual 516	org/eclipse/swt/widgets/Tree:setRedraw	(Z)V
    //   422: aload 9
    //   424: athrow
    //   425: aload 6
    //   427: iconst_1
    //   428: invokevirtual 516	org/eclipse/swt/widgets/Tree:setRedraw	(Z)V
    //   431: return
    // Line number table:
    //   Java source line #402	-> byte code offset #0
    //   Java source line #403	-> byte code offset #8
    //   Java source line #404	-> byte code offset #16
    //   Java source line #405	-> byte code offset #25
    //   Java source line #406	-> byte code offset #32
    //   Java source line #407	-> byte code offset #38
    //   Java source line #408	-> byte code offset #47
    //   Java source line #409	-> byte code offset #53
    //   Java source line #410	-> byte code offset #60
    //   Java source line #411	-> byte code offset #81
    //   Java source line #412	-> byte code offset #93
    //   Java source line #414	-> byte code offset #105
    //   Java source line #416	-> byte code offset #117
    //   Java source line #417	-> byte code offset #129
    //   Java source line #408	-> byte code offset #139
    //   Java source line #422	-> byte code offset #153
    //   Java source line #423	-> byte code offset #160
    //   Java source line #424	-> byte code offset #166
    //   Java source line #425	-> byte code offset #172
    //   Java source line #426	-> byte code offset #179
    //   Java source line #427	-> byte code offset #194
    //   Java source line #428	-> byte code offset #206
    //   Java source line #430	-> byte code offset #218
    //   Java source line #432	-> byte code offset #230
    //   Java source line #433	-> byte code offset #242
    //   Java source line #424	-> byte code offset #252
    //   Java source line #438	-> byte code offset #263
    //   Java source line #439	-> byte code offset #291
    //   Java source line #440	-> byte code offset #300
    //   Java source line #442	-> byte code offset #307
    //   Java source line #443	-> byte code offset #313
    //   Java source line #444	-> byte code offset #322
    //   Java source line #445	-> byte code offset #338
    //   Java source line #446	-> byte code offset #348
    //   Java source line #447	-> byte code offset #365
    //   Java source line #448	-> byte code offset #374
    //   Java source line #449	-> byte code offset #385
    //   Java source line #450	-> byte code offset #394
    //   Java source line #448	-> byte code offset #401
    //   Java source line #453	-> byte code offset #414
    //   Java source line #454	-> byte code offset #416
    //   Java source line #455	-> byte code offset #422
    //   Java source line #454	-> byte code offset #425
    //   Java source line #457	-> byte code offset #431
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	432	0	this	ResourceModelContentProvider
    //   0	432	1	event	IDiffChangeEvent
    //   7	368	2	refreshes	List
    //   15	315	3	additions	List
    //   23	333	4	removals	List
    //   36	82	5	existingResources	Set
    //   158	100	5	changedProjects	IProject[]
    //   298	97	5	viewer	TreeViewer
    //   45	100	6	changedResources	IResource[]
    //   164	67	6	existingProjects	Set
    //   305	121	6	tree	Tree
    //   48	95	7	i	int
    //   167	89	7	i	int
    //   380	22	7	iter	Iterator
    //   58	74	8	resource	IResource
    //   177	68	8	project	IProject
    //   392	5	8	element	Object
    //   414	9	9	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   307	414	414	finally
  }
  
  private boolean isFlatPresentation()
  {
    ISynchronizePageConfiguration configuration = getConfiguration();
    if (configuration != null)
    {
      String p = (String)configuration.getProperty("org.eclipse.team.ui.pageLayout");
      return (p != null) && (p.equals("org.eclipse.team.ui.flatLayout"));
    }
    return false;
  }
  
  private boolean hasVisibleChanges(IDiffTree tree, IResource resource)
  {
    tree.hasMatchingDiffs(resource.getFullPath(), new FastDiffFilter()
    {
      public boolean select(IDiff diff)
      {
        return isVisible(diff);
      }
    });
  }
  
  private IProject[] getChangedProjects(IDiffChangeEvent event)
  {
    Set result = new HashSet();
    IDiff[] changes = event.getChanges();
    for (int i = 0; i < changes.length; i++)
    {
      IDiff diff = changes[i];
      IResource resource = ResourceDiffTree.getResourceFor(diff);
      if (resource != null) {
        result.add(resource.getProject());
      }
    }
    IDiff[] additions = event.getAdditions();
    for (int i = 0; i < additions.length; i++)
    {
      IDiff diff = additions[i];
      IResource resource = ResourceDiffTree.getResourceFor(diff);
      if (resource != null) {
        result.add(resource.getProject());
      }
    }
    IPath[] removals = event.getRemovals();
    for (int i = 0; i < removals.length; i++)
    {
      IPath path = removals[i];
      if (path.segmentCount() > 0)
      {
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
        result.add(project);
      }
    }
    return (IProject[])result.toArray(new IProject[result.size()]);
  }
  
  private Set getVisibleProjects()
  {
    TreeViewer viewer = (TreeViewer)getViewer();
    Tree tree = viewer.getTree();
    TreeItem[] children = tree.getItems();
    Set result = new HashSet();
    for (int i = 0; i < children.length; i++)
    {
      TreeItem control = children[i];
      Object data = control.getData();
      IResource resource = Utils.getResource(data);
      if ((resource != null) && (resource.getType() == 4)) {
        result.add(resource);
      }
    }
    return result;
  }
  
  private Set getVisibleResources()
  {
    TreeViewer viewer = (TreeViewer)getViewer();
    Tree tree = viewer.getTree();
    TreeItem[] children = tree.getItems();
    Set result = new HashSet();
    for (int i = 0; i < children.length; i++)
    {
      TreeItem control = children[i];
      Object data = control.getData();
      IResource resource = Utils.getResource(data);
      if (resource != null) {
        result.add(resource);
      }
    }
    return result;
  }
  
  private IResource[] getChangedResources(IDiffChangeEvent event, Set existingResources)
  {
    Set result = new HashSet();
    IDiff[] changes = event.getChanges();
    for (int i = 0; i < changes.length; i++)
    {
      IDiff diff = changes[i];
      IResource resource = ResourceDiffTree.getResourceFor(diff);
      if (resource != null) {
        result.add(resource);
      }
    }
    IDiff[] additions = event.getAdditions();
    for (int i = 0; i < additions.length; i++)
    {
      IDiff diff = additions[i];
      IResource resource = ResourceDiffTree.getResourceFor(diff);
      if (resource != null) {
        result.add(resource);
      }
    }
    IPath[] removals = event.getRemovals();
    for (int i = 0; i < removals.length; i++)
    {
      IPath path = removals[i];
      if (path.segmentCount() > 0)
      {
        IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
        if (resource != null) {
          result.add(resource);
        } else {
          for (Iterator iterator = existingResources.iterator(); iterator
                .hasNext();)
          {
            resource = (IResource)iterator.next();
            if (resource.getFullPath().equals(path))
            {
              result.add(resource);
              break;
            }
          }
        }
      }
    }
    return (IResource[])result.toArray(new IResource[result.size()]);
  }
}

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

import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;

class ResourceModelLabelProvider$1
  extends FastDiffFilter
{
  public boolean select(IDiff diff)
  {
    if ((diff instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)diff;
      return twd.getDirection() == 768;
    }
    return false;
  }
}

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

import org.eclipse.jface.viewers.StructuredViewer;

class ResourceModelLabelProvider$2
  implements Runnable
{
  final ResourceModelLabelProvider this$0;
  private final Object[] val$resources;
  
  ResourceModelLabelProvider$2(ResourceModelLabelProvider paramResourceModelLabelProvider, Object[] paramArrayOfObject)
  {
    this$0 = paramResourceModelLabelProvider;val$resources = paramArrayOfObject;
  }
  
  public void run()
  {
    ResourceModelLabelProvider.access$0(this$0).getStructuredViewer().update(
      val$resources, null);
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreePathLabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.ViewerLabel;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.ImageManager;
import org.eclipse.team.ui.mapping.SynchronizationLabelProvider;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.IExtensionStateModel;
import org.eclipse.ui.navigator.INavigatorContentExtension;

public class ResourceModelLabelProvider
  extends SynchronizationLabelProvider
  implements IFontProvider, IResourceChangeListener, ITreePathLabelProvider
{
  public static final FastDiffFilter CONFLICT_FILTER = new FastDiffFilter()
  {
    public boolean select(IDiff diff)
    {
      if ((diff instanceof IThreeWayDiff))
      {
        IThreeWayDiff twd = (IThreeWayDiff)diff;
        return twd.getDirection() == 768;
      }
      return false;
    }
  };
  private ILabelProvider provider;
  private ResourceModelContentProvider contentProvider;
  private ImageManager localImageManager;
  
  public void init(ICommonContentExtensionSite site)
  {
    ITreeContentProvider aContentProvider = site.getExtension().getContentProvider();
    if ((aContentProvider instanceof ResourceModelContentProvider))
    {
      contentProvider = ((ResourceModelContentProvider)aContentProvider);
      ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
    }
    super.init(site);
  }
  
  public void dispose()
  {
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    if (localImageManager != null) {
      localImageManager.dispose();
    }
    if (provider != null) {
      provider.dispose();
    }
    super.dispose();
  }
  
  protected ILabelProvider getDelegateLabelProvider()
  {
    if (provider == null) {
      provider = new WorkbenchLabelProvider();
    }
    return provider;
  }
  
  protected IDiff getDiff(Object elementOrPath)
  {
    IResource resource = getResource(elementOrPath);
    IResourceDiffTree tree = getDiffTree(elementOrPath);
    if ((tree != null) && (resource != null))
    {
      IDiff delta = tree.getDiff(resource.getFullPath());
      return delta;
    }
    return null;
  }
  
  private IResource getResource(Object elementOrPath)
  {
    Object element = internalGetElement(elementOrPath);
    if ((element instanceof IResource)) {
      return (IResource)element;
    }
    return null;
  }
  
  protected boolean isIncludeOverlays()
  {
    return true;
  }
  
  protected boolean isBusy(Object elementOrPath)
  {
    IResource resource = getResource(elementOrPath);
    IResourceDiffTree tree = getDiffTree(elementOrPath);
    if ((tree != null) && (resource != null)) {
      return tree.getProperty(resource.getFullPath(), 1);
    }
    return super.isBusy(elementOrPath);
  }
  
  private TreePath internalGetPath(Object elementOrPath)
  {
    if ((elementOrPath instanceof TreePath)) {
      return (TreePath)elementOrPath;
    }
    return null;
  }
  
  protected boolean hasDecendantConflicts(Object elementOrPath)
  {
    IResource resource = getResource(elementOrPath);
    IResourceDiffTree tree = getDiffTree(elementOrPath);
    if ((tree != null) && (resource != null))
    {
      int depth = getTraversalCalculator().getLayoutDepth(resource, internalGetPath(elementOrPath));
      if ((depth == 2) || (resource.getType() == 1)) {
        return tree.getProperty(resource.getFullPath(), 2);
      }
      return tree.hasMatchingDiffs(getTraversalCalculator().getTraversals(resource, internalGetPath(elementOrPath)), CONFLICT_FILTER);
    }
    return super.hasDecendantConflicts(elementOrPath);
  }
  
  protected IResourceDiffTree getDiff
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