|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.core.runtime.PlatformObject
org.eclipse.compare.CompareEditorInput
org.eclipse.team.ui.synchronize.SaveableCompareEditorInput
public abstract class SaveableCompareEditorInput
A compare editor input that makes use of a Saveable to 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.
| Field Summary |
|---|
| Fields inherited from class org.eclipse.compare.CompareEditorInput |
|---|
DIRTY_STATE, PROP_SELECTED_EDITION, PROP_TITLE, PROP_TITLE_IMAGE |
| Constructor Summary | |
|---|---|
SaveableCompareEditorInput(CompareConfiguration configuration,
IWorkbenchPage page)
Creates a LocalResourceCompareEditorInput which is initialized with the given
compare configuration. |
|
| Method Summary | |
|---|---|
void |
addCompareInputChangeListener(ICompareInput input,
ICompareInputChangeListener listener)
Register for change events for the given compare input. |
boolean |
canRunAsJob()
Return whether this compare editor input can be run as a job. |
protected boolean |
closeEditor(boolean checkForUnsavedChanges)
Close the editor if it is not dirty. |
protected void |
contentsCreated()
Callback that occurs after the control for the input has been created. |
static ITypedElement |
createFileElement(IFile file)
Return a typed element that represents a local file. |
protected Saveable |
createSaveable()
Create the saveable that provides the save behavior for this compare editor input. |
Viewer |
findContentViewer(Viewer oldViewer,
ICompareInput input,
Composite parent)
Implements the dynamic viewer switching for content viewers. |
protected 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. |
Saveable[] |
getActiveSaveables()
Returns the saveables currently active in the workbench part. |
java.lang.Object |
getAdapter(java.lang.Class adapter)
Returns an object which is an instance of the given class associated with this object. |
protected ICompareInput |
getCompareInput()
Return the compare input of this editor input. |
ImageDescriptor |
getImageDescriptor()
Returns the image descriptor for this input. |
protected Saveable |
getSaveable()
Get the saveable that provides the save behavior for this compare editor input. |
Saveable[] |
getSaveables()
Returns the saveables presented by the workbench part. |
Image |
getTitleImage()
Returns the title image which will be used in the compare editor's title bar. |
protected void |
handleDispose()
Callback that occurs when the UI associated with this compare editor input is disposed. |
boolean |
isDirty()
Returns true if there are unsaved changes. |
protected abstract ICompareInput |
prepareCompareInput(IProgressMonitor monitor)
Method called from prepareInput(IProgressMonitor) to obtain the input. |
protected java.lang.Object |
prepareInput(IProgressMonitor monitor)
Prepare the compare input of this editor input. |
void |
registerContextMenu(MenuManager menu,
ISelectionProvider selectionProvider)
Register 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. |
void |
removeCompareInputChangeListener(ICompareInput input,
ICompareInputChangeListener listener)
Remove the change listener from the given compare input. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SaveableCompareEditorInput(CompareConfiguration configuration,
IWorkbenchPage page)
LocalResourceCompareEditorInput which is initialized with the given
compare configuration.
The compare configuration is passed to subsequently created viewers.
configuration - the compare configurationpage - the workbench page that will contain the editor| Method Detail |
|---|
public static ITypedElement createFileElement(IFile file)
SaveableCompareEditorInput, then the file will
be properly saved when the compare editor input or viewers are saved.
file - the file
protected void contentsCreated()
CompareEditorInputCompareEditorInput.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.
contentsCreated in class CompareEditorInputprotected void handleDispose()
CompareEditorInputCompareEditorInput.createContents(Composite).
Subclasses can extend this method but ensure that the overridden method
is invoked.
handleDispose in class CompareEditorInput
protected java.lang.Object prepareInput(IProgressMonitor monitor)
throws java.lang.reflect.InvocationTargetException,
java.lang.InterruptedException
prepareCompareInput(IProgressMonitor)
method which subclasses must implement.
prepareInput in class CompareEditorInputmonitor - the progress monitor to use to display progress and receive
requests for cancelation
null if there are no differences
java.lang.reflect.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
java.lang.InterruptedException - if the operation detects a request to cancel,
using IProgressMonitor.isCanceled(), it should exit by throwing
InterruptedExceptionCompareEditorInput.prepareInput(org.eclipse.core.runtime.IProgressMonitor)
protected abstract ICompareInput prepareCompareInput(IProgressMonitor monitor)
throws java.lang.reflect.InvocationTargetException,
java.lang.InterruptedException
prepareInput(IProgressMonitor) to obtain the input.
It's purpose is to ensure that the input is an instance of ICompareInput.
monitor - a progress monitor
java.lang.reflect.InvocationTargetException
java.lang.InterruptedExceptionprotected final ICompareInput getCompareInput()
protected abstract void fireInputChange()
createFileElement(IFile).
protected boolean closeEditor(boolean checkForUnsavedChanges)
checkForUnsavedChanges - whether to check for unsaved changes
true if the editor was closed (note that the
close may be asynchronous)protected Saveable getSaveable()
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
prepareCompareInput(IProgressMonitor).
protected Saveable createSaveable()
public Saveable[] getActiveSaveables()
ISaveablesSourceCertain 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.
getActiveSaveables in interface ISaveablesSourcepublic Saveable[] getSaveables()
ISaveablesSourceISaveablesLifecycleListener.handleLifecycleEvent(SaveablesLifecycleEvent).
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_CLOSE followed by an event of type
SaveablesLifecycleEvent.POST_CLOSE. Since firing the
PRE_CLOSE event 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_CLOSE notification is sufficient.
The listener is obtained from the part site by calling
partSite.getService(ISaveablesLifecycleListener.class).
The part must not notify from its initialization methods (e.g. init
or createPartControl), or from its dispose method. Parts that
implement IReusableEditor must notify when their input is changed
through IReusableEditor.setInput(IEditorInput).
getSaveables in interface ISaveablesSourceISaveablesLifecycleListener
public void addCompareInputChangeListener(ICompareInput input,
ICompareInputChangeListener listener)
ICompareContainer
addCompareInputChangeListener in interface ICompareContaineraddCompareInputChangeListener in class CompareEditorInputinput - the compare inputlistener - the compare input change listener
public void removeCompareInputChangeListener(ICompareInput input,
ICompareInputChangeListener listener)
ICompareContainer
removeCompareInputChangeListener in interface ICompareContainerremoveCompareInputChangeListener in class CompareEditorInputinput - the compare inputlistener - the compare input change listenerpublic java.lang.Object getAdapter(java.lang.Class adapter)
PlatformObjectnull if
no such object can be found.
This implementation of the method declared by IAdaptable
passes 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).
getAdapter in interface IAdaptablegetAdapter in class CompareEditorInputadapter - the class to adapt to
nullIAdaptable.getAdapter(Class)public Image getTitleImage()
CompareEditorInput
getTitleImage in class CompareEditorInputnull if nonepublic ImageDescriptor getImageDescriptor()
IEditorInputNote: 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()).
getImageDescriptor in interface IEditorInputgetImageDescriptor in class CompareEditorInputnull if
there is no image.
public Viewer findContentViewer(Viewer oldViewer,
ICompareInput input,
Composite parent)
CompareEditorInputnull can be returned to indicate that no viewer could be found.
This implementation forwards the request to CompareUI.findContentViewer.
Subclasses may override to implement a different strategy.
findContentViewer in class CompareEditorInputoldViewer - a new viewer is only created if this old viewer cannot show the given inputinput - the input object for which to find a structure viewerparent - the SWT parent composite under which the new viewer is created
nullpublic boolean canRunAsJob()
CompareEditorInputfalse is 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.
canRunAsJob in class CompareEditorInputpublic boolean isDirty()
CompareEditorInputtrue if 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.
isDirty in class CompareEditorInputtrue if there are unsaved changes
public void registerContextMenu(MenuManager menu,
ISelectionProvider selectionProvider)
ICompareContainerIWorkbenchActionConstants.MB_ADDITIONS
separator as this is where the container will add actions.
registerContextMenu in interface ICompareContainerregisterContextMenu in class CompareEditorInputmenu - the menu being registeredselectionProvider - the selection provider
|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.