Search in sources :

Example 1 with ICompareEditingDomain

use of org.eclipse.emf.compare.domain.ICompareEditingDomain in project tdq-studio-se by Talend.

the class ExampleLauncher method compare.

public static void compare() {
    // Load the two input models
    ResourceSet resourceSet1 = new ResourceSetImpl();
    ResourceSet resourceSet2 = new ResourceSetImpl();
    // String xmi1 = "path/to/first/model.xmi";
    // String xmi2 = "path/to/second/model.xmi";
    load(fileName1, resourceSet1);
    load(fileName2, resourceSet2);
    // Configure EMF Compare
    IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
    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 scope = new DefaultComparisonScope(resourceSet1, resourceSet2, null);
    Comparison compare = comparator.compare(scope);
    comparator.compare(scope);
    EList<Diff> differences = compare.getDifferences();
    ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(scope.getLeft(), scope.getRight(), null);
    AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration());
    CompareEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain, adapterFactory, comparator, scope);
    // CompareUI.openCompareDialog(input); // or CompareUI.openCompareEditor(input);
    CompareUI.openCompareEditor(input);
}
Also used : MatchEngineFactoryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl) Diff(org.eclipse.emf.compare.Diff) CompareConfiguration(org.eclipse.compare.CompareConfiguration) EMFCompareConfiguration(org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) MatchEngineFactoryRegistryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) Comparison(org.eclipse.emf.compare.Comparison) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) ICompareEditingDomain(org.eclipse.emf.compare.domain.ICompareEditingDomain) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) EMFCompareConfiguration(org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration) ComparisonScopeEditorInput(org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeEditorInput) CompareEditorInput(org.eclipse.compare.CompareEditorInput) EMFCompare(org.eclipse.emf.compare.EMFCompare) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher) IMatchEngine(org.eclipse.emf.compare.match.IMatchEngine)

Aggregations

CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 CompareEditorInput (org.eclipse.compare.CompareEditorInput)1 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)1 Comparison (org.eclipse.emf.compare.Comparison)1 Diff (org.eclipse.emf.compare.Diff)1 EMFCompare (org.eclipse.emf.compare.EMFCompare)1 ICompareEditingDomain (org.eclipse.emf.compare.domain.ICompareEditingDomain)1 EMFCompareConfiguration (org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration)1 ComparisonScopeEditorInput (org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeEditorInput)1 DefaultComparisonFactory (org.eclipse.emf.compare.match.DefaultComparisonFactory)1 DefaultEqualityHelperFactory (org.eclipse.emf.compare.match.DefaultEqualityHelperFactory)1 IComparisonFactory (org.eclipse.emf.compare.match.IComparisonFactory)1 IMatchEngine (org.eclipse.emf.compare.match.IMatchEngine)1 IEObjectMatcher (org.eclipse.emf.compare.match.eobject.IEObjectMatcher)1 MatchEngineFactoryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl)1 MatchEngineFactoryRegistryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl)1 DefaultComparisonScope (org.eclipse.emf.compare.scope.DefaultComparisonScope)1 IComparisonScope (org.eclipse.emf.compare.scope.IComparisonScope)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1