Browse Source

Merge pull request #865 from Yakindu/issue_864

Avoid unregistered transitionPriorityChangeListener
Andreas Mülder 9 years ago
parent
commit
034333e010

+ 1 - 1
manual-tests/org.yakindu.sct.test.manual/testcases/sct_testcase_02_editor.textile

@@ -24,4 +24,4 @@ h1(#Test2). Yakindu SCT Testcase 02 - Editor
 | 2.16.3 | Navigator View | Expand the region entry in the tree view. | The initial state and the LightOff and LightOn states are displayed as children with icons. | %{color:red}open% |
 | 2.16.4 | Navigator View | Expand the states entries in the tree view. | The outgoing transitions of the states are displayed with icon and trigger/guard. | %{color:red}open% |
 | 2.17 | View | Press *[Ctrl++]* to zoom in and *[Ctrl++]* to zoom out. | The view should zoom in and out. | %{color:red}open% |
-
+| 2.18 | Undo & Redo | Select a region which includes at least a state with an outgoing transition <p> Press *DEL* to delete the region <p>Undo deletion by Strg+Z <p> Redo deletion by Strg+Y <p> Try to move the affected element by dragging | The deletion should properly be undone an redone<p> The elements involved during undo and redo have to be still changeable (move, delete change e.g. name) afterwards | %{color:red}open% |

File diff suppressed because it is too large
+ 1 - 0
manual-tests/org.yakindu.sct.test.manual/testcases/sct_testcase_12_refactor.textile


+ 13 - 8
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/TransitionPriorityDecorationProvider.java

@@ -82,6 +82,8 @@ public class TransitionPriorityDecorationProvider extends AbstractDecoratorProvi
 
 	public static class PriorityDecorator extends BaseDecorator {
 
+		private Vertex owningElement;
+
 		public PriorityDecorator(IDecoratorTarget decoratorTarget) {
 			super(decoratorTarget);
 		}
@@ -101,20 +103,23 @@ public class TransitionPriorityDecorationProvider extends AbstractDecoratorProvi
 					|| !(((Transition) semanticElement).eContainer() instanceof Vertex)) {
 				return;
 			}
-			Vertex owningElement = (Vertex) ((Transition) semanticElement).eContainer();
-			DiagramEventBroker.getInstance(gep.getEditingDomain()).addNotificationListener(owningElement,
-					transitionPriorityChangeListener);
+			if (((Transition) semanticElement).eContainer() != null) {
+				owningElement = (Vertex) ((Transition) semanticElement).eContainer();
+				DiagramEventBroker.getInstance(gep.getEditingDomain()).addNotificationListener(owningElement,
+						transitionPriorityChangeListener);
+			}
 		}
 
 		@Override
 		public void deactivate() {
-			if (!(semanticElement instanceof Transition)
-					|| !(((Transition) semanticElement).eContainer() instanceof Vertex)) {
+			if (!(semanticElement instanceof Transition)) {
 				return;
 			}
-			Vertex owningElement = (Vertex) ((Transition) semanticElement).eContainer();
-			DiagramEventBroker.getInstance(gep.getEditingDomain()).removeNotificationListener(owningElement,
-					transitionPriorityChangeListener);
+			if (owningElement != null) {
+				DiagramEventBroker.getInstance(gep.getEditingDomain()).removeNotificationListener(owningElement,
+						transitionPriorityChangeListener);
+				owningElement = null;
+			}
 			super.deactivate();
 		}