Class ModelMergeOperation

    • 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
      • 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.
      • 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:
         Job.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