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


Java IComparisonScope类代码示例

本文整理汇总了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();
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:22,代码来源:GenericTraceExtractor.java

示例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);
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:SCTMatchEngineFactory.java

示例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);
}
 
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:31,代码来源:LazyMatchEngine.java

示例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;

}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:30,代码来源:JaMoPPDiffer.java

示例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();
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:28,代码来源:DiffComputer.java

示例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);
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:39,代码来源:EObjectConnector.java

示例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);
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:9,代码来源:Test.java

示例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);
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:10,代码来源:Test.java

示例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;
    }
 
开发者ID:adisandro,项目名称:MMINT,代码行数:15,代码来源:Fix.java

示例10: isMatchEngineFactoryFor

import org.eclipse.emf.compare.scope.IComparisonScope; //导入依赖的package包/类
@Override
public boolean isMatchEngineFactoryFor(IComparisonScope scope) {
	return true;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:5,代码来源:SCTMatchEngineFactory.java

示例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);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:ComparisonManager.java

示例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;
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:46,代码来源:AbstractCompareWithRouteActionHandler.java

示例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);
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:4,代码来源:Test.java

示例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;		
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:57,代码来源:Activator.java


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