@ParameterizedTest @ArgumentsSource(ContextProvider.All.class) void testRemoveAttributes(Context context) throws IOException { String value0 = "Value0"; String value1 = "Value1"; String value2 = "Value2"; String value3 = "Value3"; try (PersistentResource resource = createPersistentResource(context)) { PrimaryObject primary = fillResource(resource); FeatureMap featureMapAttributes = primary.getFeatureMapAttributeCollection(); List<String> attributes1 = primary.getFeatureMapAttributeType1(); List<String> attributes2 = primary.getFeatureMapAttributeType2(); attributes1.add(value0); attributes1.add(value1); attributes2.add(value2); attributes1.add(value3); attributes1.remove(1); assertThat(attributes1).hasSize(2); assertThat(featureMapAttributes).hasSize(3); assertThat(featureMapAttributes.getValue(0)).isEqualTo(value0); assertThat(featureMapAttributes.getValue(1)).isEqualTo(value2); assertThat(featureMapAttributes.getValue(2)).isEqualTo(value3); attributes1.remove(value0); assertThat(attributes1).hasSize(1); assertThat(featureMapAttributes).hasSize(2); assertThat(featureMapAttributes.getValue(0)).isEqualTo(value2); assertThat(featureMapAttributes.getValue(1)).isEqualTo(value3); } }
@ParameterizedTest @ArgumentsSource(ContextProvider.All.class) void testSetAttributes(Context context) throws IOException { String value0 = "Value0"; String value1 = "Value1"; String value2 = "Value2"; String value3 = "Value3"; try (PersistentResource resource = createPersistentResource(context)) { PrimaryObject primary = fillResource(resource); FeatureMap featureMapAttributes = primary.getFeatureMapAttributeCollection(); List<String> attributes1 = primary.getFeatureMapAttributeType1(); List<String> attributes2 = primary.getFeatureMapAttributeType2(); attributes1.add(value0); attributes2.add(value1); attributes1.add(value2); assertThat(attributes1).hasSize(2); assertThat(attributes2).hasSize(1); assertThat(featureMapAttributes).hasSize(3); assertThat(featureMapAttributes.getValue(0)).isEqualTo(value0); assertThat(featureMapAttributes.getValue(1)).isEqualTo(value1); assertThat(featureMapAttributes.getValue(2)).isEqualTo(value2); attributes2.set(0, value3); // Replace 1 by 3 assertThat(attributes1).hasSize(2); assertThat(attributes2).hasSize(1); assertThat(featureMapAttributes).hasSize(3); assertThat(featureMapAttributes.getValue(0)).isEqualTo(value0); assertThat(featureMapAttributes.getValue(1)).isEqualTo(value3); assertThat(featureMapAttributes.getValue(2)).isEqualTo(value2); } }
@Override protected Object getValue(EObject object, EStructuralFeature feature) { // When the value is changed, the property sheet page doesn't update the property sheet viewer input // before refreshing, and this gets called on the obsolete wrapper. So, we need to read directly from the // model object. // //return needsEncoding(feature) ? encode((String)getEntryValue()) : getEntryValue(); FeatureMap featureMap = (FeatureMap)((EObject)owner).eGet(FeatureMapEntryWrapperItemProvider.this.feature); Object result = index >= 0 && index < featureMap.size() ? featureMap.getValue(index) : getEntryValue(); return needsEncoding(feature) ? encode((String)result) : result; }
@ParameterizedTest @ArgumentsSource(ContextProvider.All.class) void testAddAttributes(Context context) throws IOException { String value0 = "Value0"; String value1 = "Value1"; String value2 = "Value2"; String value3 = "Value3"; try (PersistentResource resource = createPersistentResource(context)) { PrimaryObject primary = fillResource(resource); FeatureMap featureMapAttributes = primary.getFeatureMapAttributeCollection(); List<String> attributes1 = primary.getFeatureMapAttributeType1(); List<String> attributes2 = primary.getFeatureMapAttributeType2(); attributes1.add(value0); attributes1.add(value1); attributes2.add(value2); attributes1.add(value3); assertThat(attributes1).hasSize(3); assertThat(attributes2).hasSize(1); assertThat(featureMapAttributes).hasSize(4); assertThat(featureMapAttributes.getValue(0)).isEqualTo(value0); assertThat(featureMapAttributes.getValue(1)).isEqualTo(value1); assertThat(featureMapAttributes.getValue(2)).isEqualTo(value2); assertThat(featureMapAttributes.getValue(3)).isEqualTo(value3); } }
/** * Call to handle copying the contained objects within a feature map. * @param featureMap the feature map the copy. * @since 2.10 */ protected void copyFeatureMap(FeatureMap featureMap) { for (int i = 0, size = featureMap.size(); i < size; ++i) { EStructuralFeature feature = featureMap.getEStructuralFeature(i); if (feature instanceof EReference && ((EReference)feature).isContainment()) { Object value = featureMap.getValue(i); if (value != null) { // The containment references are hooked up later during copyReferences. // copy((EObject)value); } } } }
/** * Call to handle copying the contained objects within a feature map. * @param featureMap the feature map the copy. * @since 2.10 */ protected void copyFeatureMap(FeatureMap featureMap) { for (int i = 0, size = featureMap.size(); i < size; ++i) { EStructuralFeature feature = featureMap.getEStructuralFeature(i); if (feature instanceof EReference && ((EReference)feature).isContainment()) { Object value = featureMap.getValue(i); if (value != null) { // The containment references are hooked up later during copyReferences. // copy((EObject)value); } } } }
for (int i = 0, size = featureMap.size(); i < size; ++i) if (featureMap.getValue(i) == eObject)
for (int i = 0, size = featureMap.size(); i < size; ++i) if (featureMap.getValue(i) == eObject)
assertThat(featureMapReferences).hasSize(3); assertThat(featureMapReferences.getValue(0)).isEqualTo(target0); assertThat(featureMapReferences.getValue(1)).isEqualTo(target1); assertThat(featureMapReferences.getValue(2)).isEqualTo(target2); assertThat(featureMapReferences).hasSize(3); assertThat(featureMapReferences.getValue(0)).isEqualTo(target0); assertThat(featureMapReferences.getValue(1)).isEqualTo(target3); assertThat(featureMapReferences.getValue(2)).isEqualTo(target2);
assertThat(featureMapReferences).hasSize(3); assertThat(featureMapReferences.getValue(0)).isEqualTo(target0); assertThat(featureMapReferences.getValue(1)).isEqualTo(target2); assertThat(featureMapReferences.getValue(2)).isEqualTo(target3); assertThat(featureMapReferences).hasSize(2); assertThat(featureMapReferences.getValue(0)).isEqualTo(target2); assertThat(featureMapReferences.getValue(1)).isEqualTo(target3);
@ParameterizedTest @ArgumentsSource(ContextProvider.All.class) void testAddReferences(Context context) throws IOException { TargetObject target0 = EFACTORY.createTargetObject(); target0.setName("Target0"); TargetObject target1 = EFACTORY.createTargetObject(); target1.setName("Target1"); TargetObject target2 = EFACTORY.createTargetObject(); target2.setName("Target2"); TargetObject target3 = EFACTORY.createTargetObject(); target3.setName("Target3"); try (PersistentResource resource = createPersistentResource(context)) { PrimaryObject primary = fillResource(resource); FeatureMap featureMapReferences = primary.getFeatureMapReferenceCollection(); List<TargetObject> references1 = primary.getFeatureMapReferenceType1(); List<TargetObject> references2 = primary.getFeatureMapReferenceType2(); references1.add(target0); references1.add(target1); references2.add(target2); references1.add(target3); assertThat(references1).hasSize(3); assertThat(references2).hasSize(1); assertThat(featureMapReferences).hasSize(4); assertThat(featureMapReferences.getValue(0)).isEqualTo(target0); assertThat(featureMapReferences.getValue(1)).isEqualTo(target1); assertThat(featureMapReferences.getValue(2)).isEqualTo(target2); assertThat(featureMapReferences.getValue(3)).isEqualTo(target3); } }
Meta meta = NCXFactory.eINSTANCE.createMeta(); meta.setName("dtb:uid"); //$NON-NLS-1$ meta.setContent(getIdentifier().getMixed().getValue(0).toString()); ncxTOC.getHead().getMetas().add(meta); int playOrder = 0;
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ public static StrucDocText createStrucDocText(Section section, String xmlString) { StrucDocText text = null; try { Resource.Factory factory = new GenericXMLResourceFactoryImpl(); XMLResource resource = (XMLResource) factory.createResource(null); resource.load(new URIConverter.ReadableInputStream("<text>" + xmlString + "</text>"), null); XMLTypeDocumentRoot root = (XMLTypeDocumentRoot) resource.getContents().get(0); AnyType value = (AnyType) root.getMixed().getValue(0); text = CDAFactory.eINSTANCE.createStrucDocText(); text.getMixed().addAll(value.getMixed()); section.setText(text); } catch (Exception e) { } return text; }
for (int j = 0, size = featureMap.size(); j < size; ++j) if (isIncludedEntry(featureMap.getEStructuralFeature(j)) && featureMap.getValue(j) != null)
for (int j = 0, size = featureMap.size(); j < size; ++j) if (isIncludedEntry(featureMap.getEStructuralFeature(j)) && featureMap.getValue(j) != null)
for (int j = 0, size = featureMap.size(); j < size; ++j) if (isIncludedEntry(featureMap.getEStructuralFeature(j)) && featureMap.getValue(j) != null)
for (int j = 0, size = featureMap.size(); j < size; ++j) if (isIncludedEntry(featureMap.getEStructuralFeature(j)) && featureMap.getValue(j) != null)
value = featureMap.getValue(j);