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

RED

refs 2255
parent eab646b4
No related branches found
No related tags found
No related merge requests found
......@@ -29,10 +29,9 @@ import org.fortiss.tooling.base.model.element.IModelElement;
/**
* </p>The class {@link AnnotationEntry} is responsible for providing those annotations of a given
* model
* element that are relevant for the current view. It should be noted that annotation views should
* never work directly on {@link IAnnotatedSpecification}s, but use {@link AnnotationEntry}s as an
* interface to the model.</p>
* model element that are relevant for the current view. It should be noted that annotation views
* should never work directly on {@link IAnnotatedSpecification}s, but use {@link AnnotationEntry}s
* as an interface to the model.</p>
*
* <p>
* {@link AnnotationEntry}
......@@ -52,8 +51,8 @@ import org.fortiss.tooling.base.model.element.IModelElement;
public final class AnnotationEntry {
/**
* Model element for which set of relevant {@link IAnnotatedSpecification}s is managed by this
* {@link AnnotationEntry}.
* Model element for which the set of relevant {@link IAnnotatedSpecification}s is managed by
* this {@link AnnotationEntry}.
*/
private IModelElement modelElement;
......@@ -68,11 +67,10 @@ public final class AnnotationEntry {
/** Constructs a new {@link AnnotationEntry}. */
public AnnotationEntry(IModelElement modelElement) {
this.modelElement = modelElement;
}
/**
* Predicate if the given {@link AnnotationEntry} is empty, i.e. if it does not contain any
* Predicate if the given {@link AnnotationEntry} is empty, i.e., if it does not contain any
* {@link IAnnotatedSpecification}s.
*/
public boolean isEmpty() {
......@@ -119,7 +117,7 @@ public final class AnnotationEntry {
getAnnotationValueProvider(clazz).setAnnotationName(name, specification);
}
throw new Exception("Could not find a AnnotationValueProvider for " + clazz.toString());
throw new Exception("Could not find an AnnotationValueProvider for " + clazz.toString());
}
/** Predicate if the given annotation can be edited. */
......@@ -134,7 +132,7 @@ public final class AnnotationEntry {
return false;
}
/** Predicate if the given annotation can be edited. */
/** Predicate if the given annotation can be edited. TODO(VA) for the given instanceKey? */
public boolean canEdit(Class<? extends IAnnotatedSpecification> clazz, String instanceKey) {
IAnnotatedSpecification specification = getSpecification(clazz);
......@@ -191,6 +189,8 @@ public final class AnnotationEntry {
if(isOperationEnabled(specification)) {
getAnnotationValueProvider(clazz).setAnnotationValue(value, specification, instanceKey);
} else {
// TODO(VA) The following exception and message are repeated many times. Would be worth
// factorizing? e.g., using a method "couldNotFindProviderExn(Class clazz)"
throw new Exception("Could not find a AnnotationValueProvider for " + clazz.toString());
}
}
......
......@@ -125,7 +125,7 @@ public class AnnotationValueService extends
new ArrayList<IAnnotationValueProvider<IAnnotatedSpecification>>(valueProviderSet);
// Cache the result as the lookup that walks the entire super-type hierarchy is really
// expensive (in particular since super.getRegisteredHandlers(current); also partially walks
// expensive (in particular since super.getRegisteredHandlers(current) also partially walks
// the super-type hierarchy to perform a nearest match.
valueProviderCache.put(modelElementClass, valueProviderList);
......@@ -203,6 +203,7 @@ public class AnnotationValueService extends
if(registeredHandlers != null && !registeredHandlers.isEmpty()) {
if(wrapIntoCommand) {
// TODO(VA) B17
KernelModelElementUtils.runAsCommand(element, new Runnable() {
@Override
......
......@@ -78,6 +78,9 @@ public interface IAnnotationValueProvider<T extends IAnnotatedSpecification> ext
public boolean canEdit(T specification, String instanceKey);
/** Returns the value of the annotation. */
// TODO(VA) In a couple of places, this method is called in a context where the thrown exception
// is just ignored.
// Might be worth adding an "exception-free" version of this method...?
public <U> U getAnnotationValue(T specification) throws Exception;
/**
......
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