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

break;
    case 1: 
      if ((event instanceof CompareInputChangeNotifier.InputChangeEvent))
      {
        CompareInputChangeNotifier.InputChangeEvent changeEvent = (CompareInputChangeNotifier.InputChangeEvent)event;
        ICompareInput[] inputs = changeEvent.getChangedInputs();
        synchronized (changedInputs)
        {
          for (int i = 0; i < inputs.length; i++)
          {
            ICompareInput input = inputs[i];
            changedInputs.add(input);
          }
        }
      }
      break;
    }
  }
  
  private void executeRunnableDuringDispatch(BackgroundEventHandler.Event event)
  {
    synchronized (pendingRunnables)
    {
      pendingRunnables.add(event);
    }
  }
  
  private void executeRunnableNow(BackgroundEventHandler.Event event, IProgressMonitor monitor)
  {
    try
    {
      dispatchEvents(Policy.subMonitorFor(monitor, 1));
    }
    catch (TeamException e)
    {
      handleException(e);
    }
    try
    {
      ((BackgroundEventHandler.RunnableEvent)event).run(Policy.subMonitorFor(monitor, 1));
    }
    catch (CoreException e)
    {
      handleException(e);
    }
  }
  
  protected synchronized void queueEvent(BackgroundEventHandler.Event event)
  {
    super.queueEvent(event, false);
  }
  
  protected long getShortDispatchDelay()
  {
    return 250L;
  }
  
  protected boolean belongsTo(Object family)
  {
    return this$0.belongsTo(family);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier.InputChangeEventHandler
 * 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.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.IResource;
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.IProgressMonitor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.core.BackgroundEventHandler;
import org.eclipse.team.internal.core.BackgroundEventHandler.Event;
import org.eclipse.team.internal.core.BackgroundEventHandler.RunnableEvent;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIMessages;

public abstract class CompareInputChangeNotifier
  implements IResourceChangeListener
{
  private Map inputs = new HashMap();
  private InputChangeEventHandler eventHandler;
  private static final int COMPARE_INPUT_CHANGE = 1;
  
  private class CompareInputConnecton
  {
    private int connections;
    
    CompareInputConnecton(CompareInputConnecton paramCompareInputConnecton)
    {
      this();
    }
    
    public void increment()
    {
      connections += 1;
    }
    
    public void decrement()
    {
      if (connections > 0) {
        connections -= 1;
      }
    }
    
    public boolean isDisconnected()
    {
      return connections == 0;
    }
    
    private CompareInputConnecton() {}
  }
  
  private static class InputChangeEvent
    extends BackgroundEventHandler.Event
  {
    private final ICompareInput[] inputs;
    
    public InputChangeEvent(ICompareInput[] inputs)
    {
      super();
      this.inputs = inputs;
    }
    
    public ICompareInput[] getChangedInputs()
    {
      return inputs;
    }
  }
  
  private class InputChangeEventHandler
    extends BackgroundEventHandler
  {
    private final Set changedInputs = new HashSet();
    private final List pendingRunnables = new ArrayList();
    
    protected InputChangeEventHandler()
    {
      super(TeamUIMessages.CompareInputChangeNotifier_1);
    }
    
    protected boolean doDispatchEvents(IProgressMonitor monitor)
      throws TeamException
    {
      BackgroundEventHandler.RunnableEvent[] events;
      ICompareInput[] toDispatch;
      synchronized (pendingRunnables)
      {
        synchronized (changedInputs)
        {
          if ((changedInputs.isEmpty()) && (pendingRunnables.isEmpty())) {
            return false;
          }
          ICompareInput[] toDispatch = (ICompareInput[])changedInputs.toArray(new ICompareInput[changedInputs.size()]);
          BackgroundEventHandler.RunnableEvent[] events = (BackgroundEventHandler.RunnableEvent[])pendingRunnables.toArray(new BackgroundEventHandler.RunnableEvent[pendingRunnables.size()]);
          changedInputs.clear();
          pendingRunnables.clear();
        }
      }
      BackgroundEventHandler.RunnableEvent[] events;
      ICompareInput[] toDispatch;
      dispatchChanges(toDispatch, monitor);
      for (int i = 0; i < events.length; i++)
      {
        BackgroundEventHandler.RunnableEvent event = events[i];
        executeRunnableNow(event, monitor);
      }
      return true;
    }
    
    protected void processEvent(BackgroundEventHandler.Event event, IProgressMonitor monitor)
      throws CoreException
    {
      int type = event.getType();
      switch (type)
      {
      case 1000: 
        BackgroundEventHandler.RunnableEvent runnableEvent = (BackgroundEventHandler.RunnableEvent)event;
        if (runnableEvent.isPreemtive()) {
          executeRunnableNow(event, monitor);
        } else {
          executeRunnableDuringDispatch(event);
        }
        break;
      case 1: 
        if ((event instanceof CompareInputChangeNotifier.InputChangeEvent))
        {
          CompareInputChangeNotifier.InputChangeEvent changeEvent = (CompareInputChangeNotifier.InputChangeEvent)event;
          ICompareInput[] inputs = changeEvent.getChangedInputs();
          synchronized (changedInputs)
          {
            for (int i = 0; i < inputs.length; i++)
            {
              ICompareInput input = inputs[i];
              changedInputs.add(input);
            }
          }
        }
        break;
      }
    }
    
    private void executeRunnableDuringDispatch(BackgroundEventHandler.Event event)
    {
      synchronized (pendingRunnables)
      {
        pendingRunnables.add(event);
      }
    }
    
    private void executeRunnableNow(BackgroundEventHandler.Event event, IProgressMonitor monitor)
    {
      try
      {
        dispatchEvents(Policy.subMonitorFor(monitor, 1));
      }
      catch (TeamException e)
      {
        handleException(e);
      }
      try
      {
        ((BackgroundEventHandler.RunnableEvent)event).run(Policy.subMonitorFor(monitor, 1));
      }
      catch (CoreException e)
      {
        handleException(e);
      }
    }
    
    protected synchronized void queueEvent(BackgroundEventHandler.Event event)
    {
      super.queueEvent(event, false);
    }
    
    protected long getShortDispatchDelay()
    {
      return 250L;
    }
    
    protected boolean belongsTo(Object family)
    {
      return CompareInputChangeNotifier.this.belongsTo(family);
    }
  }
  
  public void initialize()
  {
    ResourcesPlugin.getWorkspace().addResourceChangeListener(this, 1);
    eventHandler = new InputChangeEventHandler();
  }
  
  public void dispose()
  {
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    if (eventHandler != null) {
      eventHandler.shutdown();
    }
  }
  
  public void connect(ICompareInput input)
  {
    CompareInputConnecton con = (CompareInputConnecton)inputs.get(input);
    if (con == null)
    {
      con = new CompareInputConnecton(null);
      inputs.put(input, con);
    }
    con.increment();
  }
  
  public void disconnect(ICompareInput input)
  {
    CompareInputConnecton con = (CompareInputConnecton)inputs.get(input);
    if (con != null)
    {
      con.decrement();
      if (con.isDisconnected()) {
        inputs.remove(input);
      }
    }
  }
  
  protected ICompareInput[] getConnectedInputs()
  {
    return (ICompareInput[])inputs.keySet().toArray(new ICompareInput[inputs.size()]);
  }
  
  protected void inputsChanged(ICompareInput[] inputs)
  {
    InputChangeEvent event = new InputChangeEvent(inputs);
    eventHandler.queueEvent(event);
  }
  
  protected void dispatchChanges(ICompareInput[] inputs, IProgressMonitor monitor)
  {
    prepareInputs(inputs, monitor);
    Display.getDefault().syncExec(new Runnable()
    {
      private final ICompareInput[] val$inputs;
      
      public void run()
      {
        fireChanges(val$inputs);
      }
    });
  }
  
  protected void prepareInputs(ICompareInput[] inputs, IProgressMonitor monitor)
  {
    monitor.beginTask(null, inputs.length * 100);
    for (int i = 0; i < inputs.length; i++)
    {
      ICompareInput input = inputs[i];
      prepareInput(input, Policy.subMonitorFor(monitor, 100));
    }
    monitor.done();
  }
  
  protected void prepareInput(ICompareInput input, IProgressMonitor monitor) {}
  
  protected void fireChanges(ICompareInput[] inputs)
  {
    for (int i = 0; i < inputs.length; i++)
    {
      ICompareInput input = inputs[i];
      fireChange(input);
    }
  }
  
  protected void runInBackground(IWorkspaceRunnable runnable)
  {
    eventHandler.queueEvent(new BackgroundEventHandler.RunnableEvent(runnable, false));
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    List changedInputs = new ArrayList();
    ICompareInput[] inputs = getConnectedInputs();
    for (int i = 0; i < inputs.length; i++)
    {
      ICompareInput input = inputs[i];
      IResource[] resources = getResources(input);
      for (int j = 0; j < resources.length; j++)
      {
        IResource resource = resources[j];
        if (resource != null)
        {
          IResourceDelta delta = event.getDelta().findMember(resource.getFullPath());
          if ((delta != null) && (
            ((delta.getKind() & 0x3) > 0) || (
            ((delta.getKind() & 0x4) > 0) && 
            ((delta.getFlags() & 0x40100) > 0))))
          {
            changedInputs.add(input);
            break;
          }
        }
      }
    }
    if (!changedInputs.isEmpty()) {
      handleInputChanges((ICompareInput[])changedInputs.toArray(new ICompareInput[changedInputs.size()]), true);
    }
  }
  
  protected abstract IResource[] getResources(ICompareInput paramICompareInput);
  
  protected void handleInputChanges(ICompareInput[] inputs, boolean force)
  {
    ICompareInput[] realChanges;
    ICompareInput[] realChanges;
    if (force)
    {
      realChanges = inputs;
    }
    else
    {
      List result = new ArrayList();
      for (int i = 0; i < inputs.length; i++)
      {
        ICompareInput input = inputs[i];
        if (isChanged(input)) {
          result.add(input);
        }
      }
      realChanges = (ICompareInput[])result.toArray(new ICompareInput[result.size()]);
    }
    if (realChanges.length > 0) {
      inputsChanged(realChanges);
    }
  }
  
  protected boolean isChanged(ICompareInput input)
  {
    if ((input instanceof AbstractCompareInput))
    {
      AbstractCompareInput ci = (AbstractCompareInput)input;
      return ci.needsUpdate();
    }
    return false;
  }
  
  protected void fireChange(ICompareInput input)
  {
    if ((input instanceof AbstractCompareInput))
    {
      AbstractCompareInput ci = (AbstractCompareInput)input;
      ci.update();
    }
  }
  
  protected boolean belongsTo(Object family)
  {
    return false;
  }
}

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

import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.team.core.mapping.ResourceMappingMerger;

public class DefaultResourceMappingMerger
  extends ResourceMappingMerger
{
  private final ModelProvider provider;
  
  public DefaultResourceMappingMerger(ModelProvider provider)
  {
    this.provider = provider;
  }
  
  protected ModelProvider getModelProvider()
  {
    return provider;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.DefaultResourceMappingMerger
 * 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.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class DiffTreeChangesSection$1
  extends JobChangeAdapter
{
  final DiffTreeChangesSection this$0;
  
  DiffTreeChangesSection$1(DiffTreeChangesSection paramDiffTreeChangesSection)
  {
    this$0 = paramDiffTreeChangesSection;
  }
  
  public void running(IJobChangeEvent event)
  {
    if ((isJobOfInterest(event.getJob())) && 
      (DiffTreeChangesSection.access$0(this$0).getDiffTree().isEmpty())) {
      this$0.calculateDescription();
    }
  }
  
  private boolean isJobOfInterest(Job job)
  {
    if (job.belongsTo(DiffTreeChangesSection.access$1(this$0).getParticipant())) {
      return true;
    }
    SubscriberDiffTreeEventHandler handler = DiffTreeChangesSection.access$2(this$0);
    if ((handler != null) && (handler.getEventHandlerJob() == job)) {
      return true;
    }
    return false;
  }
  
  public void done(IJobChangeEvent event)
  {
    if ((isJobOfInterest(event.getJob())) && 
      (DiffTreeChangesSection.access$0(this$0).getDiffTree().isEmpty())) {
      this$0.calculateDescription();
    }
  }
}

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

import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$10
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  
  DiffTreeChangesSection$10(DiffTreeChangesSection paramDiffTreeChangesSection)
  {
    this$0 = paramDiffTreeChangesSection;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    this$0.showErrors();
  }
}

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

import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$11
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  
  DiffTreeChangesSection$11(DiffTreeChangesSection paramDiffTreeChangesSection)
  {
    this$0 = paramDiffTreeChangesSection;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    DiffTreeChangesSection.access$6(this$0, null);
    this$0.calculateDescription();
    SubscriberDiffTreeEventHandler handler = DiffTreeChangesSection.access$2(this$0);
    if (handler != null) {
      handler.initializeIfNeeded();
    } else {
      DiffTreeChangesSection.access$1(this$0).getParticipant().run(DiffTreeChangesSection.access$1(this$0).getSite().getPart());
    }
  }
}

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

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$2
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  private final ITeamContentProviderDescriptor[] val$descriptors;
  
  DiffTreeChangesSection$2(DiffTreeChangesSection paramDiffTreeChangesSection, ITeamContentProviderDescriptor[] paramArrayOfITeamContentProviderDescriptor)
  {
    this$0 = paramDiffTreeChangesSection;val$descriptors = paramArrayOfITeamContentProviderDescriptor;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    ModelSynchronizeParticipant participant = (ModelSynchronizeParticipant)DiffTreeChangesSection.access$1(this$0).getParticipant();
    ModelProvider[] providers = participant.getEnabledModelProviders();
    Set toEnable = new HashSet();
    toEnable.addAll(Arrays.asList(val$descriptors));
    for (int i = 0; i < providers.length; i++)
    {
      ModelProvider provider = providers[i];
      ITeamContentProviderDescriptor desc = TeamUI.getTeamContentProviderManager().getDescriptor(provider.getId());
      if ((desc != null) && (!desc.isEnabled())) {
        toEnable.add(desc);
      }
    }
    TeamUI.getTeamContentProviderManager().setEnabledDescriptors(
      (ITeamContentProviderDescriptor[])toEnable
      .toArray(new ITeamContentProviderDescriptor[toEnable.size()]));
    DiffTreeChangesSection.access$1(this$0).setProperty("org.eclipse.team.ui.activeModelProvider", "org.eclipse.team.ui.activeModelProvider");
  }
}

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

import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$3
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  private final boolean[] val$remember;
  private final PreferenceStore val$store;
  
  DiffTreeChangesSection$3(DiffTreeChangesSection paramDiffTreeChangesSection, boolean[] paramArrayOfBoolean, PreferenceStore paramPreferenceStore)
  {
    this$0 = paramDiffTreeChangesSection;val$remember = paramArrayOfBoolean;val$store = paramPreferenceStore;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    if ((val$remember[0] != 0) && (val$store != null)) {
      val$store.putValue("startupAction", "populate");
    }
    DiffTreeChangesSection.access$2(this$0).initializeIfNeeded();
  }
}

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

import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$4
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  private final boolean[] val$remember;
  private final PreferenceStore val$store;
  
  DiffTreeChangesSection$4(DiffTreeChangesSection paramDiffTreeChangesSection, boolean[] paramArrayOfBoolean, PreferenceStore paramPreferenceStore)
  {
    this$0 = paramDiffTreeChangesSection;val$remember = paramArrayOfBoolean;val$store = paramPreferenceStore;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    if ((val$remember[0] != 0) && (val$store != null)) {
      val$store.putValue("startupAction", "synchronize");
    }
    DiffTreeChangesSection.access$1(this$0).getParticipant().run(DiffTreeChangesSection.access$1(this$0).getSite().getPart());
  }
}

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

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

class DiffTreeChangesSection$5
  implements SelectionListener
{
  final DiffTreeChangesSection this$0;
  private final boolean[] val$remember;
  private final Button val$rememberButton;
  
  DiffTreeChangesSection$5(DiffTreeChangesSection paramDiffTreeChangesSection, boolean[] paramArrayOfBoolean, Button paramButton)
  {
    this$0 = paramDiffTreeChangesSection;val$remember = paramArrayOfBoolean;val$rememberButton = paramButton;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    val$remember[0] = val$rememberButton.getSelection();
  }
  
  public void widgetDefaultSelected(SelectionEvent e) {}
}

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

import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$6
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  private final ModelProvider val$provider;
  
  DiffTreeChangesSection$6(DiffTreeChangesSection paramDiffTreeChangesSection, ModelProvider paramModelProvider)
  {
    this$0 = paramDiffTreeChangesSection;val$provider = paramModelProvider;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    DiffTreeChangesSection.access$1(this$0).setProperty("org.eclipse.team.ui.activeModelProvider", val$provider.getDescriptor().getId());
  }
}

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

import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

class DiffTreeChangesSection$7
  extends HyperlinkAdapter
{
  final DiffTreeChangesSection this$0;
  
  DiffTreeChangesSection$7(DiffTreeChangesSection paramDiffTreeChangesSection)
  {
    this$0 = paramDiffTreeChangesSection;
  }
  
  public void linkActivated(HyperlinkEvent e)
  {
    DiffTreeChangesSection.access$1(this$0).setProperty("org.eclipse.team.ui.activeModelProvider", "org.eclipse.team.ui.activeModelProvider");
  }
}

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

import org.eclipse.ui.part.PageBook;

class DiffTreeChangesSection$8
  implements Runnable
{
  final DiffTreeChangesSection this$0;
  
  DiffTreeChangesSection$8(DiffTreeChangesSection paramDiffTreeChangesSection)
  {
    this$0 = paramDiffTreeChangesSection;
  }
  
  public void run()
  {
    if (!this$0.getContainer().isDisposed()) {
      DiffTreeChangesSection.access$3(this$0, this$0.getEmptyChangesComposite(this$0.getContainer()));
    }
  }
}

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

class DiffTreeChangesSection$9
  implements Runnable
{
  final DiffTreeChangesSection this$0;
  
  DiffTreeChangesSection$9(DiffTreeChangesSection paramDiffTreeChangesSection)
  {
    this$0 = paramDiffTreeChangesSection;
  }
  
  public void run()
  {
    DiffTreeChangesSection.access$3(this$0, DiffTreeChangesSection.access$4(this$0, this$0.getContainer()));
    DiffTreeChangesSection.access$5(this$0, true);
  }
}

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

import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.team.core.mapping.ISynchronizationScope;

public abstract interface DiffTreeChangesSection$ITraversalFactory
{
  public abstract ResourceTraversal[] getTraversals(ISynchronizationScope paramISynchronizationScope);
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.DiffTreeChangesSection.ITraversalFactory
 * 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.List;
import java.util.Set;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiffChangeEvent;
import org.eclipse.team.core.diff.IDiffChangeListener;
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.internal.core.subscribers.SubscriberDiffTreeEventHandler;
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.synchronize.AbstractSynchronizePage;
import org.eclipse.team.internal.ui.synchronize.ForwardingChangesSection;
import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ModelOperation;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
import org.eclipse.ui.forms.HyperlinkGroup;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.part.PageBook;

public class DiffTreeChangesSection
  extends ForwardingChangesSection
  implements IDiffChangeListener, IPropertyChangeListener, IEmptyTreeListener
{
  private ISynchronizationContext context;
  private IStatus[] errors;
  private boolean showingError;
  
  public DiffTreeChangesSection(Composite parent, AbstractSynchronizePage page, ISynchronizePageConfiguration configuration)
  {
    super(parent, page, configuration);
    context = ((ISynchronizationContext)configuration.getProperty("org.eclipse.team.ui.synchronizationContext"));
    context.getDiffTree().addDiffChangeListener(this);
    getConfiguration().addPropertyChangeListener(this);
    Job.getJobManager().addJobChangeListener(new JobChangeAdapter()
    {
      public void running(IJobChangeEvent event)
      {
        if ((isJobOfInterest(event.getJob())) && 
          (context.getDiffTree().isEmpty())) {
          calculateDescription();
        }
      }
      
      private boolean isJobOfInterest(Job job)
      {
        if (job.belongsTo(getConfiguration().getParticipant())) {
          return true;
        }
        SubscriberDiffTreeEventHandler handler = DiffTreeChangesSection.this.getHandler();
        if ((handler != null) && (handler.getEventHandlerJob() == job)) {
          return true;
        }
        return false;
      }
      
      public void done(IJobChangeEvent event)
      {
        if ((isJobOfInterest(event.getJob())) && 
          (context.getDiffTree().isEmpty())) {
          calculateDescription();
        }
      }
    });
  }
  
  public void dispose()
  {
    context.getDiffTree().removeDiffChangeListener(this);
    getConfiguration().removePropertyChangeListener(this);
    super.dispose();
  }
  
  protected int getChangesCount()
  {
    return context.getDiffTree().size();
  }
  
  protected long getChangesInMode(int candidateMode)
  {
    long numConflicts = context.getDiffTree().countFor(768, 768);
    long numChanges;
    long numChanges;
    long numChanges;
    long numChanges;
    long numChanges;
    switch (candidateMode)
    {
    case 8: 
      numChanges = numConflicts;
      break;
    case 2: 
      numChanges = numConflicts + context.getDiffTree().countFor(256, 768);
      break;
    case 1: 
      numChanges = numConflicts + context.getDiffTree().countFor(512, 768);
      break;
    case 4: 
      numChanges = numConflicts + context.getDiffTree().countFor(512, 768) + 
        context.getDiffTree().countFor(256, 768);
      break;
    case 3: 
    case 5: 
    case 6: 
    case 7: 
    default: 
      numChanges = 0L;
    }
    return numChanges;
  }
  
  protected boolean hasChangesInMode(String id, ISynchronizationCompareAdapter adapter, int candidateMode)
  {
    switch (candidateMode)
    {
    case 8: 
      return hasChangesFor(id, adapter, context, new int[] { 768 }, 768);
    case 2: 
      return hasChangesFor(id, adapter, context, new int[] { 768, 256 }, 768);
    case 1: 
      return hasChangesFor(id, adapter, context, new int[] { 768, 512 }, 768);
    case 4: 
      return hasChangesFor(id, adapter, context, new int[] { 768, 512, 256 }, 768);
    }
    return false;
  }
  
  private boolean hasChangesFor(String id, ISynchronizationCompareAdapter adapter, ISynchronizationContext context, int[] states, int mask)
  {
    ITraversalFactory factory = (ITraversalFactory)Utils.getAdapter(adapter, ITraversalFactory.class);
    ResourceTraversal[] traversals;
    ResourceTraversal[] traversals;
    if (factory == null) {
      traversals = context.getScope().getTraversals(id);
    } else {
      traversals = factory.getTraversals(context.getScope());
    }
    return context.getDiffTree().hasMatchingDiffs(traversals, FastDiffFilter.getStateFilter(states, mask));
  }
  
  protected long getVisibleChangesCount()
  {
    ISynchronizePageConfiguration configuration = getConfiguration();
    if (configuration.getComparisonType() == "two-way") {
      return context.getDiffTree().size();
    }
    int currentMode = configuration.getMode();
    String id = (String)configuration.getProperty("org.eclipse.team.ui.activeModelProvider");
    if ((id != null) && (!id.equals("org.eclipse.team.ui.activeModelProvider"))) {
      try
      {
        IModelProviderDescriptor desc = ModelProvider.getModelProviderDescriptor(id);
        ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(desc.getModelProvider());
        if (adapter != null) {
          return hasChangesInMode(desc.getId(), adapter, getConfiguration().getMode()) ? -1 : 0;
        }
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
        
        return isViewerEmpty() ? 0 : -1;
      }
    }
    return getChangesInMode(currentMode);
  }
  
  protected int getCandidateMode()
  {
    SynchronizePageConfiguration configuration = (SynchronizePageConfiguration)getConfiguration();
    long outgoingChanges = context.getDiffTree().countFor(256, 768);
    if (outgoingChanges > 0L)
    {
      if (configuration.isModeSupported(2)) {
        return 2;
      }
      if (configuration.isModeSupported(4)) {
        return 4;
      }
    }
    long incomingChanges = context.getDiffTree().countFor(512, 768);
    if (incomingChanges > 0L)
    {
      if (configuration.isModeSupported(1)) {
        return 1;
      }
      if (configuration.isModeSupported(4)) {
        return 4;
      }
    }
    return configuration.getMode();
  }
  
  public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor)
  {
    IStatus[] errors = event.getErrors();
    if (errors.length > 0) {
      this.errors = errors;
    }
    calculateDescription();
  }
  
  public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if ((event.getProperty().equals("org.eclipse.team.ui.P_SYNCVIEWPAGE_MODE")) || 
      (event.getProperty().equals("org.eclipse.team.ui.activeModelProvider"))) {
      calculateDescription();
    }
  }
  
  protected Composite getEmptyChangesComposite(Composite parent)
  {
    if (context.getDiffTree().isEmpty())
    {
      SubscriberDiffTreeEventHandler handler = getHandler();
      if ((handler != null) && (handler.getState() == 1)) {
        return getInitializationPane(parent);
      }
      if ((isRefreshRunning()) || ((handler != null) && (handler.getEventHandlerJob().getState() != 0))) {
        return getInitializingMessagePane(parent);
      }
    }
    else
    {
      ISynchronizePageConfiguration configuration = getConfiguration();
      String id = (String)configuration.getProperty("org.eclipse.team.ui.activeModelProvider");
      if (id == null) {
        id = "org.eclipse.team.ui.activeModelProvider";
      }
      if (id.equals("org.eclipse.team.ui.activeModelProvider"))
      {
        if ((getChangesInMode(getConfiguration().getMode()) > 0L) && (isAtLeastOneProviderDisabled())) {
          return createEnableParticipantModelProvidersPane(parent);
        }
      }
      else
      {
        ModelProvider[] providers = findModelsWithChangesInMode(getConfiguration().getMode());
        ModelProvider currentProvider = null;
        for (int i = 0; i < providers.length; i++)
        {
          ModelProvider provider = providers[i];
          if (isEnabled(provider)) {
            if (provider.getDescriptor().getId().equals(id)) {
              currentProvider = provider;
            } else {
              return getPointerToModel(parent, provider, id);
            }
          }
        }
        if ((currentProvider != null) || (providers.length > 0)) {
          return createEnableParticipantModelProvidersPane(parent);
        }
      }
    }
    return super.getEmptyChangesComposite(parent);
  }
  
  private boolean isAtLeastOneProviderDisabled()
  {
    ModelProvider[] providers = findModelsWithChangesInMode(getConfiguration().getMode());
    for (int i = 0; i < providers.length; i++)
    {
      ModelProvider provider = providers[i];
      if (!isEnabled(provider)) {
        return true;
      }
    }
    return false;
  }
  
  private ModelProvider[] findModelsWithChangesInMode(int mode)
  {
    ModelProvider[] providers = context.getScope().getModelProviders();
    providers = ModelOperation.sortByExtension(providers);
    List result = new ArrayList();
    for (int i = 0; i < providers.length; i++)
    {
      ModelProvider provider = providers[i];
      ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(provider);
      if (adapter != null)
      {
        boolean hasChanges = hasChangesInMode(provider.getId(), adapter, getConfiguration().getMode());
        if (hasChanges) {
          result.add(provider);
        }
      }
    }
    return (ModelProvider[])result.toArray(new ModelProvider[result.size()]);
  }
  
  private boolean isEnabled(ModelProvider provider)
  {
    ITeamContentProviderDescriptor desc = TeamUI.getTeamContentProviderManager().getDescriptor(provider.getId());
    return (desc != null) && (desc.isEnabled());
  }
  
  private Composite createEnableParticipantModelProvidersPane(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setBackground(getListBackgroundColor());
    GridLayout layout = new GridLayout();
    numColumns = 2;
    composite.setLayout(layout);
    GridData data = new GridData(1808);
    grabExcessVerticalSpace = true;
    composite.setLayoutData(data);
    
    int changesCount = getChangesCount();
    String message;
    String message;
    if (changesCount == 1) {
      message = TeamUIMessages.DiffTreeChangesSection_8;
    } else {
      message = NLS.bind(TeamUIMessages.DiffTreeChangesSection_9, new Integer(changesCount));
    }
    ITeamContentProviderDescriptor[] descriptors = getEnabledContentDescriptors();
    if (descriptors.length == 0) {
      message = NLS.bind(TeamUIMessages.DiffTreeChangesSection_10, message);
    } else {
      message = NLS.bind(TeamUIMessages.DiffTreeChangesSection_11, message);
    }
    createDescriptionLabel(composite, message);
    
    Label warning = new Label(composite, 0);
    warning.setImage(TeamUIPlugin.getPlugin().getImage("ovr/warning_co.gif"));
    
    Hyperlink link = getForms().createHyperlink(composite, TeamUIMessages.DiffTreeChangesSection_12, 64);
    link.addHyperlinkListener(new HyperlinkAdapter()
    {
      private final ITeamContentProviderDescriptor[] val$descriptors;
      
      public void linkActivated(HyperlinkEvent e)
      {
        ModelSynchronizeParticipant participant = (ModelSynchronizeParticipant)getConfiguration().getParticipant();
        ModelProvider[] providers = participant.getEnabledModelProviders();
        Set toEnable = new HashSet();
        toEnable.addAll(Arrays.asList(val$descriptors));
        for (int i = 0; i < providers.length; i++)
        {
          ModelProvider provider = providers[i];
          ITeamContentProviderDescriptor desc = TeamUI.getTeamContentProviderManager().getDescriptor(provider.getId());
          if ((desc != null) && (!desc.isEnabled())) {
            toEnable.add(desc);
          }
        }
        TeamUI.getTeamContentProviderManager().setEnabledDescriptors(
          (ITeamContentProviderDescriptor[])toEnable
          .toArray(new ITeamContentProviderDescriptor[toEnable.size()]));
        getConfiguration().setProperty("org.eclipse.team.ui.activeModelProvider", "org.eclipse.team.ui.activeModelProvider");
      }
    });
    getForms().getHyperlinkGroup().add(link);
    
    return composite;
  }
  
  private ITeamContentProviderDescriptor[] getEnabledCon
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