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

(participant);
      }
    }
    if (!removed.isEmpty())
    {
      saveState();
      fireUpdate((ISynchronizeParticipant[])removed.toArray(new ISynchronizeParticipant[removed.size()]), 2);
    }
  }
  
  public ISynchronizeParticipantReference get(String id, String secondaryId)
  {
    String key = Utils.getKey(id, secondaryId);
    return (ISynchronizeParticipantReference)participantReferences.get(key);
  }
  
  public ISynchronizeParticipantReference[] get(String id)
  {
    ISynchronizeParticipantReference[] refs = getSynchronizeParticipants();
    ArrayList refsForId = new ArrayList();
    for (int i = 0; i < refs.length; i++)
    {
      ISynchronizeParticipantReference reference = refs[i];
      if (reference.getId().equals(id)) {
        refsForId.add(reference);
      }
    }
    return (ISynchronizeParticipantReference[])refsForId.toArray(new ISynchronizeParticipantReference[refsForId.size()]);
  }
  
  public synchronized ISynchronizeParticipantReference[] getSynchronizeParticipants()
  {
    return (ISynchronizeParticipantReference[])participantReferences.values().toArray(new ISynchronizeParticipantReference[participantReferences.values().size()]);
  }
  
  public ISynchronizeView showSynchronizeViewInActivePage()
  {
    IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    
    boolean switchPerspectives = promptForPerspectiveSwitch();
    IWorkbenchPage activePage = null;
    if (switchPerspectives) {
      try
      {
        String pId = TeamUIPlugin.getPlugin().getPreferenceStore().getString("org.eclipse.team.ui.syncview_default_perspective");
        activePage = workbench.showPerspective(pId, window);
      }
      catch (WorkbenchException e)
      {
        Utils.handleError(window.getShell(), e, TeamUIMessages.SynchronizeView_14, e.getMessage());
      }
    }
    try
    {
      if (activePage == null)
      {
        activePage = TeamUIPlugin.getActivePage();
        if (activePage == null) {
          return null;
        }
      }
      IViewPart part = activePage.showView("org.eclipse.team.sync.views.SynchronizeView");
      try
      {
        return (ISynchronizeView)part;
      }
      catch (ClassCastException e)
      {
        TeamUIPlugin.log(4, NLS.bind(TeamUIMessages.SynchronizeManager_18, new String[] { part.getClass().getName() }), e);
        return null;
      }
      return null;
    }
    catch (PartInitException pe)
    {
      Utils.handleError(window.getShell(), pe, TeamUIMessages.SynchronizeView_16, pe.getMessage());
    }
  }
  
  private boolean promptForPerspectiveSwitch()
  {
    IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
    String option = store.getString("org.eclipse.team.ui.sychronizing_default_perspective_to_show");
    if (option.equals("always")) {
      return true;
    }
    if (option.equals("never")) {
      return false;
    }
    IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
    String defaultSyncPerspectiveId = store.getString("org.eclipse.team.ui.syncview_default_perspective");
    IPerspectiveDescriptor perspectiveDescriptor = registry.findPerspectiveWithId(defaultSyncPerspectiveId);
    IWorkbenchPage page = TeamUIPlugin.getActivePage();
    if (page != null)
    {
      IPerspectiveDescriptor p = page.getPerspective();
      if ((p != null) && (p.getId().equals(defaultSyncPerspectiveId))) {
        return false;
      }
    }
    if (perspectiveDescriptor != null)
    {
      String desc = perspectiveDescriptor.getDescription();
      String message;
      String message;
      if (desc == null) {
        message = NLS.bind(TeamUIMessages.SynchronizeManager_30, new String[] { perspectiveDescriptor.getLabel() });
      } else {
        message = NLS.bind(TeamUIMessages.SynchronizeManager_32, new String[] { perspectiveDescriptor.getLabel(), desc });
      }
      MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(Utils.getShell(null), 
        TeamUIMessages.SynchronizeManager_27, 
        message, 
        TeamUIMessages.SynchronizeManager_31, 
        false, 
        store, 
        "org.eclipse.team.ui.sychronizing_default_perspective_to_show");
      
      int result = m.getReturnCode();
      switch (result)
      {
      case 0: 
      case 2: 
        return true;
      case 3: 
        return false;
      }
    }
    return false;
  }
  
  public void init()
  {
    try
    {
      participantRegistry.readRegistry(Platform.getExtensionRegistry(), "org.eclipse.team.ui", "synchronizeParticipants");
      
      wizardRegistry.readRegistry(Platform.getExtensionRegistry(), "org.eclipse.team.ui", "synchronizeWizards");
      
      restoreSavedParticipants();
    }
    catch (CoreException e)
    {
      TeamUIPlugin.log(new Status(4, "org.eclipse.team.ui", 1, TeamUIMessages.SynchronizeManager_8, e));
    }
  }
  
  public void dispose()
  {
    saveState();
    for (Iterator it = participantReferences.values().iterator(); it.hasNext();)
    {
      ParticipantInstance ref = (ParticipantInstance)it.next();
      if (ref.isInstantiated()) {
        try
        {
          ref.getParticipant().dispose();
        }
        catch (TeamException localTeamException) {}
      }
    }
    participantReferences = null;
  }
  
  private void restoreSavedParticipants()
    throws CoreException
  {
    File file = getStateFile();
    try
    {
      reader = new BufferedReader(new FileReader(file));
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      Reader reader;
      return;
    }
    Reader reader;
    IMemento memento = XMLMemento.createReadRoot(reader);
    IMemento[] participantNodes = memento.getChildren("participant");
    for (int i = 0; i < participantNodes.length; i++)
    {
      IMemento memento2 = participantNodes[i];
      String id = memento2.getString("id");
      String secondayId = memento2.getString("secondary_id");
      if (secondayId != null)
      {
        String displayName = memento2.getString("displayName");
        SynchronizeParticipantDescriptor desc = participantRegistry.find(id);
        if (desc != null)
        {
          String key = Utils.getKey(id, secondayId);
          participantReferences.put(key, new ParticipantInstance(desc, secondayId, displayName, memento2.getChild("data")));
        }
        else
        {
          TeamUIPlugin.log(new Status(4, "org.eclipse.team.ui", 1, NLS.bind(TeamUIMessages.SynchronizeManager_9, new String[] { id }), null));
        }
      }
    }
  }
  
  private void saveState()
  {
    XMLMemento xmlMemento = XMLMemento.createWriteRoot("syncparticipants");
    for (Iterator it = participantReferences.values().iterator(); it.hasNext();)
    {
      ref = (ParticipantInstance)it.next();
      if (ref.getDescriptor().isPersistent())
      {
        IMemento participantNode = xmlMemento.createChild("participant");
        participantNode.putString("id", ref.getId());
        String secondaryId = ref.getSecondaryId();
        if (secondaryId != null) {
          participantNode.putString("secondary_id", secondaryId);
        }
        participantNode.putString("displayName", ref.getDisplayName());
        IMemento participantData = participantNode.createChild("data");
        ref.save(participantData);
      }
    }
    try
    {
      Writer writer = new BufferedWriter(new FileWriter(getStateFile()));
      try
      {
        xmlMemento.save(writer);
      }
      finally
      {
        writer.close();
      }
    }
    catch (IOException e)
    {
      TeamUIPlugin.log(new Status(4, "org.eclipse.team.ui", 1, TeamUIMessages.SynchronizeManager_10, e));
    }
  }
  
  private File getStateFile()
  {
    IPath pluginStateLocation = TeamUIPlugin.getPlugin().getStateLocation();
    return pluginStateLocation.append("syncParticipants.xml").toFile();
  }
  
  private void fireUpdate(ISynchronizeParticipant[] participants, int type)
  {
    new SynchronizeViewPageNotifier().notify(participants, type);
  }
  
  public ISynchronizeParticipantDescriptor getParticipantDescriptor(String id)
  {
    return participantRegistry.find(id);
  }
  
  public SynchronizeWizardDescription[] getWizardDescriptors()
  {
    return wizardRegistry.getSynchronizeWizards();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.SynchronizeManager
 * 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.ISafeRunnable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class SynchronizeModelElement$1
  implements ISafeRunnable
{
  final SynchronizeModelElement this$0;
  private final IPropertyChangeListener val$listener;
  private final PropertyChangeEvent val$event;
  
  SynchronizeModelElement$1(SynchronizeModelElement paramSynchronizeModelElement, IPropertyChangeListener paramIPropertyChangeListener, PropertyChangeEvent paramPropertyChangeEvent)
  {
    this$0 = paramSynchronizeModelElement;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.SynchronizeModelElement.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize;

import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.ui.model.IWorkbenchAdapter;

public abstract class SynchronizeModelElement
  extends DiffNode
  implements IAdaptable, ISynchronizeModelElement
{
  private static final int BUSY_FLAG = 1;
  private static final int PROPAGATED_CONFLICT_FLAG = 2;
  private static final int PROPAGATED_ERROR_FLAG = 4;
  private static final int PROPAGATED_WARNING_FLAG = 8;
  private int flags;
  private ListenerList listeners;
  private SynchronizeModelElement parent;
  
  public SynchronizeModelElement(IDiffContainer parent)
  {
    super(parent, 0);
    internalSetParent(parent);
  }
  
  public Object getAdapter(Class adapter)
  {
    return Platform.getAdapterManager().getAdapter(this, adapter);
  }
  
  public synchronized void addPropertyChangeListener(IPropertyChangeListener listener)
  {
    if (listeners == null) {
      listeners = new ListenerList(1);
    }
    listeners.add(listener);
  }
  
  public synchronized void removePropertyChangeListener(IPropertyChangeListener listener)
  {
    if (listeners != null)
    {
      listeners.remove(listener);
      if (listeners.isEmpty()) {
        listeners = null;
      }
    }
  }
  
  public void setParent(IDiffContainer parent)
  {
    super.setParent(parent);
    internalSetParent(parent);
  }
  
  public boolean getProperty(String propertyName)
  {
    return (getFlags() & getFlag(propertyName)) > 0;
  }
  
  public void setProperty(String propertyName, boolean value)
  {
    if (value)
    {
      if (!getProperty(propertyName))
      {
        int flag = getFlag(propertyName);
        flags |= flag;
        firePropertyChange(propertyName);
      }
    }
    else if (getProperty(propertyName))
    {
      int flag = getFlag(propertyName);
      flags ^= flag;
      firePropertyChange(propertyName);
    }
  }
  
  public void setPropertyToRoot(String propertyName, boolean value)
  {
    if (value) {
      addToRoot(propertyName);
    } else {
      removeToRoot(propertyName);
    }
  }
  
  public void fireChanges()
  {
    fireChange();
  }
  
  public ImageDescriptor getImageDescriptor(Object object)
  {
    IResource resource = getResource();
    if (resource != null)
    {
      IWorkbenchAdapter adapter = (IWorkbenchAdapter)resource.getAdapter(IWorkbenchAdapter.class);
      return adapter.getImageDescriptor(resource);
    }
    return null;
  }
  
  public abstract IResource getResource();
  
  private void addToRoot(String flag)
  {
    setProperty(flag, true);
    if (parent != null)
    {
      if (parent.getProperty(flag)) {
        return;
      }
      parent.addToRoot(flag);
    }
  }
  
  private void firePropertyChange(String propertyName)
  {
    Object[] allListeners;
    synchronized (this)
    {
      if (listeners == null) {
        return;
      }
      allListeners = listeners.getListeners();
    }
    Object[] allListeners;
    boolean set = getProperty(propertyName);
    PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName, Boolean.valueOf(!set), Boolean.valueOf(set));
    for (int i = 0; i < allListeners.length; i++)
    {
      Object object = allListeners[i];
      if ((object instanceof IPropertyChangeListener))
      {
        IPropertyChangeListener listener = (IPropertyChangeListener)object;
        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);
          }
        });
      }
    }
  }
  
  private int getFlag(String propertyName)
  {
    if (propertyName == "org.eclipse.team.ui.busy") {
      return 1;
    }
    if (propertyName == "org.eclipse.team.ui.conflict") {
      return 2;
    }
    if (propertyName == "org.eclipse.team.ui.error") {
      return 4;
    }
    if (propertyName == "org.eclipse.team.ui.warning") {
      return 8;
    }
    return 0;
  }
  
  private int getFlags()
  {
    return flags;
  }
  
  private boolean hasChildWithFlag(String flag)
  {
    IDiffElement[] childen = getChildren();
    for (int i = 0; i < childen.length; i++)
    {
      IDiffElement element = childen[i];
      if (((SynchronizeModelElement)element).getProperty(flag)) {
        return true;
      }
    }
    return false;
  }
  
  private void removeToRoot(String flag)
  {
    boolean hasProperty = getProperty(flag);
    if (hasProperty)
    {
      setProperty(flag, false);
      if (parent != null) {
        if ((parent.getProperty(flag)) && (!parent.hasChildWithFlag(flag))) {
          parent.removeToRoot(flag);
        }
      }
    }
  }
  
  private void internalSetParent(IDiffContainer parent)
  {
    if ((parent != null) && ((parent instanceof SynchronizeModelElement))) {
      this.parent = ((SynchronizeModelElement)parent);
    }
  }
  
  public boolean equals(Object object)
  {
    return this == object;
  }
  
  public int hashCode()
  {
    return getName().hashCode();
  }
}

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

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.DecorationOverlayIcon;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.ui.model.WorkbenchLabelProvider;

public class SynchronizeModelElementLabelProvider
  extends LabelProvider
  implements IColorProvider, IFontProvider
{
  private Map fgImageCache;
  CompareConfiguration compareConfig = new CompareConfiguration();
  private WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider();
  private Font busyFont;
  
  public Color getForeground(Object element)
  {
    return null;
  }
  
  public Color getBackground(Object element)
  {
    return null;
  }
  
  public Font getFont(Object element)
  {
    if ((element instanceof ISynchronizeModelElement))
    {
      ISynchronizeModelElement node = (ISynchronizeModelElement)element;
      if (node.getProperty("org.eclipse.team.ui.busy"))
      {
        if (busyFont == null)
        {
          Font defaultFont = JFaceResources.getDefaultFont();
          FontData[] data = defaultFont.getFontData();
          for (int i = 0; i < data.length; i++) {
            data[i].setStyle(2);
          }
          busyFont = new Font(TeamUIPlugin.getStandardDisplay(), data);
        }
        return busyFont;
      }
    }
    return null;
  }
  
  public Image getImage(Object element)
  {
    Image base = workbenchLabelProvider.getImage(element);
    if ((base != null) && 
      ((element instanceof ISynchronizeModelElement)))
    {
      ISynchronizeModelElement syncNode = (ISynchronizeModelElement)element;
      int kind = syncNode.getKind();
      
      Image decoratedImage = getCompareImage(base, kind);
      
      return propagateConflicts(decoratedImage, syncNode);
    }
    return base;
  }
  
  public String getText(Object element)
  {
    String base = workbenchLabelProvider.getText(element);
    if (((element instanceof DiffNode)) && 
      (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean("org.eclipse.team.ui.view_syncinfo_in_label")))
    {
      int kind = ((DiffNode)element).getKind();
      if (kind != 0)
      {
        String syncKindString = SyncInfo.kindToString(kind);
        return NLS.bind(TeamUIMessages.TeamSubscriberSyncPage_labelWithSyncKind, new String[] { base, syncKindString });
      }
    }
    return base;
  }
  
  protected Image getCompareImage(Image base, int kind)
  {
    switch (kind & 0xC)
    {
    case 4: 
      kind = kind & 0xFFFFFFFB | 0x8;
      break;
    case 8: 
      kind = kind & 0xFFFFFFF7 | 0x4;
    }
    return compareConfig.getImage(base, kind);
  }
  
  private Image propagateConflicts(Image base, ISynchronizeModelElement element)
  {
    ImageDescriptor[] overlayImages = new ImageDescriptor[4];
    boolean hasOverlay = false;
    if (element.getProperty("org.eclipse.team.ui.busy"))
    {
      overlayImages[0] = TeamUIPlugin.getImageDescriptor("ovr/waiting_ovr.gif");
      hasOverlay = true;
    }
    int kind = element.getKind();
    if ((kind & 0xC) != 12) {
      if (hasDecendantConflicts(element))
      {
        overlayImages[3] = TeamUIPlugin.getImageDescriptor("ovr/confchg_ov.gif");
        hasOverlay = true;
      }
    }
    if (hasErrorMarker(element))
    {
      overlayImages[2] = TeamUIPlugin.getImageDescriptor("ovr/error_co.gif");
      hasOverlay = true;
    }
    else if (hasWarningMarker(element))
    {
      overlayImages[2] = TeamUIPlugin.getImageDescriptor("ovr/warning_co.gif");
      hasOverlay = true;
    }
    if (hasOverlay)
    {
      ImageDescriptor overlay = new DecorationOverlayIcon(base, overlayImages, new Point(getBoundswidth, getBoundsheight));
      if (fgImageCache == null) {
        fgImageCache = new HashMap(10);
      }
      Image conflictDecoratedImage = (Image)fgImageCache.get(overlay);
      if (conflictDecoratedImage == null)
      {
        conflictDecoratedImage = overlay.createImage();
        fgImageCache.put(overlay, conflictDecoratedImage);
      }
      return conflictDecoratedImage;
    }
    return base;
  }
  
  private boolean hasDecendantConflicts(ISynchronizeModelElement node)
  {
    return node.getProperty("org.eclipse.team.ui.conflict");
  }
  
  private boolean hasErrorMarker(ISynchronizeModelElement node)
  {
    return node.getProperty("org.eclipse.team.ui.error");
  }
  
  private boolean hasWarningMarker(ISynchronizeModelElement node)
  {
    return node.getProperty("org.eclipse.team.ui.warning");
  }
  
  public void dispose()
  {
    workbenchLabelProvider.dispose();
    if (busyFont != null) {
      busyFont.dispose();
    }
    compareConfig.dispose();
    if (fgImageCache != null)
    {
      Iterator it = fgImageCache.values().iterator();
      while (it.hasNext())
      {
        Image element = (Image)it.next();
        element.dispose();
      }
    }
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.views.navigator.ResourceSorter;

public class SynchronizeModelElementSorter
  extends ResourceSorter
{
  public SynchronizeModelElementSorter()
  {
    super(1);
  }
  
  public int compare(Viewer viewer, Object o1, Object o2)
  {
    IResource resource1 = getResource(o1);
    IResource resource2 = getResource(o2);
    Object objectToCompare1 = resource1 == null ? o1 : resource1;
    Object objectToCompare2 = resource2 == null ? o2 : resource2;
    
    return super.compare(viewer, objectToCompare1, objectToCompare2);
  }
  
  protected IResource getResource(Object obj)
  {
    IResource[] resources = Utils.getResources(new Object[] { obj });
    return resources.length == 1 ? resources[0] : null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.SynchronizeModelElementSorter
 * 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.IProgressMonitor;
import org.eclipse.swt.widgets.Display;

class SynchronizeModelManager$1
  implements IProgressMonitor
{
  final SynchronizeModelManager this$0;
  
  SynchronizeModelManager$1(SynchronizeModelManager paramSynchronizeModelManager)
  {
    this$0 = paramSynchronizeModelManager;
  }
  
  public void beginTask(String name, int totalWork) {}
  
  public void done() {}
  
  public void internalWorked(double work) {}
  
  public boolean isCanceled()
  {
    return false;
  }
  
  public void setCanceled(boolean value) {}
  
  public void setTaskName(String name) {}
  
  public void subTask(String name) {}
  
  public void worked(int work)
  {
    while (Display.getCurrent().readAndDispatch()) {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager.1
 * 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.Action;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class SynchronizeModelManager$ToggleModelProviderAction
  extends Action
  implements IPropertyChangeListener
{
  private ISynchronizeModelProviderDescriptor descriptor;
  final SynchronizeModelManager this$0;
  
  protected SynchronizeModelManager$ToggleModelProviderAction(SynchronizeModelManager paramSynchronizeModelManager, ISynchronizeModelProviderDescriptor descriptor)
  {
    super(descriptor.getName(), 8);this$0 = paramSynchronizeModelManager;
    setImageDescriptor(descriptor.getImageDescriptor());
    setToolTipText(descriptor.getName());
    this.descriptor = descriptor;
    update();
    SynchronizeModelManager.access$0(paramSynchronizeModelManager).addPropertyChangeListener(this);
  }
  
  public void run()
  {
    if (!this$0.getSelectedProviderId().equals(descriptor.getId())) {
      this$0.setInput(descriptor.getId(), null);
    }
  }
  
  public void update()
  {
    setChecked(this$0.getSelectedProviderId().equals(descriptor.getId()));
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("org.eclipse.team.ui.P_MODEL")) {
      update();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager.ToggleModelProviderAction
 * 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.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
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.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.synchronize.SyncInfoSet;
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.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
import org.eclipse.ui.IActionBars;

public abstract class SynchronizeModelManager
  extends SynchronizePageActionGroup
{
  private static final String P_LAST_PROVIDER = "org.eclipse.team.ui.P_LAST_MODELPROVIDER";
  private ISynchronizeModelProvider modelProvider;
  private List toggleModelProviderActions;
  private ISynchronizePageConfiguration configuration;
  private TreeViewerAdvisor advisor;
  
  private class ToggleModelProviderAction
    extends Action
    implements IPropertyChangeListener
  {
    private ISynchronizeModelProviderDescriptor descriptor;
    
    protected ToggleModelProviderAction(ISynchronizeModelProviderDescriptor descriptor)
    {
      super(8);
      setImageDescriptor(descriptor.getImageDescriptor());
      setToolTipText(descriptor.getName());
      this.descriptor = descriptor;
      update();
      configuration.addPropertyChangeListener(this);
    }
    
    public void run()
    {
      if (!getSelectedProviderId().equals(descriptor.getId())) {
        setInput(descriptor.getId(), null);
      }
    }
    
    public void update()
    {
      setChecked(getSelectedProviderId().equals(descriptor.getId()));
    }
    
    public void propertyChange(PropertyChangeEvent event)
    {
      if (event.getProperty().equals("org.eclipse.team.ui.P_MODEL")) {
        update();
      }
    }
  }
  
  public SynchronizeModelManager(ISynchronizePageConfiguration configuration)
  {
    Assert.isNotNull(configuration, "configuration cannot be null");
    this.configuration = configuration;
    configuration.addActionContribution(this);
  }
  
  public void setViewerAdvisor(TreeViewerAdvisor advisor)
  {
    this.advisor = advisor;
  }
  
  protected abstract ISynchronizeModelProviderDescriptor[] getSupportedModelProviders();
  
  protected abstract ISynchronizeModelProvider createModelProvider(String paramString);
  
  public ISynchronizeModelProvider getActiveModelProvider()
  {
    return modelProvider;
  }
  
  protected String getDefaultProviderId()
  {
    String defaultLayout = TeamUIPlugin.getPlugin().getPreferenceStore().getString("org.eclipse.team.ui.default_layout");
    if (defaultLayout.equals("org.eclipse.team.ui.tree_layout")) {
      return "org.eclipse.team.ui.modelprovider_hierarchical";
    }
    if (defaultLayout.equals("org.eclipse.team.ui.flay_layout")) {
      return "org.eclipse.team.ui.modelprovider_flat";
    }
    return "org.eclipse.team.ui.modelprovider_compressedfolders";
  }
  
  protected String getSelectedProviderId()
  {
    ISynchronizeModelProvider provider = getActiveModelProvider();
    if (provider != null) {
      return provider.getDescriptor().getId();
    }
    return getDefaultProviderId();
  }
  
  protected void setInput(String id, IProgressMonitor monitor)
  {
    if (modelProvider != null)
    {
      modelProvider.saveState();
      modelProvider.dispose();
    }
    modelProvider = createModelProvider(id);
    saveProviderSettings(id);
    modelProvider.prepareInput(monitor);
    setInput();
  }
  
  protected void saveProviderSettings(String id)
  {
    IDialogSettings pageSettings = getConfiguration().getSite().getPageSettings();
    if (pageSettings != null) {
      pageSettings.put("org.eclipse.team.ui.P_LAST_MODELPROVIDER", id);
    }
  }
  
  protected void setInput()
  {
    configuration.setProperty("org.eclipse.team.ui.P_MODEL", modelProvider.getModelRoot());
    if (advisor != null) {
      advisor.setInput(modelProvider);
    }
  }
  
  public ISynchronizeModelElement getModelRoot()
  {
    if ((modelProvider != null) && ((modelProvider instanceof SynchronizeModelProvider)))
    {
      ((SynchronizeModelProvider)modelProvider).waitUntilDone(new IProgressMonitor()
      {
        public void beginTask(String name, int totalWork) {}
        
        public void done() {}
        
        public void internalWorked(double work) {}
        
        public boolean isCanceled()
        {
          return false;
        }
        
        public void setCanceled(boolean value) {}
        
        public void setTaskName(String name) {}
        
        public void subTask(String name) {}
        
        public void worked(int work)
        {
          while (Display.getCurrent().readAndDispatch()) {}
        }
      });
      return modelProvider.getModelRoot();
    }
    return null;
  }
  
  public void initialize(ISynchronizePageConfiguration configuration)
  {
    super.initialize(configuration);
    ISynchronizeModelProviderDescriptor[] providers = getSupportedModelProviders();
    if (providers.length > 1)
    {
      toggleModelProviderActions = new ArrayList();
      for (int i = 0; i < providers.length; i++)
      {
        ISynchronizeModelProviderDescriptor provider = providers[i];
        toggleModelProviderActions.add(new ToggleModelProviderAction(provider));
      }
    }
    if (modelProvider == null)
    {
      String defaultProviderId = getDefaultProviderId();
      IDialogSettings pageSettings = configuration.getSite().getPageSettings();
      if ((pageSettings != null) && (pageSettings.get("org.eclipse.team.ui.P_LAST_MODELPROVIDER") != null)) {
        defaultProviderId = pageSettings.get("org.eclipse.team.ui.P_LAST_MODELPROVIDER");
      }
      setInput(defaultProviderId, null);
    }
    else
    {
      setInput();
    }
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    if (toggleModelProviderActions == null) {
      return;
    }
    IToolBarManager toolbar = actionBars.getToolBarManager();
    IMenuManager menu = actionBars.getMenuManager();
    IContributionItem group = findGroup(menu, "layout");
    if ((menu != null) && (group != null))
    {
      MenuManager layout = new MenuManager(Utils.getString("action.layout.label", Policy.getActionBundle()));
      menu.appendToGroup(group.getId(), layout);
      appendToMenu(null, layout);
    }
    else if (toolbar != null)
    {
      group = findGroup(toolbar, "layout");
      if (group != null) {
        appendToMenu(group.getId(), toolbar);
      }
    }
  }
  
  private void appendToMenu(String groupId, IContributionManager menu)
  {
    for (Iterator iter = toggleModelProviderActions.iterator(); iter.hasNext();) {
      if (groupId == null) {
        menu.add((Action)iter.next());
      } else {
        menu.appendToGroup(groupId, (Action)iter.next());
      }
    }
  }
  
  public void dispose()
  {
    if (modelProvider != null) {
      modelProvider.dispose();
    }
    super.dispose();
  }
  
  public ISynchronizePageConfiguration getConfiguration()
  {
    return configuration;
  }
  
  protected SyncInfoSet getSyncInfoSet()
  {
    return (SyncInfoSet)getConfiguration().getProperty("org.eclipse.team.ui.P_SYNC_INFO_SET");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.SynchronizeModelManager
 * 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.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.ViewerSorter;
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.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public abstract class SynchronizeModelProvider
  extends AbstractSynchronizeModelProvider
  implements ISyncInfoSetChangeListener
{
  protected final Map resourceMap = Collections.synchronizedMap(new HashMap());
  protected static final boolean DEBUG = false;
  
  public SynchronizeModelProvider(ISynchronizePageConfiguration configuration, SyncInfoSet set)
  {
    super(configuration, set);
  }
  
  public SynchronizeModelProvider(AbstractSynchronizeModelProvider parentProvider, ISynchronizeModelElement modelRoot, ISynchronizePageConfiguration configuration, SyncInfoSet set)
  {
    super(parentProvider, modelRoot, configuration, set);
    associateRoot(modelRoot);
  }
  
  private void associateRoot(ISynchronizeModelElement modelRoot)
  {
    resourceMap.put(ResourcesPlugin.getWorkspace().getRoot(), modelRoot);
  }
  
  public void dispose()
  {
    resourceMap.clear();
    super.dispose();
  }
  
  public abstract ViewerSorter getViewerSorter();
  
  protected ISynchronizeModelElement getModelObject(IResource resource)
  {
    return (ISynchronizeModelElement)resourceMap.get(resource);
  }
  
  protected ISynchronizeModelElement[] getModelObjects(IResource resource)
  {
    ISynchronizeModelElement element = getModelObject(resource);
    if (element == null) {
      return new ISynchronizeModelElement[0];
    }
    return new ISynchronizeModelElement[] { element };
  }
  
  protected void associateDiffNode(ISynchronizeModelElement node)
  {
    IResource resource = node.getResource();
    if (resource != null) {
      resourceMap.put(resource, node);
    }
  }
  
  protected void unassociateDiffNode(IResource resource)
  {
    resourceMap.remove(resource);
  }
  
  protected void removeFromViewer(IResource resource)
  {
    ISynchronizeModelElement element = getModelObject(resource);
    if (element != null) {
      removeFromViewer(new ISynchronizeModelElement[] { element });
    }
  }
  
  protected void removeFromViewer(IResource[] resources)
  {
    List elements = new ArrayList();
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      ISynchronizeModelElement element = getModelObject(resource);
      if (element != null) {
        elements.add(element);
      }
    }
    if (!elements.isEmpty()) {
      removeFromViewer((ISynchronizeModelElement[])elements.toArray(new ISynchronizeModelElement[elements.size()]));
    }
  }
  
  protected void recursiveClearModelObjects(ISynchronizeModelElement node)
  {
    super.recursiveClearModelObjects(node);
    if (node == getModelRoot())
    {
      resourceMap.clear();
      
      associateRoot(getModelRoot());
    }
    else
    {
      IResource resource = node.getResource();
      if (resource != null) {
        unassociateDiffNode(resource);
      }
    }
  }
  
  protected void addToViewer(ISynchronizeModelElement node)
  {
    associateDiffNode(node);
    super.addToViewer(node);
  }
  
  protected boolean hasViewerState()
  {
    return !resourceMap.isEmpty();
  }
  
  public ISynchronizeModelElement[] getClosestExistingParents(IResource resource)
  {
    ISynchronizeModelElement element = getModelObject(resource);
    if (element == null) {
      do
      {
        resource = resource.getParent();
        element = getModelObject(resource);
      } while ((element == null) && (resource != null));
    }
    if (element == null) {
      return new ISynchronizeModelElement[0];
    }
    return new ISynchronizeModelElement[] { element };
  }
  
  protected final void handleChanges(ISyncInfoTreeChangeEvent event, IProgressMonitor monitor)
  {
    super.handleChanges(event, monitor);
  }
  
  protected void handleResourceChanges(ISyncInfoTreeChangeEvent event)
  {
    SyncInfo[] infos = event.getChangedResources();
    for (int i = 0; i < infos.length; i++)
    {
      SyncInfo info = infos[i];
      IResource local = info.getLocal();
      ISynchronizeModelElement diffNode = getModelObject(local);
      if (diffNode != null) {
        handleChange(diffNode, info);
      }
    }
  }
  
  protected void handleChange(ISynchronizeModelElement diffNode, SyncInfo info)
  {
    IResource local = info.getLocal();
    if ((diffNode instanceof SyncInfoModelElement))
    {
      ((SyncInfoModelElement)diffNode).update(info);
      propogateConflictState(diffNode, false);
      queueForLabelUpdate(diffNode);
    }
    else
    {
      removeFromViewer(local);
      addResource(info);
      ISynchronizeModelElement node = getModelObject(info.getLocal());
      buildModelObjects(node);
    }
  }
  
  protected void addResources(SyncInfo[] added)
  {
    for (int i = 0; i < added.length; i++)
    {
      SyncInfo info = added[i];
      addResource(info);
    }
  }
  
  protected abstract void addResource(SyncInfo paramSyncInfo);
  
  protected abstract ISynchronizeModelElement createModelObject(ISynchronizeModelElement paramISynchronizeModelElement, SyncInfo paramSyncInfo);
}

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

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;

class SynchronizeModelUpdateHandler$1
  implements IPropertyChangeListener
{
  final SynchronizeModelUpdateHandler this$0;
  
  SynchronizeModelUpdateHandler$1(SynchronizeModelUpdateHandler paramSynchronizeModelUpdateHandler)
  {
    this$0 = paramSynchronizeModelUpdateHandler;
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty() == "org.eclipse.team.ui.busy")
    {
      Object source = event.getSource();
      if ((source instanceof ISynchronizeModelElement)) {
        this$0.upd
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