Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.team.ui.synchronize
Class ModelMergeOperation


java.lang.Object
  extended by 

org.eclipse.core.runtime.jobs.JobChangeAdapter
      extended by 

org.eclipse.team.ui.TeamOperation
          extended by 

org.eclipse.team.ui.synchronize.ModelOperation
              extended by 
org.eclipse.team.ui.synchronize.ModelMergeOperation
All Implemented Interfaces:
IJobChangeListener, IRunnableWithProgress
Direct Known Subclasses:
ModelParticipantMergeOperation

public abstract class ModelMergeOperation
extends ModelOperation

A model operation that executes a merge according to the merge lifecycle associated with an IMergeContext and IResourceMappingMerger instances obtained from the model providers involved.

Since:
3.2

Constructor Summary
protected ModelMergeOperation ( IWorkbenchPart part, ISynchronizationScopeManager manager)
          Create a model merge operation.
 
Method Summary
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.
 
Methods inherited from class org.eclipse.team.ui.synchronize. ModelOperation
beginOperation, endOperation, getContext, getPreviewRequestMessage, getScope, getScopeManager, initializeScope, isPreviewRequested, promptForInputChange, promptIfInputChange, run, sortByExtension
 
Methods inherited from class org.eclipse.team.ui. TeamOperation
belongsTo, 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
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelMergeOperation

protected ModelMergeOperation(
IWorkbenchPart part,
                              
ISynchronizationScopeManager manager)
Create a model merge operation.

Parameters:
part - the workbench part from which the operation was requested or null
manager - the scope manager
Method Detail

validateMerge

public static 
IStatus validateMerge(
IMergeContext context,
                                    
IProgressMonitor monitor)
Validate the merge context with the model providers that have mappings in the scope of the context. The IResourceMappingMerger for each model provider will be consulted and any non-OK status will be accumulated and returned,

Parameters:
context - the merge context being validated
monitor - a progress monitor
Returns:
a status or multi-status that identify any conditions that should force a preview of the merge

execute

protected void execute(
IProgressMonitor monitor)
                throws 
InvocationTargetException,
                       
InterruptedException
Perform a merge. First initializeContext(IProgressMonitor) is called to determine the set of resource changes. Then the executeMerge(IProgressMonitor) method is invoked.

Specified by:
execute in class ModelOperation
Parameters:
monitor - a progress monitor
Throws:
InvocationTargetException
InterruptedException

executeMerge

protected void executeMerge(
IProgressMonitor monitor)
                     throws 
CoreException
Perform a merge. This method is invoked from 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.

Parameters:
monitor - a progress monitor
Throws:
CoreException

handlePreviewRequest

protected void handlePreviewRequest()
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 the ModelOperation.getPreviewRequestMessage() to have the option presented to the user if the scope changes.


initializeContext

protected abstract void initializeContext(
IProgressMonitor monitor)
                                   throws 
CoreException
Initialize the merge context for this merge operation. After this method is invoked, the ModelOperation.getContext() method must return an instance of IMergeContext that is fully initialized.

Parameters:
monitor - a progress monitor
Throws:
CoreException

handleValidationFailure

protected void handleValidationFailure(
IStatus status)
Method invoked when the context contains changes that failed validation by at least one IResourceMappingMerger. By default, the user is prompted to inform them that unmergeable changes were found and the handlePreviewRequest() method is invoked. Subclasses may override.

Parameters:
status - the status returned from the mergers that reported the validation failures

handleMergeFailure

protected void handleMergeFailure(
IStatus status)
Method invoked when the context contains unmergable changes. By default, the user is prompted to inform them that unmergeable changes were found. Subclasses may override.

Parameters:
status - the status returned from the merger that reported the conflict

handleNoChanges

protected void handleNoChanges()
Method invoked when the context contains no changes. By default, the user is prompted to inform them that no changes were found. Subclasses may override.


performMerge

protected 
IStatus performMerge(
IProgressMonitor monitor)
                        throws 
CoreException
Attempt a headless merge of the elements in the context of this operation. The merge is performed by obtaining the 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.

Parameters:
monitor - a progress monitor
Returns:
a status that indicates whether the merge succeeded.
Throws:
CoreException - if an error occurred

performMerge

protected 
IStatus performMerge(
ModelProvider provider,
                               
IProgressMonitor monitor)
                        throws 
CoreException
Attempt to merge all the mappings that come from the given provider. Return a status which indicates whether the merge succeeded or if unmergeable conflicts were found. By default, this method invokes the 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:
 Platform.getJobManager().join(getContext(), monitor);
 

This method will throw a runtime exception if the operation does not have a merge context.

Parameters:
provider - the model provider whose mappings are to be merged
monitor - a progress monitor
Returns:
a non-OK status if there were unmergable conflicts
Throws:
CoreException - if an error occurred

hasChangesOfInterest

protected boolean hasChangesOfInterest()
Return whether the context of this operation has changes that are of interest to the operation. Subclasses may override.

Returns:
whether the context of this operation has changes that are of interest to the operation

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire