Package org.eclipse.team.ui.synchronize
Class ParticipantPageCompareEditorInput
java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.compare.CompareEditorInput
org.eclipse.team.ui.PageCompareEditorInput
org.eclipse.team.ui.synchronize.ParticipantPageCompareEditorInput
- All Implemented Interfaces:
ICompareContainer
,IContentChangeListener
,IPropertyChangeNotifier
,IAdaptable
,IRunnableContext
,IRunnableWithProgress
,IEditorInput
Displays a synchronize participant page combined with the compare/merge infrastructure. This only works if the
synchronize page viewer provides selections that are of the following types: ITypedElement and ICompareInput
or if the participant is a
ModelSynchronizeParticipant
.- Since:
- 3.3
-
Field Summary
Fields inherited from class org.eclipse.compare.CompareEditorInput
DIRTY_STATE, PROP_SELECTED_EDITION, PROP_TITLE, PROP_TITLE_IMAGE
-
Constructor Summary
ConstructorDescriptionParticipantPageCompareEditorInput
(CompareConfiguration configuration, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) Creates a part for the provided participant. -
Method Summary
Modifier and TypeMethodDescriptionprotected ICompareInput
asCompareInput
(ISelection selection) Return a compare input that represents the selection.void
TheCANCEL
button was pressed in a dialog.void
contentChanged
(IContentChangeNotifier source) Called whenever the content of the given source has changed.createContents
(Composite parent) Creates the SWT controls that are used to display the result of the compare operation.protected IPage
createPage
(CompareViewerPane parent, IToolBarManager toolBarManager) Create the page for this part and return the top level control for the page.Returns the label used for theCANCEL
button when this input is shown in a compare dialog usingCompareUI.openCompareDialog(CompareEditorInput)
.Returns the label to be used for theOK
button when this input is displayed in a dialog.Return the synchronize page configuration for this partReturn the Synchronize participant for this partprotected ISelectionProvider
Return the selection provider for the page.Returns the title image which will be used in the compare editor's title bar.protected void
Callback that occurs when the UI associated with this compare editor input is disposed.protected boolean
Return whether the ability to remember the participant in the synchronize view should be presented to the user.boolean
Returnstrue
if there are unsaved changes in either left or right side.boolean
TheOK
button was pressed in a dialog.protected void
prepareInput
(ICompareInput input, CompareConfiguration configuration, IProgressMonitor monitor) Prepare the compare input for display in a content viewer.protected Object
prepareInput
(IProgressMonitor monitor) Runs the compare operation and returns the compare result.void
saveChanges
(IProgressMonitor monitor) Saves any unsaved changes.Methods inherited from class org.eclipse.team.ui.PageCompareEditorInput
canRunAsJob, createStructureInputPane, prepareCompareInput, setPageDescription
Methods inherited from class org.eclipse.compare.CompareEditorInput
addCompareInputChangeListener, addPropertyChangeListener, belongsTo, contentsCreated, contributeToToolBar, createContentViewerSwitchingPane, createDiffViewer, createOutlineContents, exists, findContentViewer, findStructureViewer, firePropertyChange, flushLeftViewers, flushRightViewers, flushViewers, getActionBars, getAdapter, getCompareConfiguration, getCompareResult, getContainer, getContentViewerDescriptor, getImageDescriptor, getMessage, getName, getNavigator, getPersistable, getSelectedEdition, getServiceLocator, getStructureViewerDescriptor, getTitle, getToolTipText, getWorkbenchPart, isDirty, isEditionSelectionDialog, isLeftSaveNeeded, isRightSaveNeeded, registerContextMenu, removeCompareInputChangeListener, removePropertyChangeListener, run, run, runAsynchronously, save, setContainer, setContentViewerDescriptor, setDirty, setFocus, setFocus2, setHelpContextId, setLeftDirty, setMessage, setRightDirty, setStatusMessage, setStructureViewerDescriptor, setTitle
-
Constructor Details
-
ParticipantPageCompareEditorInput
public ParticipantPageCompareEditorInput(CompareConfiguration configuration, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) Creates a part for the provided participant. The page configuration is used when creating the participant page and the resulting compare/merge panes will be configured with the provided compare configuration.For example, clients can decide if the user can edit the compare panes by calling
CompareConfiguration.setLeftEditable(boolean)
orCompareConfiguration.setRightEditable(boolean)
.- Parameters:
configuration
- the compare configuration that will be used to create the compare panespageConfiguration
- the configuration that will be provided to the participant prior to creating the pageparticipant
- the participant whose page will be displayed in this part
-
-
Method Details
-
prepareInput
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException Description copied from class:CompareEditorInput
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.
- Specified by:
prepareInput
in classCompareEditorInput
- 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
-
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 classCompareEditorInput
- Returns:
- the title image, or
null
if none
-
handleDispose
protected void handleDispose()Description copied from class:CompareEditorInput
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 toCompareEditorInput.createContents(Composite)
. Subclasses can extend this method but ensure that the overridden method is invoked.- Overrides:
handleDispose
in classPageCompareEditorInput
-
createPage
Description copied from class:PageCompareEditorInput
Create the page for this part and return the top level control for the page.- Specified by:
createPage
in classPageCompareEditorInput
- Parameters:
parent
- the parent compositetoolBarManager
- the toolbar manager for the page- Returns:
- the top-level control for the page
-
getSelectionProvider
Description copied from class:PageCompareEditorInput
Return the selection provider for the page. This method is called after the page is created in order to register a selection listener on the page.- Specified by:
getSelectionProvider
in classPageCompareEditorInput
- Returns:
- the selection provider for the page
-
asCompareInput
Description copied from class:PageCompareEditorInput
Return a compare input that represents the selection. This input is used to feed the structure and content viewers. By default, a compare input is returned if the selection is of size 1 and the selected element implementsICompareInput
. Subclasses may override.- Overrides:
asCompareInput
in classPageCompareEditorInput
- Parameters:
selection
- the selection- Returns:
- a compare input representing the selection
-
prepareInput
protected void prepareInput(ICompareInput input, CompareConfiguration configuration, IProgressMonitor monitor) throws InvocationTargetException Description copied from class:PageCompareEditorInput
Prepare the compare input for display in a content viewer. This method is called fromPageCompareEditorInput.prepareCompareInput(ICompareInput)
and may be called from a non-UI thread. This method should not be called by others.- Specified by:
prepareInput
in classPageCompareEditorInput
- Parameters:
input
- the inputconfiguration
- the compare configurationmonitor
- a progress monitor- Throws:
InvocationTargetException
- if an error occurs
-
isSaveNeeded
public boolean isSaveNeeded()Description copied from class:CompareEditorInput
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.- Overrides:
isSaveNeeded
in classCompareEditorInput
- Returns:
true
if there are changes that need to be saved
-
saveChanges
Description copied from class:CompareEditorInput
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.- Overrides:
saveChanges
in classCompareEditorInput
- Parameters:
monitor
- anIProgressMonitor
that the implementation of save may use to show progress- Throws:
CoreException
- If save fails.
-
contentChanged
Description copied from interface:IContentChangeListener
Called whenever the content of the given source has changed.- Specified by:
contentChanged
in interfaceIContentChangeListener
- Overrides:
contentChanged
in classPageCompareEditorInput
- Parameters:
source
- the source whose contents has changed
-
getPageConfiguration
Return the synchronize page configuration for this part- Returns:
- Returns the pageConfiguration.
-
getParticipant
Return the Synchronize participant for this part- Returns:
- Returns the participant.
-
createContents
Description copied from class:CompareEditorInput
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.
- Overrides:
createContents
in classCompareEditorInput
- Parameters:
parent
- the parent control under which the control must be created- Returns:
- the SWT control hierarchy for the compare editor
-
isOfferToRememberParticipant
protected boolean isOfferToRememberParticipant()Return whether the ability to remember the participant in the synchronize view should be presented to the user. By default,true
is returned. Subclasses may override.- Returns:
- whether the ability to remember the participant in the synchronize view should be presented to the user
-
okPressed
public boolean okPressed()Description copied from class:CompareEditorInput
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 (seeCompareEditorInput.isEditionSelectionDialog()
), it is up to subclasses to override this method in order to perform the appropriate operation on the selected edition.- Overrides:
okPressed
in classCompareEditorInput
- Returns:
- whether the dialog should be closed or not.
-
cancelPressed
public void cancelPressed()Description copied from class:CompareEditorInput
TheCANCEL
button was pressed in a dialog. By default, nothing is done. Subclasses may override.- Overrides:
cancelPressed
in classCompareEditorInput
-
getOKButtonLabel
Description copied from class:CompareEditorInput
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 (seeCompareEditorInput.isEditionSelectionDialog()
.- Overrides:
getOKButtonLabel
in classCompareEditorInput
- Returns:
- the label to be used for the
OK
button when this input is displayed in a dialog
-
getCancelButtonLabel
Description copied from class:CompareEditorInput
Returns the label used for theCANCEL
button when this input is shown in a compare dialog usingCompareUI.openCompareDialog(CompareEditorInput)
.- Overrides:
getCancelButtonLabel
in classCompareEditorInput
- Returns:
- the label used for the
CANCEL
button
-