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

RED

refs 2255
parent 41c66e7a
No related branches found
No related tags found
No related merge requests found
...@@ -48,20 +48,19 @@ public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnot ...@@ -48,20 +48,19 @@ public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnot
private List<String> keys = new ArrayList<String>(); private List<String> keys = new ArrayList<String>();
/** /**
* Constructs a {@link IAnnotationValueProvider} for a pure derived annotations (i.e., an * Constructs a {@link IAnnotationValueProvider} for a pure derived annotation (i.e., an
* {@link IDerivedAnnotation} that does not contain any additional {@link EStructuralFeature}s. * {@link IDerivedAnnotation} that does not contain any additional {@link EStructuralFeature}s).
*/ */
public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass) { public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass) {
super(annotatedSpecificationEClass); super(annotatedSpecificationEClass);
handlesMultipleEstructuralFeatures = false; handlesMultipleEstructuralFeatures = false;
derivedKey = DEFAULT_KEY; derivedKey = DEFAULT_KEY;
keys.add(DEFAULT_KEY); keys.add(DEFAULT_KEY);
} }
/** /**
* Constructs a {@link IAnnotationValueProvider} for a pure derived annotations (i.e., an * Constructs a {@link IAnnotationValueProvider} for a pure derived annotations (i.e., an
* {@link IDerivedAnnotation} that does not contain any additional {@link EStructuralFeature}s. * {@link IDerivedAnnotation} that does not contain any additional {@link EStructuralFeature}s).
*/ */
public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass, public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass,
boolean isEditableByUser) { boolean isEditableByUser) {
...@@ -71,7 +70,7 @@ public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnot ...@@ -71,7 +70,7 @@ public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnot
/** /**
* Constructs a {@link IAnnotationValueProvider} for a derived annotations (i.e., based on an * Constructs a {@link IAnnotationValueProvider} for a derived annotations (i.e., based on an
* {@link IDerivedAnnotation}) that contains additional {@link EStructuralFeature}s. * {@link IDerivedAnnotation}) that contains additional {@link EStructuralFeature}s).
* *
* @param annotatedSpecificationEClass * @param annotatedSpecificationEClass
* {@link EClass} implementing the annotation * {@link EClass} implementing the annotation
...@@ -136,6 +135,7 @@ public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnot ...@@ -136,6 +135,7 @@ public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnot
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean canEdit(T specification, String instanceKey) { public boolean canEdit(T specification, String instanceKey) {
// TODO(VA) B11
if(isDerivedKey(instanceKey) && if(isDerivedKey(instanceKey) &&
!isEditableByUser || !isEditableByUser ||
(isEditableByUser && (!specification.isUserAnnotatedValuePreferred() && specification (isEditableByUser && (!specification.isUserAnnotatedValuePreferred() && specification
......
...@@ -39,7 +39,7 @@ import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; ...@@ -39,7 +39,7 @@ import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
* </p> * </p>
* *
* <p> * <p>
* The underlying {@link EMap} must be declared in the {@link IAnnotatedSpecification}'s meta-model * The underlying {@link EMap} must be declared in the {@link IAnnotatedSpecification}'s metamodel
* as detailed here: <a href="http://wiki.eclipse.org/EMF/FAQ#How_do_I_create_a_Map_in_EMF.3F"> * as detailed here: <a href="http://wiki.eclipse.org/EMF/FAQ#How_do_I_create_a_Map_in_EMF.3F">
* http://wiki.eclipse.org/EMF/FAQ#How_do_I_create_a_Map_in_EMF.3F</a>. * http://wiki.eclipse.org/EMF/FAQ#How_do_I_create_a_Map_in_EMF.3F</a>.
* </p> * </p>
...@@ -65,6 +65,9 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno ...@@ -65,6 +65,9 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno
EFactory valueFactory; EFactory valueFactory;
/** /**
* TODO(VA) Typo below "that whose". I don't fix myself cause it's also copy-pasted in the next
* comment, so I just let you have a look so that you can check if the copy-pasting is relevant.
*
* Constructs a multi-instance enabled {@link IAnnotationValueProvider} for a * Constructs a multi-instance enabled {@link IAnnotationValueProvider} for a
* {@link IAnnotatedSpecification} that whose storage is implemented by a single * {@link IAnnotatedSpecification} that whose storage is implemented by a single
* {@link EAttribute}. * {@link EAttribute}.
...@@ -96,6 +99,7 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno ...@@ -96,6 +99,7 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno
EMap<String, V> map = super.getAnnotationValue(specification, DEFAULT_KEY); EMap<String, V> map = super.getAnnotationValue(specification, DEFAULT_KEY);
return map.get(instanceKey); return map.get(instanceKey);
// TODO(VA) B10 ;-)
} }
...@@ -110,6 +114,14 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno ...@@ -110,6 +114,14 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno
EMap<String, V> map = super.getAnnotationValue(specification, DEFAULT_KEY); EMap<String, V> map = super.getAnnotationValue(specification, DEFAULT_KEY);
V val = (V)valueFactory.createFromString(valueDataType, value); V val = (V)valueFactory.createFromString(valueDataType, value);
// TODO(VA) I always find more beautiful to write:
// val = val == null ? (V)valueDataType.getDefaultValue() : val;
// val = val == null ? (V)valueFactory.createFromString(valueDataType, "0") : val;
// because more concise than the 6 above lines, but everybody hates me for that, so do it if
// you like it.
//
// If you don't, you could maybe put the second "if" inside the first one: semantically
// clearer.
if(val == null) { if(val == null) {
val = (V)valueDataType.getDefaultValue(); val = (V)valueDataType.getDefaultValue();
} }
...@@ -127,6 +139,7 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno ...@@ -127,6 +139,7 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno
if(value instanceof String) { if(value instanceof String) {
setAnnotationValueFromString((String)value, specification, instanceKey); setAnnotationValueFromString((String)value, specification, instanceKey);
} else { } else {
// TODO(VA) If you like unreadable but concise code, you can inline "map"
EMap<String, V> map = super.getAnnotationValue(specification, DEFAULT_KEY); EMap<String, V> map = super.getAnnotationValue(specification, DEFAULT_KEY);
map.put(instanceKey, value); map.put(instanceKey, value);
} }
...@@ -150,14 +163,19 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno ...@@ -150,14 +163,19 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno
kVMap = super.getAnnotationValue(specification, DEFAULT_KEY); kVMap = super.getAnnotationValue(specification, DEFAULT_KEY);
} catch(Exception e) { } catch(Exception e) {
// Ignore exception // Ignore exception
// TODO(VA) Theoretically B8, but I'm starting to question this guideline...
} }
if(kVMap != null) { if(kVMap != null) {
// TODO(VA) Slightly more concise than the two lines below:
// List<String> rval = new ArrayList<String>(kVMap.keySet());
List<String> rval = new ArrayList<String>(); List<String> rval = new ArrayList<String>();
rval.addAll(kVMap.keySet()); rval.addAll(kVMap.keySet());
// TODO(VA) B17
Collections.sort(rval); Collections.sort(rval);
return rval; return rval;
} }
// TODO(VA) B17
return Collections.emptyList(); return Collections.emptyList();
} }
......
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