Eclipse Platform
Release 3.1

org.eclipse.team.ui.synchronize
Class SyncInfoCompareInput

java.lang.Object
  extended byorg.eclipse.compare.CompareEditorInput
      extended byorg.eclipse.team.ui.synchronize.SyncInfoCompareInput
All Implemented Interfaces:
EventListener, IAdaptable, IEditorInput, IPropertyChangeNotifier, IResourceChangeListener, IRunnableWithProgress

public final class SyncInfoCompareInput
extends CompareEditorInput
implements IResourceChangeListener

A SyncInfo editor input used as input to a two-way or three-way compare viewer. It defines methods for accessing the three sides for the compare, and a name and image which is used when displaying the three way input in an editor. This input can alternately be used to show compare results in a dialog by calling CompareUI.openCompareDialog(org.eclipse.compare.CompareEditorInput).

The editor will not update when the elements in the sync info are changed.

Supports saving the local resource that is changed in the editor and will be updated when the local resources is changed.

This class cannot be subclassed by clients.

Since:
3.0
See Also:
SyncInfo

Field Summary
 
Fields inherited from class org.eclipse.compare.CompareEditorInput
DIRTY_STATE
 
Constructor Summary
SyncInfoCompareInput(ISynchronizeParticipant participant, SyncInfo sync)
          Creates a compare editor input based on an existing SyncInfo from the given participant.
SyncInfoCompareInput(String description, SyncInfo sync)
          Creates a compare editor input based on an existing SyncInfo.
 
Method Summary
 Control createContents(Composite parent)
          Create the SWT controls that are used to display the result of the compare operation.
 boolean equals(Object other)
           
 Object getAdapter(Class adapter)
          Returns an object which is an instance of the given class associated with this object.
 ImageDescriptor getImageDescriptor()
          Returns the image descriptor for this input.
 SyncInfo getSyncInfo()
           
 String getTitle()
          Returns the title which will be used in the compare editor's title bar.
 Image getTitleImage()
          Returns the title image which will be used in the compare editor's title bar.
 String getToolTipText()
          Returns the tool tip text for this editor input.
protected  Object prepareInput(IProgressMonitor monitor)
          Runs the compare operation and returns the compare result.
 void resourceChanged(IResourceChangeEvent event)
          Note that until the compare editor inputs can be part of the compare editors lifecycle we can't register as a listener because there is no dispose() method to remove the listener.
 void saveChanges(IProgressMonitor pm)
          Save any unsaved changes.
 
Methods inherited from class org.eclipse.compare.CompareEditorInput
addPropertyChangeListener, contributeToToolBar, createDiffViewer, createOutlineContents, exists, findContentViewer, findStructureViewer, getCompareConfiguration, getCompareResult, getMessage, getName, getPersistable, isSaveNeeded, removePropertyChangeListener, run, save, setDirty, setFocus, setMessage, setTitle
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncInfoCompareInput

public SyncInfoCompareInput(String description,
                            SyncInfo sync)
Creates a compare editor input based on an existing SyncInfo.

Parameters:
description - a description of the context of this sync info. This is displayed to the user.
sync - the SyncInfo used as the base for the compare input.

SyncInfoCompareInput

public SyncInfoCompareInput(ISynchronizeParticipant participant,
                            SyncInfo sync)
Creates a compare editor input based on an existing SyncInfo from the given participant.

Parameters:
participant - the participant from which the sync info was obtained. The name of the participant is used as the description which is displayed to the user.
sync - the SyncInfo used as the base for the compare input.
Since:
3.1
Method Detail

createContents

public Control createContents(Composite parent)
Description copied from class: CompareEditorInput
Create the SWT controls that are used to display the result of the compare operation. Creates the SWT Controls and sets up the wiring between the individual panes. This implementation creates all four panes but makes only the necessary ones visible. Finally it feeds the compare result into the top left structure viewer and the content viewer.

Subclasses may override if they need to change the layout or wiring between panes.

Overrides:
createContents in class CompareEditorInput
Parameters:
parent - the parent control under which the control must be created
Returns:
the SWT control hierarchy for the compare editor

getAdapter

public Object getAdapter(Class adapter)
Description copied from interface: IAdaptable
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class CompareEditorInput

resourceChanged

public void resourceChanged(IResourceChangeEvent event)
Note that until the compare editor inputs can be part of the compare editors lifecycle we can't register as a listener because there is no dispose() method to remove the listener.

Specified by:
resourceChanged in interface IResourceChangeListener
Parameters:
event - the resource change event
See Also:
IResourceDelta

getTitleImage

public Image getTitleImage()
Description copied from class: CompareEditorInput
Returns the title image which will be used in the compare editor's title bar. Returns the title image which will be used when presenting the compare result. This implementation returns a generic compare icon. Subclasses can override.

Overrides:
getTitleImage in class CompareEditorInput
Returns:
the title image, or null if none

prepareInput

protected Object prepareInput(IProgressMonitor monitor)
                       throws InvocationTargetException,
                              InterruptedException
Description copied from class: CompareEditorInput
Runs the compare operation and returns the compare result. If null is returned no differences were found and no compare editor needs to be opened. Progress should be reported to the given progress monitor. A request to cancel the operation should be honored and acknowledged by throwing InterruptedException.

Note: this method is typically called in a modal context thread which doesn't have a Display assigned. Implementors of this method shouldn't therefore allocated any SWT resources in this method.

Specified by:
prepareInput in class CompareEditorInput
Parameters:
monitor - the progress monitor to use to display progress and receive requests for cancelation
Returns:
the result of the compare operation, or null if there are no differences
Throws:
InterruptedException - if the operation detects a request to cancel, using IProgressMonitor.isCanceled(), it should exit by throwing InterruptedException
InvocationTargetException - if the prepareInput method must propagate a checked exception, it should wrap it inside an InvocationTargetException; runtime exceptions are automatically wrapped in an InvocationTargetException by the calling context

getTitle

public String getTitle()
Description copied from class: CompareEditorInput
Returns the title which will be used in the compare editor's title bar. It can be set with setTitle.

Overrides:
getTitle in class CompareEditorInput
Returns:
the title

getImageDescriptor

public ImageDescriptor getImageDescriptor()
Description copied from interface: IEditorInput
Returns the image descriptor for this input.

Note: although a null return value has never been permitted from this method, there are many known buggy implementations that return null. Clients that need the image for an editor are advised to use IWorkbenchPart.getImage() instead of IEditorInput.getImageDescriptor(), or to recover from a null return value in a manner that records the ID of the problematic editor input. Implementors that have been returning null from this method should pick some other default return value (such as ImageDescriptor.getMissingImageDescriptor()).

Specified by:
getImageDescriptor in interface IEditorInput
Overrides:
getImageDescriptor in class CompareEditorInput

getToolTipText

public String getToolTipText()
Description copied from interface: IEditorInput
Returns the tool tip text for this editor input. This text is used to differentiate between two input with the same name. For instance, MyClass.java in folder X and MyClass.java in folder Y. The format of the text varies between input types.

Specified by:
getToolTipText in interface IEditorInput
Overrides:
getToolTipText in class CompareEditorInput

equals

public boolean equals(Object other)

saveChanges

public void saveChanges(IProgressMonitor pm)
                 throws CoreException
Description copied from class: CompareEditorInput
Save any unsaved changes. Subclasses must override to save any changes. This implementation tries to flush changes in all viewers by calling ISavable.save on them.

Overrides:
saveChanges in class CompareEditorInput
Parameters:
pm - an IProgressMonitor that the implementation of save may use to show progress
Throws:
CoreException

getSyncInfo

public SyncInfo getSyncInfo()

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.