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

iewers.ICheckStateListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.synchronize.ISynchronizeScope;
import org.eclipse.team.ui.synchronize.ResourceScope;
import org.eclipse.team.ui.synchronize.WorkingSetScope;
import org.eclipse.team.ui.synchronize.WorkspaceScope;
import org.eclipse.ui.IDecoratorManager;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class GlobalRefreshResourceSelectionPage
  extends GlobalRefreshElementSelectionPage
{
  private List resources;
  
  class MyContentProvider
    extends BaseWorkbenchContentProvider
  {
    MyContentProvider() {}
    
    public Object[] getChildren(Object element)
    {
      if ((element instanceof List)) {
        return ((List)element).toArray(new IResource[((List)element).size()]);
      }
      return super.getChildren(element);
    }
  }
  
  class MyLabelProvider
    extends LabelProvider
  {
    private LabelProvider workbenchProvider = new WorkbenchLabelProvider();
    
    MyLabelProvider() {}
    
    public String getText(Object element)
    {
      if ((element instanceof IContainer))
      {
        IContainer c = (IContainer)element;
        if ((c.getType() != 4) && (resources.contains(c))) {
          return c.getFullPath().toString();
        }
      }
      return workbenchProvider.getText(element);
    }
    
    public Image getImage(Object element)
    {
      return workbenchProvider.getImage(element);
    }
  }
  
  public GlobalRefreshResourceSelectionPage(IResource[] resources)
  {
    super(TeamUIMessages.GlobalRefreshResourceSelectionPage_1);
    
    this.resources = Arrays.asList(resources);
    setDescription(TeamUIMessages.GlobalRefreshResourceSelectionPage_2);
    setTitle(TeamUIMessages.GlobalRefreshResourceSelectionPage_3);
  }
  
  protected ContainerCheckedTreeViewer createViewer(Composite top)
  {
    ContainerCheckedTreeViewer fViewer = new ContainerCheckedTreeViewer(top, 2048);
    GridData data = new GridData(1808);
    
    heightHint = 100;
    fViewer.getControl().setLayoutData(data);
    fViewer.setContentProvider(new MyContentProvider());
    fViewer.setLabelProvider(new DecoratingLabelProvider(new MyLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
    fViewer.addCheckStateListener(new ICheckStateListener()
    {
      public void checkStateChanged(CheckStateChangedEvent event)
      {
        updateOKStatus();
      }
    });
    fViewer.setComparator(new ResourceComparator(1));
    fViewer.setInput(resources);
    return fViewer;
  }
  
  protected void checkAll()
  {
    getViewer().setCheckedElements(resources.toArray());
  }
  
  protected boolean checkWorkingSetElements()
  {
    List allWorkingSetResources = new ArrayList();
    IWorkingSet[] workingSets = getWorkingSets();
    for (int i = 0; i < workingSets.length; i++)
    {
      IWorkingSet set = workingSets[i];
      allWorkingSetResources.addAll(IDE.computeSelectedResources(new StructuredSelection(set.getElements())));
    }
    getViewer().setCheckedElements(allWorkingSetResources.toArray(new IResource[allWorkingSetResources.size()]));
    return !allWorkingSetResources.isEmpty();
  }
  
  public IResource[] getRootResources()
  {
    Object[] objects = getRootElement();
    IResource[] resources = new IResource[objects.length];
    for (int i = 0; i < resources.length; i++) {
      resources[i] = ((IResource)objects[i]);
    }
    return resources;
  }
  
  public ISynchronizeScope getSynchronizeScope()
  {
    if (isWorkingSetSelected()) {
      return new WorkingSetScope(getWorkingSets());
    }
    if (isWorkspaceSelected()) {
      return new WorkspaceScope();
    }
    return new ResourceScope(getRootResources());
  }
}

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

import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public class HierarchicalModelManager
  extends SynchronizeModelManager
{
  public HierarchicalModelManager(ISynchronizePageConfiguration configuration)
  {
    super(configuration);
  }
  
  protected ISynchronizeModelProviderDescriptor[] getSupportedModelProviders()
  {
    return new ISynchronizeModelProviderDescriptor[] {
      new FlatModelProvider.FlatModelProviderDescriptor(), 
      new HierarchicalModelProvider.HierarchicalModelProviderDescriptor(), 
      new CompressedFoldersModelProvider.CompressedFolderModelProviderDescriptor() };
  }
  
  protected ISynchronizeModelProvider createModelProvider(String id)
  {
    if (id == null) {
      id = getDefaultProviderId();
    }
    if (id.endsWith("org.eclipse.team.ui.modelprovider_flat")) {
      return new FlatModelProvider(getConfiguration(), getSyncInfoSet());
    }
    if (id.endsWith("org.eclipse.team.ui.modelprovider_compressedfolders")) {
      return new CompressedFoldersModelProvider(getConfiguration(), getSyncInfoSet());
    }
    return new HierarchicalModelProvider(getConfiguration(), getSyncInfoSet());
  }
}

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

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.TeamImages;

public class HierarchicalModelProvider$HierarchicalModelProviderDescriptor
  implements ISynchronizeModelProviderDescriptor
{
  public static final String ID = "org.eclipse.team.ui.modelprovider_hierarchical";
  
  public String getId()
  {
    return "org.eclipse.team.ui.modelprovider_hierarchical";
  }
  
  public String getName()
  {
    return TeamUIMessages.HierarchicalModelProvider_0;
  }
  
  public ImageDescriptor getImageDescriptor()
  {
    return TeamImages.getImageDescriptor("elcl16/hierarchicalLayout.gif");
  }
}

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

import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ViewerSorter;
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.core.synchronize.SyncInfoTree;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.TeamImages;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public class HierarchicalModelProvider
  extends SynchronizeModelProvider
{
  public static class HierarchicalModelProviderDescriptor
    implements ISynchronizeModelProviderDescriptor
  {
    public static final String ID = "org.eclipse.team.ui.modelprovider_hierarchical";
    
    public String getId()
    {
      return "org.eclipse.team.ui.modelprovider_hierarchical";
    }
    
    public String getName()
    {
      return TeamUIMessages.HierarchicalModelProvider_0;
    }
    
    public ImageDescriptor getImageDescriptor()
    {
      return TeamImages.getImageDescriptor("elcl16/hierarchicalLayout.gif");
    }
  }
  
  private static final HierarchicalModelProviderDescriptor hierarchicalDescriptor = new HierarchicalModelProviderDescriptor();
  
  public HierarchicalModelProvider(ISynchronizePageConfiguration configuration, SyncInfoSet set)
  {
    super(configuration, set);
  }
  
  public HierarchicalModelProvider(AbstractSynchronizeModelProvider parentProvider, ISynchronizeModelElement modelRoot, ISynchronizePageConfiguration configuration, SyncInfoSet set)
  {
    super(parentProvider, modelRoot, configuration, set);
  }
  
  public ISynchronizeModelProviderDescriptor getDescriptor()
  {
    return hierarchicalDescriptor;
  }
  
  public ViewerSorter getViewerSorter()
  {
    return new SynchronizeModelElementSorter();
  }
  
  protected SyncInfoTree getSyncInfoTree()
  {
    return (SyncInfoTree)getSyncInfoSet();
  }
  
  protected IDiffElement[] createModelObjects(ISynchronizeModelElement container)
  {
    IResource resource = null;
    if (container == getModelRoot()) {
      resource = ResourcesPlugin.getWorkspace().getRoot();
    } else {
      resource = container.getResource();
    }
    if (resource != null)
    {
      SyncInfoTree infoTree = getSyncInfoTree();
      IResource[] children = infoTree.members(resource);
      ISynchronizeModelElement[] nodes = new ISynchronizeModelElement[children.length];
      for (int i = 0; i < children.length; i++) {
        nodes[i] = createModelObject(container, children[i]);
      }
      return nodes;
    }
    return new IDiffElement[0];
  }
  
  protected ISynchronizeModelElement createModelObject(ISynchronizeModelElement parent, IResource resource)
  {
    SyncInfo info = getSyncInfoTree().getSyncInfo(resource);
    SynchronizeModelElement newNode;
    SynchronizeModelElement newNode;
    if (info != null) {
      newNode = new SyncInfoModelElement(parent, info);
    } else {
      newNode = new UnchangedResourceModelElement(parent, resource);
    }
    addToViewer(newNode);
    return newNode;
  }
  
  protected Object[] getModelObjects(IResource[] resources)
  {
    Object[] result = new Object[resources.length];
    for (int i = 0; i < resources.length; i++) {
      result[i] = getModelObject(resources[i]);
    }
    return result;
  }
  
  protected void addResources(IResource[] added)
  {
    for (int i = 0; i < added.length; i++)
    {
      IResource resource = added[i];
      addResource(resource);
    }
  }
  
  private void addResource(IResource resource)
  {
    ISynchronizeModelElement node = getModelObject(resource);
    if (node != null) {
      removeFromViewer(resource);
    }
    ISynchronizeModelElement parent = getModelObject(resource.getParent());
    if (parent != null)
    {
      node = createModelObject(parent, resource);
      buildModelObjects(node);
    }
  }
  
  protected IDiffElement[] buildModelObjects(ISynchronizeModelElement node)
  {
    IDiffElement[] children = createModelObjects(node);
    for (int i = 0; i < children.length; i++)
    {
      IDiffElement element = children[i];
      if ((element instanceof ISynchronizeModelElement)) {
        buildModelObjects((ISynchronizeModelElement)element);
      }
    }
    return children;
  }
  
  protected void handleResourceAdditions(ISyncInfoTreeChangeEvent event)
  {
    SyncInfo[] infos = event.getAddedResources();
    HashSet set = new HashSet();
    for (int i = 0; i < infos.length; i++)
    {
      SyncInfo info = infos[i];
      set.add(info.getLocal().getProject());
    }
    for (Iterator it = set.iterator(); it.hasNext();) {
      addResource((IResource)it.next());
    }
  }
  
  protected void handleResourceRemovals(ISyncInfoTreeChangeEvent event)
  {
    IResource[] removedRoots = event.getRemovedSubtreeRoots();
    removeFromViewer(removedRoots);
    
    IResource[] removedResources = event.getRemovedResources();
    for (int i = 0; i < removedResources.length; i++)
    {
      IResource resource = removedResources[i];
      if (resource.getType() != 1)
      {
        ISynchronizeModelElement node = getModelObject(resource);
        if (node != null) {
          removeFromViewer(resource);
        }
      }
    }
  }
  
  protected ISynchronizeModelElement createModelObject(ISynchronizeModelElement parent, SyncInfo info)
  {
    return createModelObject(parent, info.getLocal());
  }
  
  protected void addResource(SyncInfo info)
  {
    addResource(info.getLocal());
  }
}

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

public abstract interface IChangeSetProvider
{
  public abstract ChangeSetCapability getChangeSetCapability();
}

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

public abstract interface IPageValidator
{
  public abstract void setComplete(String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.IPageValidator
 * 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.IStatus;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;

public abstract interface IRefreshEvent
{
  public static final int STATUS_CHANGES = 1;
  public static final int STATUS_NEW_CHANGES = 2;
  public static final int STATUS_NO_CHANGES = 0;
  public static final int SCHEDULED_REFRESH = 1;
  public static final int USER_REFRESH = 2;
  
  public abstract int getRefreshType();
  
  public abstract ISynchronizeParticipant getParticipant();
  
  public abstract RefreshParticipantJob.IChangeDescription getChangeDescription();
  
  public abstract long getStartTime();
  
  public abstract long getStopTime();
  
  public abstract IStatus getStatus();
  
  public abstract void setIsLink(boolean paramBoolean);
  
  public abstract boolean isLink();
}

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

import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;

public abstract interface IRefreshSubscriberListener
{
  public abstract void refreshStarted(IRefreshEvent paramIRefreshEvent);
  
  public abstract ActionFactory.IWorkbenchAction refreshDone(IRefreshEvent paramIRefreshEvent);
}

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

import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;

public abstract interface IRefreshable
{
  public abstract SubscriberRefreshSchedule getRefreshSchedule();
  
  public abstract void setRefreshSchedule(SubscriberRefreshSchedule paramSubscriberRefreshSchedule);
  
  public abstract ISynchronizeParticipant getParticipant();
  
  public abstract RefreshParticipantJob createJob(String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.IRefreshable
 * 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.jface.util.IPropertyChangeListener;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;

public abstract interface ISynchronizeModelProvider
{
  public static final String P_VIEWER_SORTER = "org.eclipse.team.ui.P_VIEWER_SORTER";
  
  public abstract SyncInfoSet getSyncInfoSet();
  
  public abstract ISynchronizeModelProviderDescriptor getDescriptor();
  
  public abstract StructuredViewer getViewer();
  
  public abstract ISynchronizeModelElement prepareInput(IProgressMonitor paramIProgressMonitor);
  
  public abstract void dispose();
  
  public abstract ISynchronizeModelElement getModelRoot();
  
  public abstract ViewerSorter getViewerSorter();
  
  public abstract void saveState();
  
  public abstract void addPropertyChangeListener(IPropertyChangeListener paramIPropertyChangeListener);
  
  public abstract void removePropertyChangeListener(IPropertyChangeListener paramIPropertyChangeListener);
}

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

import org.eclipse.jface.resource.ImageDescriptor;

public abstract interface ISynchronizeModelProviderDescriptor
{
  public abstract String getName();
  
  public abstract String getId();
  
  public abstract ImageDescriptor getImageDescriptor();
}

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

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class ImageManager$1
  implements DisposeListener
{
  private final ImageManager val$newRegistry;
  
  ImageManager$1(ImageManager paramImageManager)
  {
    val$newRegistry = paramImageManager;
  }
  
  public void widgetDisposed(DisposeEvent e)
  {
    val$newRegistry.dispose();
  }
}

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

import org.eclipse.team.core.ICache;
import org.eclipse.team.core.ICacheListener;

class ImageManager$2
  implements ICacheListener
{
  private final ImageManager val$newRegistry;
  
  ImageManager$2(ImageManager paramImageManager)
  {
    val$newRegistry = paramImageManager;
  }
  
  public void cacheDisposed(ICache cache)
  {
    val$newRegistry.dispose();
  }
}

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

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Control;
import org.eclipse.team.core.ICache;
import org.eclipse.team.core.ICacheListener;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.ui.synchronize.ISynchronizePage;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

public class ImageManager
{
  private static final String PROP_IMAGE_MANAGER = "org.eclipse.team.ui.imageManager";
  private LocalResourceManager imageManager;
  private CompareConfiguration compareConfig = new CompareConfiguration();
  private boolean disposed = false;
  
  public static synchronized ImageManager getImageManager(ISynchronizationContext context, ISynchronizePageConfiguration configuration)
  {
    ImageManager manager = (ImageManager)context.getCache().get("org.eclipse.team.ui.imageManager");
    if ((manager == null) || (disposed))
    {
      ImageManager newRegistry = new ImageManager();
      context.getCache().put("org.eclipse.team.ui.imageManager", newRegistry);
      Viewer v = getViewer(configuration);
      if (v != null) {
        v.getControl().addDisposeListener(new DisposeListener()
        {
          public void widgetDisposed(DisposeEvent e)
          {
            dispose();
          }
        });
      } else {
        context.getCache().addCacheListener(new ICacheListener()
        {
          public void cacheDisposed(ICache cache)
          {
            dispose();
          }
        });
      }
      manager = newRegistry;
    }
    return manager;
  }
  
  private static Viewer getViewer(ISynchronizePageConfiguration configuration)
  {
    if (configuration == null) {
      return null;
    }
    if (configuration.getPage() == null) {
      return null;
    }
    return configuration.getPage().getViewer();
  }
  
  public Image getImage(ImageDescriptor descriptor)
  {
    if ((descriptor == null) || (disposed)) {
      return null;
    }
    ResourceManager manager = getResourceManager();
    Image image = manager.createImage(descriptor);
    return image;
  }
  
  private synchronized ResourceManager getResourceManager()
  {
    if (imageManager == null) {
      imageManager = new LocalResourceManager(JFaceResources.getResources());
    }
    return imageManager;
  }
  
  public void dispose()
  {
    disposed = true;
    compareConfig.dispose();
    if (imageManager != null) {
      imageManager.dispose();
    }
  }
  
  public Image getImage(Image base, int compareKind)
  {
    if (disposed) {
      return null;
    }
    return compareConfig.getImage(base, compareKind);
  }
}

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

import org.eclipse.compare.IContentChangeListener;
import org.eclipse.compare.IContentChangeNotifier;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.team.internal.ui.TeamUIPlugin;

class LocalResourceSaveableComparison$1
  implements IContentChangeListener
{
  final LocalResourceSaveableComparison this$0;
  
  LocalResourceSaveableComparison$1(LocalResourceSaveableComparison paramLocalResourceSaveableComparison)
  {
    this$0 = paramLocalResourceSaveableComparison;
  }
  
  public void contentChanged(IContentChangeNotifier source)
  {
    try
    {
      if (!LocalResourceSaveableComparison.access$0(this$0)) {
        this$0.performSave(new NullProgressMonitor());
      }
    }
    catch (CoreException e)
    {
      TeamUIPlugin.log(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.LocalResourceSaveableComparison.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.CompareEditorInput;
import org.eclipse.compare.IContentChangeListener;
import org.eclipse.compare.IContentChangeNotifier;
import org.eclipse.compare.ISharedDocumentAdapter;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.SharedDocumentAdapter;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
import org.eclipse.compare.internal.ISavingSaveable;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
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.ui.mapping.SaveableComparison;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.Saveable;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;

public abstract class LocalResourceSaveableComparison
  extends SaveableComparison
  implements IPropertyChangeListener, ISavingSaveable
{
  private final ICompareInput input;
  private final CompareEditorInput editorInput;
  private boolean isSaving;
  private IContentChangeListener contentChangeListener;
  private ITypedElement fileElement;
  private IDocument document;
  
  public LocalResourceSaveableComparison(ICompareInput input, CompareEditorInput editorInput)
  {
    this(input, editorInput, input.getLeft());
  }
  
  public LocalResourceSaveableComparison(ICompareInput input, CompareEditorInput editorInput, ITypedElement fileElement)
  {
    this.input = input;
    this.editorInput = editorInput;
    this.fileElement = fileElement;
    initializeContentChangeListeners();
  }
  
  protected void initializeHashing()
  {
    Object document = getAdapter(IDocument.class);
    if (document != null) {
      this.document = ((IDocument)document);
    }
  }
  
  private void initializeContentChangeListeners()
  {
    ITypedElement te = getFileElement();
    if ((te instanceof IContentChangeNotifier))
    {
      if (contentChangeListener == null) {
        contentChangeListener = new IContentChangeListener()
        {
          public void contentChanged(IContentChangeNotifier source)
          {
            try
            {
              if (!isSaving) {
                performSave(new NullProgressMonitor());
              }
            }
            catch (CoreException e)
            {
              TeamUIPlugin.log(e);
            }
          }
        };
      }
      ((IContentChangeNotifier)te).addContentChangeListener(contentChangeListener);
    }
  }
  
  public void dispose()
  {
    if (contentChangeListener != null)
    {
      ITypedElement te = getFileElement();
      if ((te instanceof IContentChangeNotifier)) {
        ((IContentChangeNotifier)te).removeContentChangeListener(contentChangeListener);
      }
    }
    ITypedElement left = getFileElement();
    if ((left instanceof LocalResourceTypedElement)) {
      ((LocalResourceTypedElement)left).discardBuffer();
    }
    document = null;
  }
  
  private ITypedElement getFileElement()
  {
    return fileElement;
  }
  
  /* Error */
  protected void performSave(IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 341	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:checkForUpdateConflicts	()Z
    //   4: ifeq +4 -> 8
    //   7: return
    //   8: aload_0
    //   9: iconst_1
    //   10: putfield 305	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:isSaving	Z
    //   13: aload_1
    //   14: aconst_null
    //   15: bipush 100
    //   17: invokeinterface 370 3 0
    //   22: aload_0
    //   23: aload_1
    //   24: bipush 40
    //   26: invokestatic 335	org/eclipse/team/internal/ui/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   29: invokevirtual 345	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:flushViewers	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   32: aload_0
    //   33: invokespecial 344	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:getFileElement	()Lorg/eclipse/compare/ITypedElement;
    //   36: astore_2
    //   37: aload_2
    //   38: instanceof 174
    //   41: ifeq +46 -> 87
    //   44: aload_2
    //   45: checkcast 174	org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement
    //   48: astore_3
    //   49: aload_3
    //   50: aload_1
    //   51: bipush 60
    //   53: invokestatic 335	org/eclipse/team/internal/ui/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   56: invokevirtual 353	org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement:commit	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   59: goto +28 -> 87
    //   62: astore 4
    //   64: aload_0
    //   65: invokevirtual 339	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:fireInputChange	()V
    //   68: aload_0
    //   69: iconst_0
    //   70: invokevirtual 343	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:setDirty	(Z)V
    //   73: aload_0
    //   74: iconst_0
    //   75: putfield 305	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:isSaving	Z
    //   78: aload_1
    //   79: invokeinterface 369 1 0
    //   84: aload 4
    //   86: athrow
    //   87: aload_0
    //   88: invokevirtual 339	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:fireInputChange	()V
    //   91: aload_0
    //   92: iconst_0
    //   93: invokevirtual 343	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:setDirty	(Z)V
    //   96: aload_0
    //   97: iconst_0
    //   98: putfield 305	org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison:isSaving	Z
    //   101: aload_1
    //   102: invokeinterface 369 1 0
    //   107: return
    // Line number table:
    //   Java source line #125	-> byte code offset #0
    //   Java source line #126	-> byte code offset #7
    //   Java source line #129	-> byte code offset #8
    //   Java source line #130	-> byte code offset #13
    //   Java source line #133	-> byte code offset #22
    //   Java source line #136	-> byte code offset #32
    //   Java source line #137	-> byte code offset #37
    //   Java source line #138	-> byte code offset #44
    //   Java source line #139	-> byte code offset #49
    //   Java source line #141	-> byte code offset #62
    //   Java source line #143	-> byte code offset #64
    //   Java source line #144	-> byte code offset #68
    //   Java source line #145	-> byte code offset #73
    //   Java source line #146	-> byte code offset #78
    //   Java source line #147	-> byte code offset #84
    //   Java source line #143	-> byte code offset #87
    //   Java source line #144	-> byte code offset #91
    //   Java source line #145	-> byte code offset #96
    //   Java source line #146	-> byte code offset #101
    //   Java source line #148	-> byte code offset #107
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	108	0	this	LocalResourceSaveableComparison
    //   0	108	1	monitor	IProgressMonitor
    //   36	9	2	te	ITypedElement
    //   48	2	3	lrte	LocalResourceTypedElement
    //   62	23	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   8	62	62	finally
  }
  
  protected void flushViewers(IProgressMonitor monitor)
    throws CoreException
  {
    if ((editorInput instanceof SaveablesCompareEditorInput)) {
      ((SaveablesCompareEditorInput)editorInput).saveChanges(monitor, this);
    } else {
      editorInput.saveChanges(monitor);
    }
  }
  
  protected abstract void fireInputChange();
  
  private boolean checkForUpdateConflicts()
  {
    if (hasSaveConflict())
    {
      if (Utils.RUNNING_TESTS) {
        return !Utils.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE;
      }
      MessageDialog dialog = 
        new MessageDialog(TeamUIPlugin.getStandardDisplay().getActiveShell(), 
        TeamUIMessages.SyncInfoCompareInput_0, 
        null, 
        TeamUIMessages.SyncInfoCompareInput_1, 
        3, 
        new String[] {
        TeamUIMessages.SyncInfoCompareInput_2, 
        IDialogConstants.CANCEL_LABEL }, 
        0);
      
      int retval = dialog.open();
      switch (retval)
      {
      case 0: 
        return false;
      case 1: 
        return true;
      }
    }
    return false;
  }
  
  private boolean hasSaveConflict()
  {
    ITypedElement left = getFileElement();
    if ((left instanceof LocalResourceTypedElement))
    {
      LocalResourceTypedElement te = (LocalResourceTypedElement)left;
      return !te.isSynchronized();
    }
    return false;
  }
  
  public boolean isDirty()
  {
    if ((editorInput instanceof SaveablesCompareEditorInput)) {
      return ((SaveablesCompareEditorInput)editorInput).isSaveNeeded(this);
    }
    return editorInput.isSaveNeeded();
  }
  
  protected void setDirty(boolean dirty)
  {
    if ((editorInput instanceof SaveablesCompareEditorInput))
    {
      ((SaveablesCompareEditorInput)editorInput).setDirty(dirty, 
        this);
      return;
    }
    editorInput.setDirty(dirty);
  }
  
  protected void performRevert(IProgressMonitor monitor)
  {
    ITypedElement left = getFileElement();
    if ((left instanceof LocalResourceTypedElement)) {
      ((LocalResourceTypedElement)left).discardBuffer();
    }
  }
  
  public String getName()
  {
    if (fileElement.equals(input.getLeft())) {
      return input.getLeft().getName();
    }
    if (fileElement.equals(input.getRight())) {
      return input.getRight().getName();
    }
    return input.getName();
  }
  
  public String getToolTipText()
  {
    return editorInput.getToolTipText();
  }
  
  public ImageDescriptor getImageDescriptor()
  {
    Image image = input.getImage();
    if (image != null) {
      return ImageDescriptor.createFromImage(image);
    }
    return TeamUIPlugin.getImageDescriptor("eview16/synch_synch.gif");
  }
  
  public void propertyChange(PropertyChangeEvent e)
  {
    String propertyName = e.getProperty();
    if ("DIRTY_STATE".equals(propertyName))
    {
      boolean changed = false;
      Object newValue = e.getNewValue();
      if ((newValue instanceof Boolean)) {
        changed = ((Boolean)newValue).booleanValue();
      }
      ContentMergeViewer cmv = (ContentMergeViewer)e.getSource();
      if (fileElement.equals(input.getLeft())) {
        if ((changed) && (cmv.internalIsLeftDirty())) {
          setDirty(changed);
        } else if ((!changed) && (!cmv.internalIsLeftDirty())) {
          setDirty(changed);
        }
      }
      if (fileElement.equals(input.getRight())) {
        if ((changed) && (cmv.internalIsRightDirty())) {
          setDirty(changed);
        } else if ((!changed) && (!cmv.internalIsRightDirty())) {
          setDirty(changed);
        }
      }
    }
  }
  
  public int hashCode()
  {
    if (document != null) {
      return document.hashCode();
    }
    return input.hashCode();
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof Saveable)) {
      return false;
    }
    if (document != null)
    {
      Object otherDocument = ((Saveable)obj).getAdapter(IDocument.class);
      if ((document == null) && (otherDocument == null)) {
        return false;
      }
      return (document != null) && (document.equals(otherDocument));
    }
    if ((obj instanceof LocalResourceSaveableComparison))
    {
      LocalResourceSaveableComparison rscm = (LocalResourceSaveableComparison)obj;
      return input.equals(input);
    }
    return false;
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == IDocument.class)
    {
      if (document != null) {
        return document;
      }
      if ((fileElement instanceof LocalResourceTypedElement))
      {
        LocalResourceTypedElement lrte = (LocalResourceTypedElement)fileElement;
        if (lrte.isConnected())
        {
          ISharedDocumentAdapter sda = (ISharedDocumentAdapter)Utils.getAdapter(lrte, ISharedDocumentAdapter.class);
          if (sda != null)
          {
            IEditorInput input = sda.getDocumentKey(lrte);
            if (input != null)
            {
              IDocumentProvider provider = SharedDocumentAdapter.getDocumentProvider(input);
              if (provider != null) {
                return provider.getDocument(input);
              }
            }
          }
        }
      }
    }
    if ((adapter == IEditorInput.class) && 
      ((fileElement instanceof LocalResourceTypedElement)))
    {
      LocalResourceTypedElement lrte = (LocalResourceTypedElement)fileElement;
      return new FileEditorInput((IFile)lrte.getResource());
    }
    return super.getAdapter(adapter);
  }
  
  public ICompareInput getInput()
  {
    return input;
  }
  
  public boolean isConnectedToSharedDocument()
  {
    if ((fileElement instanceof LocalResourceTypedElement))
    {
      LocalResourceTypedElement lrte = (LocalResourceTypedElement)fileElement;
      return lrte.isConnected();
    }
    return false;
  }
  
  public boolean isSaving()
  {
    return isSaving;
  }
}

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

class LocalResourceTypedElement$1
  implements EditableSharedDocumentAdapter.ISharedDocumentAdapterListener
{
  final LocalResourceTypedElement this$0;
  
  LocalResourceTypedElement$1(LocalResourceTypedElement paramLocalResourceTypedElement)
  {
    this$0 = paramLocalResourceTypedElement;
  }
  
  public void handleDocumentConnected()
  {
    this$0.updateTimestamp();
    if (LocalResourceTypedElement.access$0(this$0) != null) {
      LocalResourceTypedElement.access$0(this$0).handleDocumentConnected();
    }
  }
  
  public void handleDocumentFlushed()
  {
    this$0.fireContentChanged();
    if (LocalResourceTypedElement.access$0(this$0) != null) {
      LocalResourceTypedElement.access$0(this$0).handleDocumentFlushed();
    }
  }
  
  public void handleDocumentDeleted()
  {
    this$0.update();
    if (LocalResourceTypedElement.access$0(this$0) != null) {
      LocalResourceTypedElement.access$0(this$0).handleDocumentDeleted();
    }
  }
  
  public void handleDocumentSaved()
  {
    this$0.updateTimestamp();
    if (LocalResourceTypedElement.access$0(this$0) != null) {
      LocalResourceTypedElement.access$0(this$0).handleDocumentSaved();
    }
  }
  
  public void handleDocumentDisconnected()
  {
    if (LocalResourceTypedElement.access$0(this$0) != null) {
      LocalResourceTypedElement.access$0(this$0).handleDocumentDisconnected();
    }
  }
}

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

import java.io.InputStream;
import org.eclipse.compare.ISharedDocumentAdapter;
import org.eclipse.compare.ResourceNode;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.team.core.history.IFileHistoryProvider;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.IEditorInput;

public class LocalResourceTypedElement
  extends ResourceNode
  implements IAdaptable
{
  private boolean fDirty = false;
  private EditableSharedDocumentAdapter sharedDocumentAdapter;
  private long timestamp;
  private boolean exists;
  private boolean useSharedDocument = true;
  private EditableSharedDocumentAdapter.ISharedDocumentAdapterListener sharedDocumentListener;
  private String author;
  
  public LocalResourceTypedElement(IResource resource)
  {
    super(resource);
    exists = resource.exists();
  }
  
  public void setContent(byte[] contents)
  {
    fDirty = true;
    super.setContent(contents);
  }
  
  /* Error */
  public void commit(IProgressMonitor mon
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