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

hronize.LocalResourceSaveableComparison;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.ui.ISaveablesLifecycleListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.Saveable;
import org.eclipse.ui.SaveablesLifecycleEvent;

class SaveableCompareEditorInput$InternalResourceSaveableComparison
  extends LocalResourceSaveableComparison
  implements EditableSharedDocumentAdapter.ISharedDocumentAdapterListener
{
  private LocalResourceTypedElement lrte;
  private boolean connected;
  final SaveableCompareEditorInput this$0;
  
  public SaveableCompareEditorInput$InternalResourceSaveableComparison(SaveableCompareEditorInput arg1, ICompareInput input, CompareEditorInput editorInput)
  {
    super(input, editorInput, SaveableCompareEditorInput.access$0(input, editorInput));this$0 = ???;connected = false;
    ITypedElement element = SaveableCompareEditorInput.access$0(input, editorInput);
    if ((element instanceof LocalResourceTypedElement))
    {
      lrte = ((LocalResourceTypedElement)element);
      if (lrte.isConnected()) {
        registerSaveable(true);
      } else {
        lrte.setSharedDocumentListener(this);
      }
    }
  }
  
  protected void fireInputChange()
  {
    this$0.fireInputChange();
  }
  
  public void dispose()
  {
    super.dispose();
    if (lrte != null) {
      lrte.setSharedDocumentListener(null);
    }
  }
  
  public void handleDocumentConnected()
  {
    if (connected) {
      return;
    }
    connected = true;
    registerSaveable(false);
    if (lrte != null) {
      lrte.setSharedDocumentListener(null);
    }
  }
  
  private void registerSaveable(boolean init)
  {
    ICompareContainer container = this$0.getContainer();
    IWorkbenchPart part = container.getWorkbenchPart();
    if (part != null)
    {
      ISaveablesLifecycleListener lifecycleListener = SaveableCompareEditorInput.access$1(this$0, part);
      if (!init) {
        lifecycleListener.handleLifecycleEvent(
          new SaveablesLifecycleEvent(part, 3, new Saveable[] { this }, false));
      }
      initializeHashing();
      
      lifecycleListener.handleLifecycleEvent(
        new SaveablesLifecycleEvent(part, 1, new Saveable[] { this }, false));
    }
  }
  
  public void handleDocumentDeleted() {}
  
  public void handleDocumentDisconnected() {}
  
  public void handleDocumentFlushed() {}
  
  public void handleDocumentSaved() {}
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.ICompareContainer;
import org.eclipse.compare.IPropertyChangeNotifier;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
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.history.CompareFileRevisionEditorInput;
import org.eclipse.team.internal.ui.synchronize.EditableSharedDocumentAdapter.ISharedDocumentAdapterListener;
import org.eclipse.team.internal.ui.synchronize.LocalResourceSaveableComparison;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput;
import org.eclipse.team.ui.mapping.SaveableComparison;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.ISaveablesLifecycleListener;
import org.eclipse.ui.ISaveablesSource;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.Saveable;
import org.eclipse.ui.SaveablesLifecycleEvent;
import org.eclipse.ui.services.IDisposable;

public abstract class SaveableCompareEditorInput
  extends CompareEditorInput
  implements ISaveablesSource
{
  private ICompareInputChangeListener compareInputChangeListener;
  private final IWorkbenchPage page;
  private final ListenerList inputChangeListeners = new ListenerList(1);
  private Saveable saveable;
  private IPropertyListener propertyListener;
  
  public static ITypedElement createFileElement(IFile file)
  {
    return new LocalResourceTypedElement(file);
  }
  
  private static ITypedElement getFileElement(ICompareInput input, CompareEditorInput editorInput)
  {
    if ((input.getLeft() instanceof LocalResourceTypedElement)) {
      return input.getLeft();
    }
    if ((editorInput instanceof CompareFileRevisionEditorInput)) {
      return ((CompareFileRevisionEditorInput)editorInput).getLocalElement();
    }
    return null;
  }
  
  private class InternalResourceSaveableComparison
    extends LocalResourceSaveableComparison
    implements EditableSharedDocumentAdapter.ISharedDocumentAdapterListener
  {
    private LocalResourceTypedElement lrte;
    private boolean connected = false;
    
    public InternalResourceSaveableComparison(ICompareInput input, CompareEditorInput editorInput)
    {
      super(editorInput, SaveableCompareEditorInput.getFileElement(input, editorInput));
      ITypedElement element = SaveableCompareEditorInput.getFileElement(input, editorInput);
      if ((element instanceof LocalResourceTypedElement))
      {
        lrte = ((LocalResourceTypedElement)element);
        if (lrte.isConnected()) {
          registerSaveable(true);
        } else {
          lrte.setSharedDocumentListener(this);
        }
      }
    }
    
    protected void fireInputChange()
    {
      SaveableCompareEditorInput.this.fireInputChange();
    }
    
    public void dispose()
    {
      super.dispose();
      if (lrte != null) {
        lrte.setSharedDocumentListener(null);
      }
    }
    
    public void handleDocumentConnected()
    {
      if (connected) {
        return;
      }
      connected = true;
      registerSaveable(false);
      if (lrte != null) {
        lrte.setSharedDocumentListener(null);
      }
    }
    
    private void registerSaveable(boolean init)
    {
      ICompareContainer container = getContainer();
      IWorkbenchPart part = container.getWorkbenchPart();
      if (part != null)
      {
        ISaveablesLifecycleListener lifecycleListener = SaveableCompareEditorInput.this.getSaveablesLifecycleListener(part);
        if (!init) {
          lifecycleListener.handleLifecycleEvent(
            new SaveablesLifecycleEvent(part, 3, new Saveable[] { this }, false));
        }
        initializeHashing();
        
        lifecycleListener.handleLifecycleEvent(
          new SaveablesLifecycleEvent(part, 1, new Saveable[] { this }, false));
      }
    }
    
    public void handleDocumentDeleted() {}
    
    public void handleDocumentDisconnected() {}
    
    public void handleDocumentFlushed() {}
    
    public void handleDocumentSaved() {}
  }
  
  public SaveableCompareEditorInput(CompareConfiguration configuration, IWorkbenchPage page)
  {
    super(configuration);
    this.page = page;
  }
  
  protected void contentsCreated()
  {
    super.contentsCreated();
    compareInputChangeListener = new ICompareInputChangeListener()
    {
      public void compareInputChanged(ICompareInput source)
      {
        if (source == getCompareResult())
        {
          boolean closed = false;
          if (source.getKind() == 0) {
            closed = closeEditor(true);
          }
          if (!closed) {
            propogateInputChange();
          }
        }
      }
    };
    getCompareInput().addCompareInputChangeListener(compareInputChangeListener);
    if ((getSaveable() instanceof SaveableComparison))
    {
      SaveableComparison scm = (SaveableComparison)saveable;
      propertyListener = new IPropertyListener()
      {
        public void propertyChanged(Object source, int propId)
        {
          if (propId == 257) {
            setDirty(saveable.isDirty());
          }
        }
      };
      scm.addPropertyListener(propertyListener);
    }
    setDirty(saveable.isDirty());
  }
  
  private ISaveablesLifecycleListener getSaveablesLifecycleListener(IWorkbenchPart part)
  {
    ISaveablesLifecycleListener listener = (ISaveablesLifecycleListener)Utils.getAdapter(part, ISaveablesLifecycleListener.class);
    if (listener == null) {
      listener = (ISaveablesLifecycleListener)part.getSite().getService(ISaveablesLifecycleListener.class);
    }
    return listener;
  }
  
  protected void handleDispose()
  {
    super.handleDispose();
    ICompareInput compareInput = getCompareInput();
    if (compareInput != null) {
      compareInput.removeCompareInputChangeListener(compareInputChangeListener);
    }
    compareInputChangeListener = null;
    if (((saveable instanceof SaveableComparison)) && (propertyListener != null))
    {
      SaveableComparison scm = (SaveableComparison)saveable;
      scm.removePropertyListener(propertyListener);
      propertyListener = null;
    }
    if ((saveable instanceof LocalResourceSaveableComparison))
    {
      LocalResourceSaveableComparison rsc = (LocalResourceSaveableComparison)saveable;
      rsc.dispose();
    }
    if ((getCompareResult() instanceof IDisposable)) {
      ((IDisposable)getCompareResult()).dispose();
    }
  }
  
  protected Object prepareInput(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    ICompareInput input = prepareCompareInput(monitor);
    if (input != null) {
      setTitle(NLS.bind(TeamUIMessages.SyncInfoCompareInput_title, new String[] { input.getName() }));
    }
    return input;
  }
  
  protected abstract ICompareInput prepareCompareInput(IProgressMonitor paramIProgressMonitor)
    throws InvocationTargetException, InterruptedException;
  
  protected final ICompareInput getCompareInput()
  {
    return (ICompareInput)getCompareResult();
  }
  
  protected abstract void fireInputChange();
  
  protected boolean closeEditor(boolean checkForUnsavedChanges)
  {
    if ((isSaveNeeded()) && (checkForUnsavedChanges)) {
      return false;
    }
    IWorkbenchPage page = getPage();
    if (page == null) {
      return false;
    }
    Runnable runnable = new Runnable()
    {
      private final IWorkbenchPage val$page;
      
      public void run()
      {
        Shell shell = val$page.getWorkbenchWindow().getShell();
        if (shell == null) {
          return;
        }
        IEditorPart part = val$page.findEditor(SaveableCompareEditorInput.this);
        SaveableCompareEditorInput.this.getPage().closeEditor(part, false);
      }
    };
    if (Display.getCurrent() != null)
    {
      runnable.run();
    }
    else
    {
      Shell shell = page.getWorkbenchWindow().getShell();
      if (shell == null) {
        return false;
      }
      Display display = shell.getDisplay();
      display.asyncExec(runnable);
    }
    return true;
  }
  
  private IWorkbenchPage getPage()
  {
    if (page == null) {
      return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    }
    return page;
  }
  
  void propogateInputChange()
  {
    if (!inputChangeListeners.isEmpty())
    {
      Object[] allListeners = inputChangeListeners.getListeners();
      for (int i = 0; i < allListeners.length; i++)
      {
        ICompareInputChangeListener listener = (ICompareInputChangeListener)allListeners[i];
        SafeRunner.run(new ISafeRunnable()
        {
          private final ICompareInputChangeListener val$listener;
          
          public void run()
            throws Exception
          {
            val$listener.compareInputChanged((ICompareInput)getCompareResult());
          }
          
          public void handleException(Throwable exception) {}
        });
      }
    }
  }
  
  protected Saveable getSaveable()
  {
    if (saveable == null) {
      saveable = createSaveable();
    }
    return saveable;
  }
  
  protected Saveable createSaveable()
  {
    Object compareResult = getCompareResult();
    Assert.isNotNull(compareResult, "This method cannot be called until after prepareInput is called");
    return new InternalResourceSaveableComparison((ICompareInput)compareResult, this);
  }
  
  public Saveable[] getActiveSaveables()
  {
    if (getCompareResult() == null) {
      return new Saveable[0];
    }
    return new Saveable[] { getSaveable() };
  }
  
  public Saveable[] getSaveables()
  {
    return getActiveSaveables();
  }
  
  public void addCompareInputChangeListener(ICompareInput input, ICompareInputChangeListener listener)
  {
    if (input == getCompareResult()) {
      inputChangeListeners.add(listener);
    } else {
      super.addCompareInputChangeListener(input, listener);
    }
  }
  
  public void removeCompareInputChangeListener(ICompareInput input, ICompareInputChangeListener listener)
  {
    if (input == getCompareResult()) {
      inputChangeListeners.remove(listener);
    } else {
      super.removeCompareInputChangeListener(input, listener);
    }
  }
  
  public Object getAdapter(Class adapter)
  {
    if (IFile.class.equals(adapter))
    {
      IResource resource = Utils.getResource(getCompareResult());
      if ((resource instanceof IFile)) {
        return resource;
      }
    }
    return super.getAdapter(adapter);
  }
  
  public Image getTitleImage()
  {
    ImageRegistry reg = TeamUIPlugin.getPlugin().getImageRegistry();
    Image image = reg.get("eview16/synch_synch.gif");
    if (image == null)
    {
      image = getImageDescriptor().createImage();
      reg.put("eview16/synch_synch.gif", image);
    }
    return image;
  }
  
  public ImageDescriptor getImageDescriptor()
  {
    return TeamUIPlugin.getImageDescriptor("eview16/synch_synch.gif");
  }
  
  public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent)
  {
    Viewer newViewer = super.findContentViewer(oldViewer, input, parent);
    boolean isNewViewer = newViewer != oldViewer;
    if ((isNewViewer) && ((newViewer instanceof IPropertyChangeNotifier)) && ((saveable instanceof IPropertyChangeListener)))
    {
      IPropertyChangeNotifier dsp = (IPropertyChangeNotifier)newViewer;
      IPropertyChangeListener pcl = (IPropertyChangeListener)saveable;
      dsp.addPropertyChangeListener(pcl);
      Control c = newViewer.getControl();
      c.addDisposeListener(
        new DisposeListener()
        {
          private final IPropertyChangeNotifier val$dsp;
          private final IPropertyChangeListener val$pcl;
          
          public void widgetDisposed(DisposeEvent e)
          {
            val$dsp.removePropertyChangeListener(val$pcl);
          }
        });
    }
    return newViewer;
  }
  
  public boolean canRunAsJob()
  {
    return true;
  }
  
  public boolean isDirty()
  {
    if (saveable != null) {
      return saveable.isDirty();
    }
    return super.isDirty();
  }
  
  public void registerContextMenu(MenuManager menu, ISelectionProvider selectionProvider)
  {
    super.registerContextMenu(menu, selectionProvider);
    Saveable saveable = getSaveable();
    if ((saveable instanceof LocalResourceSaveableComparison))
    {
      ITypedElement element = getFileElement(getCompareInput(), this);
      menu.addMenuListener(new IMenuListener()
      {
        private final Saveable val$saveable;
        private final ITypedElement val$element;
        private final ISelectionProvider val$selectionProvider;
        
        public void menuAboutToShow(IMenuManager manager)
        {
          SaveablesCompareEditorInput.handleMenuAboutToShow(manager, getContainer(), val$saveable, val$element, val$selectionProvider);
        }
      });
    }
  }
}

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

import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.synchronize.IRefreshable;
import org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob;
import org.eclipse.team.internal.ui.synchronize.RefreshSubscriberParticipantJob;
import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicy;
import org.eclipse.team.internal.ui.synchronize.SubscriberRefreshSchedule;

class SubscriberParticipant$1
  implements IRefreshable
{
  final SubscriberParticipant this$0;
  
  SubscriberParticipant$1(SubscriberParticipant paramSubscriberParticipant)
  {
    this$0 = paramSubscriberParticipant;
  }
  
  public RefreshParticipantJob createJob(String interval)
  {
    return new RefreshSubscriberParticipantJob(this$0, 
      TeamUIMessages.RefreshSchedule_14, 
      NLS.bind(TeamUIMessages.RefreshSchedule_15, new String[] { this$0.getName(), interval }), this$0.getResources(), 
      new RefreshUserNotificationPolicy(this$0));
  }
  
  public ISynchronizeParticipant getParticipant()
  {
    return this$0;
  }
  
  public void setRefreshSchedule(SubscriberRefreshSchedule schedule)
  {
    this$0.setRefreshSchedule(schedule);
  }
  
  public SubscriberRefreshSchedule getRefreshSchedule()
  {
    return this$0.getRefreshSchedule();
  }
}

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

import java.util.Arrays;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.synchronize.SyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfoTree;
import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector;
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.IRefreshSubscriberListener;
import org.eclipse.team.internal.ui.synchronize.IRefreshable;
import org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob;
import org.eclipse.team.internal.ui.synchronize.RefreshSubscriberParticipantJob;
import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicy;
import org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicyInModalDialog;
import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage;
import org.eclipse.team.internal.ui.synchronize.SubscriberRefreshSchedule;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.progress.IProgressConstants2;

public abstract class SubscriberParticipant
  extends AbstractSynchronizeParticipant
  implements IPropertyChangeListener
{
  private SubscriberSyncInfoCollector collector;
  private SubscriberRefreshSchedule refreshSchedule;
  private ISynchronizeScope scope;
  private static final String CTX_SUBSCRIBER_PARTICIPANT_SETTINGS = "org.eclipse.team.ui.TEAMSUBSRCIBERSETTINGS";
  private static final String CTX_SUBSCRIBER_SCHEDULE_SETTINGS = "org.eclipse.team.ui.TEAMSUBSRCIBER_REFRESHSCHEDULE";
  
  public SubscriberParticipant()
  {
    refreshSchedule = new SubscriberRefreshSchedule(createRefreshable());
  }
  
  private IRefreshable createRefreshable()
  {
    new IRefreshable()
    {
      public RefreshParticipantJob createJob(String interval)
      {
        return new RefreshSubscriberParticipantJob(SubscriberParticipant.this, 
          TeamUIMessages.RefreshSchedule_14, 
          NLS.bind(TeamUIMessages.RefreshSchedule_15, new String[] { getName(), interval }), getResources(), 
          new RefreshUserNotificationPolicy(SubscriberParticipant.this));
      }
      
      public ISynchronizeParticipant getParticipant()
      {
        return SubscriberParticipant.this;
      }
      
      public void setRefreshSchedule(SubscriberRefreshSchedule schedule)
      {
        SubscriberParticipant.this.setRefreshSchedule(schedule);
      }
      
      public SubscriberRefreshSchedule getRefreshSchedule()
      {
        return SubscriberParticipant.this.getRefreshSchedule();
      }
    };
  }
  
  public SubscriberParticipant(ISynchronizeScope scope)
  {
    this();
    this.scope = scope;
    scope.addPropertyChangeListener(this);
  }
  
  public final IPageBookViewPage createPage(ISynchronizePageConfiguration configuration)
  {
    validateConfiguration(configuration);
    return new SubscriberParticipantPage(configuration, getSubscriberSyncInfoCollector());
  }
  
  public IResource[] getResources()
  {
    return collector.getRoots();
  }
  
  private void setResources(IResource[] roots)
  {
    collector.setRoots(roots);
  }
  
  public final void refreshInDialog(Shell shell, IResource[] resources, String jobName, String taskName, ISynchronizePageConfiguration configuration, IWorkbenchSite site)
  {
    IRefreshSubscriberListener listener = new RefreshUserNotificationPolicyInModalDialog(shell, taskName, configuration, this);
    internalRefresh(resources, jobName, taskName, site, listener);
  }
  
  public final void refresh(IResource[] resources, String shortTaskName, String longTaskName, IWorkbenchSite site)
  {
    IRefreshSubscriberListener listener = new RefreshUserNotificationPolicy(this);
    internalRefresh(resources, shortTaskName, longTaskName, site, listener);
  }
  
  public final IStatus refreshNow(IResource[] resources, String taskName, IProgressMonitor monitor)
  {
    Job.getJobManager().cancel(this);
    RefreshParticipantJob job = new RefreshSubscriberParticipantJob(this, taskName, taskName, resources, null);
    return job.run(monitor);
  }
  
  public void dispose()
  {
    Job.getJobManager().cancel(this);
    refreshSchedule.dispose();
    TeamUI.removePropertyChangeListener(this);
    collector.dispose();
    scope.dispose();
  }
  
  public String getName()
  {
    String name = super.getName();
    return NLS.bind(TeamUIMessages.SubscriberParticipant_namePattern, new String[] { name, scope.getName() });
  }
  
  protected final String getShortName()
  {
    return super.getName();
  }
  
  public SyncInfoTree getSyncInfoSet()
  {
    return getSubscriberSyncInfoCollector().getSyncInfoSet();
  }
  
  public Subscriber getSubscriber()
  {
    if (collector == null) {
      return null;
    }
    return collector.getSubscriber();
  }
  
  public static SubscriberParticipant getMatchingParticipant(String ID, IResource[] resources)
  {
    ISynchronizeParticipantReference[] refs = TeamUI.getSynchronizeManager().getSynchronizeParticipants();
    for (int i = 0; i < refs.length; i++)
    {
      ISynchronizeParticipantReference reference = refs[i];
      if (reference.getId().equals(ID))
      {
        try
        {
          p = (SubscriberParticipant)reference.getParticipant();
        }
        catch (TeamException localTeamException)
        {
          SubscriberParticipant p;
          continue;
        }
        SubscriberParticipant p;
        IResource[] roots = p.getResources();
        Arrays.sort(resources, Utils.resourceComparator);
        Arrays.sort(roots, Utils.resourceComparator);
        if (Arrays.equals(resources, roots)) {
          return p;
        }
      }
    }
    return null;
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("org.eclipse.team.uiglobal_ignores_changed")) {
      collector.reset();
    }
    if (event.getProperty().equals("prop_roots")) {
      setResources(scope.getRoots());
    }
    if (event.getProperty().equals("prop_name")) {
      firePropertyChange(this, "org.eclipse.jface.text", null, getName());
    }
  }
  
  public void init(String secondaryId, IMemento memento)
    throws PartInitException
  {
    super.init(secondaryId, memento);
    if (memento != null)
    {
      IMemento settings = memento.getChild("org.eclipse.team.ui.TEAMSUBSRCIBERSETTINGS");
      if (settings != null)
      {
        SubscriberRefreshSchedule schedule = SubscriberRefreshSchedule.init(settings.getChild("org.eclipse.team.ui.TEAMSUBSRCIBER_REFRESHSCHEDULE"), createRefreshable());
        setRefreshSchedule(schedule);
        scope = AbstractSynchronizeScope.createScope(settings);
        scope.addPropertyChangeListener(this);
      }
    }
  }
  
  public void saveState(IMemento memento)
  {
    super.saveState(memento);
    IMemento settings = memento.createChild("org.eclipse.team.ui.TEAMSUBSRCIBERSETTINGS");
    refreshSchedule.saveState(settings.createChild("org.eclipse.team.ui.TEAMSUBSRCIBER_REFRESHSCHEDULE"));
    AbstractSynchronizeScope.saveScope(scope, settings);
  }
  
  public void reset()
  {
    getSubscriberSyncInfoCollector().reset();
  }
  
  public SubscriberSyncInfoCollector getSubscriberSyncInfoCollector()
  {
    return collector;
  }
  
  public void setRefreshSchedule(SubscriberRefreshSchedule schedule)
  {
    if (refreshSchedule != schedule)
    {
      if (refreshSchedule != null) {
        refreshSchedule.dispose();
      }
      refreshSchedule = schedule;
    }
    firePropertyChange(this, "org.eclipse.team.schedule", schedule, schedule);
  }
  
  public SubscriberRefreshSchedule getRefreshSchedule()
  {
    return refreshSchedule;
  }
  
  protected void initializeConfiguration(ISynchronizePageConfiguration configuration)
  {
    configuration.setProperty("org.eclipse.team.ui.P_PARTICIPANT_SYNC_INFO_SET", collector.getSyncInfoSet());
  }
  
  public void run(IWorkbenchPart part)
  {
    refresh(getResources(), null, null, part != null ? part.getSite() : null);
  }
  
  protected String getShortTaskName()
  {
    return TeamUIMessages.Participant_synchronizing;
  }
  
  /**
   * @deprecated
   */
  protected String getLongTaskName()
  {
    return TeamUIMessages.Participant_synchronizing;
  }
  
  protected String getLongTaskName(IResource[] resources)
  {
    int resourceCount = 0;
    if (getResources().length == resources.length)
    {
      ISynchronizeScope scope = getScope();
      if ((scope instanceof ResourceScope)) {
        resourceCount = scope.getRoots().length;
      }
    }
    else
    {
      resourceCount = resources.length;
    }
    if (resourceCount == 1) {
      return NLS.bind(TeamUIMessages.Participant_synchronizingMoreDetails, new String[] { getShortName(), resources[0].getFullPath().toString() });
    }
    if (resourceCount > 1) {
      return NLS.bind(TeamUIMessages.Participant_synchronizingResources, new String[] { getShortName(), Integer.toString(resourceCount) });
    }
    return NLS.bind(TeamUIMessages.Participant_synchronizingDetails, new String[] { getName() });
  }
  
  protected void validateConfiguration(ISynchronizePageConfiguration configuration) {}
  
  protected void setSubscriber(Subscriber subscriber)
  {
    if (scope == null) {
      scope = new WorkspaceScope();
    }
    collector = new SubscriberSyncInfoCollector(subscriber, scope.getRoots());
    
    TeamUI.addPropertyChangeListener(this);
    
    collector.start();
    
    SubscriberRefreshSchedule schedule = getRefreshSchedule();
    if (schedule.isEnabled()) {
      getRefreshSchedule().startJob();
    }
  }
  
  protected void setSyncInfoFilter(SyncInfoFilter filter)
  {
    collector.setFilter(filter);
  }
  
  private void internalRefresh(IResource[] resources, String jobName, String taskName, IWorkbenchSite site, IRefreshSubscriberListener listener)
  {
    if (jobName == null) {
      jobName = getShortTaskName();
    }
    if (taskName == null) {
      taskName = getLongTaskName(resources);
    }
    Job.getJobManager().cancel(this);
    RefreshParticipantJob job = new RefreshSubscriberParticipantJob(this, jobName, taskName, resources, listener);
    job.setUser(true);
    job.setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
    Utils.schedule(job, site);
    
    TeamUIPlugin.getPlugin().getPreferenceStore().setValue("org.eclipse.team.ui.sychronizing_default_participant", getId());
    TeamUIPlugin.getPlugin().getPreferenceStore().setValue("org.eclipse.team.ui.sychronizing_default_participant_sec_id", getSecondaryId());
  }
  
  public ISynchronizeScope getScope()
  {
    return scope;
  }
  
  public Object getAdapter(Class adapter)
  {
    if ((adapter == IRefreshable.class) && (refreshSchedule != null)) {
      return refreshSchedule.getRefreshable();
    }
    return super.getAdapter(adapter);
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.team.internal.ui.synchronize.GlobalRefreshResourceSelectionPage;
import org.eclipse.team.ui.TeamUI;

public abstract class SubscriberParticipantWizard
  extends ParticipantSynchronizeWizard
{
  private GlobalRefreshResourceSelectionPage selectionPage;
  
  protected final WizardPage createScopeSelectionPage()
  {
    selectionPage = new GlobalRefreshResourceSelectionPage(getRootResources());
    return selectionPage;
  }
  
  protected final void createParticipant()
  {
    IResource[] resources = selectionPage.getRootResources();
    if ((resources != null) && (resources.length > 0))
    {
      SubscriberParticipant participant = createParticipant(selectionPage.getSynchronizeScope());
      TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
      
      participant.run(null);
    }
  }
  
  protected abstract SubscriberParticipant createParticipant(ISynchronizeScope paramISynchronizeScope);
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.subscribers.ISubscriberChangeEvent;
import org.eclipse.team.core.subscribers.ISubscriberChangeListener;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
import org.eclipse.team.ui.mapping.ITeamStateDescription;

public class SubscriberTeamStateProvider
  extends TeamStateProvider
  implements ISubscriberChangeListener
{
  private Subscriber subscriber;
  
  public SubscriberTeamStateProvider(Subscriber subscriber)
  {
    this.subscriber = subscriber;
    subscriber.addListener(this);
  }
  
  public boolean hasDecoratedState(Object element)
    throws CoreException
  {
    ResourceMapping mapping = Utils.getResourceMapping(element);
    if (mapping != null)
    {
      ResourceTraversal[] traversals = mapping.getTraversals(
        ResourceMappingContext.LOCAL_CONTEXT, null);
      for (int i = 0; i < traversals.length; i++)
      {
        ResourceTraversal traversal = traversals[i];
        IResource[] resources = traversal.getResources();
        for (int j = 0; j < resources.length; j++)
        {
          IResource resource = resources[j];
          if (getSubscriber().isSupervised(resource)) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  protected final int getSynchronizationState(Object element, int stateMask, IProgressMonitor monitor)
    throws CoreException
  {
    ResourceMapping mapping = Utils.getResourceMapping(element);
    if (mapping != null) {
      return getSynchronizationState(mapping, stateMask, monitor);
    }
    return 0;
  }
  
  private int getSynchronizationState(ResourceMapping mapping, int stateMask, IProgressMonitor monitor)
    throws CoreException
  {
    ISynchronizationCompareAdapter compareAdapter = (ISynchronizationCompareAdapter)Utils.getAdapter(mapping.getModelProvider(), ISynchronizationCompareAdapter.class);
    try
    {
      if (compareAdapter != null)
      {
        int state = compareAdapter.getSynchronizationState(this, mapping, stateMask, monitor);
        if (state != -1) {
          return state;
        }
      }
      return getSubscriber().getState(mapping, stateMask, monitor);
    }
    catch (CoreException e)
    {
      IProject[] projects = mapping.getProjects();
      for (int i = 0; i < projects.length; i++)
      {
        IProject project = projects[i];
        if (project.isAccessible()) {
          throw e;
        }
      }
    }
    return 0;
  }
  
  public ITeamStateDescription getStateDescription(Object element, int stateMask, String[] properties, IProgressMonitor monitor)
    throws CoreException
  {
    monitor = Policy.monitorFor(monitor);
    if (stateMask == -1) {
      stateMask = getDecoratedStateMask(element);
    }
    return new TeamStateDescription(getSynchronizationState(element, stateMask, monitor));
  }
  
  public ResourceMappingContext getResourceMappingContext(Object element)
  {
    return new SubscriberResourceMappingContext(subscriber, false);
  }
  
  protected final Subscriber getSubscriber()
  {
    return subscriber;
  }
  
  public void dispose()
  {
    subscriber.removeListener(this);
  }
  
  public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas)
  {
    fireStateChangeEvent(new TeamStateChangeEvent(deltas));
  }
  
  public String[] getDecoratedProperties(Object element)
  {
    return new String[0];
  }
}

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

import org.eclipse.compare.CompareNavigator;
import org.eclipse.compare.INavigatable;

class SyncInfoCompareInput$1
  extends CompareNavigator
{
  final SyncInfoCompareInput this$0;
  
  SyncInfoCompareInput$1(SyncInfoCompareInput paramSyncInfoCompareInput)
  {
    this$0 = paramSyncInfoCompareInput;
  }
  
  protected INavigatable[] getNavigatables()
  {
    return new INavigatable[0];
  }
}

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

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.progress.UIJob;

class SyncInfoCompareInput$2
  extends UIJob
{
  final SyncInfoCompareInput this$0;
  
  SyncInfoCompareInput$2(SyncInfoCompareInput paramSyncInfoCompareInput, String $anonymous0)
  {
    super($anonymous0);this$0 = paramSyncInfoCompareInput;
  }
  
  public IStatus runInUIThread(IProgressMonitor monitor)
  {
    this$0.isSaveNeeded();
    
    return Status.OK_STATUS;
  }
}

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

import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;

class SyncInfoCompareInput$MyDiffNode
  extends SyncInfoModelElement
{
  public SyncInfoCompareInput$MyDiffNode(IDiffContainer parent, SyncInfo info)
  {
    super(parent, info);
  }
  
  public void fireChange()
  {
    super.fireChange();
  }
}

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

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareNavigator;
import org.eclipse.compare.ICompareNavigator;
import org.eclipse.compare.INavigatable;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.core.resources.IFile;
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.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
import org.eclipse.ui.progress.UIJob;

public final class SyncInfoCompareInput
  extends SaveableCompareEditorInput
  implements IResourceChangeListener
{
  private MyDiffNode node;
  private String description;
  private IResource resource;
  private ISynchronizeParticipant participant;
  private ISynchronizePageConfiguration synchronizeConfiguration;
  
  private static class MyDiffNode
    extends SyncInfoModelElement
  {
    public MyDiffNode(IDiffContainer parent, SyncInfo info)
    {
      super(info);
    }
    
    public void fireChange()
    {
      super.fireChange();
    }
  }
  
  public SyncInfoCompareInput(String description, SyncInfo sync)
  {
    super(getDefaultCompareConfiguration(), null);
    Assert.isNotNull(sync);
    Assert.isNotNull(description);
    this.description = description;
    res
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