Skip to content
Snippets Groups Projects
Commit ec83c1a0 authored by Simon Barner's avatar Simon Barner
Browse files

- Use pickFirstInstanceOf instead of manually implemented loop

refs 1841
parent 0d14c03b
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.annotation.valueprovider;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
......@@ -34,7 +36,6 @@ import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.base.ui.annotation.AnnotationEntry;
import org.fortiss.tooling.base.ui.annotation.editingsupport.ComboBoxEditingSupport;
import org.fortiss.tooling.base.ui.annotation.editingsupport.TextEditingSupport;
......@@ -221,11 +222,15 @@ public abstract class ValueProviderBase<T extends IAnnotatedSpecification> imple
@SuppressWarnings("unchecked")
@Override
public T getAnnotatedSpecificationForModelElement(IModelElement element) throws Exception {
// Return existing annotation
for(IModelElementSpecification specification : element.getSpecifications()) {
if(annotatedSpecificationEClass.equals(specification.eClass())) {
return (T)specification;
}
T rval =
(T)pickFirstInstanceOf(
(Class<IAnnotatedSpecification>)annotatedSpecificationEClass
.getInstanceClass(),
element.getSpecifications());
if(rval != null) {
return rval;
}
// Create annotation
......
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