summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-08-17 08:31:17 (EDT)
committerJuergen Haug2013-08-29 09:22:00 (EDT)
commit1bdc6dd8fea5ef798288e6c47b81902482ba2d59 (patch)
tree9aa8109813a92d30014727fe3a818b58d9e2d8cf
parent2ab69f3e1024d95e1817b236d3b0f50b727742ac (diff)
downloadorg.eclipse.etrice-1bdc6dd8fea5ef798288e6c47b81902482ba2d59.zip
org.eclipse.etrice-1bdc6dd8fea5ef798288e6c47b81902482ba2d59.tar.gz
org.eclipse.etrice-1bdc6dd8fea5ef798288e6c47b81902482ba2d59.tar.bz2
[ui] add change recording support for create and custom featurerefs/changes/63/15563/2
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/ChoicePointSupport.java54
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java57
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java57
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java64
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateConnectionFeature.java76
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateFeature.java71
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCustomFeature.java64
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java119
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java124
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java1
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java13
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java6
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java59
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java38
14 files changed, 443 insertions, 360 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/ChoicePointSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/ChoicePointSupport.java
index 3108fd3..d2d75d4 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/ChoicePointSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/ChoicePointSupport.java
@@ -21,6 +21,8 @@ import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.StateGraph;
import org.eclipse.etrice.ui.behavior.ImageProvider;
import org.eclipse.etrice.ui.behavior.dialogs.ChoicePointPropertyDialog;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.CommonSupportUtil;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.common.support.NoResizeFeature;
@@ -93,10 +95,8 @@ public class ChoicePointSupport {
private static class FeatureProvider extends DefaultFeatureProvider {
- private static class CreateFeature extends AbstractCreateFeature {
+ private static class CreateFeature extends ChangeAwareCreateFeature {
- private boolean doneChanges = false;
-
public CreateFeature(IFeatureProvider fp, String name, String description) {
super(fp, name, description);
}
@@ -107,7 +107,7 @@ public class ChoicePointSupport {
}
@Override
- public Object[] create(ICreateContext context) {
+ public Object[] doCreate(ICreateContext context) {
ContainerShape targetContainer = context.getTargetContainer();
StateGraph sg = (StateGraph) targetContainer.getLink().getBusinessObjects().get(0);
@@ -125,23 +125,15 @@ public class ChoicePointSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
ChoicePointPropertyDialog dlg = new ChoicePointPropertyDialog(shell, cp);
- if (dlg.open()!=Window.OK) {
- if (inherited) {
- SupportUtil.undoInsertRefinedState(sg, ac, targetContainer, getFeatureProvider());
- }
- else {
- sg.getChPoints().remove(cp);
- }
- doneChanges = false;
- return EMPTY;
+ if (dlg.open()==Window.OK) {
+ // do the add
+ addGraphicalRepresentation(context, cp);
+
+ // return newly created business object(s)
+ return new Object[] { cp };
}
- // do the add
- addGraphicalRepresentation(context, cp);
- doneChanges = true;
-
- // return newly created business object(s)
- return new Object[] { cp };
+ return null;
}
@Override
@@ -265,12 +257,11 @@ public class ChoicePointSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
+ private static class PropertyFeature extends ChangeAwareCustomFeature {
private String name;
private String description;
- private boolean doneChanges = false;
-
+
public PropertyFeature(IFeatureProvider fp) {
super(fp);
this.name = "Edit Choice Point";
@@ -300,22 +291,19 @@ public class ChoicePointSupport {
}
@Override
- public void execute(ICustomContext context) {
+ public boolean doExecute(ICustomContext context) {
PictogramElement pe = context.getPictogramElements()[0];
ChoicePoint cp = (ChoicePoint) getBusinessObjectForPictogramElement(pe);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
ChoicePointPropertyDialog dlg = new ChoicePointPropertyDialog(shell, cp);
- if (dlg.open()!=Window.OK)
- return;
-
- doneChanges = true;
- updateFigure(cp, pe, manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ if (dlg.open()==Window.OK){
+ updateFigure(cp, pe, manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
+
+ return true;
+ }
+
+ return false;
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
index 00e8551..fd02cd6 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
@@ -27,6 +27,8 @@ import org.eclipse.etrice.core.room.TrPoint;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.ui.behavior.ImageProvider;
import org.eclipse.etrice.ui.behavior.dialogs.StatePropertyDialog;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.CommonSupportUtil;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.graphiti.datatypes.IDimension;
@@ -59,7 +61,6 @@ import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
-import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.features.impl.AbstractLayoutFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.features.impl.DefaultMoveShapeFeature;
@@ -114,10 +115,8 @@ public class StateSupport {
private static class FeatureProvider extends DefaultFeatureProvider {
- private class CreateFeature extends AbstractCreateFeature {
+ private class CreateFeature extends ChangeAwareCreateFeature {
- private boolean doneChanges = false;
-
public CreateFeature(IFeatureProvider fp) {
super(fp, "State", "create State");
}
@@ -140,7 +139,7 @@ public class StateSupport {
}
@Override
- public Object[] create(ICreateContext context) {
+ public Object[] doCreate(ICreateContext context) {
ContainerShape targetContainer = context.getTargetContainer();
ActorClass ac = SupportUtil.getActorClass(getDiagram());
@@ -158,27 +157,14 @@ public class StateSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
StatePropertyDialog dlg = new StatePropertyDialog(shell, ac, s, true);
- if (dlg.open()!=Window.OK) {
- if (inherited) {
- SupportUtil.undoInsertRefinedState(sg, ac, targetContainer, getFeatureProvider());
- }
- else {
- sg.getStates().remove(s);
- }
- doneChanges = false;
- return EMPTY;
+ if (dlg.open()==Window.OK) {
+ addGraphicalRepresentation(context, s);
+
+ // return newly created business object(s)
+ return new Object[] { s };
}
- addGraphicalRepresentation(context, s);
- doneChanges = true;
-
- // return newly created business object(s)
- return new Object[] { s };
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ return null;
}
}
@@ -333,9 +319,8 @@ public class StateSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
+ private static class PropertyFeature extends ChangeAwareCustomFeature {
- private boolean doneChanges = false;
private boolean editable;
public PropertyFeature(IFeatureProvider fp, boolean editable) {
@@ -367,19 +352,20 @@ public class StateSupport {
}
@Override
- public void execute(ICustomContext context) {
+ public boolean doExecute(ICustomContext context) {
ActorClass ac = SupportUtil.getActorClass(getDiagram());
State s = (State) getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
StatePropertyDialog dlg = new StatePropertyDialog(shell, ac, s, editable);
- if (dlg.open()!=Window.OK)
- return;
-
- doneChanges = true;
- updateFigure(s, context);
+ if (dlg.open()==Window.OK){
+ updateFigure(s, context);
+ adjustSubgraphLabels(s, ac);
+
+ return true;
+ }
- adjustSubgraphLabels(s, ac);
+ return false;
}
private void adjustSubgraphLabels(State s, ActorClass ac) {
@@ -423,11 +409,6 @@ public class StateSupport {
}
}
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
- }
}
private static class GoDownFeature extends AbstractCustomFeature implements
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
index fa0dc3f..e3c79db 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
@@ -29,6 +29,9 @@ import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.core.validation.ValidationUtil;
import org.eclipse.etrice.ui.behavior.ImageProvider;
import org.eclipse.etrice.ui.behavior.dialogs.TrPointPropertyDialog;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateConnectionFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.CommonSupportUtil;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.common.support.NoResizeFeature;
@@ -111,10 +114,8 @@ public class TrPointSupport {
private static class FeatureProvider extends DefaultFeatureProvider {
- private static class CreateFeature extends AbstractCreateFeature {
+ private static class CreateFeature extends ChangeAwareCreateFeature {
- private boolean doneChanges = false;
-
protected Type type;
public CreateFeature(IFeatureProvider fp, Type type, String name, String description) {
@@ -136,7 +137,7 @@ public class TrPointSupport {
}
@Override
- public Object[] create(ICreateContext context) {
+ public Object[] doCreate(ICreateContext context) {
ContainerShape targetContainer = context.getTargetContainer();
ActorClass ac = SupportUtil.getActorClass(getDiagram());
StateGraph sg = (StateGraph) targetContainer.getLink().getBusinessObjects().get(0);
@@ -163,23 +164,15 @@ public class TrPointSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
TrPointPropertyDialog dlg = new TrPointPropertyDialog(shell, tp, false);
- if (dlg.open()!=Window.OK) {
- if (inherited) {
- SupportUtil.undoInsertRefinedState(sg, ac, targetContainer, getFeatureProvider());
- }
- else {
- sg.getTrPoints().remove(tp);
- }
- return EMPTY;
+ if (dlg.open()==Window.OK) {
+ // do the add
+ addGraphicalRepresentation(context, tp);
+
+ // return newly created business object(s)
+ return new Object[] { tp };
}
-
- doneChanges = true;
- // do the add
- addGraphicalRepresentation(context, tp);
-
- // return newly created business object(s)
- return new Object[] { tp };
+ return null;
}
@Override
@@ -507,11 +500,10 @@ public class TrPointSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
+ private static class PropertyFeature extends ChangeAwareCustomFeature {
private String name;
private String description;
- private boolean doneChanges = false;
public PropertyFeature(IFeatureProvider fp) {
super(fp);
@@ -542,25 +534,22 @@ public class TrPointSupport {
}
@Override
- public void execute(ICustomContext context) {
+ public boolean doExecute(ICustomContext context) {
PictogramElement pe = context.getPictogramElements()[0];
TrPoint tp = (TrPoint) getBusinessObjectForPictogramElement(pe);
boolean subtp = isSubTP(pe);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
TrPointPropertyDialog dlg = new TrPointPropertyDialog(shell, tp, subtp);
- if (dlg.open()!=Window.OK)
- return;
-
- doneChanges = true;
- String kind = getItemKind(tp);
- Graphiti.getPeService().setPropertyValue(pe, PROP_KIND, kind);
- updateTrPointFigure(tp, pe, manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ if (dlg.open()==Window.OK){
+ String kind = getItemKind(tp);
+ Graphiti.getPeService().setPropertyValue(pe, PROP_KIND, kind);
+ updateTrPointFigure(tp, pe, manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
+
+ return true;
+ }
+
+ return false;
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
index c5eae86..2c9a2c5 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
@@ -38,6 +38,8 @@ import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.core.validation.ValidationUtil;
import org.eclipse.etrice.ui.behavior.ImageProvider;
import org.eclipse.etrice.ui.behavior.dialogs.TransitionPropertyDialog;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateConnectionFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
@@ -64,7 +66,6 @@ import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
-import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
@@ -105,10 +106,8 @@ public class TransitionSupport {
static class FeatureProvider extends DefaultFeatureProvider {
- private class CreateFeature extends AbstractCreateConnectionFeature {
+ private class CreateFeature extends ChangeAwareCreateConnectionFeature {
- private boolean doneChanges = false;
-
public CreateFeature(IFeatureProvider fp) {
super(fp, "Transition", "create Transition");
}
@@ -139,9 +138,7 @@ public class TransitionSupport {
}
@Override
- public Connection create(ICreateConnectionContext context) {
- Connection newConnection = null;
-
+ public Connection doCreate(ICreateConnectionContext context) {
ActorClass ac = SupportUtil.getActorClass(getDiagram());
TransitionTerminal src = SupportUtil.getTransitionTerminal(context.getSourceAnchor(), fp);
@@ -251,28 +248,14 @@ public class TransitionSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
TransitionPropertyDialog dlg = new TransitionPropertyDialog(shell, SupportUtil.getActorClass(getDiagram()), trans);
- if (dlg.open()!=Window.OK) {
- if (inherited) {
- SupportUtil.undoInsertRefinedState(sg, ac, targetContainer, getFeatureProvider());
- }
- else {
- sg.getTransitions().remove(trans);
- }
- return null;
+ if (dlg.open()==Window.OK) {
+ AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
+ addContext.setNewObject(trans);
+ return (Connection) getFeatureProvider().addIfPossible(addContext);
}
-
- AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
- addContext.setNewObject(trans);
- newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);
- doneChanges = true;
}
- return newConnection;
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges ;
+ return null;
}
}
@@ -593,9 +576,8 @@ public class TransitionSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
+ private static class PropertyFeature extends ChangeAwareCustomFeature {
- private boolean doneChanges = false;
private boolean editable;
public PropertyFeature(IFeatureProvider fp, boolean editable) {
@@ -633,7 +615,7 @@ public class TransitionSupport {
}
@Override
- public void execute(ICustomContext context) {
+ public boolean doExecute(ICustomContext context) {
PictogramElement pe = context.getPictogramElements()[0];
if (pe instanceof ConnectionDecorator)
pe = (PictogramElement) pe.eContainer();
@@ -642,21 +624,17 @@ public class TransitionSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
TransitionPropertyDialog dlg = new TransitionPropertyDialog(shell, SupportUtil.getActorClass(getDiagram()), trans);
- if (dlg.open()!=Window.OK)
- return;
-
- doneChanges = true;
+ if (dlg.open()==Window.OK){
+ boolean inherited = SupportUtil.isInherited(getDiagram(), trans);
+ Color lineColor = inherited? manageColor(INHERITED_COLOR):manageColor(LINE_COLOR);
+ Color fillColor = RoomHelpers.hasDetailCode(trans.getAction())?
+ lineColor:manageColor(FILL_COLOR);
+ updateLabel(trans, conn, fillColor);
- boolean inherited = SupportUtil.isInherited(getDiagram(), trans);
- Color lineColor = inherited? manageColor(INHERITED_COLOR):manageColor(LINE_COLOR);
- Color fillColor = RoomHelpers.hasDetailCode(trans.getAction())?
- lineColor:manageColor(FILL_COLOR);
- updateLabel(trans, conn, fillColor);
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ return true;
+ }
+
+ return false;
}
}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateConnectionFeature.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateConnectionFeature.java
new file mode 100644
index 0000000..90b2220
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateConnectionFeature.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.support;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.change.ChangeDescription;
+import org.eclipse.emf.ecore.change.util.BasicChangeRecorder;
+import org.eclipse.emf.ecore.change.util.ChangeRecorder;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
+import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+
+public abstract class ChangeAwareCreateConnectionFeature extends
+ AbstractCreateConnectionFeature {
+
+ boolean hasDoneChanges;
+
+ public ChangeAwareCreateConnectionFeature(IFeatureProvider fp, String name,
+ String description) {
+ super(fp, name, description);
+ this.hasDoneChanges = false;
+ }
+
+
+ @Override
+ public Connection create(ICreateConnectionContext context) {
+ EObject rootObject = getContainerModelObject(context);
+ BasicChangeRecorder changeRecorder = new ChangeRecorder(rootObject);
+
+ Connection result = doCreate(context);
+ boolean newObjects = result != null;
+
+ ChangeDescription cd = changeRecorder.endRecording();
+ hasDoneChanges = !(cd.getObjectChanges().isEmpty()
+ && cd.getObjectsToAttach().isEmpty()
+ && cd.getObjectsToDetach().isEmpty() && cd.getResourceChanges()
+ .isEmpty());
+
+ if (!newObjects && hasDoneChanges){
+ cd.apply();
+ hasDoneChanges = false;
+ }
+
+ return result;
+ }
+
+ @Override
+ public final boolean hasDoneChanges() {
+ return hasDoneChanges;
+ }
+
+ /**
+ * {@link AbstractCreateFeature#create(ICreateContext)}
+ */
+ protected abstract Connection doCreate(ICreateConnectionContext context);
+
+ /**
+ * Return the model object, that holds all changed objects for the given context
+ */
+ protected EObject getContainerModelObject(ICreateConnectionContext context){
+ return (EObject) getBusinessObjectForPictogramElement(getDiagram());
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateFeature.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateFeature.java
new file mode 100644
index 0000000..e2cebdb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCreateFeature.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.support;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.change.ChangeDescription;
+import org.eclipse.emf.ecore.change.util.BasicChangeRecorder;
+import org.eclipse.emf.ecore.change.util.ChangeRecorder;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
+
+public abstract class ChangeAwareCreateFeature extends AbstractCreateFeature {
+
+ boolean hasDoneChanges;
+
+ public ChangeAwareCreateFeature(IFeatureProvider fp, String name,
+ String description) {
+ super(fp, name, description);
+ this.hasDoneChanges = false;
+ }
+
+ @Override
+ public final Object[] create(ICreateContext context) {
+ EObject rootObject = getContainerModelObject(context);
+ BasicChangeRecorder changeRecorder = new ChangeRecorder(rootObject);
+
+ Object[] result = doCreate(context);
+ boolean newObjects = result != null && result.length > 0;
+
+ ChangeDescription cd = changeRecorder.endRecording();
+ hasDoneChanges = !(cd.getObjectChanges().isEmpty()
+ && cd.getObjectsToAttach().isEmpty()
+ && cd.getObjectsToDetach().isEmpty() && cd.getResourceChanges()
+ .isEmpty());
+
+ if (!newObjects && hasDoneChanges){
+ cd.apply();
+ hasDoneChanges = false;
+ }
+
+ return result;
+ }
+
+ @Override
+ public final boolean hasDoneChanges() {
+ return hasDoneChanges;
+ }
+
+ /**
+ * {@link AbstractCreateFeature#create(ICreateContext)}
+ */
+ protected abstract Object[] doCreate(ICreateContext context);
+
+ /**
+ * Return the model object, that holds all changed objects for the given context
+ */
+ protected EObject getContainerModelObject(ICreateContext context){
+ return (EObject) getBusinessObjectForPictogramElement(getDiagram());
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCustomFeature.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCustomFeature.java
new file mode 100644
index 0000000..82bed04
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/ChangeAwareCustomFeature.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.support;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.change.ChangeDescription;
+import org.eclipse.emf.ecore.change.util.BasicChangeRecorder;
+import org.eclipse.emf.ecore.change.util.ChangeRecorder;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
+
+public abstract class ChangeAwareCustomFeature extends AbstractCustomFeature {
+
+ boolean hasDoneChanges;
+
+ public ChangeAwareCustomFeature(IFeatureProvider fp) {
+ super(fp);
+ this.hasDoneChanges = false;
+ }
+
+ @Override
+ public final void execute(ICustomContext context) {
+ EObject rootObject = getContainerModelObject(context);
+ BasicChangeRecorder changeRecorder = new ChangeRecorder(rootObject);
+
+ boolean doExecute = doExecute(context);
+
+ ChangeDescription cd = changeRecorder.endRecording();
+ hasDoneChanges = !(cd.getObjectChanges().isEmpty()
+ && cd.getObjectsToAttach().isEmpty()
+ && cd.getObjectsToDetach().isEmpty() && cd.getResourceChanges()
+ .isEmpty());
+
+ if (!doExecute && hasDoneChanges){
+ cd.apply();
+ hasDoneChanges = false;
+ }
+ }
+
+ @Override
+ public final boolean hasDoneChanges() {
+ return hasDoneChanges;
+ }
+
+ protected abstract boolean doExecute(ICustomContext context);
+
+ /**
+ * Return the model object, that holds all changed objects for the given context
+ */
+ protected EObject getContainerModelObject(ICustomContext context){
+ return (EObject) getBusinessObjectForPictogramElement(getDiagram());
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
index ff8f935..c3429e1 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
@@ -36,6 +36,8 @@ import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.room.SubSystemRef;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.ui.common.preferences.PreferenceConstants;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.CommonSupportUtil;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.structure.DiagramAccess;
@@ -76,7 +78,6 @@ import org.eclipse.graphiti.features.context.impl.CreateConnectionContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
-import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.features.impl.AbstractLayoutFeature;
import org.eclipse.graphiti.features.impl.DefaultMoveShapeFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
@@ -374,11 +375,10 @@ public class ActorContainerRefSupport {
}
}
- private class CreateFeature extends AbstractCreateFeature {
+ private class CreateFeature extends ChangeAwareCreateFeature {
private boolean actorRef;
- private boolean doneChanges = false;
-
+
public CreateFeature(IFeatureProvider fp, boolean actorRef) {
super(fp, actorRef?"ActorRef":"SubSystemRef", "create "+(actorRef?"ActorRef":"SubSystemRef"));
this.actorRef = actorRef;
@@ -404,57 +404,47 @@ public class ActorContainerRefSupport {
return false;
}
+
@Override
- public Object[] create(ICreateContext context) {
-
- StructureClass sc = (StructureClass) context.getTargetContainer().getLink().getBusinessObjects().get(0);
-
- ActorContainerRef newRef = null;
- if (sc instanceof ActorContainerClass) {
- ActorContainerClass acc = (ActorContainerClass) sc;
-
- // create ActorRef
- ActorRef ar = RoomFactory.eINSTANCE.createActorRef();
+ protected Object[] doCreate(ICreateContext context) {
+ StructureClass sc = (StructureClass) context.getTargetContainer().getLink().getBusinessObjects().get(0);
+
+ ActorContainerRef newRef = null;
+ if (sc instanceof ActorContainerClass) {
+ ActorContainerClass acc = (ActorContainerClass) sc;
+
+ // create ActorRef
+ ActorRef ar = RoomFactory.eINSTANCE.createActorRef();
- acc.getActorRefs().add(ar);
- newRef = ar;
-
- }
- else if (sc instanceof LogicalSystem) {
- LogicalSystem sys = (LogicalSystem) sc;
-
- // create ActorRef
- SubSystemRef ssr = RoomFactory.eINSTANCE.createSubSystemRef();
-
- sys.getSubSystems().add(ssr);
- newRef = ssr;
- }
-
- newRef.setName(RoomNameProvider.getUniqueActorContainerRefName(sc));
+ acc.getActorRefs().add(ar);
+ newRef = ar;
+
+ }
+ else if (sc instanceof LogicalSystem) {
+ LogicalSystem sys = (LogicalSystem) sc;
+
+ // create ActorRef
+ SubSystemRef ssr = RoomFactory.eINSTANCE.createSubSystemRef();
+
+ sys.getSubSystems().add(ssr);
+ newRef = ssr;
+ }
+
+ newRef.setName(RoomNameProvider.getUniqueActorContainerRefName(sc));
- IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
- EReference reference = (newRef instanceof ActorRef)?RoomPackage.eINSTANCE.getActorRef_Type():RoomPackage.eINSTANCE.getSubSystemRef_Type();
- IScope scope = scopeProvider.getScope(newRef.eContainer().eContainer(), reference);
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- ActorContainerRefPropertyDialog dlg = new ActorContainerRefPropertyDialog(shell, newRef, scope, sc, true);
- if (dlg.open()!=Window.OK) {
- if (sc instanceof ActorContainerClass)
- ((ActorContainerClass)sc).getActorRefs().remove(newRef);
- else if (sc instanceof LogicalSystem)
- ((LogicalSystem) sc).getSubSystems().remove(newRef);
- return EMPTY;
- }
-
- addGraphicalRepresentation(context, newRef);
- doneChanges = true;
-
- // return newly created business object(s)
- return new Object[] { newRef };
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
+ EReference reference = (newRef instanceof ActorRef)?RoomPackage.eINSTANCE.getActorRef_Type():RoomPackage.eINSTANCE.getSubSystemRef_Type();
+ IScope scope = scopeProvider.getScope(newRef.eContainer().eContainer(), reference);
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ ActorContainerRefPropertyDialog dlg = new ActorContainerRefPropertyDialog(shell, newRef, scope, sc, true);
+
+ if (dlg.open()==Window.OK) {
+ addGraphicalRepresentation(context, newRef);
+
+ return new Object[] { newRef };
+ }
+
+ return EMPTY;
}
}
@@ -586,9 +576,7 @@ public class ActorContainerRefSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
-
- private boolean doneChanges = false;
+ private static class PropertyFeature extends ChangeAwareCustomFeature {
public PropertyFeature(IFeatureProvider fp) {
super(fp);
@@ -616,9 +604,9 @@ public class ActorContainerRefSupport {
}
return false;
}
-
+
@Override
- public void execute(ICustomContext context) {
+ protected boolean doExecute(ICustomContext context) {
ContainerShape containerShape = (ContainerShape) context.getPictogramElements()[0];
ActorContainerRef acr = (ActorContainerRef) getBusinessObjectForPictogramElement(containerShape);
StructureClass sc = (StructureClass)acr.eContainer();
@@ -628,18 +616,15 @@ public class ActorContainerRefSupport {
IScope scope = scopeProvider.getScope(acr.eContainer().eContainer(), reference);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
ActorContainerRefPropertyDialog dlg = new ActorContainerRefPropertyDialog(shell, acr, scope, sc, false);
- if (dlg.open()!=Window.OK)
- return;
- EObject parent = (EObject) getBusinessObjectForPictogramElement(containerShape.getContainer());
- updateRefFigure(acr, containerShape, isInherited(acr, parent), getDiagram());
+ if (dlg.open()==Window.OK){
+ EObject parent = (EObject) getBusinessObjectForPictogramElement(containerShape.getContainer());
+ updateRefFigure(acr, containerShape, isInherited(acr, parent), getDiagram());
+
+ return true;
+ }
- doneChanges = true;
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ return false;
}
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java
index be74498..873f92a 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java
@@ -24,6 +24,8 @@ import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.validation.ValidationUtil;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateConnectionFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.structure.ImageProvider;
import org.eclipse.etrice.ui.structure.dialogs.SubProtocolSelectionDialog;
@@ -51,10 +53,8 @@ import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.ReconnectionContext;
-import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
-import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
@@ -85,9 +85,7 @@ public class BindingSupport {
static class FeatureProvider extends DefaultFeatureProvider {
- private class CreateFeature extends AbstractCreateConnectionFeature {
-
- private boolean doneChanges = false;
+ private class CreateFeature extends ChangeAwareCreateConnectionFeature {
public CreateFeature(IFeatureProvider fp) {
super(fp, "Binding", "create Binding");
@@ -141,52 +139,6 @@ public class BindingSupport {
}
@Override
- public Connection create(ICreateConnectionContext context) {
- Connection newConnection = null;
-
- endHighLightMatches();
-
- IFeatureProvider featureProvider = getFeatureProvider();
- Port src = SupportUtil.getPort(context.getSourceAnchor(), featureProvider);
- Port dst = SupportUtil.getPort(context.getTargetAnchor(), featureProvider);
- StructureClass sc = SupportUtil.getParent(context, featureProvider);
- if (src!=null && dst!=null && sc!=null) {
- Binding bind = RoomFactory.eINSTANCE.createBinding();
- BindingEndPoint ep1 = RoomFactory.eINSTANCE.createBindingEndPoint();
- ActorContainerRef ar1 = SupportUtil.getRef(context.getSourceAnchor(), featureProvider);
- ep1.setPort(src);
- ep1.setActorRef(ar1);
- BindingEndPoint ep2 = RoomFactory.eINSTANCE.createBindingEndPoint();
- ActorContainerRef ar2 = SupportUtil.getRef(context.getTargetAnchor(), featureProvider);
- ep2.setPort(dst);
- ep2.setActorRef(ar2);
- bind.setEndpoint1(ep1);
- bind.setEndpoint2(ep2);
-
- GeneralProtocolClass srcGPC = src.getProtocol();
- GeneralProtocolClass dstGPC = dst.getProtocol();
- if (srcGPC instanceof CompoundProtocolClass || dstGPC instanceof CompoundProtocolClass) {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- SubProtocolSelectionDialog dlg = new SubProtocolSelectionDialog(shell, src, ar1, dst, ar2, null, sc);
- if (dlg.open()!=Window.OK)
- return null;
-
- ep1.setSub(dlg.getSelected().getLeft());
- ep2.setSub(dlg.getSelected().getRight());
- }
-
- sc.getBindings().add(bind);
-
- AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
- addContext.setNewObject(bind);
- newConnection = (Connection) featureProvider.addIfPossible(addContext);
- doneChanges = true;
- }
-
- return newConnection;
- }
-
- @Override
public void attachedToSource(ICreateConnectionContext context) {
Port src = SupportUtil.getPort(context.getSourceAnchor(), getFeatureProvider());
ActorContainerRef ref = SupportUtil.getRef(context.getSourceAnchor(), getFeatureProvider());
@@ -240,8 +192,48 @@ public class BindingSupport {
}
@Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ protected Connection doCreate(ICreateConnectionContext context) {
+ Connection newConnection = null;
+
+ endHighLightMatches();
+
+ IFeatureProvider featureProvider = getFeatureProvider();
+ Port src = SupportUtil.getPort(context.getSourceAnchor(), featureProvider);
+ Port dst = SupportUtil.getPort(context.getTargetAnchor(), featureProvider);
+ StructureClass sc = SupportUtil.getParent(context, featureProvider);
+ if (src!=null && dst!=null && sc!=null) {
+ Binding bind = RoomFactory.eINSTANCE.createBinding();
+ BindingEndPoint ep1 = RoomFactory.eINSTANCE.createBindingEndPoint();
+ ActorContainerRef ar1 = SupportUtil.getRef(context.getSourceAnchor(), featureProvider);
+ ep1.setPort(src);
+ ep1.setActorRef(ar1);
+ BindingEndPoint ep2 = RoomFactory.eINSTANCE.createBindingEndPoint();
+ ActorContainerRef ar2 = SupportUtil.getRef(context.getTargetAnchor(), featureProvider);
+ ep2.setPort(dst);
+ ep2.setActorRef(ar2);
+ bind.setEndpoint1(ep1);
+ bind.setEndpoint2(ep2);
+
+ GeneralProtocolClass srcGPC = src.getProtocol();
+ GeneralProtocolClass dstGPC = dst.getProtocol();
+ if (srcGPC instanceof CompoundProtocolClass || dstGPC instanceof CompoundProtocolClass) {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ SubProtocolSelectionDialog dlg = new SubProtocolSelectionDialog(shell, src, ar1, dst, ar2, null, sc);
+ if (dlg.open()!=Window.OK)
+ return null;
+
+ ep1.setSub(dlg.getSelected().getLeft());
+ ep2.setSub(dlg.getSelected().getRight());
+ }
+
+ sc.getBindings().add(bind);
+
+ AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
+ addContext.setNewObject(bind);
+ newConnection = (Connection) featureProvider.addIfPossible(addContext);
+ }
+
+ return newConnection;
}
}
@@ -450,9 +442,7 @@ public class BindingSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
-
- private boolean doneChanges;
+ private static class PropertyFeature extends ChangeAwareCustomFeature {
public PropertyFeature(IFeatureProvider fp) {
super(fp);
@@ -472,12 +462,8 @@ public class BindingSupport {
return getBusinessObjectForPictogramElement(context.getPictogramElements()[0]) instanceof Binding;
}
- /* (non-Javadoc)
- * @see org.eclipse.graphiti.features.custom.ICustomFeature#execute(org.eclipse.graphiti.features.context.ICustomContext)
- */
@Override
- public void execute(ICustomContext context) {
- doneChanges = false;
+ public boolean doExecute(ICustomContext context) {
Binding bind = (Binding) getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
StructureClass sc = (StructureClass) bind.eContainer();
@@ -487,19 +473,17 @@ public class BindingSupport {
bind.getEndpoint1().getPort(), bind.getEndpoint1().getActorRef(),
bind.getEndpoint2().getPort(), bind.getEndpoint2().getActorRef(),
bind, sc);
- if (dlg.open()!=Window.OK)
- return;
- bind.getEndpoint1().setSub(dlg.getSelected().getLeft());
- bind.getEndpoint2().setSub(dlg.getSelected().getRight());
+ if (dlg.open()==Window.OK){
+ bind.getEndpoint1().setSub(dlg.getSelected().getLeft());
+ bind.getEndpoint2().setSub(dlg.getSelected().getRight());
+
+ return true;
+ }
- doneChanges = true;
+ return false;
}
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
- }
}
private IFeatureProvider fp;
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java
index f50137e..44ba2b5 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java
@@ -21,7 +21,6 @@ import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.LayerConnection;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.ui.structure.support.provider.IPositionProvider.PosAndSize;
-import org.eclipse.graphiti.mm.Property;
import org.eclipse.graphiti.mm.PropertyContainer;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java
index 675c520..1459fdd 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java
@@ -22,6 +22,8 @@ import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.SPP;
import org.eclipse.etrice.core.room.SubSystemRef;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateFeature;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.common.support.NoResizeFeature;
import org.eclipse.etrice.ui.structure.support.context.PositionUpdateContext;
@@ -45,9 +47,7 @@ import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IResizeShapeContext;
import org.eclipse.graphiti.features.context.ITargetContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
-import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
-import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.features.impl.AbstractLayoutFeature;
import org.eclipse.graphiti.features.impl.DefaultMoveShapeFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
@@ -83,10 +83,9 @@ public class InterfaceItemSupport {
protected static class FeatureProvider extends DefaultFeatureProvider {
- protected abstract static class CreateFeature extends AbstractCreateFeature {
+ protected abstract static class CreateFeature extends ChangeAwareCreateFeature {
protected boolean internal;
- protected boolean doneChanges = false;
public CreateFeature(IFeatureProvider fp, boolean internal, String name, String description) {
super(fp, name, description);
@@ -108,10 +107,6 @@ public class InterfaceItemSupport {
return false;
}
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
- }
}
protected abstract static class AddFeature extends AbstractAddFeature {
@@ -431,7 +426,7 @@ public class InterfaceItemSupport {
}
- protected static abstract class PropertyFeature extends AbstractCustomFeature {
+ protected static abstract class PropertyFeature extends ChangeAwareCustomFeature {
private String name;
private String description;
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java
index 4837526..dc2c5a8 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java
@@ -24,6 +24,7 @@ import org.eclipse.etrice.core.room.SPP;
import org.eclipse.etrice.core.room.SPPoint;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.validation.ValidationUtil;
+import org.eclipse.etrice.ui.common.support.ChangeAwareCreateConnectionFeature;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.structure.ImageProvider;
import org.eclipse.etrice.ui.structure.support.context.ConnectionUpdateContext;
@@ -48,7 +49,6 @@ import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.ReconnectionContext;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
-import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
@@ -76,7 +76,7 @@ public class LayerConnectionSupport {
class FeatureProvider extends DefaultFeatureProvider {
- private class CreateFeature extends AbstractCreateConnectionFeature {
+ private class CreateFeature extends ChangeAwareCreateConnectionFeature{
public CreateFeature(IFeatureProvider fp) {
super(fp, "LayerConnection", "create LayerConnection");
@@ -108,7 +108,7 @@ public class LayerConnectionSupport {
}
@Override
- public Connection create(ICreateConnectionContext context) {
+ protected Connection doCreate(ICreateConnectionContext context) {
IFeatureProvider featureProvider = getFeatureProvider();
SPP src = SupportUtil.getSPP(context.getSourceAnchor(), featureProvider);
ActorContainerRef srcRef = SupportUtil.getRef(context.getSourceAnchor(), featureProvider);
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
index 113214f..f12a6b0 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
@@ -95,7 +95,7 @@ public class PortSupport extends InterfaceItemSupport {
}
@Override
- public Object[] create(ICreateContext context) {
+ public Object[] doCreate(ICreateContext context) {
ActorContainerClass acc = (ActorContainerClass) context.getTargetContainer().getLink().getBusinessObjects().get(0);
// create Port
@@ -127,31 +127,17 @@ public class PortSupport extends InterfaceItemSupport {
IScope scope = scopeProvider.getScope(port, RoomPackage.eINSTANCE.getPort_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
PortPropertyDialog dlg = new PortPropertyDialog(shell, port, scope, acc, true, false, internal);
- if (dlg.open()!=Window.OK) {
- if (acc instanceof ActorClass) {
- ActorClass ac = (ActorClass) acc;
- if (internal)
- ac.getInternalPorts().remove(port);
- else {
- ac.getInterfacePorts().remove(port);
- ac.getExternalPorts().remove(xp);
- }
- }
- else if (acc instanceof SubSystemClass) {
- SubSystemClass ssc = (SubSystemClass) acc;
- ssc.getRelayPorts().remove(port);
- }
- return EMPTY;
+ if (dlg.open()==Window.OK) {
+ // do the add
+ addGraphicalRepresentation(context, port);
+
+ // return newly created business object(s)
+ return new Object[] { port };
}
-
- doneChanges = true;
-
- // do the add
- addGraphicalRepresentation(context, port);
-
- // return newly created business object(s)
- return new Object[] { port };
+
+ return null;
}
+
}
private static class AddFeature extends InterfaceItemSupport.FeatureProvider.AddFeature {
@@ -182,8 +168,6 @@ public class PortSupport extends InterfaceItemSupport {
private static class PropertyFeature extends InterfaceItemSupport.FeatureProvider.PropertyFeature {
- private boolean doneChanges = false;
-
public PropertyFeature(IFeatureProvider fp) {
super(fp, "Edit Port...", "Edit Port Properties");
}
@@ -202,7 +186,7 @@ public class PortSupport extends InterfaceItemSupport {
}
@Override
- public void execute(ICustomContext context) {
+ public boolean doExecute(ICustomContext context) {
Object bo = getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
if (bo instanceof Port) {
Port port = (Port) bo;
@@ -214,21 +198,18 @@ public class PortSupport extends InterfaceItemSupport {
IScope scope = scopeProvider.getScope(port.eContainer().eContainer(), RoomPackage.eINSTANCE.getPort_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
PortPropertyDialog dlg = new PortPropertyDialog(shell, port, scope, acc, false, refport, internal);
- if (dlg.open()!=Window.OK)
- return;
-
- doneChanges = true;
- updatePortFigure(port, context.getPictogramElements()[0], manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
- String kind = getPortKind(port);
- Graphiti.getPeService().setPropertyValue(context.getPictogramElements()[0], PROP_KIND, kind);
+ if (dlg.open()==Window.OK){
+ updatePortFigure(port, context.getPictogramElements()[0], manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
+ String kind = getPortKind(port);
+ Graphiti.getPeService().setPropertyValue(context.getPictogramElements()[0], PROP_KIND, kind);
+
+ return true;
+ }
+
+ return false;
}
}
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
- }
-
}
private class UpdateFeature extends InterfaceItemSupport.FeatureProvider.UpdateFeature {
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
index fe93e1a..ce0003c 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
@@ -94,7 +94,7 @@ public class SPPSupport extends InterfaceItemSupport {
}
@Override
- public Object[] create(ICreateContext context) {
+ public Object[] doCreate(ICreateContext context) {
ActorContainerClass acc = (ActorContainerClass) context.getTargetContainer().getLink().getBusinessObjects().get(0);
// create SPP
@@ -107,18 +107,15 @@ public class SPPSupport extends InterfaceItemSupport {
IScope scope = scopeProvider.getScope(spp.eContainer().eContainer(), RoomPackage.eINSTANCE.getSAP_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
SPPPropertyDialog dlg = new SPPPropertyDialog(shell, spp, scope, true, false);
- if (dlg.open()!=Window.OK) {
- acc.getServiceProvisionPoints().remove(spp);
- return EMPTY;
+ if (dlg.open()==Window.OK) {
+ // do the add
+ addGraphicalRepresentation(context, spp);
+
+ // return newly created business object(s)
+ return new Object[] { spp };
}
-
- doneChanges = true;
- // do the add
- addGraphicalRepresentation(context, spp);
-
- // return newly created business object(s)
- return new Object[] { spp };
+ return null;
}
}
@@ -150,8 +147,6 @@ public class SPPSupport extends InterfaceItemSupport {
private static class PropertyFeature extends InterfaceItemSupport.FeatureProvider.PropertyFeature {
- private boolean doneChanges = false;
-
public PropertyFeature(IFeatureProvider fp) {
super(fp, "Edit SPP...", "Edit SPP Properties");
}
@@ -170,7 +165,7 @@ public class SPPSupport extends InterfaceItemSupport {
}
@Override
- public void execute(ICustomContext context) {
+ public boolean doExecute(ICustomContext context) {
SPP spp = (SPP) getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
boolean refport = isRefItem(context.getPictogramElements()[0]);
@@ -178,16 +173,13 @@ public class SPPSupport extends InterfaceItemSupport {
IScope scope = scopeProvider.getScope(spp.eContainer().eContainer(), RoomPackage.eINSTANCE.getSAP_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
SPPPropertyDialog dlg = new SPPPropertyDialog(shell, spp, scope, false, refport);
- if (dlg.open()!=Window.OK)
- return;
+ if (dlg.open()==Window.OK){
+ updateSPPFigure(spp, context.getPictogramElements()[0], manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
+
+ return true;
+ }
- doneChanges = true;
- updateSPPFigure(spp, context.getPictogramElements()[0], manageColor(DARK_COLOR), manageColor(BRIGHT_COLOR));
- }
-
- @Override
- public boolean hasDoneChanges() {
- return doneChanges;
+ return false;
}
}