Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-08-17 12:31:17 +0000
committerJuergen Haug2013-08-29 13:22:00 +0000
commit1bdc6dd8fea5ef798288e6c47b81902482ba2d59 (patch)
tree9aa8109813a92d30014727fe3a818b58d9e2d8cf /plugins/org.eclipse.etrice.ui.behavior
parent2ab69f3e1024d95e1817b236d3b0f50b727742ac (diff)
downloadorg.eclipse.etrice-1bdc6dd8fea5ef798288e6c47b81902482ba2d59.tar.gz
org.eclipse.etrice-1bdc6dd8fea5ef798288e6c47b81902482ba2d59.tar.xz
org.eclipse.etrice-1bdc6dd8fea5ef798288e6c47b81902482ba2d59.zip
[ui] add change recording support for create and custom feature
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.behavior')
-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
4 files changed, 84 insertions, 148 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 3108fd36f..d2d75d4f8 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 00e8551df..fd02cd6a6 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 fa0dc3f88..e3c79db8e 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 c5eae86fc..2c9a2c5d7 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;
}
}

Back to the top