diff --git a/plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/decorators/BaseDecorator.java b/plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/decorators/BaseDecorator.java index 6df134c76d..f3cacd8617 100644 --- a/plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/decorators/BaseDecorator.java +++ b/plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/decorators/BaseDecorator.java @@ -25,9 +25,9 @@ */ public abstract class BaseDecorator extends AbstractDecorator { - private IGraphicalEditPart gep; + protected IGraphicalEditPart gep; - private EObject semanticElement; + protected EObject semanticElement; public BaseDecorator(IDecoratorTarget decoratorTarget) { super(decoratorTarget); @@ -54,9 +54,6 @@ public void activate() { public void deactivate() { removeDecoration(); - IGraphicalEditPart gep = (IGraphicalEditPart) getDecoratorTarget() - .getAdapter(IGraphicalEditPart.class); - assert gep != null; DiagramEventBroker.getInstance(gep.getEditingDomain()) .removeNotificationListener(semanticElement, diff --git a/plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/TransitionPriorityDecorationProvider.java b/plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/TransitionPriorityDecorationProvider.java index c7ea9867cf..5870b0577d 100644 --- a/plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/TransitionPriorityDecorationProvider.java +++ b/plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/TransitionPriorityDecorationProvider.java @@ -13,9 +13,12 @@ import java.util.ArrayList; import java.util.List; +import org.eclipse.emf.common.notify.Notification; import org.eclipse.gef.EditDomain; import org.eclipse.gef.EditPart; import org.eclipse.gef.editparts.AbstractConnectionEditPart; +import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; +import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator; @@ -27,6 +30,8 @@ import org.eclipse.ui.IEditorPart; import org.yakindu.base.gmf.runtime.decorators.AbstractDecoratorProvider; import org.yakindu.base.gmf.runtime.decorators.BaseDecorator; +import org.yakindu.sct.model.sgraph.SGraphPackage; +import org.yakindu.sct.model.sgraph.State; import org.yakindu.sct.model.sgraph.Transition; import org.yakindu.sct.model.sgraph.Vertex; import org.yakindu.sct.ui.editor.DiagramActivator; @@ -58,7 +63,7 @@ public void createDecorators(IDecoratorTarget decoratorTarget) { if (!(ed instanceof DiagramEditDomain)) { return; } - if (shouldInstall(((DiagramEditDomain) ed).getEditorPart())) { + if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof TransitionEditPart) { IDecorator decorator = createStatusDecorator(decoratorTarget); decorators.add(decorator); decoratorTarget.installDecorator(getDecoratorKey(), decorator); @@ -84,6 +89,32 @@ public PriorityDecorator(IDecoratorTarget decoratorTarget) { super(decoratorTarget); } + protected NotificationListener transitionPriorityChangeListener = new NotificationListener() { + + public void notifyChanged(Notification notification) { + if (notification.getFeatureID(State.class) == SGraphPackage.STATE__OUTGOING_TRANSITIONS) + refresh(); + } + }; + + @Override + public void activate() { + super.activate(); + // priorities will be changed via reordering the list of transitions + // within the owning element + Vertex owningElement = (Vertex) ((Transition) semanticElement).eContainer(); + DiagramEventBroker.getInstance(gep.getEditingDomain()).addNotificationListener(owningElement, + transitionPriorityChangeListener); + } + + @Override + public void deactivate() { + Vertex owningElement = (Vertex) ((Transition) semanticElement).eContainer(); + DiagramEventBroker.getInstance(gep.getEditingDomain()).removeNotificationListener(owningElement, + transitionPriorityChangeListener); + super.deactivate(); + } + @Override public void refresh() { removeDecoration(); @@ -120,8 +151,8 @@ public int getPriority(TransitionEditPart editPart) { Transition transition = ((Transition) editPart.resolveSemanticElement()); Vertex container = (Vertex) transition.eContainer(); int indexOf = container.getOutgoingTransitions().indexOf(transition); - //visible priorities should start with 1 - return indexOf+1; + // visible priorities should start with 1 + return indexOf + 1; } }