diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/.ratings index a39d9e2e815bfea8397e4af49ba3c26d0aafbfe5..71eaf932efca4a341fdf614e5c2abe291331008b 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/.ratings @@ -1,4 +1,4 @@ -AnnotationLabelProvider.java b45aa4fcfb72726a4c43d2053a713aa5f6b3b7b5 GREEN +AnnotationLabelProvider.java 27d5bbb02d122e603abd158fa5a1fb39e79b0dc5 YELLOW CheckBoxLabelProvider.java 4030bef65a3b919cb087828b4616e5c966380e3e GREEN ElementCommentLabelProvider.java 76aa6e9b930ce5680607852fd776172942c89ce5 GREEN ElementLabelProviderBase.java f33502f73033ebdf30316df627e8a9c87e7d1b28 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/AnnotationLabelProvider.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/AnnotationLabelProvider.java index b45aa4fcfb72726a4c43d2053a713aa5f6b3b7b5..27d5bbb02d122e603abd158fa5a1fb39e79b0dc5 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/AnnotationLabelProvider.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/labelprovider/AnnotationLabelProvider.java @@ -35,7 +35,7 @@ import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart; public class AnnotationLabelProvider extends LabelProviderBase { /** Background color for annotations that cannot be edited (and that are not derived). */ - private static final Color READ_ONLY_ANNOTATION_BACKGROUND_COLOR = + public static final Color READ_ONLY_ANNOTATION_BACKGROUND_COLOR = SWTResourceManager.getColor(230, 230, 230); /** Background color for derived (computed) annotations. */ @@ -96,21 +96,33 @@ public class AnnotationLabelProvider extends LabelProviderBase { /** {@inheritDoc} */ @Override public Color getBackground(Object element) { + Color color = super.getBackground(element); if(element instanceof AnnotationEntry) { AnnotationEntry annotationEntry = (AnnotationEntry)element; if(annotationEntry.getModelElement().equals(viewPart.getCurrentlySelectedObject())) { - return super.getBackground(element); + return color; } - if(!annotationEntry.canEdit(clazz)) { - if(IDerivedAnnotation.class.isAssignableFrom(clazz) && - annotationEntry.getSpecificationValue(clazz) != null) { - return DERIVED_ANNOTATION_BACKGROUND_COLOR; - } - return READ_ONLY_ANNOTATION_BACKGROUND_COLOR; - } + return getAnnotatationBackgroundColor(annotationEntry, clazz, color); + } + return color; + } + + /** + * Returns the background {@link Color} for the {@link AnnotationEntry} of the given + * {@code type}. The method returns dedicated colors for special cases such as read-only or + * "derived" annotations. Otherwise, the provided {@code defaultColor} is returned. + */ + public static Color getAnnotatationBackgroundColor(AnnotationEntry annotationEntry, + Class<? extends IAnnotatedSpecification> type, Color defaultColor) { + if(annotationEntry.canEdit(type)) { + return defaultColor; + } + if(IDerivedAnnotation.class.isAssignableFrom(type) && + annotationEntry.getSpecificationValue(type) != null) { + return DERIVED_ANNOTATION_BACKGROUND_COLOR; } - return super.getBackground(element); + return READ_ONLY_ANNOTATION_BACKGROUND_COLOR; } /**