Package org.eclipse.team.ui.synchronize
Class ModelParticipantMergeOperation
- java.lang.Object
-
- org.eclipse.core.runtime.jobs.JobChangeAdapter
-
- org.eclipse.team.ui.TeamOperation
-
- org.eclipse.team.ui.synchronize.ModelOperation
-
- org.eclipse.team.ui.synchronize.ModelMergeOperation
-
- org.eclipse.team.ui.synchronize.ModelParticipantMergeOperation
-
- All Implemented Interfaces:
IJobChangeListener
,IRunnableWithProgress
public abstract class ModelParticipantMergeOperation extends ModelMergeOperation
A model merge operation that uses a participant to preview the changes in either a dialog or the Synchronize view.- Since:
- 3.2
-
-
Field Summary
Fields Modifier and Type Field Description static int
REQUEST_PREVIEW
Status code that can be returned from theModelMergeOperation.performMerge(IProgressMonitor)
method to indicate that a subclass would like to force a preview of the merge.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ModelParticipantMergeOperation(IWorkbenchPart part, ISynchronizationScopeManager manager)
Create a merge participant operation for the scope of the given manager.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
belongsTo(Object family)
Return whether the job that is running this operation should be considered a member member of the given family.protected abstract SynchronizationContext
createMergeContext()
Create a merge context for use by this operation.protected ModelSynchronizeParticipant
createParticipant()
Create the synchronize participant to be used by this operation to preview changes.protected void
execute(IProgressMonitor monitor)
Perform a merge.protected void
executeMerge(IProgressMonitor monitor)
Perform a merge.protected ISynchronizationContext
getContext()
Return the synchronization context for the operation ornull
if the operation doesn't have one or if it has not yet been created.protected String
getPreviewRequestMessage()
Return a string to be used in the preview request on the scope prompt ornull
if a preview of the operation results is not possible.protected void
handlePreviewRequest()
A preview of the merge has been requested.protected void
initializeContext(IProgressMonitor monitor)
Initialize the merge context for this merge operation.protected boolean
isPreviewInDialog()
Return whether previews should occur in a dialog or in the synchronize view.-
Methods inherited from class org.eclipse.team.ui.synchronize.ModelMergeOperation
handleMergeFailure, handleNoChanges, handleValidationFailure, hasChangesOfInterest, performMerge, performMerge, validateMerge
-
Methods inherited from class org.eclipse.team.ui.synchronize.ModelOperation
beginOperation, endOperation, getScope, getScopeManager, initializeScope, isPreviewRequested, promptForInputChange, promptIfInputChange, run, sortByExtension
-
Methods inherited from class org.eclipse.team.ui.TeamOperation
canRunAsJob, getGotoAction, getJobName, getKeepOperation, getOperationIcon, getPart, getSchedulingRule, getShell, isKeepOneProgressServiceEntry, isPostponeAutobuild, isSameFamilyAs, isUserInitiated, run, shouldRun
-
Methods inherited from class org.eclipse.core.runtime.jobs.JobChangeAdapter
aboutToRun, awake, done, running, scheduled, sleeping
-
-
-
-
Field Detail
-
REQUEST_PREVIEW
public static final int REQUEST_PREVIEW
Status code that can be returned from theModelMergeOperation.performMerge(IProgressMonitor)
method to indicate that a subclass would like to force a preview of the merge. The message of such a status should be ignored.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ModelParticipantMergeOperation
protected ModelParticipantMergeOperation(IWorkbenchPart part, ISynchronizationScopeManager manager)
Create a merge participant operation for the scope of the given manager.- Parameters:
part
- the workbench part from which the merge was launched ornull
manager
- the scope manager
-
-
Method Detail
-
initializeContext
protected void initializeContext(IProgressMonitor monitor) throws CoreException
Description copied from class:ModelMergeOperation
Initialize the merge context for this merge operation. After this method is invoked, theModelOperation.getContext()
method must return an instance ofIMergeContext
that is fully initialized.- Specified by:
initializeContext
in classModelMergeOperation
- Parameters:
monitor
- a progress monitor- Throws:
CoreException
- if an error occurs
-
execute
protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
Description copied from class:ModelMergeOperation
Perform a merge. FirstModelMergeOperation.initializeContext(IProgressMonitor)
is called to determine the set of resource changes. Then theModelMergeOperation.executeMerge(IProgressMonitor)
method is invoked.- Overrides:
execute
in classModelMergeOperation
- Parameters:
monitor
- a progress monitor- Throws:
InvocationTargetException
- if an error occursInterruptedException
- if operation is interrupted
-
executeMerge
protected void executeMerge(IProgressMonitor monitor) throws CoreException
Description copied from class:ModelMergeOperation
Perform a merge. This method is invoked fromModelMergeOperation.execute(IProgressMonitor)
after the context has been initialized. If there are changes in the context, they will be validating by callingModelMergeOperation.validateMerge(IMergeContext, IProgressMonitor)
. If there are no validation problems,ModelMergeOperation.performMerge(IProgressMonitor)
will then be called to perform the merge. If there are problems encountered or if a preview was requested,ModelMergeOperation.handlePreviewRequest()
is called.- Overrides:
executeMerge
in classModelMergeOperation
- Parameters:
monitor
- a progress monitor- Throws:
CoreException
-
handlePreviewRequest
protected void handlePreviewRequest()
Description copied from class:ModelMergeOperation
A preview of the merge has been requested. By default, this method does nothing. Subclasses that wish to support previewing must override this method to preview the merge and theModelOperation.getPreviewRequestMessage()
to have the option presented to the user if the scope changes.- Overrides:
handlePreviewRequest
in classModelMergeOperation
-
belongsTo
public boolean belongsTo(Object family)
Description copied from class:TeamOperation
Return whether the job that is running this operation should be considered a member member of the given family. Subclasses can override this method in order to support the family based functionality provided by theIJobManager
. By default,false
is always returned. Subclasses that override theisKeepOneProgressServiceEntry
method do not need to override this method, but instead should overrideisSameFamilyAs
.- Overrides:
belongsTo
in classTeamOperation
- Parameters:
family
- the family being tested.- Returns:
- whether the job that is running this operation should be considered a member member of the given family.
-
isPreviewInDialog
protected boolean isPreviewInDialog()
Return whether previews should occur in a dialog or in the synchronize view.- Returns:
- whether previews should occur in a dialog or in the synchronize view
-
getContext
protected ISynchronizationContext getContext()
Description copied from class:ModelOperation
Return the synchronization context for the operation ornull
if the operation doesn't have one or if it has not yet been created. By default, the method always returnsnull
. Subclasses may override.- Overrides:
getContext
in classModelOperation
- Returns:
- the synchronization context for the operation or
null
-
getPreviewRequestMessage
protected String getPreviewRequestMessage()
Description copied from class:ModelOperation
Return a string to be used in the preview request on the scope prompt ornull
if a preview of the operation results is not possible. By default,null
is returned but subclasses may override.- Overrides:
getPreviewRequestMessage
in classModelOperation
- Returns:
- a string to be used in the preview request on the scope prompt
or
null
if a preview of the operation results is not possible
-
createParticipant
protected ModelSynchronizeParticipant createParticipant()
Create the synchronize participant to be used by this operation to preview changes. By default, aModelSynchronizeParticipant
is created using the scope manager (ModelOperation.getScopeManager()
) context from (createMergeContext()
) and job name (TeamOperation.getJobName()
) of this operation. Subclasses may override this method.Once created, it is the responsibility of the participant to dispose of the synchronization context when it is no longer needed.
- Returns:
- a newly created synchronize participant to be used by this operation
-
createMergeContext
protected abstract SynchronizationContext createMergeContext()
Create a merge context for use by this operation. This method is not long running so the operation should not refresh the context or perform other long running operations in this thread. However the context may start initializing in another thread as long as the job used to perform the initialization belongs to the family that matches the context.- Returns:
- a merge context for use by this operation
-
-