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

Add getAnnotatationBackgroundColor()

* Enable re-use of color scheme also for other editors that embed
  annotations

Issue-Ref: 3696
Issue-Url: https://af3-developer.fortiss.org/issues/3696



Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent 1bac7104
No related branches found
No related tags found
1 merge request!543696: Memory Modeling
AnnotationLabelProvider.java b45aa4fcfb72726a4c43d2053a713aa5f6b3b7b5 GREEN AnnotationLabelProvider.java 27d5bbb02d122e603abd158fa5a1fb39e79b0dc5 YELLOW
CheckBoxLabelProvider.java 4030bef65a3b919cb087828b4616e5c966380e3e GREEN CheckBoxLabelProvider.java 4030bef65a3b919cb087828b4616e5c966380e3e GREEN
ElementCommentLabelProvider.java 76aa6e9b930ce5680607852fd776172942c89ce5 GREEN ElementCommentLabelProvider.java 76aa6e9b930ce5680607852fd776172942c89ce5 GREEN
ElementLabelProviderBase.java f33502f73033ebdf30316df627e8a9c87e7d1b28 GREEN ElementLabelProviderBase.java f33502f73033ebdf30316df627e8a9c87e7d1b28 GREEN
......
...@@ -35,7 +35,7 @@ import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart; ...@@ -35,7 +35,7 @@ import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart;
public class AnnotationLabelProvider extends LabelProviderBase { public class AnnotationLabelProvider extends LabelProviderBase {
/** Background color for annotations that cannot be edited (and that are not derived). */ /** 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); SWTResourceManager.getColor(230, 230, 230);
/** Background color for derived (computed) annotations. */ /** Background color for derived (computed) annotations. */
...@@ -96,21 +96,33 @@ public class AnnotationLabelProvider extends LabelProviderBase { ...@@ -96,21 +96,33 @@ public class AnnotationLabelProvider extends LabelProviderBase {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Color getBackground(Object element) { public Color getBackground(Object element) {
Color color = super.getBackground(element);
if(element instanceof AnnotationEntry) { if(element instanceof AnnotationEntry) {
AnnotationEntry annotationEntry = (AnnotationEntry)element; AnnotationEntry annotationEntry = (AnnotationEntry)element;
if(annotationEntry.getModelElement().equals(viewPart.getCurrentlySelectedObject())) { if(annotationEntry.getModelElement().equals(viewPart.getCurrentlySelectedObject())) {
return super.getBackground(element); return color;
} }
if(!annotationEntry.canEdit(clazz)) { return getAnnotatationBackgroundColor(annotationEntry, clazz, color);
if(IDerivedAnnotation.class.isAssignableFrom(clazz) && }
annotationEntry.getSpecificationValue(clazz) != null) { return color;
return DERIVED_ANNOTATION_BACKGROUND_COLOR; }
}
return READ_ONLY_ANNOTATION_BACKGROUND_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;
} }
/** /**
......
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