public abstract class ModelMergeOperation extends ModelOperation
IMergeContext
and IResourceMappingMerger
instances obtained from the model providers involved.Modifier | Constructor and Description |
---|---|
protected |
ModelMergeOperation(IWorkbenchPart part,
ISynchronizationScopeManager manager)
Create a model merge operation.
|
Modifier and Type | Method and Description |
---|---|
protected void |
execute(IProgressMonitor monitor)
Perform a merge.
|
protected void |
executeMerge(IProgressMonitor monitor)
Perform a merge.
|
protected void |
handleMergeFailure(IStatus status)
Method invoked when the context contains unmergable changes.
|
protected void |
handleNoChanges()
Method invoked when the context contains no changes.
|
protected void |
handlePreviewRequest()
A preview of the merge has been requested.
|
protected void |
handleValidationFailure(IStatus status)
Method invoked when the context contains changes that failed validation
by at least one
IResourceMappingMerger . |
protected boolean |
hasChangesOfInterest()
Return whether the context of this operation has changes that are
of interest to the operation.
|
protected abstract void |
initializeContext(IProgressMonitor monitor)
Initialize the merge context for this merge operation.
|
protected IStatus |
performMerge(IProgressMonitor monitor)
Attempt a headless merge of the elements in the context of this
operation.
|
protected IStatus |
performMerge(ModelProvider provider,
IProgressMonitor monitor)
Attempt to merge all the mappings that come from the given provider.
|
static IStatus |
validateMerge(IMergeContext context,
IProgressMonitor monitor)
Validate the merge context with the model providers that have mappings in
the scope of the context.
|
beginOperation, endOperation, getContext, getPreviewRequestMessage, getScope, getScopeManager, initializeScope, isPreviewRequested, promptForInputChange, promptIfInputChange, run, sortByExtension
belongsTo, canRunAsJob, getGotoAction, getJobName, getKeepOperation, getOperationIcon, getPart, getSchedulingRule, getShell, isKeepOneProgressServiceEntry, isPostponeAutobuild, isSameFamilyAs, isUserInitiated, run, shouldRun
aboutToRun, awake, done, running, scheduled, sleeping
protected ModelMergeOperation(IWorkbenchPart part, ISynchronizationScopeManager manager)
part
- the workbench part from which the operation was requested or null
manager
- the scope managerpublic static IStatus validateMerge(IMergeContext context, IProgressMonitor monitor)
IResourceMappingMerger
for each
model provider will be consulted and any non-OK status will be
accumulated and returned,context
- the merge context being validatedmonitor
- a progress monitorprotected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
initializeContext(IProgressMonitor)
is
called to determine the set of resource changes. Then the
executeMerge(IProgressMonitor)
method is invoked.execute
in class ModelOperation
monitor
- a progress monitorInvocationTargetException
InterruptedException
protected void executeMerge(IProgressMonitor monitor) throws CoreException
execute(IProgressMonitor)
after the context has been
initialized. If there are changes in the context, they will be validating
by calling validateMerge(IMergeContext, IProgressMonitor)
. If
there are no validation problems, performMerge(IProgressMonitor)
will then be called to perform the merge. If there are problems encountered
or if a preview was requested, handlePreviewRequest()
is called.monitor
- a progress monitorCoreException
protected void handlePreviewRequest()
ModelOperation.getPreviewRequestMessage()
to have the option presented to the user if the scope changes.protected abstract void initializeContext(IProgressMonitor monitor) throws CoreException
ModelOperation.getContext()
method must return an instance of IMergeContext
that is fully initialized.monitor
- a progress monitorCoreException
protected void handleValidationFailure(IStatus status)
IResourceMappingMerger
.
By default, the user is prompted to inform them that unmergeable changes were found
and the handlePreviewRequest()
method is invoked.
Subclasses may override.status
- the status returned from the mergers that reported the validation failuresprotected void handleMergeFailure(IStatus status)
status
- the status returned from the merger that reported the conflictprotected void handleNoChanges()
protected IStatus performMerge(IProgressMonitor monitor) throws CoreException
IResourceMappingMerger
for the model providers in the context's
scope. The merger of the model providers are invoked in the order
determined by the ModelOperation.sortByExtension(ModelProvider[])
method. The method will stop on the first conflict encountered.
This method will throw a runtime exception
if the operation does not have a merge context.monitor
- a progress monitorCoreException
- if an error occurredprotected IStatus performMerge(ModelProvider provider, IProgressMonitor monitor) throws CoreException
IResourceMappingMerger.merge(IMergeContext, IProgressMonitor)
method but does not wait for the context to update (see ISynchronizationContext
.
Callers that are invoking the merge on multiple models should wait until the
context has updated before invoking merge on another merger. The following
line of code will wait for the context to update:
Job.getJobManager().join(getContext(), monitor);
This method will throw a runtime exception if the operation does not have a merge context.
provider
- the model provider whose mappings are to be mergedmonitor
- a progress monitorCoreException
- if an error occurredprotected boolean hasChangesOfInterest()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.