当前位置: 首页>>代码示例>>Java>>正文


Java DefaultComparisonScope类代码示例

本文整理汇总了Java中org.eclipse.emf.compare.scope.DefaultComparisonScope的典型用法代码示例。如果您正苦于以下问题:Java DefaultComparisonScope类的具体用法?Java DefaultComparisonScope怎么用?Java DefaultComparisonScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultComparisonScope类属于org.eclipse.emf.compare.scope包,在下文中一共展示了DefaultComparisonScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compareEObjects

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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();
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:22,代码来源:GenericTraceExtractor.java

示例2: findMatchingObjects

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
protected List<EObject> findMatchingObjects(final EObject model, final Collection<EObject> objects) {
  boolean _isEmpty = objects.isEmpty();
  if (_isEmpty) {
    throw new IllegalArgumentException();
  }
  Resource _eResource = model.eResource();
  EObject _head = IterableExtensions.<EObject>head(objects);
  Resource _eResource_1 = _head.eResource();
  final DefaultComparisonScope scope = new DefaultComparisonScope(_eResource, _eResource_1, null);
  EMFCompare.Builder _builder = EMFCompare.builder();
  EMFCompare _build = _builder.build();
  final Comparison comparison = _build.compare(scope);
  final Function1<EObject, EObject> _function = new Function1<EObject, EObject>() {
    @Override
    public EObject apply(final EObject object) {
      Match _match = comparison.getMatch(object);
      return _match.getLeft();
    }
  };
  Iterable<EObject> _map = IterableExtensions.<EObject, EObject>map(objects, _function);
  Iterable<EObject> _filterNull = IterableExtensions.<EObject>filterNull(_map);
  return IterableExtensions.<EObject>toList(_filterNull);
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:24,代码来源:GenericModelMerger.java

示例3: match

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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);
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:SCTMatchEngineFactory.java

示例4: compareEObjects

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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();
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:28,代码来源:DiffComputer.java

示例5: updateEObjectContainer

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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);
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:39,代码来源:EObjectConnector.java

示例6: findMatchingObject

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
@Override
public EObject findMatchingObject(final EObject model, final EObject object) {
  Resource _eResource = model.eResource();
  Resource _eResource_1 = object.eResource();
  final DefaultComparisonScope scope = new DefaultComparisonScope(_eResource, _eResource_1, null);
  EMFCompare.Builder _builder = EMFCompare.builder();
  EMFCompare _build = _builder.build();
  final Comparison comparison = _build.compare(scope);
  Match _match = comparison.getMatch(object);
  return _match.getLeft();
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:12,代码来源:GenericModelMerger.java

示例7: merge

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
@Override
public void merge(final EObject source, final EObject destination) {
  final DefaultComparisonScope scope = new DefaultComparisonScope(destination, source, null);
  EMFCompare.Builder _builder = EMFCompare.builder();
  EMFCompare _build = _builder.build();
  final Comparison comparison = _build.compare(scope);
  EMFCompareRCPPlugin _default = EMFCompareRCPPlugin.getDefault();
  IMerger.Registry _mergerRegistry = _default.getMergerRegistry();
  final BatchMerger merger = new BatchMerger(_mergerRegistry);
  EList<Diff> _differences = comparison.getDifferences();
  BasicMonitor _basicMonitor = new BasicMonitor();
  merger.copyAllRightToLeft(_differences, _basicMonitor);
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:14,代码来源:GenericModelMerger.java

示例8: assertTraceEquals

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
protected void assertTraceEquals(Trace t2gTraceModel, ModelExtent actualTraceModel) throws IOException {
    assertEquals(1, t2gTraceModel.getTraceContent().size());
    EObject expectedTrace = t2gTraceModel.getTraceContent().get(0);
    assertEquals(1, actualTraceModel.getContents().size());
    EObject actualTrace = actualTraceModel.getContents().get(0);

    sortTraceRecords(expectedTrace);
    sortTraceRecords(actualTrace);

    debugSerialize(Arrays.asList(expectedTrace), actualTraceModel.getContents());

    DefaultComparisonScope scope = new DefaultComparisonScope(expectedTrace, actualTrace, null);
    DefaultDiffEngine de = new DefaultDiffEngine() {

        @Override
        protected FeatureFilter createFeatureFilter() {
            return new FeatureFilter() {
                private final Collection<EClass> ignoredEClasses = Sets.newHashSet(
                        TracePackage.eINSTANCE.getMappingOperationToTraceRecordMapEntry(),
                        TracePackage.eINSTANCE.getObjectToTraceRecordMapEntry());

                @Override
                protected boolean isIgnoredReference(Match match, EReference reference) {
                    if (ignoredEClasses.contains(reference.getEContainingClass())) {
                        return true;
                    }
                    return super.isIgnoredReference(match, reference);
                }
            };
        }
    };

    Comparison comparison = EMFCompare.builder().setDiffEngine(de).build().compare(scope);
    assertEquals(prettyPrint(comparison), 0, comparison.getDifferences().size());
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:36,代码来源:TraceRecordTransformationTestBase.java

示例9: buildComparisonScope

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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);
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:9,代码来源:Test.java

示例10: isFixed

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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;
    }
 
开发者ID:adisandro,项目名称:MMINT,代码行数:15,代码来源:Fix.java

示例11: compareStrict

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:ComparisonManager.java

示例12: compareStrict

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
public Comparison compareStrict(EObject expected, EObject actual) {
    DefaultComparisonScope scope = new DefaultComparisonScope(expected, actual, null);
    return EMFCompare.builder().build().compare(scope);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:ModelComparator.java

示例13: compare

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
public Comparison compare(EObject expected, EObject actual) {
    DefaultComparisonScope scope = new DefaultComparisonScope(expected, actual, null);
    scope.setEObjectContentFilter(o -> IGNORED_ECLASSES.stream().allMatch(c -> !c.isSuperTypeOf(o.eClass())));
    return createComparator().compare(scope);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:6,代码来源:ModelComparator.java

示例14: execute

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的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;
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:46,代码来源:AbstractCompareWithRouteActionHandler.java

示例15: doTest

import org.eclipse.emf.compare.scope.DefaultComparisonScope; //导入依赖的package包/类
/**
 * test method
 * 
 * @throws IOException
 */
@Test
public void doTest() throws IOException {
	TransformationExecutor exe = new TransformationExecutor();

	// setup tmp resource
	Resource[] resources = initResources(testCase);
	exe.setSourceModelFile(resources[0]);
	exe.setTargetModelFile(resources[1]);

	// get expected model
	EObject expectedModel = EcoreUtil.copy(testCase.getCromModel());

	// execute transformation
	try {
		exe.execute();
	} catch (Exception e) {
		fail("Error in transformation execution of test case \""
				+ testCase.eResource().getURI().toFileString() + "\":\n"
				+ e.toString());
	}
	// reload all resources
	for (Resource res : resources) {
		res.load(Collections.EMPTY_MAP);
	}

	// get transformed model
	EObject toCompare = resources[1].getContents().get(0);

	// create emf comparator
	IComparisonScope scope = new DefaultComparisonScope(expectedModel,
			toCompare, null);
	EMFCompare comparator = setupComparator();

	// compare both models
	Comparison comp = comparator.compare(scope);

	int diffs = comp.getDifferences().size();

	// if there are diffs this test failed
	if (diffs > 0) {
		// build error message
		StringBuilder builder = new StringBuilder();
		builder.append("Test \"");
		builder.append(testCase.getTitle());
		builder.append("\" failed :\n");
		builder.append("\tDescription: ");
		builder.append(testCase.getDescription());
		builder.append("\n\n");
		
		builder.append("Expected model:\n");
		builder.append(getModelXML(expectedModel));
		
		builder.append("\n\n");
		builder.append("Current model:\n");
		builder.append(getModelXML(toCompare));
		
		builder.append("\n\n");
		builder.append("\tDifferences: ");
		builder.append(comp.getDifferences());

		// some empty lines
		for (int i = 0; i < 3; i++) {
			builder.append("\n");
		}

		// Fail it!
		fail(builder.toString());
	}
}
 
开发者ID:leondart,项目名称:FRaMED,代码行数:75,代码来源:TransformationTestSuite.java


注:本文中的org.eclipse.emf.compare.scope.DefaultComparisonScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。