From cf6692c89ad5bb61b8d2f9a076f175e4347e11d5 Mon Sep 17 00:00:00 2001 From: Johannes Eder <eder@fortiss.org> Date: Wed, 18 Dec 2013 15:15:08 +0000 Subject: [PATCH] refs 1841 --- .../ui/annotation/AnnotationViewPartBase.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationViewPartBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationViewPartBase.java index 827232413..3dd3f5cae 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationViewPartBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationViewPartBase.java @@ -17,11 +17,16 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.base.ui.annotation; +import static org.eclipse.swt.SWT.COLOR_DARK_GRAY; + import java.util.List; import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.part.ViewPart; @@ -41,6 +46,12 @@ import org.fortiss.tooling.kernel.ui.util.SelectionUtils; public abstract class AnnotationViewPartBase<T extends EObject, V extends IAnnotatedSpecification> extends ViewPart implements ISelectionListener { + /** Color of the selected component */ + protected Color currentlySelectedColor = Display.getCurrent().getSystemColor(SWT.COLOR_CYAN); + + /** Color of non editable components */ + protected Color notEditibleColor = Display.getCurrent().getSystemColor(COLOR_DARK_GRAY); + /** The currently selected Object */ private T currentlySelectedObject; @@ -67,7 +78,8 @@ public abstract class AnnotationViewPartBase<T extends EObject, V extends IAnnot currentlySelectedObject = (T)editPart.getModel(); } - if(currentlySelectedObject != null) { + if(currentlySelectedObject instanceof EObject && + isAcceptedSelection(currentlySelectedObject)) { addAll(); annotatedSpecification = extractAnnotatedSpecification(); onUpdateView(); @@ -104,6 +116,9 @@ public abstract class AnnotationViewPartBase<T extends EObject, V extends IAnnot /** Returns all annotated specs of Type V */ protected abstract List<V> getAllAnnotatedSpecs(); + /** called every time the view is updated */ protected abstract void onUpdateView(); + protected abstract boolean isAcceptedSelection(EObject object); + } -- GitLab