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

mport org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class AbstractSynchronizeModelProvider$6
  implements ISafeRunnable
{
  final AbstractSynchronizeModelProvider this$0;
  private final IPropertyChangeListener val$listener;
  private final PropertyChangeEvent val$event;
  
  AbstractSynchronizeModelProvider$6(AbstractSynchronizeModelProvider paramAbstractSynchronizeModelProvider, IPropertyChangeListener paramIPropertyChangeListener, PropertyChangeEvent paramPropertyChangeEvent)
  {
    this$0 = paramAbstractSynchronizeModelProvider;val$listener = paramIPropertyChangeListener;val$event = paramPropertyChangeEvent;
  }
  
  public void handleException(Throwable exception) {}
  
  public void run()
    throws Exception
  {
    val$listener.propertyChange(val$event);
  }
}

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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.TreeEvent;
import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.team.core.ITeamStatus;
import org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent;
import org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener;
import org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.internal.core.TeamPlugin;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePage;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;

public abstract class AbstractSynchronizeModelProvider
  implements ISynchronizeModelProvider, ISyncInfoSetChangeListener, TreeListener
{
  public static final String P_VIEWER_EXPANSION_STATE = "org.eclipse.team.ui.P_VIEWER_EXPANSION_STATE";
  public static final String P_VIEWER_SELECTION_STATE = "org.eclipse.team.ui.P_VIEWER_SELECTION_STATE";
  public static final String P_VIEWER_CHECKED_STATE = "org.eclipse.team.ui.P_VIEWER_CHECKED_STATE";
  private ISynchronizeModelElement root;
  private ISynchronizePageConfiguration configuration;
  private SyncInfoSet set;
  private SynchronizeModelUpdateHandler updateHandler;
  private boolean disposed = false;
  private SynchronizePageActionGroup actionGroup;
  private ListenerList listeners;
  private static final boolean DEBUG = false;
  
  protected AbstractSynchronizeModelProvider(AbstractSynchronizeModelProvider parentProvider, ISynchronizeModelElement parentNode, ISynchronizePageConfiguration configuration, SyncInfoSet set)
  {
    Assert.isNotNull(set);
    Assert.isNotNull(parentNode);
    root = parentNode;
    this.set = set;
    this.configuration = configuration;
    if (parentProvider == null)
    {
      updateHandler = new SynchronizeModelUpdateHandler(this);
      getTree().addTreeListener(this);
    }
    else
    {
      updateHandler = updateHandler;
      set.addSyncSetChangedListener(this);
    }
  }
  
  private Tree getTree()
  {
    return (Tree)((AbstractTreeViewer)getViewer()).getControl();
  }
  
  protected AbstractSynchronizeModelProvider(ISynchronizePageConfiguration configuration, SyncInfoSet set)
  {
    this(null, new UnchangedResourceModelElement(null, ResourcesPlugin.getWorkspace().getRoot())
    {
      public boolean hasChildren()
      {
        return true;
      }
    }, configuration, set);
    
    SynchronizePageActionGroup actionGroup = getActionGroup();
    if (actionGroup != null) {
      configuration.addActionContribution(actionGroup);
    }
  }
  
  public final synchronized SynchronizePageActionGroup getActionGroup()
  {
    if (actionGroup == null) {
      actionGroup = createActionGroup();
    }
    return actionGroup;
  }
  
  protected SynchronizePageActionGroup createActionGroup()
  {
    return null;
  }
  
  public SyncInfoSet getSyncInfoSet()
  {
    return set;
  }
  
  public ISynchronizeModelElement getModelRoot()
  {
    return root;
  }
  
  public ISynchronizePageConfiguration getConfiguration()
  {
    return configuration;
  }
  
  public StructuredViewer getViewer()
  {
    ISynchronizePage page = configuration.getPage();
    if (page == null) {
      return null;
    }
    Viewer viewer = page.getViewer();
    if ((viewer instanceof AbstractTreeViewer)) {
      return (AbstractTreeViewer)viewer;
    }
    return null;
  }
  
  public ISynchronizeModelElement prepareInput(IProgressMonitor monitor)
  {
    if (isRootProvider()) {
      updateHandler.connect(monitor);
    } else {
      getSyncInfoSet().connect(this, monitor);
    }
    return getModelRoot();
  }
  
  public String calculateProblemMarker(ISynchronizeModelElement element)
  {
    IResource resource = element.getResource();
    String property = null;
    if ((resource != null) && (resource.exists()))
    {
      try
      {
        IMarker[] markers = resource.findMarkers("org.eclipse.core.resources.problemmarker", true, getLogicalModelDepth(resource));
        for (int i = 0; i < markers.length; i++)
        {
          IMarker marker = markers[i];
          try
          {
            Integer severity = (Integer)marker.getAttribute("severity");
            if (severity != null)
            {
              if (severity.intValue() == 2)
              {
                property = "org.eclipse.team.ui.error";
                break;
              }
              if (severity.intValue() == 1) {
                property = "org.eclipse.team.ui.warning";
              }
            }
          }
          catch (CoreException e)
          {
            if (!resource.exists())
            {
              property = null;
              break;
            }
            if (marker.exists()) {
              TeamPlugin.log(e);
            }
          }
        }
      }
      catch (CoreException e)
      {
        if (!resource.isAccessible()) {
          return property;
        }
      }
      if ((e.getStatus().getCode() != 368) && 
        (e.getStatus().getCode() != 372)) {
        TeamPlugin.log(e);
      }
    }
    else if (resource == null)
    {
      IDiffElement[] children = element.getChildren();
      for (int i = 0; i < children.length; i++)
      {
        IDiffElement child = children[i];
        if ((child instanceof ISynchronizeModelElement))
        {
          ISynchronizeModelElement childElement = (ISynchronizeModelElement)child;
          if (childElement.getProperty("org.eclipse.team.ui.error"))
          {
            property = "org.eclipse.team.ui.error";
            break;
          }
          if (childElement.getProperty("org.eclipse.team.ui.warning")) {
            property = "org.eclipse.team.ui.warning";
          }
        }
      }
    }
    return property;
  }
  
  protected int getLogicalModelDepth(IResource resource)
  {
    return 2;
  }
  
  protected void queueForLabelUpdate(ISynchronizeModelElement diffNode)
  {
    updateHandler.queueForLabelUpdate(diffNode);
  }
  
  protected void reset()
  {
    if ((isRootProvider()) && (hasViewerState())) {
      saveViewerState();
    }
    clearModelObjects(getModelRoot());
    
    buildModelObjects(getModelRoot());
    
    ISynchronizeModelElement root = getModelRoot();
    if ((root instanceof SynchronizeModelElement)) {
      ((SynchronizeModelElement)root).fireChanges();
    }
    if (Utils.canUpdateViewer(getViewer())) {
      refreshModelRoot();
    } else if (!updateHandler.isPerformingBackgroundUpdate()) {
      Utils.asyncExec(new Runnable()
      {
        public void run()
        {
          AbstractSynchronizeModelProvider.this.refreshModelRoot();
        }
      }, getViewer());
    }
  }
  
  /* Error */
  private void refreshModelRoot()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 758	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:getViewer	()Lorg/eclipse/jface/viewers/StructuredViewer;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnull +88 -> 94
    //   9: aload_1
    //   10: invokevirtual 728	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   13: invokevirtual 729	org/eclipse/swt/widgets/Control:isDisposed	()Z
    //   16: ifne +78 -> 94
    //   19: aload_1
    //   20: invokevirtual 728	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   23: iconst_0
    //   24: invokevirtual 730	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   27: aload_0
    //   28: invokespecial 752	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:isRootProvider	()Z
    //   31: ifne +15 -> 46
    //   34: aload_0
    //   35: invokevirtual 764	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:getModelRoot	()Lorg/eclipse/team/ui/synchronize/ISynchronizeModelElement;
    //   38: invokeinterface 841 1 0
    //   43: ifnonnull +10 -> 53
    //   46: aload_1
    //   47: invokevirtual 725	org/eclipse/jface/viewers/StructuredViewer:refresh	()V
    //   50: goto +11 -> 61
    //   53: aload_0
    //   54: aload_0
    //   55: invokevirtual 764	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:getModelRoot	()Lorg/eclipse/team/ui/synchronize/ISynchronizeModelElement;
    //   58: invokevirtual 765	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:addToViewer	(Lorg/eclipse/team/ui/synchronize/ISynchronizeModelElement;)V
    //   61: aload_0
    //   62: invokespecial 752	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:isRootProvider	()Z
    //   65: ifeq +21 -> 86
    //   68: aload_0
    //   69: invokevirtual 749	org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider:restoreViewerState	()V
    //   72: goto +14 -> 86
    //   75: astore_2
    //   76: aload_1
    //   77: invokevirtual 728	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   80: iconst_1
    //   81: invokevirtual 730	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   84: aload_2
    //   85: athrow
    //   86: aload_1
    //   87: invokevirtual 728	org/eclipse/jface/viewers/StructuredViewer:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   90: iconst_1
    //   91: invokevirtual 730	org/eclipse/swt/widgets/Control:setRedraw	(Z)V
    //   94: return
    // Line number table:
    //   Java source line #342	-> byte code offset #0
    //   Java source line #343	-> byte code offset #5
    //   Java source line #345	-> byte code offset #19
    //   Java source line #346	-> byte code offset #27
    //   Java source line #348	-> byte code offset #46
    //   Java source line #353	-> byte code offset #53
    //   Java source line #356	-> byte code offset #61
    //   Java source line #357	-> byte code offset #68
    //   Java source line #358	-> byte code offset #75
    //   Java source line #359	-> byte code offset #76
    //   Java source line #360	-> byte code offset #84
    //   Java source line #359	-> byte code offset #86
    //   Java source line #362	-> byte code offset #94
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	95	0	this	AbstractSynchronizeModelProvider
    //   4	83	1	viewer	StructuredViewer
    //   75	10	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   19	75	75	finally
  }
  
  protected abstract IDiffElement[] buildModelObjects(ISynchronizeModelElement paramISynchronizeModelElement);
  
  protected abstract boolean hasViewerState();
  
  protected IResource[] getExpandedResources()
  {
    Set expanded = new HashSet();
    IResource[] savedExpansionState = getCachedResources("org.eclipse.team.ui.P_VIEWER_EXPANSION_STATE");
    for (int i = 0; i < savedExpansionState.length; i++)
    {
      IResource resource = savedExpansionState[i];
      expanded.add(resource);
    }
    StructuredViewer viewer = getViewer();
    Object[] objects = ((AbstractTreeViewer)viewer).getVisibleExpandedElements();
    IResource[] currentExpansionState = getResources(objects);
    for (int i = 0; i < currentExpansionState.length; i++)
    {
      IResource resource = currentExpansionState[i];
      expanded.add(resource);
    }
    return (IResource[])expanded.toArray(new IResource[expanded.size()]);
  }
  
  protected IResource[] getSelectedResources()
  {
    StructuredViewer viewer = getViewer();
    return getResources(((IStructuredSelection)viewer.getSelection()).toArray());
  }
  
  protected IResource[] getCheckedResources()
  {
    StructuredViewer viewer = getViewer();
    if ((viewer instanceof CheckboxTreeViewer)) {
      return getResources(((CheckboxTreeViewer)viewer).getCheckedElements());
    }
    return new IResource[0];
  }
  
  protected void expandResources(IResource[] resources)
  {
    Set expandedElements = new HashSet();
    StructuredViewer viewer = getViewer();
    for (int j = 0; j < resources.length; j++)
    {
      IResource resource = resources[j];
      ISynchronizeModelElement[] elements = getModelObjects(resource);
      if (elements.length == 1) {
        for (int i = 0; i < elements.length; i++)
        {
          ISynchronizeModelElement element = elements[i];
          while (element != null)
          {
            expandedElements.add(element);
            element = (ISynchronizeModelElement)element.getParent();
          }
        }
      }
    }
    if (!expandedElements.isEmpty()) {
      ((AbstractTreeViewer)viewer).setExpandedElements(expandedElements.toArray());
    }
  }
  
  protected IResource[] getResources(Object[] objects)
  {
    Set result = new HashSet();
    if (objects.length > 0) {
      for (int i = 0; i < objects.length; i++) {
        if ((objects[i] instanceof ISynchronizeModelElement))
        {
          IResource resource = ((ISynchronizeModelElement)objects[i]).getResource();
          if (resource != null) {
            result.add(resource);
          }
        }
      }
    }
    return (IResource[])result.toArray(new IResource[result.size()]);
  }
  
  private void clearResourceCache(String configProperty)
  {
    getConfiguration().setProperty(configProperty, null);
  }
  
  private void cacheResources(IResource[] resources, String configProperty)
  {
    if (resources.length > 0)
    {
      ISynchronizePageConfiguration config = getConfiguration();
      ArrayList paths = new ArrayList();
      for (int i = 0; i < resources.length; i++)
      {
        IResource resource = resources[i];
        String path = resource.getFullPath().toString();
        if ((resource.getType() != 1) && (path.charAt(path.length() - 1) != '/')) {
          path = path + '/';
        }
        paths.add(path);
      }
      config.setProperty(configProperty, paths);
    }
    else
    {
      clearResourceCache(configProperty);
    }
  }
  
  private IResource[] getCachedResources(String configProperty)
  {
    List paths = (List)getConfiguration().getProperty(configProperty);
    if (paths == null) {
      return new IResource[0];
    }
    IContainer container = ResourcesPlugin.getWorkspace().getRoot();
    ArrayList resources = new ArrayList();
    for (Iterator it = paths.iterator(); it.hasNext();)
    {
      String path = (String)it.next();
      IResource resource = getResourceForPath(container, path);
      if (resource != null) {
        resources.add(resource);
      }
    }
    return (IResource[])resources.toArray(new IResource[resources.size()]);
  }
  
  protected void saveViewerState()
  {
    StructuredViewer viewer = getViewer();
    if ((viewer != null) && (!viewer.getControl().isDisposed()) && ((viewer instanceof AbstractTreeViewer)))
    {
      boolean storeChecks = ((SynchronizePageConfiguration)configuration).getViewerStyle() == 1;
      IResource[][] expandedResources = new IResource[1][0];
      IResource[][] selectedResources = new IResource[1][0];
      IResource[][] checkedResources = new IResource[1][0];
      viewer.getControl().getDisplay().syncExec(new Runnable()
      {
        private final StructuredViewer val$viewer;
        private final IResource[][] val$expandedResources;
        private final IResource[][] val$selectedResources;
        private final boolean val$storeChecks;
        private final IResource[][] val$checkedResources;
        
        public void run()
        {
          if ((val$viewer != null) && (!val$viewer.getControl().isDisposed()))
          {
            val$expandedResources[0] = getExpandedResources();
            val$selectedResources[0] = getSelectedResources();
            if (val$storeChecks) {
              val$checkedResources[0] = getCheckedResources();
            }
          }
        }
      });
      cacheResources(expandedResources[0], "org.eclipse.team.ui.P_VIEWER_EXPANSION_STATE");
      cacheResources(selectedResources[0], "org.eclipse.team.ui.P_VIEWER_SELECTION_STATE");
      if (storeChecks) {
        cacheResources(checkedResources[0], "org.eclipse.team.ui.P_VIEWER_CHECKED_STATE");
      }
    }
  }
  
  protected void restoreViewerState()
  {
    StructuredViewer viewer = getViewer();
    if ((viewer != null) && (!viewer.getControl().isDisposed()) && ((viewer instanceof AbstractTreeViewer)))
    {
      IResource[] resourcesToExpand = getCachedResources("org.eclipse.team.ui.P_VIEWER_EXPANSION_STATE");
      IResource[] resourcesToSelect = getCachedResources("org.eclipse.team.ui.P_VIEWER_SELECTION_STATE");
      if (((SynchronizePageConfiguration)configuration).getViewerStyle() == 1)
      {
        IResource[] resourcesToCheck = getCachedResources("org.eclipse.team.ui.P_VIEWER_CHECKED_STATE");
        checkResources(resourcesToCheck);
      }
      expandResources(resourcesToExpand);
      selectResources(resourcesToSelect);
    }
  }
  
  protected void selectResources(IResource[] resourcesToSelect)
  {
    StructuredViewer viewer = getViewer();
    ArrayList selectedElements = new ArrayList();
    for (int i = 0; i < resourcesToSelect.length; i++)
    {
      IResource resource = resourcesToSelect[i];
      ISynchronizeModelElement[] elements = getModelObjects(resource);
      if (elements.length == 1) {
        selectedElements.add(elements[0]);
      }
    }
    if (!selectedElements.isEmpty()) {
      viewer.setSelection(new StructuredSelection(selectedElements));
    }
  }
  
  protected void checkResources(IResource[] resourcesToCheck)
  {
    Set checkedElements = new HashSet();
    StructuredViewer viewer = getViewer();
    if (!(viewer instanceof CheckboxTreeViewer)) {
      return;
    }
    for (int j = 0; j < resourcesToCheck.length; j++)
    {
      IResource resource = resourcesToCheck[j];
      if (resource.getType() == 1)
      {
        ISynchronizeModelElement[] elements = getModelObjects(resource);
        if (elements.length == 1) {
          for (int i = 0; i < elements.length; i++)
          {
            ISynchronizeModelElement element = elements[i];
            checkedElements.add(element);
          }
        }
      }
    }
    if (!checkedElements.isEmpty()) {
      ((CheckboxTreeViewer)viewer).setCheckedElements(checkedElements.toArray());
    }
  }
  
  private IResource getResourceForPath(IContainer container, String path)
  {
    IResource resource = container.findMember(path, true);
    if (resource == null) {
      try
      {
        if (path.endsWith(Character.toString('/'))) {
          resource = container.getFolder(new Path(null, path));
        } else {
          resource = container.getFile(new Path(null, path));
        }
      }
      catch (IllegalArgumentException localIllegalArgumentException) {}
    }
    return resource;
  }
  
  public void treeCollapsed(TreeEvent e)
  {
    clearResourceCache("org.eclipse.team.ui.P_VIEWER_EXPANSION_STATE");
  }
  
  public void treeExpanded(TreeEvent e)
  {
    clearResourceCache("org.eclipse.team.ui.P_VIEWER_EXPANSION_STATE");
  }
  
  protected abstract ISynchronizeModelElement[] getModelObjects(IResource paramIResource);
  
  public void saveState()
  {
    saveViewerState();
  }
  
  protected void propogateConflictState(ISynchronizeModelElement element, boolean clear)
  {
    boolean isConflict = clear ? false : isConflicting(element);
    boolean wasConflict = element.getProperty("org.eclipse.team.ui.conflict");
    if (isConflict != wasConflict)
    {
      element.setPropertyToRoot("org.eclipse.team.ui.conflict", isConflict);
      updateHandler.updateParentLabels(element);
    }
  }
  
  protected boolean isConflicting(ISynchronizeModelElement element)
  {
    return (element.getKind() & 0xC) == 12;
  }
  
  public void dispose()
  {
    if (isRootProvider())
    {
      updateHandler.dispose();
      getTree().removeTreeListener(this);
    }
    else
    {
      set.removeSyncSetChangedListener(this);
    }
    if (actionGroup != null) {
      Utils.syncExec(new Runnable()
      {
        public void run()
        {
          actionGroup.dispose();
        }
      }, getViewer());
    }
    disposed = true;
  }
  
  private boolean isRootProvider()
  {
    return updateHandler.getProvider() == this;
  }
  
  public boolean isDisposed()
  {
    return disposed;
  }
  
  public abstract ISynchronizeModelElement[] getClosestExistingParents(IResource paramIResource);
  
  protected void handleChanges(ISyncInfoTreeChangeEvent event, IProgressMonitor monitor)
  {
    handleResourceChanges(event);
    handleResourceRemovals(event);
    handleResourceAdditions(event);
  }
  
  protected abstract void handleResourceAdditions(ISyncInfoTreeChangeEvent paramISyncInfoTreeChangeEvent);
  
  protected abstract void handleResourceChanges(ISyncInfoTreeChangeEvent paramISyncInfoTreeChangeEvent);
  
  protected abstract void handleResourceRemovals(ISyncInfoTreeChangeEvent paramISyncInfoTreeChangeEvent);
  
  public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor)
  {
    if (!(event instanceof ISyncInfoTreeChangeEvent)) {
      reset();
    } else {
      updateHandler.runViewUpdate(new Runnable()
      {
        private final ISyncInfoSetChangeEvent val$event;
        private final IProgressMonitor val$monitor;
        
        public void run()
        {
          handleChanges((ISyncInfoTreeChangeEvent)val$event, val$monitor);
        }
      }, true);
    }
  }
  
  public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {}
  
  public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor)
  {
    reset();
  }
  
  protected void addToViewer(ISynchronizeModelElement node)
  {
    propogateConflictState(node, false);
    
    String property = calculateProblemMarker(node);
    if (property != null)
    {
      node.setProperty(property, true);
      
      propogateMarkerPropertyToParent(node, property);
    }
    if (Utils.canUpdateViewer(getViewer())) {
      doAdd((SynchronizeModelElement)node.getParent(), node);
    }
    updateHandler.nodeAdded(node, this);
  }
  
  private void propogateMarkerPropertyToParent(ISynchronizeModelElement node, String property)
  {
    ISynchronizeModelElement parent = (ISynchronizeModelElement)node.getParent();
    if ((parent != null) && 
      (!parent.getProperty(property)) && 
      (!parent.getProperty("org.eclipse.team.ui.error")))
    {
      parent.setProperty(property, true);
      propogateMarkerPropertyToParent(parent, property);
    }
  }
  
  protected void removeFromViewer(ISynchronizeModelElement[] nodes)
  {
    List rootsToClear = new ArrayList();
    for (int i = 0; i < nodes.length; i++)
    {
      ISynchronizeModelElement node = nodes[i];
      
      ISynchronizeModelElement rootToClear = getRootToClear(node);
      
      propogateConflictState(rootToClear, true);
      clearModelObjects(rootToClear);
      rootsToClear.add(rootToClear);
    }
    ISynchronizeModelElement[] roots = (ISynchronizeModelElement[])rootsToClear.toArray(new ISynchronizeModelElement[rootsToClear.size()]);
    if (Utils.canUpdateViewer(getViewer())) {
      doRemove(roots);
    }
    for (int i = 0; i < roots.length; i++)
    {
      ISynchronizeModelElement element = roots[i];
      updateHandler.nodeRemoved(element, this);
    }
  }
  
  protected final void clearModelObjects(ISynchronizeModelElement node)
  {
    ISynchronizeModelElement rootToClear = getRootToClear(node);
    
    recursiveClearModelObjects(rootToClear);
    if (node == getModelRoot())
    {
      IDiffElement[] children = node.getChildren();
      for (int i = 0; i < children.length; i++)
      {
        IDiffElement element = children[i];
        ((SynchronizeModelElement)node).remove(element);
      }
    }
    else
    {
      SynchronizeModelElement parent = (SynchronizeModelElement)node.getParent();
      if (parent != null) {
        parent.remove(node);
      }
    }
  }
  
  protected void recursiveClearModelObjects(ISynchronizeModelElement node)
  {
    IDiffElement[] children = node.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      IDiffElement element = children[i];
      if ((element instanceof ISynchronizeModelElement))
      {
        ISynchronizeModelElement sme = (ISynchronizeModelElement)element;
        ISynchronizeModelProvider provider = getProvider(sme);
        if ((provider != null) && ((provider instanceof AbstractSynchronizeModelProvider))) {
          ((AbstractSynchronizeModelProvider)provider).recursiveClearModelObjects(sme);
        } else {
          recursiveClearModelObjects(sme);
        }
      }
    }
    if (node != getModelRoot()) {
      updateHandler.modelObjectCleared(node);
    }
  }
  
  private ISynchronizeModelElement getRootToClear(ISynchronizeModelElement node)
  {
    if (node == getModelRoot()) {
      return node;
    }
    ISynchronizeModelElement parent = (ISynchronizeModelElement)node.getParent();
    if ((parent != null) && (parent != getModelRoot()) && (!isOutOfSync(parent)) && (parent.getChildren().length == 1)) {
      return getRootToClear(parent);
    }
    return node;
  }
  
  protected boolean isOutOfSync(ISynchronizeModelElement node)
  {
    SyncInfo info = Utils.getSyncInfo(node);
    return (info != null) && (info.getKind() != 0);
  }
  
  protected boolean isOutOfSync(IResource resource)
  {
    SyncInfo info = getSyncInfoSet().getSyncInfo(resource);
    return (info != null) && (info.getKind() != 0);
  }
  
  protected ISynchronizeModelProvider getProvider(ISynchronizeModelElement element)
  {
    return this;
  }
  
  protected void doAdd(ISynchronizeModelElement parent, ISynchronizeModelElement element)
  {
    updateHandler.doAdd(parent, element);
  }
  
  protected void doRemove(ISynchronizeModelElement[] elements)
  {
    AbstractTreeViewer viewer = (AbstractTreeViewer)getViewer();
    try
    {
      viewer.remove(elements);
    }
    catch (SWTException e)
    {
      TeamUIPlugin.log(4, "An error occurred removing elements from the synchronize view", e);
    }
  }
  
  protected void nodeAdded(ISynchronizeModelElement node, AbstractSynchronizeModelProvider provider) {}
  
  protected void nodeRemoved(ISynchronizeModelElement node, AbstractSynchronizeModelProvider provider) {}
  
  public void modelObjectCleared(ISynchronizeModelElement node) {}
  
  public void addPropertyChangeListener(IPropertyChangeListener listener)
  {
    synchronized (this)
    {
      if (listeners == null) {
        listeners = new ListenerList(1);
      }
      listeners.add(listener);
    }
  }
  
  public void removePropertyChangeListener(IPropertyChangeListener listener)
  {
    if (listeners != null) {
      synchronized (this)
      {
        listeners.remove(listener);
        if (listeners.isEmpty()) {
          listeners = null;
        }
      }
    }
  }
  
  protected void firePropertyChange(String key, Object oldValue, Object newValue)
  {
    Object[] allListeners;
    synchronized (this)
    {
      allListeners = listeners.getListeners();
    }
    Object[] allListeners;
    PropertyChangeEvent event = new PropertyChangeEvent(this, key, oldValue, newValue);
    for (int i = 0; i < allListeners.length; i++)
    {
      IPropertyChangeListener listener = (IPropertyChangeListener)allListeners[i];
      SafeRunner.run(new ISafeRunnable()
      {
        private final IPropertyChangeListener val$listener;
        private final PropertyChangeEvent val$event;
        
        public void handleException(Throwable exception) {}
        
        public void run()
          throws Exception
        {
          val$listener.propertyChange(val$event);
        }
      });
    }
  }
  
  public void waitUntilDone(IProgressMonitor monitor)
  {
    monitor.worked(1);
    while (updateHandler.getEventHandlerJob().getState() != 0)
    {
      monitor.worked(1);
      try
      {
        Thread.sleep(10L);
      }
      catch (InterruptedException localInterruptedException) {}
      Policy.checkCanceled(monitor);
    }
    monitor.worked(1);
  }
  
  public String toString()
  {
    ISynchronizeModelElement element = getModelRoot();
    String name = getClass().getName();
    int index = name.lastIndexOf(".");
    if (index != -1) {
      name = name.substring(index + 1);
    }
    String name2 = element.getName();
    if (name2.length() == 0) {
      name2 = "/";
    }
    return name + ": " + name2;
  }
  
  public void performUpdate(IWorkspaceRunnable runnable, boolean preserveExpansion, boolean runInUIThread)
  {
    updateHandler.performUpdate(runnable, preserveExpansion, runInUIThread);
  }
}

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

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.ShowInContext;

class AbstractSynchronizePage$1
  implements IShowInSource
{
  final AbstractSynchronizePage this$0;
  
  AbstractSynchronizePage$1(AbstractSynchronizePage paramAbstractSynchronizePage)
  {
    this$0 = paramAbstractSynchronizePage;
  }
  
  public ShowInContext getShowInContext()
  {
    StructuredViewer v = (StructuredViewer)AbstractSynchronizePage.access$1(this$0);
    if (v == null) {
      return null;
    }
    ISelection s = v.getSelection();
    if ((s instanceof IStructuredSelection))
    {
      Object[] resources = Utils.getResources(((IStructuredSelection)s).toArray());
      return new ShowInContext(null, new StructuredSelection(resources));
    }
    return null;
  }
}

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

import org.eclipse.ui.part.IShowInTargetList;

class AbstractSynchronizePage$2
  implements IShowInTargetList
{
  final AbstractSynchronizePage this$0;
  
  AbstractSynchronizePage$2(AbstractSynchronizePage paramAbstractSynchronizePage)
  {
    this$0 = paramAbstractSynchronizePage;
  }
  
  public String[] getShowInTargetIds()
  {
    return new String[] { "org.eclipse.ui.views.ResourceNavigator" };
  }
}

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

import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
import org.eclipse.ui.IActionBars;

class AbstractSynchronizePage$ModeFilterActions
  extends SynchronizePageActionGroup
{
  private DirectionFilterActionGroup modes;
  final AbstractSynchronizePage this$0;
  
  AbstractSynchronizePage$ModeFilterActions(AbstractSynchronizePage paramAbstractSynchronizePage)
  {
    this$0 = paramAbstractSynchronizePage;
  }
  
  public void initialize(ISynchronizePageConfiguration configuration)
  {
    super.initialize(configuration);
    if (isThreeWay()) {
      modes = new DirectionFilterActionGroup(configuration);
    }
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    super.fillActionBars(actionBars);
    if (modes == null) {
      return;
    }
    IToolBarManager manager = actionBars.getToolBarManager();
    IContributionItem group = findGroup(manager, "modes");
    if ((manager != null) && (group != null)) {
      modes.fillToolBar(group.getId(), manager);
    }
    IMenuManager viewMenu = actionBars.getMenuManager();
    group = findGroup(manager, "modes");
    if ((viewMenu != null) && (group != null))
    {
      IContributionItem layoutGroup = findGroup(manager, "layout");
      if (layoutGroup != null) {
        group = layoutGroup;
      }
      MenuManager modesItem = new MenuManager(Utils.getString("action.modes.label", Policy.getActionBundle()));
      viewMenu.appendToGroup(group.getId(), modesItem);
      modes.fillMenu(modesItem);
    }
  }
  
  private boolean isThreeWay()
  {
    return "three-way".equals(AbstractSynchronizePage.access$0(this$0).getComparisonType());
  }
}

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

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
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.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup;
import org.eclipse.team.ui.synchronize.ISynchronizePage;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.part.ShowInContext;

public abstract class AbstractSynchronizePage
  extends Page
  implements ISynchronizePage, IAdaptable
{
  private ISynchronizePageConfiguration configuration;
  private ISynchronizePageSite site;
  private Composite composite;
  private ChangesSection changesSection;
  private Viewer changesViewer;
  private AbstractViewerAdvisor viewerAdvisor;
  
  class ModeFilterActions
    extends SynchronizePageActionGroup
  {
    private DirectionFilterActionGroup modes;
    
    ModeFilterActions() {}
    
    public void initialize(ISynchronizePageConfiguration configuration)
    {
      super.initialize(configuration);
      if (isThreeWay()) {
        modes = new DirectionFilterActionGroup(configuration);
      }
    }
    
    public void fillActionBars(IActionBars actionBars)
    {
      super.fillActionBars(actionBars);
      if (modes == null) {
        return;
      }
      IToolBarManager manager = actionBars.getToolBarManager();
      IContributionItem group = findGroup(manager, "modes");
      if ((manager != null) && (group != null)) {
        modes.fillToolBar(group.getId(), manager);
      }
      IMenuManager viewMenu = actionBars.getMenuManager();
      group = findGroup(manager, "modes");
      if ((viewMenu != null) && (group != null))
      {
        IContributionItem layoutGroup = findGroup(manager, "layout");
        if (layoutGroup != null) {
          group = layoutGroup;
        }
        MenuManager modesItem = new MenuManager(Utils.getString("action.modes.label", Policy.getActionBundle()));
        viewMenu.appendToGroup(group.getId(), modesItem);
        modes.fillMenu(modesItem);
      }
    }
    
    private boolean isThreeWay()
    {
      return "three-way".equals(configuration.getComparisonType());
    }
  }
  
  protected AbstractSynchronizePage(ISynchronizePageConfiguration configuration)
  {
    this.configuration = configuration;
    configuration.setPage(this);
    configuration.addActionContribution(new ModeFilterActions());
  }
  
  public void createControl(Composite parent)
  {
    composite = new Composite(parent, 0);
    
    GridLayout gridLayout = new GridLayout();
    makeColumnsEqualWidth = false;
    marginWidth = 0;
    marginHeight = 0;
    verticalSpacing = 0;
    composite.setLayout(gridLayout);
    GridData data = new GridData(1808);
    grabExcessVerticalSpace = true;
    composite.setLayoutData(data);
    
    changesSection = createChangesSection(composite);
    createChangesViewer(changesSection.getContainer());
    changesSection.setViewer(changesViewer);
  }
  
  protected abstract ChangesSection createChangesSection(Composite paramComposite);
  
  private void createChangesViewer(Composite parent)
  {
    viewerAdvisor = createViewerAdvisor(parent);
    changesViewer = viewerAdvisor.getViewer();
    viewerAdvi
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