Skip to content
Snippets Groups Projects
Commit 41c66e7a authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

RED

refs 2255
parent 7f4b7a6e
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,11 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
protected boolean handlesMultipleEstructuralFeatures;
/**
* FIXME(VA) a few typos in all the following constructor comments ("that whose", "of of",
* "is implemented all").
* (could fix it myself but since it appears in a bunch of places, I guess it's the outcome of a
* copy-paste so I let you check how relevant it is).
*
* Constructs a {@link IAnnotationValueProvider} for a {@link IAnnotatedSpecification} that
* whose storage is implemented by a single {@link EAttribute}.
*/
......@@ -117,6 +122,8 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
}
/**
* TODO(VA) Exactly the same comment as above, but I guess it should be updated
*
* Constructs a {@link IAnnotationValueProvider} for a {@link IAnnotatedSpecification} that
* whose storage is implemented all {@link EStructuralFeature}s defined locally in a single
* {@link EClass} (i.e., not considering inherited attributes). The instance keys, and the
......@@ -137,6 +144,8 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
featureList = annotatedSpecificationEClass.getEStructuralFeatures();
}
// TODO(VA) Couldn't the two following blocks be factorized in only one loop?
// Is there a reason why we use the DEFAULT_KEY when there is only feature?
if(featureList.size() == 1) {
if(featureList.get(0) instanceof EAttribute) {
structuralFeatureDescriptorMap.put(DEFAULT_KEY, new EStructuralFeatureDescriptor(
......@@ -168,6 +177,7 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
*/
public EStructuralFeature getEStructuralFeature(T specification, String instanceKey)
throws Exception {
// TODO(VA) B11
EStructuralFeature structuralFeature =
structuralFeatureDescriptorMap.get(instanceKey)
.getEStructuralFeature(specification);
......@@ -201,6 +211,7 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
EStructuralFeature structuralFeature = getEStructuralFeature(specification, instanceKey);
if(structuralFeature instanceof EAttribute) {
// TODO(VA) B11
specification.eSet(
structuralFeature,
getEFactory(structuralFeature).createFromString(
......@@ -223,10 +234,10 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
public <U> void setAnnotationValue(U value, T specification, String instanceKey)
throws Exception {
if(value instanceof String) {
// In case, the input choice is presented in dynamically managed combo box (i.e., where
// new value choices can be entered by the user, the empty String indicates that the
// In case the input choice is presented in dynamically managed combo box (i.e., where
// new value choices can be entered by the user), the empty String indicates that the
// current value should be deleted, and a neighboring value from the set should be used.
// In case the last occurrence of a value choice has been removed, it will be no longer
// In case the last occurrence of a value choice has been removed, it will no longer
// be offered in the combo box.
if(((String)value).isEmpty()) {
String rval =
......@@ -301,9 +312,9 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
}
/**
* Creates a new instance of the {@link EStructuralFeature} (use to populate newly created
* Creates a new instance of the {@link EStructuralFeature} (used to populate newly created
* annotation instances created in
* {@link #getAnnotatedSpecificationForModelElement(IModelElement)}.
* {@link #getAnnotatedSpecificationForModelElement(IModelElement)}).
*/
protected Object createStructuralFeatureInstance(String instanceKey) throws Exception {
EStructuralFeature structuralFeature = getEStructuralFeature(null, instanceKey);
......@@ -314,6 +325,7 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
EDataType attributeEDataType = ((EAttribute)structuralFeature).getEAttributeType();
if(structuralFeature.getDefaultValueLiteral() != null) {
// TODO(VA) B11
// Use default value if it has been specified
return factory.createFromString(attributeEDataType,
structuralFeature.getDefaultValueLiteral());
......@@ -338,6 +350,7 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
// Create and set structural feature implementing the annotation
Object structuralFeatureVal = createStructuralFeatureInstance(instanceKey);
if(structuralFeatureVal != null) {
// TODO(VA) B11
specification.eSet(getEStructuralFeature(specification, instanceKey),
structuralFeatureVal);
}
......
......@@ -261,6 +261,7 @@ public abstract class ValueProviderBase<T extends IAnnotatedSpecification> imple
// TODO(VA,B11)
if((value == null || value.isEmpty()) && currentInputChoiceMap.get(instanceKey) != null &&
!currentInputChoiceMap.get(instanceKey).isEmpty()) {
// Only one entry left: do not remove
if(currentInputChoiceMap.get(instanceKey).size() == 1) {
return currentInputChoiceMap.get(instanceKey).iterator().next();
......@@ -292,6 +293,27 @@ public abstract class ValueProviderBase<T extends IAnnotatedSpecification> imple
}
rval = s;
}
// TODO(VA) Not sure if it's much better but the following code is I think equivalent
// and covers all the cases at once:
//
// String currentValue = getAnnotationValue(specification);
// String rval = null;
// boolean valueSeen = false;
// for(String s : currentInputChoiceMap.get(instanceKey)) {
// if(s.equals(currentValue)) {
// valueSeen = true;
// } else {
// rval = s;
// }
// if (valueSeen && rval != null) {
// break;
// }
// }
// if(rval != null) {
// currentInputChoiceMap.get(instanceKey).remove(currentValue);
// }
// return rval;
}
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment