- All Implemented Interfaces:
- Direct Known Subclasses:
Saveableto manage the save lifecycle of the editor input. If the element returned from
createFileElement(IFile)is used as the left side of the compare input and the default saveable returned from
createSaveable()is used, then this compare input will provide the complete save lifecycle for the local file.
Clients may subclass this class.
Method SummaryModifier and TypeMethodDescription
voidRegister for change events for the given compare input.
booleanReturns whether this compare editor input can be run as a job.
(boolean checkForUnsavedChanges)Close the editor if it is not dirty.
protected voidCallback that occurs after the control for the input has been created.
static ITypedElementReturns a typed element that represents a local file.
protected SaveableCreate the saveable that provides the save behavior for this compare editor input.Implements the dynamic viewer switching for content viewers.
protected abstract voidCallback from the resource saveable that is invoked when the resource is saved so that this input can fire a change event for its input.
SaveableReturns the saveables currently active in the workbench part.
<T> TReturns an object which is an instance of the given class associated with this object.
protected final ICompareInputReturns the compare input of this editor input.Returns the image descriptor for this input.
protected SaveableGet the saveable that provides the save behavior for this compare editor input.
SaveableReturns the saveables presented by the workbench part.Returns the title image which will be used in the compare editor's title bar.
protected voidCallback that occurs when the UI associated with this compare editor input is disposed.
trueif there are unsaved changes.
protected abstract ICompareInputMethod called from
prepareInput(IProgressMonitor)to obtain the input.
protected ObjectPrepares the compare input of this editor input.
voidRegister the content menu with the container to give the container a chance to add additional items to the context menu such as popup menu object contributions.
voidRemove the change listener from the given compare input.
Methods inherited from class org.eclipse.compare.CompareEditorInput
addPropertyChangeListener, belongsTo, cancelPressed, contributeToToolBar, createContents, createContentViewerSwitchingPane, createDiffViewer, createOutlineContents, createStructureInputPane, exists, findStructureViewer, firePropertyChange, flushLeftViewers, flushRightViewers, flushViewers, getActionBars, getCancelButtonLabel, getCompareConfiguration, getCompareResult, getContainer, getContentViewerDescriptor, getMessage, getName, getNavigator, getOKButtonLabel, getPersistable, getSelectedEdition, getServiceLocator, getStructureViewerDescriptor, getTitle, getToolTipText, getWorkbenchPart, isEditionSelectionDialog, isLeftSaveNeeded, isRightSaveNeeded, isSaveNeeded, okPressed, removePropertyChangeListener, run, run, runAsynchronously, save, saveChanges, setContainer, setContentViewerDescriptor, setDirty, setFocus, setFocus2, setHelpContextId, setLeftDirty, setMessage, setRightDirty, setStatusMessage, setStructureViewerDescriptor, setTitle
LocalResourceCompareEditorInputwhich is initialized with the given compare configuration. The compare configuration is passed to subsequently created viewers.
configuration- the compare configuration
page- the workbench page that will contain the editor
createFileElementReturns a typed element that represents a local file. If the element returned from this method is used as the left contributor of the compare input for a
SaveableCompareEditorInput, then the file will be properly saved when the compare editor input or viewers are saved.
file- the file
- a typed element that represents a local file.
contentsCreatedprotected void contentsCreated()Callback that occurs after the control for the input has been created. If this method gets invoked then
CompareEditorInput.handleDispose()will be invoked when the control is disposed. Subclasses may extend this method to register any listeners that need to be de-registered when the input is disposed.
handleDisposeprotected void handleDispose()Callback that occurs when the UI associated with this compare editor input is disposed. This method will only be invoked if the UI has been created (i.e. after the call to
CompareEditorInput.createContents(Composite). Subclasses can extend this method but ensure that the overridden method is invoked.
prepareInputprotected Object prepareInput
(IProgressMonitor monitor) throws InvocationTargetException, InterruptedExceptionPrepares the compare input of this editor input. This method is not intended to be overridden of extended by subclasses (but is not final for backwards compatibility reasons). The implementation of this method in this class delegates the creation of the compare input to the
prepareCompareInput(IProgressMonitor)method which subclasses must implement.
- Specified by:
monitor- the progress monitor to use to display progress and receive requests for cancellation
- the result of the compare operation, or
nullif there are no differences
InvocationTargetException- if the
prepareInputmethod must propagate a checked exception, it should wrap it inside an
InvocationTargetException; runtime exceptions are automatically wrapped in an
InvocationTargetExceptionby the calling context
InterruptedException- if the operation detects a request to cancel, using
IProgressMonitor.isCanceled(), it should exit by throwing
- See Also:
prepareCompareInputprotected abstract ICompareInput prepareCompareInput
(IProgressMonitor monitor) throws InvocationTargetException, InterruptedExceptionMethod called from
prepareInput(IProgressMonitor)to obtain the input. Its purpose is to ensure that the input is an instance of
getCompareInputprotected final ICompareInput getCompareInput()Returns the compare input of this editor input.
- the compare input of this editor input
fireInputChangeprotected abstract void fireInputChange()Callback from the resource saveable that is invoked when the resource is saved so that this input can fire a change event for its input. Subclasses only need this method if the left side of their compare input is an element returned from
closeEditorprotected boolean closeEditor
(boolean checkForUnsavedChanges)Close the editor if it is not dirty. If it is still dirty, let the content merge viewer handle the compare input change.
checkForUnsavedChanges- whether to check for unsaved changes
trueif the editor was closed (note that the close may be asynchronous)
getSaveableprotected Saveable getSaveable()Get the saveable that provides the save behavior for this compare editor input. The
createSaveable()is called to create the saveable if it does not yet exist. This method cannot be called until after the input is prepared (i.e. until after the
CompareEditorInput.run(IProgressMonitor)method is called which will in turn will invoke
- saveable that provides the save behavior for this compare editor input.
createSaveableprotected Saveable createSaveable()Create the saveable that provides the save behavior for this compare editor input. By default, a saveable that handles local files is returned.
- the saveable that provides the save behavior for this compare editor input
getActiveSaveablespublic Saveable getActiveSaveables()Description copied from interface:
ISaveablesSourceReturns the saveables currently active in the workbench part.
Certain workbench actions, such as Save, target only the active saveables in the active part. For example, the active saveables could be determined based on the current selection in the part.
getSaveablespublic Saveable getSaveables()Description copied from interface:
ISaveablesSourceReturns the saveables presented by the workbench part. If the return value of this method changes during the lifetime of this part (i.e. after initialization and control creation but before disposal) the part must notify an implicit listener using
Additions of saveables to the list of saveables of this part are announced using an event of type
SaveablesLifecycleEvent.POST_OPEN. Removals are announced in a two-stage process, first using an event of type
SaveablesLifecycleEvent.PRE_CLOSEfollowed by an event of type
SaveablesLifecycleEvent.POST_CLOSE. Since firing the
PRE_CLOSEevent may trigger prompts to save dirty saveables, the cancellation status of the event must be checked by the part after the notification. When removing only non-dirty saveables,
POST_CLOSEnotification is sufficient.
The listener is obtained from the part site by calling
The part must not notify from its initialization methods (e.g.
createPartControl), or from its dispose method. Parts that implement
IReusableEditormust notify when their input is changed through
addCompareInputChangeListenerpublic void addCompareInputChangeListener
(ICompareInput input, ICompareInputChangeListener listener)Register for change events for the given compare input. Although clients can register with the compare input directly, registering through the container allows for deterministic and optimized behavior in some cases. Registering multiple times for the same compare input has no effect.
removeCompareInputChangeListenerpublic void removeCompareInputChangeListener
(ICompareInput input, ICompareInputChangeListener listener)Remove the change listener from the given compare input. Removing a listener that is not registered has no effect.
getAdapterpublic <T> T getAdapter
(Class<T> adapter)Description copied from class:
PlatformObjectReturns an object which is an instance of the given class associated with this object. Returns
nullif no such object can be found.
This implementation of the method declared by
IAdaptablepasses the request along to the platform's adapter manager; roughly
Platform.getAdapterManager().getAdapter(this, adapter). Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).
getTitleImagepublic Image getTitleImage()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.
getImageDescriptorpublic ImageDescriptor getImageDescriptor()Description copied from interface:
IEditorInputReturns 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()).
findContentViewerImplements the dynamic viewer switching for content viewers. The method must return a compare viewer based on the old (or current) viewer and a new input object. If the old viewer is suitable for showing the new input the old viewer can be returned. Otherwise a new viewer must be created under the given parent composite or
nullcan be returned to indicate that no viewer could be found.
This implementation forwards the request to
Subclasses may override to implement a different strategy.
oldViewer- a new viewer is only created if this old viewer cannot show the given input
input- the input object for which to find a structure viewer
parent- the SWT parent composite under which the new viewer is created
- a compare viewer which is suitable for the given input object or
canRunAsJobpublic boolean canRunAsJob()Returns whether this compare editor input can be run as a job. By default,
falseis returned since traditionally inputs were prepared in the foreground (i.e the UI was blocked when the
CompareEditorInput.run(IProgressMonitor)method (and indirectly the
CompareEditorInput.prepareInput(IProgressMonitor)method) was invoked. Subclasses may override.
isDirtypublic boolean isDirty()Returns
trueif there are unsaved changes. The method should be called by any parts or dialogs that contain the input. By default, this method calls
CompareEditorInput.isSaveNeeded()but subclasses may extend.
registerContextMenuRegister the content menu with the container to give the container a chance to add additional items to the context menu such as popup menu object contributions. The provided menu should have a
IWorkbenchActionConstants.MB_ADDITIONSseparator as this is where the container will add actions.