本文整理汇总了Java中org.eclipse.emf.compare.scope.IComparisonScope类的典型用法代码示例。如果您正苦于以下问题:Java IComparisonScope类的具体用法?Java IComparisonScope怎么用?Java IComparisonScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IComparisonScope类属于org.eclipse.emf.compare.scope包,在下文中一共展示了IComparisonScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareEObjects
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
private boolean compareEObjects(EObject e1, EObject e2) {
if (e1 == e2) {
return true;
}
if (e1 == null || e2 == null) {
return false;
}
if (!compareInitialized) {
descriptor = new BasicPostProcessorDescriptorImpl(customPostProcessor, Pattern.compile(".*"), null);
registry = new PostProcessorDescriptorRegistryImpl<String>();
registry.put(customPostProcessor.getClass().getName(), descriptor);
compare = EMFCompare.builder().setPostProcessorRegistry(registry).setDiffEngine(diffEngine).build();
compareInitialized = true;
}
final IComparisonScope scope = new DefaultComparisonScope(e1, e2, null);
final Comparison comparison = compare.compare(scope);
return comparison.getDifferences().isEmpty();
}
示例2: match
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
@Override
public Comparison match(IComparisonScope scope, Monitor monitor) {
Predicate<EObject> predicate = new Predicate<EObject>() {
@Override
public boolean apply(EObject eobject) {
// We only want to diff the SGraph and notation elements,
// not the transient palceholders for concrete languages
EPackage ePackage = eobject.eClass().getEPackage();
return ePackage == SGraphPackage.eINSTANCE || ePackage == NotationPackage.eINSTANCE;
}
};
if (scope instanceof DefaultComparisonScope) {
DefaultComparisonScope defaultScope = (DefaultComparisonScope) scope;
defaultScope.setEObjectContentFilter(predicate);
defaultScope.setResourceContentFilter(predicate);
}
return super.match(scope, monitor);
}
示例3: match
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <b>Note:</b> This method overrides
* {@link DefaultMatchEngine#match(Comparison, IComparisonScope, EObject, EObject, EObject, Monitor)}
* to remove incompatible Guava dependencies. It should be removed if/when
* Guava dependencies become compatible with NeoEMF.
*/
@Override
protected void match(Comparison comparison, IComparisonScope scope, EObject left,
EObject right, EObject origin, Monitor monitor) {
if (left == null || right == null) {
throw new IllegalArgumentException();
}
final Iterator<? extends EObject> leftEObjects = Iterators.concat(
Iterators.singletonIterator(left), scope.getChildren(left));
final Iterator<? extends EObject> rightEObjects = Iterators.concat(
Iterators.singletonIterator(right), scope.getChildren(right));
final Iterator<? extends EObject> originEObjects;
if (origin != null) {
originEObjects = Iterators.concat(Iterators.singletonIterator(origin),
scope.getChildren(origin));
} else {
originEObjects = Collections.emptyIterator();
}
getEObjectMatcher().createMatches(comparison, leftEObjects, rightEObjects, originEObjects,
monitor);
}
示例4: doDiff
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
/**
* Diffing the models contained in the provided resource sets.<br>
*
* {@inheritDoc}
*
* @return null if no supported source models available.
* @throws DiffingNotSupportedException
* Thrown if no reasonable JaMoPP model is contained in the resource sets.
*/
@Override
public Comparison doDiff(ResourceSet resourceSetLeading, ResourceSet resourceSetIntegration,
Map<String, String> diffingOptions) throws DiffingException, DiffingNotSupportedException {
List<String> ignorePackages = buildIgnorePackageList(diffingOptions);
PackageIgnoreChecker packageIgnoreChecker = new PackageIgnoreChecker(ignorePackages);
EMFCompare comparator = initCompare(packageIgnoreChecker, diffingOptions);
// Compare the two models
// In comparison, the left side is always the changed one.
// push in the integration model first
IComparisonScope scope = new JavaModelMatchScope(resourceSetIntegration, resourceSetLeading,
packageIgnoreChecker);
Comparison comparisonModel = comparator.compare(scope);
return comparisonModel;
}
示例5: compareEObjects
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean compareEObjects(EObject e1, EObject e2) {
if (e1 == e2) {
return true;
}
if (e1 == null || e2 == null) {
return false;
}
if (e1.eClass() != e2.eClass()) {
return false;
}
if (!compareInitialized) {
configureDiffEngine();
descriptor = new BasicPostProcessorDescriptorImpl(customPostProcessor, Pattern.compile(".*"), null);
registry = new PostProcessorDescriptorRegistryImpl();
registry.put(customPostProcessor.getClass().getName(), descriptor);
compare = EMFCompare.builder().setPostProcessorRegistry(registry).setDiffEngine(diffEngine).build();
compareInitialized = true;
}
final IComparisonScope scope = new DefaultComparisonScope(e1, e2, null);
final Comparison comparison = compare.compare(scope);
return comparison.getDifferences().isEmpty();
}
示例6: updateEObjectContainer
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
/**
* Updates the given {@link IEObjectContainer} with the given {@link Resource}.
*
* @param container
* the {@link ILocationContainer}
* @param eObjectContainer
* the {@link IEObjectContainer}
* @param newResource
* the {@link Resource}
* @throws Exception
* if the XMI serialization failed
*/
public void updateEObjectContainer(ILocationContainer container, IEObjectContainer eObjectContainer,
Resource newResource) throws Exception {
if (eObjectContainer.getXMIContent() != null && !eObjectContainer.getXMIContent().isEmpty()) {
final XMIResourceImpl oldResource = new XMIResourceImpl(URI.createURI(""));
oldResource.load(new ByteArrayInputStream(eObjectContainer.getXMIContent().getBytes(UTF_8)),
new HashMap<Object, Object>());
final IComparisonScope scope = new DefaultComparisonScope(oldResource, newResource, null);
final Comparison comparison = EMFCompare.builder().build().compare(scope);
for (ILocation child : new ArrayList<ILocation>(eObjectContainer.getContents())) {
if (child instanceof IEObjectLocation && !child.isMarkedAsDeleted()) {
final IEObjectLocation location = (IEObjectLocation)child;
updateEObjectLocation(oldResource, comparison, location, needSavedURIFragment(
newResource));
}
}
}
eObjectContainer.getSavedURIFragments().clear();
if (needSavedURIFragment(newResource)) {
updateSavedURIFragment(container, eObjectContainer, newResource);
}
final String newXMIContent = XMLHelperImpl.saveString(new HashMap<Object, Object>(), newResource
.getContents(), UTF_8, null);
eObjectContainer.setXMIContent(newXMIContent);
}
示例7: buildComparisonScope
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
private static IComparisonScope buildComparisonScope(String uri1,
String uri2) {
ResourceSet resourceSet1 = new ResourceSetImpl();
ResourceSet resourceSet2 = new ResourceSetImpl();
resourceSet1.getResource(URI.createFileURI(uri1), true);
resourceSet2.getResource(URI.createFileURI(uri2), true);
return new DefaultComparisonScope(resourceSet1, resourceSet2, null);
}
示例8: unidirectionalComparation
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
private static double unidirectionalComparation(String first, String second, boolean semanticFlag) {
IComparisonScope comparisonScope = buildComparisonScope(first, second);
IMatchEngine.Factory.Registry registry = buildMatchEngineFactoryRegistry(semanticFlag);
Comparison comparison = executeComparison(registry, comparisonScope);
if(semanticFlag){
printComparisonResults(comparison);
}
return evaluateComparisonResult(comparison);
}
示例9: isFixed
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
private boolean isFixed(Model model1, Model model2) {
ResourceSet srcResourceSet = new ResourceSetImpl();
srcResourceSet.getResource(URI.createPlatformResourceURI(model1.getUri(), true), true);
ResourceSet tgtResourceSet = new ResourceSetImpl();
tgtResourceSet.getResource(URI.createPlatformResourceURI(model2.getUri(), true), true);
IComparisonScope scope = new DefaultComparisonScope(srcResourceSet, tgtResourceSet, null);
Comparison comparison = EMFCompare.builder().build().compare(scope);
if (!comparison.getDifferences().isEmpty()) {
return false;
}
return true;
}
示例10: isMatchEngineFactoryFor
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
@Override
public boolean isMatchEngineFactoryFor(IComparisonScope scope) {
return true;
}
示例11: compareStrict
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
private static Comparison compareStrict(Resource resource, Resource resource2) {
IComparisonScope scope = new DefaultComparisonScope(resource, resource2, null);
return EMFCompare.builder().setDiffEngine(new DefaultDiffEngineExtension()).build().compare(scope);
}
示例12: execute
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
/**
* The command has been executed, so extract the needed information
* from the application context.
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
if (currentSelection != null && currentSelection instanceof IStructuredSelection) {
// Retrieve file corresponding to current selection.
IStructuredSelection selection = (IStructuredSelection)currentSelection;
IFile selectionFile = (IFile)selection.getFirstElement();
// Open compare target selection dialog.
CompareTargetSelectionDialog dialog = new CompareTargetSelectionDialog(
HandlerUtil.getActiveShellChecked(event),
selectionFile.getName());
if (dialog.open() != Window.OK) {
return null;
}
// Ask concrete subclass to parse source file and extract Route for comparison.
Route left = extractRouteFromFile(selectionFile);
// Retrieve EMF Object corresponding to selected reference Route.
Route right = dialog.getSelectedRoute();
// Cause Spring parser cannot retrieve route name, force it using those of the model.
// TODO Find a fix later for that in the generator/parser couple
left.setName(right.getName());
// Launch EMFCompare UI with input.
EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration());
ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(left, right, null);
AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
EMFCompare comparator = EMFCompare.builder().setPostProcessorRegistry(EMFCompareRCPPlugin.getDefault().getPostProcessorRegistry()).build();
IComparisonScope scope = new DefaultComparisonScope(left, right, null);
CompareEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain, adapterFactory, comparator, scope);
CompareUI.openCompareDialog(input);
}
return null;
}
示例13: executeComparison
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
private static Comparison executeComparison(IMatchEngine.Factory.Registry registry, IComparisonScope scope) {
return EMFCompare.builder().setMatchEngineFactoryRegistry(registry).build().compare(scope);
}
示例14: isMatchEngineFactoryFor
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean isMatchEngineFactoryFor(IComparisonScope scope) {
return true;
}
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:8,代码来源:SemanticRCPMatchEngineFactoryImpl.java
示例15: merge
import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
public static EObject merge(URI localChanges, URI original, URI remote) throws IncQueryException {
Resource originalModel = new ResourceSetImpl().getResource(original, true);
Resource remoteModel = new ResourceSetImpl().getResource(remote, true);
// Configure EMF Compare
IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
matchEngineFactory.setRanking(20);
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
matchEngineRegistry.add(matchEngineFactory);
EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
// Compare the two models
IComparisonScope scopeOR = EMFCompare.createDefaultScope(remoteModel, originalModel);
Comparison comparisonOR = comparator.compare(scopeOR);
ChangeSet changeSetOR = EMFCompareTranslator.translate(comparisonOR);
ChangeSet changeSetOL = null;
boolean hasLocalChanges = new File(localChanges.toFileString()).exists();
if(hasLocalChanges) {
changeSetOL = (ChangeSet) new ResourceSetImpl().getResource(localChanges, true).getContents().get(0);
EList<Change> changes = changeSetOL.getChanges();
for (Change change : changes) {
change.setExecutable(true);
}
} else {
changeSetOL = ModelFactory.eINSTANCE.createChangeSet();
}
Collection<DSETransformationRule<?,?>>rules = Lists.<DSETransformationRule<?,?>>newArrayList(
new DSETransformationRule<CreateMatch,CreateMatcher>(CreateQuerySpecification.instance(), new CreateOperation()),
new DSETransformationRule<DeleteMatch,DeleteMatcher>(DeleteQuerySpecification.instance(), new DeleteOperation()),
new DSETransformationRule<SetReferenceMatch,SetReferenceMatcher>(SetReferenceQuerySpecification.instance(), new SetReferenceOperation()),
new DSETransformationRule<AddReferenceMatch,AddReferenceMatcher>(AddReferenceQuerySpecification.instance(), new AddReferenceOperation()),
new DSETransformationRule<RemoveReferenceMatch,RemoveReferenceMatcher>(RemoveReferenceQuerySpecification.instance(), new RemoveReferenceOperation()),
new DSETransformationRule<SetAttributeMatch,SetAttributeMatcher>(SetAttributeQuerySpecification.instance(), new SetAttributeOperation()),
new DSETransformationRule<AddAttributeMatch,AddAttributeMatcher>(AddAttributeQuerySpecification.instance(), new AddAttributeOperation()),
new DSETransformationRule<RemoveAttributeMatch,RemoveAttributeMatcher>(RemoveAttributeQuerySpecification.instance(), new RemoveAttributeOperation()));
Collection<IQuerySpecification<?>>goals = Lists.<IQuerySpecification<?>>newArrayList(
GoalPatternQuerySpecification.instance()
);
DSEMergeManager manager = DSEMergeManager.create(originalModel.getContents().get(0), changeSetOL, changeSetOR);
manager.setMetamodel(WTSpec4MPackage.eINSTANCE);
manager.setId2EObject(Id2objectQuerySpecification.instance());
manager.setRules(rules);
manager.setObjectives(goals);
Collection<Solution> solutions = manager.start();
EObject merged = solutions.iterator().next().getScope().getOrigin();
return merged;
}