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

Eliminate incorrect AnnotationInstSpec.getAnnotatedSpecification()


Issue-Ref: 4140
Issue-Url: #4140

Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent 7d5f379e
No related branches found
No related tags found
1 merge request!1444140: Remove AnnotationInstSpec.getAnnotatedSpecification()
Pipeline #30899 passed
Pipeline: maven-releng

#30900

    This commit is part of merge request !144. Comments created here will be created in the context of that merge request.
    AnnotationFxViewPart.java ca1548c49aa3842a9436262531464ba345b83688 GREEN AnnotationFxViewPart.java ca1548c49aa3842a9436262531464ba345b83688 GREEN
    AnnotationTreeTableUIProvider.java 8a6be639582f761db85908cca42533ab9289808d YELLOW AnnotationTreeTableUIProvider.java 85dfcf003c79d45f82c901b0f3f6bb30db59effa YELLOW
    AnnotationViewFXController.java 87d70534cde579cbd5f6470e729783306a139324 GREEN AnnotationViewFXController.java 4351373c216d0aa4539784c9742f4db8bbf161e6 YELLOW
    AnnotationsFXUtils.java 754152735e037da59a4c40fa045602c3ed85a40f GREEN AnnotationsFXUtils.java 754152735e037da59a4c40fa045602c3ed85a40f GREEN
    ColumnHandle.java 761c2517b3f3e4725feb7ce7e8d5927ba191a4bb GREEN ColumnHandle.java 7b0fe536d4eb9faa63c4d812f0c078cf83d0fd42 YELLOW
    FXAnnotationFilterContentProvider.java 2d3b32115f47bea44279e8bdf54691b93311d27b GREEN FXAnnotationFilterContentProvider.java ca4587ef5dce1288ee4d7bf3bea5bd544ce6b89e YELLOW
    ...@@ -58,10 +58,11 @@ import javafx.scene.paint.Color; ...@@ -58,10 +58,11 @@ import javafx.scene.paint.Color;
    } }
    return ""; return "";
    default: default:
    IAnnotatedSpecification columnSpec = this.viewController.colIdxAnnotationMap Class<? extends IAnnotatedSpecification> columnSpecType =
    .get(column).getAnnotatedSpecification(); this.viewController.colIdxAnnotationMap.get(column)
    .getAnnotatedSpecificationType();
    Object specificationValue = entry.getSpecificationValue(columnSpec.getClass()); Object specificationValue = entry.getSpecificationValue(columnSpecType);
    if(specificationValue != null) { if(specificationValue != null) {
    return specificationValue.toString(); return specificationValue.toString();
    } }
    ...@@ -89,9 +90,8 @@ import javafx.scene.paint.Color; ...@@ -89,9 +90,8 @@ import javafx.scene.paint.Color;
    /** {@inheritDoc} */ /** {@inheritDoc} */
    @Override @Override
    public void updateValue(AnnotationEntry element, int column, Object value) { public void updateValue(AnnotationEntry element, int column, Object value) {
    IAnnotatedSpecification specification = IAnnotatedSpecification spec = getAnnotation(column, element);
    this.viewController.colIdxAnnotationMap.get(column).getAnnotatedSpecification(); this.viewController.setAnnotationEntryValue(spec, element, (String)value);
    this.viewController.setAnnotationEntryValue(specification, element, (String)value);
    super.updateValue(element, column, value); super.updateValue(element, column, value);
    } }
    ...@@ -99,24 +99,29 @@ import javafx.scene.paint.Color; ...@@ -99,24 +99,29 @@ import javafx.scene.paint.Color;
    /** {@inheritDoc} */ /** {@inheritDoc} */
    @Override @Override
    public boolean isEditable(int column, AnnotationEntry ae) { public boolean isEditable(int column, AnnotationEntry ae) {
    IAnnotatedSpecification spec = getAnnotation(column, ae);
    // Check 'editable' predicate for specification/annotation contained by model element
    // associated to given annotation entry (if it exists)
    IAnnotationValueProvider<IAnnotatedSpecification> valueProvider =
    spec != null ? ae.getAnnotationValueProvider(spec.getClass()) : null;
    return valueProvider != null && valueProvider.canEdit(spec);
    }
    /** Get annotation specification associated to given annotation entry and column. */
    private IAnnotatedSpecification getAnnotation(int column, AnnotationEntry ae) {
    if(column > 1 && this.viewController.colIdxAnnotationMap.containsKey(column)) { if(column > 1 && this.viewController.colIdxAnnotationMap.containsKey(column)) {
    ColumnHandle<IAnnotatedSpecification> columnHandle = ColumnHandle<IAnnotatedSpecification> columnHandle =
    this.viewController.colIdxAnnotationMap.get(column); this.viewController.colIdxAnnotationMap.get(column);
    // Get annotation value provider for specification associated to given annotation entry
    Class<IAnnotatedSpecification> specType = columnHandle.getAnnotatedSpecificationType(); Class<IAnnotatedSpecification> specType = columnHandle.getAnnotatedSpecificationType();
    IAnnotationValueService as = IAnnotationValueService.getInstance(); IAnnotationValueService as = IAnnotationValueService.getInstance();
    IAnnotatedSpecification spec = IAnnotatedSpecification spec =
    as.getAnnotationEntry(ae.getModelElement()).getSpecification(specType); as.getAnnotationEntry(ae.getModelElement()).getSpecification(specType);
    return spec;
    // Check 'editable' predicate for specification/annotation contained by model element
    // associated to given annotation entry (if it exists)
    IAnnotationValueProvider<IAnnotatedSpecification> valueProvider =
    spec != null ? ae.getAnnotationValueProvider(spec.getClass()) : null;
    return valueProvider != null && valueProvider.canEdit(spec);
    } }
    return null;
    return false;
    } }
    /** {@inheritDoc} */ /** {@inheritDoc} */
    ......
    ...@@ -250,7 +250,8 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP ...@@ -250,7 +250,8 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
    for(AnnotationEntry entry : annotationEntries) { for(AnnotationEntry entry : annotationEntries) {
    for(IAnnotatedSpecification spec : entry.getSpecificationsList()) { for(IAnnotatedSpecification spec : entry.getSpecificationsList()) {
    ColumnHandle<IAnnotatedSpecification> columnHandle = ColumnHandle<IAnnotatedSpecification> columnHandle =
    new ColumnHandle<IAnnotatedSpecification>(entry, spec); new ColumnHandle<IAnnotatedSpecification>(entry,
    (Class<IAnnotatedSpecification>)spec.getClass());
    columnHandles.add(columnHandle); columnHandles.add(columnHandle);
    colNameToSpecification.put(columnHandle.getColumnName(), spec); colNameToSpecification.put(columnHandle.getColumnName(), spec);
    } }
    ...@@ -390,12 +391,11 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP ...@@ -390,12 +391,11 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
    /** Creates the annotation column for the given handle. */ /** Creates the annotation column for the given handle. */
    private TreeTableColumn<AnnotationEntry, ?> createColumnForHandle(int columnIdx, private TreeTableColumn<AnnotationEntry, ?> createColumnForHandle(int columnIdx,
    ColumnHandle<IAnnotatedSpecification> handle) { ColumnHandle<IAnnotatedSpecification> handle) {
    Class<IAnnotatedSpecification> annotationClass = Class<IAnnotatedSpecification> annotationType = handle.getAnnotatedSpecificationType();
    (Class<IAnnotatedSpecification>)handle.getAnnotatedSpecification().getClass();
    AnnotationEntry entry = handle.getEntry(); AnnotationEntry entry = handle.getEntry();
    IAnnotationValueProvider<IAnnotatedSpecification> valueProvider = IAnnotationValueProvider<IAnnotatedSpecification> valueProvider =
    entry.getAnnotationValueProvider(annotationClass); entry.getAnnotationValueProvider(annotationType);
    IAnnotatedSpecification specification = entry.getSpecification(annotationClass); IAnnotatedSpecification specification = entry.getSpecification(annotationType);
    EClassifier valueType = EClassifier valueType =
    valueProvider.getEStructuralFeatureDescriptor().getEType(specification); valueProvider.getEStructuralFeatureDescriptor().getEType(specification);
    ...@@ -418,11 +418,11 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP ...@@ -418,11 +418,11 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
    column = annotationViewer.addComboColumn(columnName, 150, rowEntry -> { column = annotationViewer.addComboColumn(columnName, 150, rowEntry -> {
    ValueProviderBase<IAnnotatedSpecification> annotationValueProvider = ValueProviderBase<IAnnotatedSpecification> annotationValueProvider =
    (ValueProviderBase<IAnnotatedSpecification>)rowEntry (ValueProviderBase<IAnnotatedSpecification>)rowEntry
    .getAnnotationValueProvider(annotationClass); .getAnnotationValueProvider(annotationType);
    EStructuralFeatureDescriptor structuralFeature = EStructuralFeatureDescriptor structuralFeature =
    annotationValueProvider.getEStructuralFeatureDescriptor(); annotationValueProvider.getEStructuralFeatureDescriptor();
    EClassifier type = EClassifier type =
    structuralFeature.getEType(rowEntry.getSpecification(annotationClass)); structuralFeature.getEType(rowEntry.getSpecification(annotationType));
    // Get the enum literals again, as it might be different for each row. // Get the enum literals again, as it might be different for each row.
    if(type instanceof EEnum) { if(type instanceof EEnum) {
    ......
    ...@@ -30,8 +30,8 @@ public class ColumnHandle<T extends IAnnotatedSpecification> extends AnnotationI ...@@ -30,8 +30,8 @@ public class ColumnHandle<T extends IAnnotatedSpecification> extends AnnotationI
    implements Comparable<ColumnHandle<T>> { implements Comparable<ColumnHandle<T>> {
    /** Constructs a new {@link ColumnHandle}. */ /** Constructs a new {@link ColumnHandle}. */
    public ColumnHandle(AnnotationEntry entry, T annotatedSpecification) { public ColumnHandle(AnnotationEntry entry, Class<T> specType) {
    super(entry, annotatedSpecification); super(entry, specType);
    } }
    /** /**
    ......
    ...@@ -175,8 +175,8 @@ public class FXAnnotationFilterContentProvider ...@@ -175,8 +175,8 @@ public class FXAnnotationFilterContentProvider
    * Returns true if the given specification passes the current annotation type * Returns true if the given specification passes the current annotation type
    * filter. * filter.
    */ */
    private boolean passesAnnotationTypeFilter(IAnnotatedSpecification spec) { private boolean passesAnnotationTypeFilter(Class<? extends IAnnotatedSpecification> specType) {
    return annotationTypeFilter == null || spec.getClass().equals(annotationTypeFilter); return annotationTypeFilter == null || specType.equals(annotationTypeFilter);
    } }
    /** /**
    ...@@ -186,8 +186,8 @@ public class FXAnnotationFilterContentProvider ...@@ -186,8 +186,8 @@ public class FXAnnotationFilterContentProvider
    public boolean passesColumnFilter(ColumnHandle<?> columnHandle) { public boolean passesColumnFilter(ColumnHandle<?> columnHandle) {
    // Whether the annotation is visible (i.e., not principally hidden from any // Whether the annotation is visible (i.e., not principally hidden from any
    // view) // view)
    boolean passesHiddenFilter = !columnHandle.getEntry() boolean passesHiddenFilter =
    .isHidden(columnHandle.getAnnotatedSpecification().getClass()); !columnHandle.getEntry().isHidden(columnHandle.getAnnotatedSpecificationType());
    // Pass name filter, if: name is not filtered, or the condition is met // Pass name filter, if: name is not filtered, or the condition is met
    boolean passesNameFilter = boolean passesNameFilter =
    ...@@ -196,7 +196,7 @@ public class FXAnnotationFilterContentProvider ...@@ -196,7 +196,7 @@ public class FXAnnotationFilterContentProvider
    // Check if column passes all tests // Check if column passes all tests
    // @CodeFormatterOff // @CodeFormatterOff
    return passesHiddenFilter && passesNameFilter && passesSelectedElementTypeFilter(columnHandle.getEntry()) return passesHiddenFilter && passesNameFilter && passesSelectedElementTypeFilter(columnHandle.getEntry())
    && passesAnnotationTypeFilter(columnHandle.getAnnotatedSpecification()); && passesAnnotationTypeFilter(columnHandle.getAnnotatedSpecificationType());
    // @CodeFormatterOn // @CodeFormatterOn
    } }
    ......
    AnnotationInstSpec.java b4f2ed47a8984e751e04049de5bdb3cad2c0a933 GREEN AnnotationInstSpec.java 7a6cb55bfa9cafa9ead1f72089e554ee8142e8bf YELLOW
    DerivedAnnotationValueProviderBase.java afedd21d3469127bbb20adb34c191b5c9c980f6c GREEN DerivedAnnotationValueProviderBase.java afedd21d3469127bbb20adb34c191b5c9c980f6c GREEN
    EStructuralFeatureDescriptor.java 9665d0d3040278243dd37591535e411a90fa63bf GREEN EStructuralFeatureDescriptor.java 9665d0d3040278243dd37591535e411a90fa63bf GREEN
    EStructuralFeatureValueProviderBase.java 287facbbce47c16d892bae82a214f64ceeef2263 GREEN EStructuralFeatureValueProviderBase.java 287facbbce47c16d892bae82a214f64ceeef2263 GREEN
    ......
    ...@@ -35,12 +35,12 @@ public class AnnotationInstSpec<T extends IAnnotatedSpecification> { ...@@ -35,12 +35,12 @@ public class AnnotationInstSpec<T extends IAnnotatedSpecification> {
    * {@link IAnnotatedSpecification} from {@code entry} to be displayed in the column * {@link IAnnotatedSpecification} from {@code entry} to be displayed in the column
    * represented by this {@link AnnotationInstSpec}. * represented by this {@link AnnotationInstSpec}.
    */ */
    private IAnnotatedSpecification annotatedSpecification; private Class<T> specType;
    /** Constructor. */ /** Constructor. */
    public AnnotationInstSpec(AnnotationEntry entry, T annotatedSpecification) { public AnnotationInstSpec(AnnotationEntry entry, Class<T> specType) {
    this.entry = entry; this.entry = entry;
    this.annotatedSpecification = annotatedSpecification; this.specType = specType;
    } }
    /** /**
    ...@@ -52,20 +52,11 @@ public class AnnotationInstSpec<T extends IAnnotatedSpecification> { ...@@ -52,20 +52,11 @@ public class AnnotationInstSpec<T extends IAnnotatedSpecification> {
    } }
    /** /**
    * Returns the {@link IAnnotatedSpecification} from {@code entry} to be displayed in the * Returns the type of {@link IAnnotatedSpecification} from {@code entry} to be displayed in the
    * column represented by this {@link AnnotationInstSpec}. * column represented by this {@link AnnotationInstSpec}.
    */ */
    @SuppressWarnings("unchecked")
    public Class<T> getAnnotatedSpecificationType() { public Class<T> getAnnotatedSpecificationType() {
    return (Class<T>)annotatedSpecification.getClass(); return specType;
    }
    /**
    * Returns the {@link IAnnotatedSpecification} from {@code entry} to be displayed in the
    * column represented by this {@link AnnotationInstSpec}.
    */
    public IAnnotatedSpecification getAnnotatedSpecification() {
    return annotatedSpecification;
    } }
    /** /**
    ......
    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