Package org.eclipse.team.ui.synchronize
Class ModelOperation
java.lang.Object
org.eclipse.core.runtime.jobs.JobChangeAdapter
org.eclipse.team.ui.TeamOperation
org.eclipse.team.ui.synchronize.ModelOperation
- All Implemented Interfaces:
- IJobChangeListener,- IRunnableWithProgress
- Direct Known Subclasses:
- ModelMergeOperation
An abstract operation that uses an 
ISynchronizationScopeManager to
 create an operation scope that includes the complete set of mappings that
 must be included in the operation to ensure model consistency. The scope
 generation phase will prompt the user if additional resources have been added
 to the scope.- Since:
- 3.2
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedModelOperation(IWorkbenchPart part, ISynchronizationScopeManager manager) Create a model operation that operates on the given scope.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidbeginOperation(IProgressMonitor monitor) Method called fromrun(IProgressMonitor)before theexecute(IProgressMonitor)method is invoked.protected voidendOperation(IProgressMonitor monitor) Method called fromrun(IProgressMonitor)after theexecute(IProgressMonitor)completes of if an exception is thrown from thebeginOperation(IProgressMonitor)or theexecute(IProgressMonitor).protected abstract voidexecute(IProgressMonitor monitor) Execute the operation.protected ISynchronizationContextReturn the synchronization context for the operation ornullif the operation doesn't have one or if it has not yet been created.protected StringReturn a string to be used in the preview request on the scope prompt ornullif a preview of the operation results is not possible.getScope()Return the scope of this operation.protected ISynchronizationScopeManagerReturn the scope manager for this operation.protected final voidinitializeScope(IProgressMonitor monitor) Adjust the input of the operation according to the selected resource mappings and the set of interested participants.booleanReturn whether a preview of the operation before it is performed is desired.protected booleanpromptForInputChange(String requestPreviewMessage, IProgressMonitor monitor) Prompt the user to inform them that additional resource mappings have been included in the operations.protected voidpromptIfInputChange(IProgressMonitor monitor) Prompt the user by callingpromptForInputChange(String, IProgressMonitor)if the scope of the operation was expanded (as described ininitializeScope(IProgressMonitor)).final voidrun(IProgressMonitor monitor) Run the operation.static ModelProvider[]sortByExtension(ModelProvider[] providers) Return the list of provides sorted by their extends relationship.Methods inherited from class org.eclipse.team.ui.TeamOperationbelongsTo, canRunAsJob, getGotoAction, getJobName, getKeepOperation, getOperationIcon, getPart, getSchedulingRule, getShell, isKeepOneProgressServiceEntry, isPostponeAutobuild, isSameFamilyAs, isUserInitiated, run, shouldRunMethods inherited from class org.eclipse.core.runtime.jobs.JobChangeAdapteraboutToRun, awake, done, running, scheduled, sleeping
- 
Constructor Details- 
ModelOperationCreate a model operation that operates on the given scope.- Parameters:
- part- the workbench part from which the merge was launched or- null
- manager- the scope manager for this operation
 
 
- 
- 
Method Details- 
sortByExtensionReturn the list of provides sorted by their extends relationship. Extended model providers will appear later in the list then those that extends them. The order of model providers that independant (i.e. no extends relationship between them) will be indeterminate.- Parameters:
- providers- the model providers
- Returns:
- the list of provides sorted by their extends relationship
 
- 
runpublic final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException Run the operation. This method first ensures that the scope is built by callinginitializeScope(IProgressMonitor)and then invokes theexecute(IProgressMonitor)method.- Parameters:
- monitor- a progress monitor
- Throws:
- InvocationTargetException- if the run method must propagate a checked exception, it should wrap it inside an- InvocationTargetException; runtime exceptions are automatically wrapped in an- InvocationTargetExceptionby the calling context
- InterruptedException- if the operation detects a request to cancel, using- IProgressMonitor.isCanceled(), it should exit by throwing- InterruptedException
- See Also:
 
- 
beginOperationMethod called fromrun(IProgressMonitor)before theexecute(IProgressMonitor)method is invoked. This is done to give the operation a chance to initialize any state required to execute. By default, theISynchronizationScopeManagerfor this operation is initialized if it was not previously initialized.- Parameters:
- monitor- a progress monitor
- Throws:
- InvocationTargetException- if an error occurs
 
- 
endOperationMethod called fromrun(IProgressMonitor)after theexecute(IProgressMonitor)completes of if an exception is thrown from thebeginOperation(IProgressMonitor)or theexecute(IProgressMonitor). By default, this method does nothing. Subclasses may override.- Parameters:
- monitor- a progress monitor
- Throws:
- InvocationTargetException
 
- 
initializeScopeAdjust the input of the operation according to the selected resource mappings and the set of interested participants. This method will prompt the user in the following cases:- The scope contains additional resources than those in the input.
- The scope has additional mappings from a model in the input
- The input contains elements from multiple models
 The scope of this operation will only be prepared once. Subsequent calls to this method will do nothing. Also, if the scope was provided as an argument to a constructor, this method will do nothing (i.e. the scope will not be prepared again and no prompting will occur). Subclasses can customize how the scope is generated by overriding the getScopeManager()to return a custom scope manager.- Parameters:
- monitor- a progress monitor
- Throws:
- InvocationTargetException
 
- 
promptIfInputChangePrompt the user by callingpromptForInputChange(String, IProgressMonitor)if the scope of the operation was expanded (as described ininitializeScope(IProgressMonitor)).- Parameters:
- monitor- a progress monitor
 
- 
getPreviewRequestMessageReturn a string to be used in the preview request on the scope prompt ornullif a preview of the operation results is not possible. By default,nullis returned but subclasses may override.- Returns:
- a string to be used in the preview request on the scope prompt
 or nullif a preview of the operation results is not possible
 
- 
promptForInputChangePrompt the user to inform them that additional resource mappings have been included in the operations.- Parameters:
- requestPreviewMessage- message to be displayed for the option to force a preview (or- nullif the preview option should not be presented
- monitor- a progress monitor
- Returns:
- whether a preview of the operation results was requested
- Throws:
- OperationCanceledException- if the user choose to cancel
 
- 
getContextReturn the synchronization context for the operation ornullif the operation doesn't have one or if it has not yet been created. By default, the method always returnsnull. Subclasses may override.- Returns:
- the synchronization context for the operation or null
 
- 
executeprotected abstract void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException Execute the operation. This method is invoked after the scope has been generated.- Parameters:
- monitor- a progress monitor
- Throws:
- InvocationTargetException- if an error occurs
- InterruptedException- if operation is interrupted
 
- 
getScopeReturn the scope of this operation.- Returns:
- the scope of this operation
 
- 
isPreviewRequestedpublic boolean isPreviewRequested()Return whether a preview of the operation before it is performed is desired.- Returns:
- whether a preview of the operation before it is performed is desired
 
- 
getScopeManagerReturn the scope manager for this operation.- Returns:
- the scope manager for this operation.
 
 
-