diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationValueService.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationValueService.java index 1681a2aa4ad6627dce996d5dd5cd0775884e0071..12f7d6dbb3ad6d63ebbe412d3ee7f44b025cb608 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationValueService.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationValueService.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; import org.fortiss.tooling.base.model.element.IModelElement; @@ -81,8 +80,8 @@ public class AnnotationValueService extends for(IAnnotationValueProvider<IAnnotatedSpecification> annotationProvider : registeredHandlers) { List<? extends IModelElement> allChildren = - getAllChildren(root, element.getClass(), - annotationProvider.excludeModelElementTypeFromAnnotatedSpecification()); + getAllChildren(root, element.getClass(), annotationProvider + .excludeModelElementTypeFromAnnotatedSpecification()); for(final IModelElement e : allChildren) { IAnnotatedSpecification annotatedSpecification = @@ -128,40 +127,28 @@ public class AnnotationValueService extends /** * Returns all children from element of the given type and filters out children of the given - * filterOut list + * {@code modelElementTypesExcludedFromAnnotatedSpecification} list. */ private <S, T> List<? extends IModelElement> getAllChildren(EObject element, - Class<? extends IModelElement> type, List<Class<? extends EObject>> modelElementTypesExcludedFromAnnotatedSpecification) { + Class<? extends IModelElement> type, + List<Class<? extends EObject>> modelElementTypesExcludedFromAnnotatedSpecification) { - List<? extends IModelElement> results = new ArrayList<IModelElement>(); - if(modelElementTypesExcludedFromAnnotatedSpecification != null) - getAllChildren2(element, type, modelElementTypesExcludedFromAnnotatedSpecification, results); - else - results = EcoreUtils.getChildrenWithType(element, type); - return results; - - } - - /** depth search for desired elements */ - @SuppressWarnings("unchecked") - private <T, S> void getAllChildren2(EObject element, Class<? extends IModelElement> type, - List<Class<? extends EObject>> modelElementTypesExcludedFromAnnotatedSpecification, final List<T> results) { - - EList<EObject> eContents = element.eContents(); - for(EObject o : eContents) { - if(type.isInstance(o)) { - results.add((T)o); - getAllChildren2(o, type, modelElementTypesExcludedFromAnnotatedSpecification, results); - } else { - boolean filter = false; + List<? extends IModelElement> results = EcoreUtils.getChildrenWithType(element, type); + if(modelElementTypesExcludedFromAnnotatedSpecification != null) { + List<IModelElement> toRemove = new ArrayList<IModelElement>(); + for(IModelElement modelElement : results) { for(Class<?> c : modelElementTypesExcludedFromAnnotatedSpecification) { - if(c.isInstance(o)) - filter = true; + if(c.isInstance(modelElement)) { + toRemove.add(modelElement); + break; + } } - if(!filter) - getAllChildren2(o, type, modelElementTypesExcludedFromAnnotatedSpecification, results); } + + results.removeAll(toRemove); } + + return results; } /** {@inheritDoc} */ diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationLabelProvider.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationLabelProvider.java index 54278df1456d492bf6f6df8dcbad90c84ca346d8..a19d91091626b67bca7d56bd4ce1a37e098c94af 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationLabelProvider.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationLabelProvider.java @@ -63,7 +63,12 @@ public class AnnotationLabelProvider extends ColumnLabelProvider { if(element instanceof AnnotationEntry) { AnnotationEntry annotationEntry = (AnnotationEntry)element; - Object value = annotationEntry.getSpecificationValue(specClass, instanceKey); + Object value = null; + try { + value = annotationEntry.getSpecificationValue(specClass, instanceKey); + } catch(Exception e) { + // Ignore. Return "" in this case. + } if(value != null) { return value.toString(); }