本文整理汇总了Java中org.eclipse.emf.ecore.util.EcoreUtil.Copier.copyAll方法的典型用法代码示例。如果您正苦于以下问题:Java Copier.copyAll方法的具体用法?Java Copier.copyAll怎么用?Java Copier.copyAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.util.EcoreUtil.Copier
的用法示例。
在下文中一共展示了Copier.copyAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSavedURIFragment
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
/**
* Updates {@link IEObjectLocation#getSavedURIFragment() saved URI fragment}.
*
* @param container
* the {@link ILocationContainer}
* @param eObjectContainer
* the {@link IEObjectContainer}
* @param newResource
* the new {@link Resource}
* @throws Exception
* if the XMI serialization failed or elements couldn't be created
*/
private static void updateSavedURIFragment(ILocationContainer container,
IEObjectContainer eObjectContainer, Resource newResource) throws Exception {
final IBase base = MappingUtils.getBase(container);
final Copier copier = new Copier();
final Collection<EObject> copiedContents = copier.copyAll(newResource.getContents());
copier.copyReferences();
final XMIResourceImpl newXMIResource = new XMIResourceImpl();
newXMIResource.getContents().addAll(copiedContents);
for (Entry<EObject, EObject> entry : copier.entrySet()) {
final EObject newEObject = entry.getKey();
final EObject savedEObject = entry.getValue();
final ICouple couple = base.getFactory().createElement(ICouple.class);
couple.setKey(newResource.getURIFragment(newEObject));
couple.setValue(newXMIResource.getURIFragment(savedEObject));
eObjectContainer.getSavedURIFragments().add(couple);
}
}
示例2: initLocationEObject
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void initLocationEObject() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final TestEObjectContainerConnector testEObjectContainerConnector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(testEObjectContainerConnector);
final EObjectConnector eObjectConnector = new EObjectConnector();
MappingUtils.getConnectorRegistry().register(eObjectConnector);
super.initLocation(container, location, producerEClass);
final Object element = eObjectConnector.getElement(location);
assertTrue(element instanceof EObject);
assertEquals(producerEClass, element);
assertNull(location.getFeatureName());
MappingUtils.getConnectorRegistry().unregister(testEObjectContainerConnector);
MappingUtils.getConnectorRegistry().unregister(eObjectConnector);
}
示例3: initLocationSetting
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void initLocationSetting() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final TestEObjectContainerConnector testEObjectContainerConnector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(testEObjectContainerConnector);
final EObjectConnector eObjectConnector = new EObjectConnector();
MappingUtils.getConnectorRegistry().register(eObjectConnector);
super.initLocation(container, location, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name()));
final Object element = eObjectConnector.getElement(location);
assertTrue(element instanceof Setting);
assertEquals(producerEClass, ((Setting)element).getEObject());
assertEquals(EcorePackage.eINSTANCE.getENamedElement_Name(), ((Setting)element)
.getEStructuralFeature());
assertEquals("Producer", ((Setting)element).get(true));
assertEquals(EcorePackage.eINSTANCE.getENamedElement_Name().getName(), location.getFeatureName());
MappingUtils.getConnectorRegistry().unregister(testEObjectContainerConnector);
MappingUtils.getConnectorRegistry().unregister(eObjectConnector);
}
示例4: getLocationEObject
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void getLocationEObject() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
container.getContents().add(location);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, producerEClass);
assertEquals(location, super.getLocation(container, producerEClass));
assertEquals(null, super.getLocation(container, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name())));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例5: getLocationSetting
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void getLocationSetting() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
copier.copyReferences();
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
container.getContents().add(location);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name()));
assertEquals(null, super.getLocation(container, producerEClass));
assertEquals(location, super.getLocation(container, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name())));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例6: addToCopier
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
private static void addToCopier(Copier copier, Resource r, String metamodelName,
MetamodelNamespace ns) {
copier.copyAll(ns.getResource().getContents());
copier.copyReferences();
EPackage newRoot = getRoot(metamodelName, ns.getResource(), copier);
r.getContents().add(newRoot);
}
示例7: updateEObjectContainerEObjectLocationDeleted
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void updateEObjectContainerEObjectLocationDeleted() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IReport.class, new BaseElementFactory.FactoryDescriptor<TestReport>(
TestReport.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final ILocation target = new TestTextLocation();
final ILink link = new BaseElementFactoryTests.TestLink();
location.getTargetLinks().add(link);
link.setSource(location);
target.getSourceLinks().add(link);
link.setTarget(target);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, producerEClass);
resource.getContents().remove(producerEClass);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
assertTrue(location.isMarkedAsDeleted());
assertEquals(1, base.getReports().size());
final IReport report = base.getReports().get(0);
assertEquals(link, report.getLink());
assertTrue(report.getDescription().contains("Producer"));
assertTrue(report.getDescription().contains(location.getURIFragment()));
assertTrue(report.getDescription().contains("has been deleted."));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例8: updateEObjectContainerEObjectLocationChanged
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void updateEObjectContainerEObjectLocationChanged() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IReport.class, new BaseElementFactory.FactoryDescriptor<TestReport>(
TestReport.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final ILocation target = new TestTextLocation();
final ILink link = new BaseElementFactoryTests.TestLink();
location.getTargetLinks().add(link);
link.setSource(location);
target.getSourceLinks().add(link);
link.setTarget(target);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, producerEClass);
producerEClass.setInterface(!producerEClass.isInterface());
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
assertEquals(1, base.getReports().size());
final IReport report = base.getReports().get(0);
assertEquals(link, report.getLink());
assertTrue(report.getDescription().contains("Attribure interface was false changed to true."));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例9: updateEObjectContainerSettingLocationChanged
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void updateEObjectContainerSettingLocationChanged() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IReport.class, new BaseElementFactory.FactoryDescriptor<TestReport>(
TestReport.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final ILocation target = new TestTextLocation();
final ILink link = new BaseElementFactoryTests.TestLink();
location.getTargetLinks().add(link);
link.setSource(location);
target.getSourceLinks().add(link);
link.setTarget(target);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, new Setting() {
public void unset() {
// nothing to do here
}
public void set(Object newValue) {
// nothing to do here
}
public boolean isSet() {
return false;
}
public EStructuralFeature getEStructuralFeature() {
return EcorePackage.eINSTANCE.getEClass_Interface();
}
public EObject getEObject() {
return producerEClass;
}
public Object get(boolean resolve) {
return producerEClass.getName();
}
});
producerEClass.setInterface(!producerEClass.isInterface());
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
assertEquals(1, base.getReports().size());
final IReport report = base.getReports().get(0);
assertEquals(link, report.getLink());
assertTrue(report.getDescription().contains("Producer"));
assertTrue(report.getDescription().contains(location.getURIFragment()));
assertTrue(report.getDescription().contains(
"feature interface value false has been changed to true."));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例10: updateEObjectContainerSettingLocationManyRemoved
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入方法依赖的package包/类
@Test
public void updateEObjectContainerSettingLocationManyRemoved() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IReport.class, new BaseElementFactory.FactoryDescriptor<TestReport>(
TestReport.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass foodEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getFood());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final ILocation target = new TestTextLocation();
final ILink link = new BaseElementFactoryTests.TestLink();
location.getTargetLinks().add(link);
link.setSource(location);
target.getSourceLinks().add(link);
link.setTarget(target);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, new Setting() {
public void unset() {
// nothing to do here
}
public void set(Object newValue) {
// nothing to do here
}
public boolean isSet() {
return false;
}
public EStructuralFeature getEStructuralFeature() {
return EcorePackage.eINSTANCE.getEClass_EOperations();
}
public EObject getEObject() {
return foodEClass;
}
public Object get(boolean resolve) {
return foodEClass.getEOperations().get(1);
}
});
foodEClass.getEOperations().remove(1);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
assertEquals(1, base.getReports().size());
final IReport report = base.getReports().get(0);
assertEquals(link, report.getLink());
assertTrue(report.getDescription().contains("Food"));
assertTrue(report.getDescription().contains(location.getURIFragment()));
assertTrue(report.getDescription().contains("has been removed from feature eOperations."));
MappingUtils.getConnectorRegistry().unregister(connector);
}