Class CompareEditorInput
- java.lang.Object
-
- org.eclipse.core.runtime.PlatformObject
-
- org.eclipse.compare.CompareEditorInput
-
- All Implemented Interfaces:
ICompareContainer
,IPropertyChangeNotifier
,IAdaptable
,IRunnableContext
,IRunnableWithProgress
,IEditorInput
- Direct Known Subclasses:
PageCompareEditorInput
,SaveableCompareEditorInput
public abstract class CompareEditorInput extends PlatformObject implements IEditorInput, IPropertyChangeNotifier, IRunnableWithProgress, ICompareContainer
A compare operation which can present its results in a special editor. Running the compare operation and presenting the results in a compare editor are combined in one class because it allows a client to keep the implementation all in one place while separating it from the innards of a specific UI implementation of compare/merge.A
CompareEditorInput
defines methods for the following sequence steps:- running a lengthy compare operation under progress monitor control,
- creating a UI for displaying the model and initializing the some widgets with the compare result,
- tracking the dirty state of the model in case of merge,
- saving the model.
openCompareEditor
method takes anCompareEditorInput
and starts sequencing through the above steps. If the compare result is not empty a new compare editor is opened and takes over the sequence until eventually closed.The
prepareInput
method should contain the code of the compare operation. It is executed under control of a progress monitor and can be canceled. If the result of the compare is not empty, that is if there are differences that needs to be presented, theICompareInput
should hold onto them and return them with thegetCompareResult
method. If the value returned fromgetCompareResult
is notnull
a compare editor is opened on theICompareInput
with title and title image initialized by the corresponding methods of theICompareInput
.Creation of the editor's SWT controls is delegated to the
createContents
method. Here the SWT controls must be created and initialized with the result of the compare operation.If merging is allowed, the modification state of the compared constituents must be tracked and the dirty state returned from method
isSaveNeeded
. The valuetrue
triggers a subsequent call tosave
where the modified resources can be saved.The most important part of this implementation is the setup of the compare/merge UI. The UI uses a simple browser metaphor to present compare results. The top half of the layout shows the structural compare results (e.g. added, deleted, and changed files), the bottom half the content compare results (e.g. textual differences between two files). A selection in the top pane is fed to the bottom pane. If a content viewer is registered for the type of the selected object, this viewer is installed in the pane. In addition if a structure viewer is registered for the selection type the top pane is split vertically to make room for another pane and the structure viewer is installed in it. When comparing Java files this second structure viewer would show the structural differences within a Java file, e.g. added, deleted or changed methods and fields.
Subclasses provide custom setups, e.g. for a Catch-up/Release operation by passing a subclass of
CompareConfiguration
and by implementing theprepareInput
method. If a subclass cannot use theDiffTreeViewer
which is installed by default in the top left pane, methodcreateDiffViewer
can be overridden.If subclasses of this class implement
ISaveablesSource
, the compare editor will pass these models through to the workbench. The editor will still show the dirty indicator if one of these underlying models is dirty. It is the responsibility of subclasses that implement this interface to callsetDirty(boolean)
when the dirty state of any of the models managed by the subclass change dirty state.- See Also:
CompareUI
,CompareEditorInput
-
-
Field Summary
Fields Modifier and Type Field Description static String
DIRTY_STATE
The name of the "dirty" property (value"DIRTY_STATE"
).static String
PROP_SELECTED_EDITION
The name of the "selected edition" property.static String
PROP_TITLE
The name of the "title" property.static String
PROP_TITLE_IMAGE
The name of the "title image" property.
-
Constructor Summary
Constructors Constructor Description CompareEditorInput(CompareConfiguration configuration)
Creates aCompareEditorInput
which is initialized with the given compare configuration.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addCompareInputChangeListener(ICompareInput input, ICompareInputChangeListener listener)
Register for change events for the given compare input.void
addPropertyChangeListener(IPropertyChangeListener listener)
Adds a listener for property changes to this notifier.boolean
belongsTo(Object family)
Returns whether this input belongs to the given family when it is run as a job.void
cancelPressed()
TheCANCEL
button was pressed in a dialog.boolean
canRunAsJob()
Returns whether this compare editor input can be run as a job.protected void
contentsCreated()
Callback that occurs after the control for the input has been created.void
contributeToToolBar(ToolBarManager toolBarManager)
Adds standard actions to the givenToolBarManager
.Control
createContents(Composite parent)
Creates the SWT controls that are used to display the result of the compare operation.protected CompareViewerSwitchingPane
createContentViewerSwitchingPane(Splitter parent, int style, CompareEditorInput cei)
Viewer
createDiffViewer(Composite parent)
Factory method for creating a differences viewer for the top left pane.Control
createOutlineContents(Composite parent, int direction)
protected CompareViewerPane
createStructureInputPane(Composite parent)
Create the pane that will contain the structure input pane (upper left).boolean
exists()
Returnsfalse
to indicate that this input should not appear in the "File Most Recently Used" menu.Viewer
findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent)
Implements the dynamic viewer switching for content viewers.Viewer
findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent)
Implements the dynamic viewer switching for structure viewers.protected void
firePropertyChange(PropertyChangeEvent event)
Fires the given property change event to all listeners registered with this compare editor input.protected void
flushLeftViewers(IProgressMonitor monitor)
protected void
flushRightViewers(IProgressMonitor monitor)
protected void
flushViewers(IProgressMonitor monitor)
Flushes the viewer contents into the input.IActionBars
getActionBars()
Return the action bars for the container ornull
if the container does not have an action bars.<T> T
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.String
getCancelButtonLabel()
Returns the label used for theCANCEL
button when this input is shown in a compare dialog usingCompareUI.openCompareDialog(CompareEditorInput)
.CompareConfiguration
getCompareConfiguration()
Returns the configuration object for the viewers within the compare editor.Object
getCompareResult()
Returns the compare result computed by the most recent call to therun
method.ICompareContainer
getContainer()
Returns the container of this input ornull
if there is no container set.org.eclipse.compare.internal.ViewerDescriptor
getContentViewerDescriptor()
ImageDescriptor
getImageDescriptor()
Returns the image descriptor for this input.String
getMessage()
String
getName()
Returns the name of this editor input for display purposes.ICompareNavigator
getNavigator()
Return theICompareNavigator
associated with this container ornull
if the container does not have a global navigator.String
getOKButtonLabel()
Returns the label to be used for theOK
button when this input is displayed in a dialog.IPersistableElement
getPersistable()
Returnsnull
since this editor cannot be persisted.Object
getSelectedEdition()
Returns the selected edition ornull
if no edition is selected.IServiceLocator
getServiceLocator()
Return the service locator for the container ornull
if the container does not have one.org.eclipse.compare.internal.ViewerDescriptor
getStructureViewerDescriptor()
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.IWorkbenchPart
getWorkbenchPart()
Return the workbench part associated with this container ornull
if there is no part or it is not available.protected void
handleDispose()
Callback that occurs when the UI associated with this compare editor input is disposed.boolean
isDirty()
Returnstrue
if there are unsaved changes.boolean
isEditionSelectionDialog()
Returns whether this input is intended to be used to select a particular edition of an element in a dialog.protected boolean
isLeftSaveNeeded()
Returnstrue
if there are unsaved changes for left side.protected boolean
isRightSaveNeeded()
Returnstrue
if there are unsaved changes for right side.boolean
isSaveNeeded()
Returnstrue
if there are unsaved changes in either left or right side.boolean
okPressed()
TheOK
button was pressed in a dialog.protected abstract Object
prepareInput(IProgressMonitor monitor)
Runs the compare operation and returns the compare result.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.void
removePropertyChangeListener(IPropertyChangeListener listener)
Removes the given content change listener from this notifier.void
run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
Runs the givenIRunnableWithProgress
in this context.void
run(IProgressMonitor monitor)
Runs the compare operation and stores the compare result.void
runAsynchronously(IRunnableWithProgress runnable)
Queue the given task to be run asynchronously.void
save(IProgressMonitor pm)
Deprecated.Override method saveChanges instead.void
saveChanges(IProgressMonitor monitor)
Saves any unsaved changes.void
setContainer(ICompareContainer container)
Sets the container of this input to the given containervoid
setContentViewerDescriptor(org.eclipse.compare.internal.ViewerDescriptor vd)
void
setDirty(boolean dirty)
Sets the dirty state of this input to the given value and sends out aPropertyChangeEvent
if the new value differs from the old value.void
setFocus()
Deprecated.Please usesetFocus2()
instead.boolean
setFocus2()
Asks this input to take focus within its container (editor).void
setHelpContextId(String helpContextId)
Sets the help context id for this input.protected void
setLeftDirty(boolean dirty)
Sets the dirty state of left site of this input to the given value and sends out aPropertyChangeEvent
if the new value for whole input differs from the old value.protected void
setMessage(String message)
protected void
setRightDirty(boolean dirty)
Sets the dirty state of right site of this input to the given value and sends out aPropertyChangeEvent
if the new value for whole input differs from the old value.void
setStatusMessage(String message)
Set the status message displayed by the container to the given messagevoid
setStructureViewerDescriptor(org.eclipse.compare.internal.ViewerDescriptor vd)
void
setTitle(String title)
Sets the title which will be used when presenting the compare result.
-
-
-
Field Detail
-
DIRTY_STATE
public static final String DIRTY_STATE
The name of the "dirty" property (value"DIRTY_STATE"
).- See Also:
- Constant Field Values
-
PROP_TITLE
public static final String PROP_TITLE
The name of the "title" property. This property is fired when the title of the compare input changes. Clients should also re-obtain the tool tip when this property changes.- Since:
- 3.3
- See Also:
getTitle()
-
PROP_TITLE_IMAGE
public static final String PROP_TITLE_IMAGE
The name of the "title image" property. This property is fired when the title image of the compare input changes.- Since:
- 3.3
- See Also:
getTitleImage()
-
PROP_SELECTED_EDITION
public static final String PROP_SELECTED_EDITION
The name of the "selected edition" property. This property is fired when the selected edition of the compare input changes.- Since:
- 3.3
- See Also:
isEditionSelectionDialog()
,getSelectedEdition()
-
-
Constructor Detail
-
CompareEditorInput
public CompareEditorInput(CompareConfiguration configuration)
Creates aCompareEditorInput
which is initialized with the given compare configuration. The compare configuration is passed to subsequently created viewers.- Parameters:
configuration
- the compare configuration
-
-
Method Detail
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from class:PlatformObject
Returns an object which is an instance of the given class associated with this object. Returnsnull
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; roughlyPlatform.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).- Specified by:
getAdapter
in interfaceIAdaptable
- Overrides:
getAdapter
in classPlatformObject
- Type Parameters:
T
- the class type- Parameters:
adapter
- the class to adapt to- Returns:
- the adapted object or
null
- See Also:
IAdaptable.getAdapter(Class)
-
getNavigator
public ICompareNavigator getNavigator()
Description copied from interface:ICompareContainer
Return theICompareNavigator
associated with this container ornull
if the container does not have a global navigator.- Specified by:
getNavigator
in interfaceICompareContainer
- Returns:
- the
ICompareNavigator
associated with this container ornull
-
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 interfaceIEditorInput
- Returns:
- the image descriptor for this input; may be
null
if there is no image.
-
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 interfaceIEditorInput
- Returns:
- the tool tip text; never
null
.
-
getName
public String getName()
Description copied from interface:IEditorInput
Returns the name of this editor input for display purposes.For instance, when the input is from a file, the return value would ordinarily be just the file name.
- Specified by:
getName
in interfaceIEditorInput
- Returns:
- the name string; never
null
;
-
getPersistable
public IPersistableElement getPersistable()
Returnsnull
since this editor cannot be persisted.- Specified by:
getPersistable
in interfaceIEditorInput
- Returns:
null
because this editor cannot be persisted
-
exists
public boolean exists()
Returnsfalse
to indicate that this input should not appear in the "File Most Recently Used" menu.- Specified by:
exists
in interfaceIEditorInput
- Returns:
false
-
setMessage
protected void setMessage(String message)
-
getMessage
public String getMessage()
-
getTitle
public String getTitle()
Returns the title which will be used in the compare editor's title bar. It can be set withsetTitle
.- Returns:
- the title
-
setTitle
public void setTitle(String title)
Sets the title which will be used when presenting the compare result. This method must be called before the editor is opened.- Parameters:
title
- the title to use for the CompareEditor
-
getTitleImage
public 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.- Returns:
- the title image, or
null
if none
-
getCompareConfiguration
public CompareConfiguration getCompareConfiguration()
Returns the configuration object for the viewers within the compare editor. Returns the configuration which was passed to the constructor.- Returns:
- the compare configuration
-
contributeToToolBar
public void contributeToToolBar(ToolBarManager toolBarManager)
Adds standard actions to the givenToolBarManager
.Subclasses may override to add their own actions.
- Parameters:
toolBarManager
- theToolBarManager
to which to contribute
-
run
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException
Runs the compare operation and stores the compare result.- Specified by:
run
in interfaceIRunnableWithProgress
- Parameters:
monitor
- the progress monitor to use to display progress and receive requests for cancellation- Throws:
InvocationTargetException
- if theprepareInput
method must propagate a checked exception, it should wrap it inside anInvocationTargetException
; runtime exceptions are automatically wrapped in anInvocationTargetException
by the calling contextInterruptedException
- if the operation detects a request to cancel, usingIProgressMonitor.isCanceled()
, it should exit by throwingInterruptedException
- See Also:
IRunnableContext.run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
-
prepareInput
protected abstract Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
Runs the compare operation and returns the compare result. Ifnull
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 throwingInterruptedException
.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.
- Parameters:
monitor
- the progress monitor to use to display progress and receive requests for cancellation- Returns:
- the result of the compare operation, or
null
if there are no differences - Throws:
InvocationTargetException
- if theprepareInput
method must propagate a checked exception, it should wrap it inside anInvocationTargetException
; runtime exceptions are automatically wrapped in anInvocationTargetException
by the calling contextInterruptedException
- if the operation detects a request to cancel, usingIProgressMonitor.isCanceled()
, it should exit by throwingInterruptedException
-
getCompareResult
public Object getCompareResult()
Returns the compare result computed by the most recent call to therun
method. Returnsnull
if no differences were found.- Returns:
- the compare result prepared in method
prepareInput
ornull
if there were no differences
-
createContents
public Control createContents(Composite parent)
Creates 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.
- Parameters:
parent
- the parent control under which the control must be created- Returns:
- the SWT control hierarchy for the compare editor
-
createContentViewerSwitchingPane
protected CompareViewerSwitchingPane createContentViewerSwitchingPane(Splitter parent, int style, CompareEditorInput cei)
- Parameters:
parent
- the parent control under which the control must be createdstyle
- the style of widget to constructcei
- the compare editor input for the viewer- Returns:
- the pane displaying content changes
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
handleDispose
protected 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 tocreateContents(Composite)
. Subclasses can extend this method but ensure that the overridden method is invoked.- Since:
- 3.3
-
contentsCreated
protected void contentsCreated()
Callback that occurs after the control for the input has been created. If this method gets invoked thenhandleDispose()
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.- Since:
- 3.3
-
createOutlineContents
public Control createOutlineContents(Composite parent, int direction)
- Parameters:
parent
- the parent control under which the control must be createddirection
- the layout direction of the contents, eitherSWT.HORIZONTAL
orSWT.VERTICAL
- Returns:
- the SWT control hierarchy for the outline part of the compare editor
- Since:
- 3.0
-
createStructureInputPane
protected CompareViewerPane createStructureInputPane(Composite parent)
Create the pane that will contain the structure input pane (upper left). By default, aCompareViewerSwitchingPane
is returned. Subclasses may override to provide an alternate pane.- Parameters:
parent
- the parent composite- Returns:
- the structure input pane
- Since:
- 3.3
-
setFocus
@Deprecated public void setFocus()
Deprecated.Please usesetFocus2()
instead.Asks this input to take focus within its container (editor).- Restriction:
- Clients should not call this method but they may override if they implement a different layout with different visual components. Clients are free to call the inherited method.
-
setFocus2
public boolean setFocus2()
Asks this input to take focus within its container (editor).- Returns:
true
if the input got focus, andfalse
if it was unable to.- Since:
- 3.5
- Restriction:
- Clients should not call this method but they may override if they implement a different layout with different visual components. Clients are free to call the inherited method.
-
createDiffViewer
public Viewer createDiffViewer(Composite parent)
Factory method for creating a differences viewer for the top left pane. It is called fromcreateContents
and returns aDiffTreeViewer
.Subclasses may override if they need a different viewer.
- Parameters:
parent
- the SWT parent control under which to create the viewer's SWT controls- Returns:
- a compare viewer for the top left pane
-
findStructureViewer
public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent)
Implements the dynamic viewer switching for structure 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 ornull
can be returned to indicate that no viewer could be found.This implementation forwards the request to
CompareUI.findStructureViewer
.Subclasses may override to implement a different strategy.
- Parameters:
oldViewer
- 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- Returns:
- a compare viewer which is suitable for the given input object or
null
-
findContentViewer
public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent)
Implements 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 ornull
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.
- Parameters:
oldViewer
- 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- Returns:
- a compare viewer which is suitable for the given input object or
null
-
setContentViewerDescriptor
public void setContentViewerDescriptor(org.eclipse.compare.internal.ViewerDescriptor vd)
- Parameters:
vd
- the content viewer descriptor- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
getContentViewerDescriptor
public org.eclipse.compare.internal.ViewerDescriptor getContentViewerDescriptor()
- Returns:
- the content viewer descriptor set for the input
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
setStructureViewerDescriptor
public void setStructureViewerDescriptor(org.eclipse.compare.internal.ViewerDescriptor vd)
- Parameters:
vd
- the structure viewer descriptor- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
getStructureViewerDescriptor
public org.eclipse.compare.internal.ViewerDescriptor getStructureViewerDescriptor()
- Returns:
- the structure viewer descriptor set for the input
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
isSaveNeeded
public boolean isSaveNeeded()
Returnstrue
if there are unsaved changes in either left or right side. The value returned is the value of theDIRTY_STATE
property of this input object. Returnstrue
if left or right side has unsaved changes Subclasses don't have to override if the functionality provided bysetDirty
is sufficient.- Returns:
true
if there are changes that need to be saved
-
isLeftSaveNeeded
protected boolean isLeftSaveNeeded()
Returnstrue
if there are unsaved changes for left side.- Returns:
true
if there are changes that need to be saved- Restriction:
- This method is not intended to be referenced by clients.
-
isRightSaveNeeded
protected boolean isRightSaveNeeded()
Returnstrue
if there are unsaved changes for right side.- Returns:
true
if there are changes that need to be saved- Restriction:
- This method is not intended to be referenced by clients.
-
isDirty
public boolean isDirty()
Returnstrue
if there are unsaved changes. The method should be called by any parts or dialogs that contain the input. By default, this method callsisSaveNeeded()
but subclasses may extend.- Returns:
true
if there are unsaved changes- Since:
- 3.3
-
setDirty
public void setDirty(boolean dirty)
Sets the dirty state of this input to the given value and sends out aPropertyChangeEvent
if the new value differs from the old value. Direct calling this method with parameter dirty equal tofalse
when there are unsaved changes in viewers, results in inconsistent state. The dirty state of compare input should be based only on the information if there are changes in viewers for left or right side.- Parameters:
dirty
- the dirty state for this compare input
-
setLeftDirty
protected void setLeftDirty(boolean dirty)
Sets the dirty state of left site of this input to the given value and sends out aPropertyChangeEvent
if the new value for whole input differs from the old value. Direct calling this method with parameter dirty equal tofalse
when there are unsaved changes in left viewer, results in inconsistent state. The dirty state of compare input should be based only on the information if there are changes in viewers for left side.- Parameters:
dirty
- the dirty state for this compare input- Since:
- 3.7
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
setRightDirty
protected void setRightDirty(boolean dirty)
Sets the dirty state of right site of this input to the given value and sends out aPropertyChangeEvent
if the new value for whole input differs from the old value. Direct calling this method with parameter dirty equal tofalse
when there are unsaved changes in right viewer, results in inconsistent state. The dirty state of compare input should be based only on the information if there are changes in viewers for right side.- Parameters:
dirty
- the dirty state for this compare input- Since:
- 3.7
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
addPropertyChangeListener
public void addPropertyChangeListener(IPropertyChangeListener listener)
Description copied from interface:IPropertyChangeNotifier
Adds a listener for property changes to this notifier. Has no effect if an identical listener is already registered.- Specified by:
addPropertyChangeListener
in interfaceIPropertyChangeNotifier
- Parameters:
listener
- a property change listener
-
removePropertyChangeListener
public void removePropertyChangeListener(IPropertyChangeListener listener)
Description copied from interface:IPropertyChangeNotifier
Removes the given content change listener from this notifier. Has no effect if the identical listener is not registered.- Specified by:
removePropertyChangeListener
in interfaceIPropertyChangeNotifier
- Parameters:
listener
- a property change listener
-
save
@Deprecated public void save(IProgressMonitor pm)
Deprecated.Override method saveChanges instead.Saves any unsaved changes. Empty implementation. Subclasses must override to save any changes.- Parameters:
pm
- anIProgressMonitor
that the implementation of save may use to show progress
-
saveChanges
public void saveChanges(IProgressMonitor monitor) throws CoreException
Saves any unsaved changes. Subclasses must override to save any changes. This implementation tries to flush changes in all viewers by callingISavable.save
on them.- Parameters:
monitor
- anIProgressMonitor
that the implementation of save may use to show progress- Throws:
CoreException
- If save fails.- Since:
- 2.0
-
flushViewers
protected void flushViewers(IProgressMonitor monitor)
Flushes the viewer contents into the input.- Parameters:
monitor
- a progress monitor- Since:
- 3.3
-
flushLeftViewers
protected void flushLeftViewers(IProgressMonitor monitor)
- Parameters:
monitor
- a progress monitor- Restriction:
- This method is not intended to be referenced by clients.
-
flushRightViewers
protected void flushRightViewers(IProgressMonitor monitor)
- Parameters:
monitor
- a progress monitor- Restriction:
- This method is not intended to be referenced by clients.
-
addCompareInputChangeListener
public void addCompareInputChangeListener(ICompareInput input, ICompareInputChangeListener listener)
Description copied from interface:ICompareContainer
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.- Specified by:
addCompareInputChangeListener
in interfaceICompareContainer
- Parameters:
input
- the compare inputlistener
- the compare input change listener
-
removeCompareInputChangeListener
public void removeCompareInputChangeListener(ICompareInput input, ICompareInputChangeListener listener)
Description copied from interface:ICompareContainer
Remove the change listener from the given compare input. Removing a listener that is not registered has no effect.- Specified by:
removeCompareInputChangeListener
in interfaceICompareContainer
- Parameters:
input
- the compare inputlistener
- the compare input change listener
-
registerContextMenu
public void registerContextMenu(MenuManager menu, ISelectionProvider selectionProvider)
Description copied from interface:ICompareContainer
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. The provided menu should have aIWorkbenchActionConstants.MB_ADDITIONS
separator as this is where the container will add actions.- Specified by:
registerContextMenu
in interfaceICompareContainer
- Parameters:
menu
- the menu being registeredselectionProvider
- the selection provider
-
setStatusMessage
public void setStatusMessage(String message)
Description copied from interface:ICompareContainer
Set the status message displayed by the container to the given message- Specified by:
setStatusMessage
in interfaceICompareContainer
- Parameters:
message
- the status message
-
getActionBars
public IActionBars getActionBars()
Description copied from interface:ICompareContainer
Return the action bars for the container ornull
if the container does not have an action bars.- Specified by:
getActionBars
in interfaceICompareContainer
- Returns:
- the action bars for the container or
null
-
getServiceLocator
public IServiceLocator getServiceLocator()
Description copied from interface:ICompareContainer
Return the service locator for the container ornull
if the container does not have one.- Specified by:
getServiceLocator
in interfaceICompareContainer
- Returns:
- the service locator for the container or
null
-
getWorkbenchPart
public IWorkbenchPart getWorkbenchPart()
Description copied from interface:ICompareContainer
Return the workbench part associated with this container ornull
if there is no part or it is not available.- Specified by:
getWorkbenchPart
in interfaceICompareContainer
- Returns:
- the workbench part associated with this container or
null
-
run
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
Description copied from interface:IRunnableContext
Runs the given
IRunnableWithProgress
in this context. For example, if this is aProgressMonitorDialog
then the runnable is run using this dialog's progress monitor.If
fork
isfalse
, the current thread is used to run the runnable. Note that iffork
istrue
, it is unspecified whether or not this method blocks until the runnable has been run. Implementers should document whether the runnable is run synchronously (blocking) or asynchronously (non-blocking), or if no assumption can be made about the blocking behaviour.- Specified by:
run
in interfaceIRunnableContext
- Parameters:
fork
-true
if the runnable should be run in a separate thread, andfalse
to run in the same threadcancelable
-true
to enable the cancelation, andfalse
to make the operation uncancellablerunnable
- the runnable to run- Throws:
InvocationTargetException
- wraps any exception or error which occurs while running the runnableInterruptedException
- propagated by the context if the runnable acknowledges cancelation by throwing this exception. This should not be thrown if cancelable isfalse
.
-
runAsynchronously
public void runAsynchronously(IRunnableWithProgress runnable)
Description copied from interface:ICompareContainer
Queue the given task to be run asynchronously. If the given runnable was previously queued to run asynchronously and it has not yet run, the task position will be moved to the end of the queue. If the task that is being queued is currently running, the running task will be canceled and added to the end of the queue.This method should be treated as a request to run the given task asynchronously. However, clients should not assume that the code will be run asynchronously. Depending on the container implementation, a call to this method may or may not block the caller until the task is completed. Also, the task may be executed in a modal or non-modal fashion.
- Specified by:
runAsynchronously
in interfaceICompareContainer
- Parameters:
runnable
- the task to be performed
-
setContainer
public void setContainer(ICompareContainer container)
Sets the container of this input to the given container- Parameters:
container
- the container- Since:
- 3.3
-
getContainer
public final ICompareContainer getContainer()
Returns the container of this input ornull
if there is no container set.- Returns:
- the container of this input or
null
- Since:
- 3.3
-
firePropertyChange
protected void firePropertyChange(PropertyChangeEvent event)
Fires the given property change event to all listeners registered with this compare editor input.- Parameters:
event
- the property change event- Since:
- 3.3
-
canRunAsJob
public boolean canRunAsJob()
Returns whether this compare editor input can be run as a job. By default,false
is returned since traditionally inputs were prepared in the foreground (i.e the UI was blocked when therun(IProgressMonitor)
method (and indirectly theprepareInput(IProgressMonitor)
method) was invoked. Subclasses may override.- Returns:
- whether this compare editor input can be run in the background
- Since:
- 3.3
-
belongsTo
public boolean belongsTo(Object family)
Returns whether this input belongs to the given family when it is run as a job.- Parameters:
family
- the job family- Returns:
- whether this input belongs to the given family
- Since:
- 3.3
- See Also:
canRunAsJob()
,Job.belongsTo(Object)
-
isEditionSelectionDialog
public boolean isEditionSelectionDialog()
Returns whether this input is intended to be used to select a particular edition of an element in a dialog. The result of this method is only consider if neither sides of the input are editable. By default,false
is returned.- Returns:
- whether this input is intended to be used to select a particular edition of an element in a dialog
- Since:
- 3.3
- See Also:
getOKButtonLabel()
,okPressed()
,getSelectedEdition()
-
getOKButtonLabel
public String getOKButtonLabel()
Returns the label to be used for theOK
button when this input is displayed in a dialog. By default, different labels are used depending on whether the input is editable or is for edition selection (seeisEditionSelectionDialog()
.- Returns:
- the label to be used for the
OK
button when this input is displayed in a dialog - Since:
- 3.3
-
getCancelButtonLabel
public String getCancelButtonLabel()
Returns the label used for theCANCEL
button when this input is shown in a compare dialog usingCompareUI.openCompareDialog(CompareEditorInput)
.- Returns:
- the label used for the
CANCEL
button - Since:
- 3.3
-
okPressed
public boolean okPressed()
TheOK
button was pressed in a dialog. If one or both of the sides of the input is editable then any changes will be saved. If the input is for edition selection (seeisEditionSelectionDialog()
), it is up to subclasses to override this method in order to perform the appropriate operation on the selected edition.- Returns:
- whether the dialog should be closed or not.
- Since:
- 3.3
-
cancelPressed
public void cancelPressed()
TheCANCEL
button was pressed in a dialog. By default, nothing is done. Subclasses may override.- Since:
- 3.3
-
getSelectedEdition
public Object getSelectedEdition()
Returns the selected edition ornull
if no edition is selected. The result of this method should only be considered ifisEditionSelectionDialog()
returnstrue
.- Returns:
- the selected edition or
null
- Since:
- 3.3
-
setHelpContextId
public void setHelpContextId(String helpContextId)
Sets the help context id for this input.- Parameters:
helpContextId
- the help context id.- Since:
- 3.3
-
-