Permalink
Browse files

SWITCHYARD-776 add support for undo/redo in editor(cherry picked from…

… commit dc73d68)
  • Loading branch information...
1 parent b3904f3 commit 2222a88f8a729be307bd201b7a2c8cfe3bbb3cc1 @rcernich committed May 16, 2012
Showing with 173 additions and 63 deletions.
  1. +1 −1 eclipse/plugins/org.switchyard.tools.models.switchyard1_0/model/config.switchyard.ecore
  2. +1 −1 ...models.switchyard1_0/src/org/switchyard/tools/models/switchyard1_0/switchyard/SwitchYardType.java
  3. +1 −1 ...hyard1_0/src/org/switchyard/tools/models/switchyard1_0/switchyard/impl/SwitchyardPackageImpl.java
  4. +12 −1 ....ui.editor/src/org/switchyard/tools/ui/editor/diagram/binding/SCADiagramCreateBindingFeature.java
  5. +14 −2 ...editor/src/org/switchyard/tools/ui/editor/diagram/component/SCADiagramCreateComponentFeature.java
  6. +12 −1 ...tchyard/tools/ui/editor/diagram/componentreference/SCADiagramCreateComponentReferenceFeature.java
  7. +46 −44 ...witchyard/tools/ui/editor/diagram/componentreference/SCADiagramCustomPromoteReferenceFeature.java
  8. +12 −1 .../switchyard/tools/ui/editor/diagram/componentservice/SCADiagramCreateComponentServiceFeature.java
  9. +14 −3 ...editor/src/org/switchyard/tools/ui/editor/diagram/composite/SCADiagramCreateCompositeFeature.java
  10. +12 −1 ...tchyard/tools/ui/editor/diagram/compositereference/SCADiagramCreateCompositeReferenceFeature.java
  11. +1 −1 .../src/org/switchyard/tools/ui/editor/diagram/connections/SCADiagramCreateReferenceLinkFeature.java
  12. +12 −1 .../org/switchyard/tools/ui/editor/diagram/implementation/SCADiagramCreateImplementationFeature.java
  13. +12 −1 ....ui.editor/src/org/switchyard/tools/ui/editor/diagram/service/SCADiagramCreateServiceFeature.java
  14. +4 −4 ...tor/src/org/switchyard/tools/ui/editor/diagram/service/SCADiagramCustomPromoteServiceFeature.java
  15. +19 −0 ...s/org.switchyard.tools.ui.editor/src/org/switchyard/tools/ui/editor/impl/SwitchyardSCAEditor.java
@@ -441,7 +441,7 @@
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="composite" eType="ecore:EClass platform:/plugin/org.switchyard.tools.models.sca.sca1_1/model/sca.ecore#//Composite"
- derived="true" containment="true">
+ containment="true">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="composite"/>
@@ -98,7 +98,7 @@
* @return the value of the '<em>Composite</em>' containment reference.
* @see #setComposite(Composite)
* @see org.switchyard.tools.models.switchyard1_0.switchyard.SwitchyardPackage#getSwitchYardType_Composite()
- * @model containment="true" derived="true"
+ * @model containment="true"
* extendedMetaData="kind='element' name='composite' namespace='http://docs.oasis-open.org/ns/opencsa/sca/200912'"
* @generated
*/
@@ -1242,7 +1242,7 @@ public void initializePackageContents() {
initEClass(switchYardTypeEClass, SwitchYardType.class, "SwitchYardType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getSwitchYardType_Name(), theXMLTypePackage.getString(), "name", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getSwitchYardType_TargetNamespace(), theXMLTypePackage.getString(), "targetNamespace", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getSwitchYardType_Composite(), theScaPackage.getComposite(), null, "composite", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+ initEReference(getSwitchYardType_Composite(), theScaPackage.getComposite(), null, "composite", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getSwitchYardType_Transforms(), this.getTransformsType(), null, "transforms", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getSwitchYardType_Validates(), this.getValidatesType(), null, "validates", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getSwitchYardType_Domain(), this.getDomainType(), null, "domain", null, 0, 1, SwitchYardType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
@@ -30,10 +30,12 @@
/**
* @author bfitzpat
- *
+ *
*/
public class SCADiagramCreateBindingFeature extends AbstractCreateFeature {
+ private boolean _hasDoneChanges;
+
/**
* @param fp feature provider
*/
@@ -42,6 +44,11 @@ public SCADiagramCreateBindingFeature(IFeatureProvider fp) {
}
@Override
+ public boolean hasDoneChanges() {
+ return _hasDoneChanges;
+ }
+
+ @Override
public boolean canCreate(ICreateContext context) {
ContainerShape targetContainer = context.getTargetContainer();
// check if user wants to add to a service or reference
@@ -71,6 +78,7 @@ public boolean canCreate(ICreateContext context) {
if (rtn_code == Window.OK) {
newBinding = wizard.getBinding();
} else {
+ _hasDoneChanges = false;
return EMPTY;
}
@@ -97,6 +105,9 @@ public boolean canCreate(ICreateContext context) {
// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);
+ // make sure we look like we actually did something.
+ _hasDoneChanges = true;
+
// return newly created business object(s)
return new Object[] {newBinding };
}
@@ -27,15 +27,22 @@
/**
* @author bfitzpat
- *
+ *
*/
public class SCADiagramCreateComponentFeature extends AbstractCreateFeature {
+ private boolean _hasDoneChanges;
+
/**
* @param fp feature provider
*/
public SCADiagramCreateComponentFeature(IFeatureProvider fp) {
- super(fp, "Component", "Create component");
+ super(fp, "Component", "Create Component");
+ }
+
+ @Override
+ public boolean hasDoneChanges() {
+ return _hasDoneChanges;
}
@Override
@@ -64,6 +71,8 @@ public boolean canCreate(ICreateContext context) {
if (rtn_code == Window.OK) {
newComponent = wizard.getComponent();
} else {
+ newComponent = null;
+ _hasDoneChanges = false;
return EMPTY;
}
// // ask user for component name
@@ -82,6 +91,9 @@ public boolean canCreate(ICreateContext context) {
// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);
+ // make sure we look like we actually did something.
+ _hasDoneChanges = true;
+
// return newly created business object(s)
return new Object[] {newComponent };
}
@@ -40,11 +40,18 @@
*/
public class SCADiagramCreateComponentReferenceFeature extends AbstractCreateFeature {
+ private boolean _hasDoneChanges;
+
/**
* @param fp the feature provider
*/
public SCADiagramCreateComponentReferenceFeature(IFeatureProvider fp) {
- super(fp, "Component Reference", "Create component reference");
+ super(fp, "Component Reference", "Create Component Reference");
+ }
+
+ @Override
+ public boolean hasDoneChanges() {
+ return _hasDoneChanges;
}
@Override
@@ -73,6 +80,7 @@ public boolean canCreate(ICreateContext context) {
newClassName = wizard.getComponentReferenceName();
newInterface = wizard.getInterface();
} else {
+ _hasDoneChanges = false;
return EMPTY;
}
@@ -102,6 +110,9 @@ public boolean canCreate(ICreateContext context) {
// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);
+ // make sure we look like we actually did something.
+ _hasDoneChanges = true;
+
// return newly created business object(s)
return new Object[] {newCReference };
}
@@ -103,8 +103,53 @@ public void execute(ICustomContext context) {
}
}
referenceShape = (Shape) getFeatureProvider().getPictogramElementForBusinessObject(targetReference);
+
this._hasDoneChanges = true;
- getDiagramEditor().refresh();
+
+ // add the connection for the wire.
+ if (referenceShape != null) {
+ getDiagramEditor().refresh(referenceShape);
+
+ String referencedShapeName = cref.getName();
+ Anchor targetAnchor = null;
+ Anchor sourceAnchor = null;
+ Anchor[] anchors = DIImport.findAnchorsWithName(getFeatureProvider(), getDiagram(),
+ referencedShapeName);
+ for (Anchor anchor : anchors) {
+ Object anchorObj = getFeatureProvider().getBusinessObjectForPictogramElement(anchor);
+ if (anchorObj instanceof ComponentReference) {
+ ComponentReference cref2 = (ComponentReference) anchorObj;
+ if (cref2.getName().contentEquals(referencedShapeName)) {
+ targetAnchor = anchor;
+ }
+ }
+ if (anchorObj instanceof Reference) {
+ Reference reference = (Reference) anchorObj;
+ if (reference.getName().contentEquals(referencedShapeName)) {
+ sourceAnchor = anchor;
+ }
+ }
+ }
+ if (sourceAnchor != null && targetAnchor != null) {
+ if (sourceAnchor.getParent() != targetAnchor.getParent()) {
+ // now define the connection between the
+ // componentreference and the new
+ // reference shape
+ AddConnectionContext addReferenceContext = new AddConnectionContext(sourceAnchor,
+ targetAnchor);
+ ArrayList<String> targetRef = new ArrayList<String>();
+ targetRef.add(referencedShapeName);
+ addReferenceContext.setNewObject(cref);
+ addReferenceContext.setTargetContainer(cshape);
+
+ IAddFeature addConnectionFeature = getFeatureProvider().getAddFeature(
+ addReferenceContext);
+ if (addConnectionFeature != null && addConnectionFeature.canAdd(addReferenceContext)) {
+ addConnectionFeature.add(addReferenceContext);
+ }
+ }
+ }
+ }
} else {
try {
Interface newInterface = null;
@@ -157,49 +202,6 @@ public void execute(ICustomContext context) {
e.printStackTrace();
}
}
- if (referenceShape != null) {
- getDiagramEditor().refresh(referenceShape);
-
- String referencedShapeName = cref.getName();
- Anchor targetAnchor = null;
- Anchor sourceAnchor = null;
- Anchor[] anchors = DIImport.findAnchorsWithName(getFeatureProvider(), getDiagram(),
- referencedShapeName);
- for (Anchor anchor : anchors) {
- Object anchorObj = getFeatureProvider().getBusinessObjectForPictogramElement(anchor);
- if (anchorObj instanceof ComponentReference) {
- ComponentReference cref2 = (ComponentReference) anchorObj;
- if (cref2.getName().contentEquals(referencedShapeName)) {
- targetAnchor = anchor;
- }
- }
- if (anchorObj instanceof Reference) {
- Reference reference = (Reference) anchorObj;
- if (reference.getName().contentEquals(referencedShapeName)) {
- sourceAnchor = anchor;
- }
- }
- }
- if (sourceAnchor != null && targetAnchor != null) {
- if (sourceAnchor.getParent() != targetAnchor.getParent()) {
- // now define the connection between the
- // componentreference and the new
- // reference shape
- AddConnectionContext addReferenceContext = new AddConnectionContext(sourceAnchor,
- targetAnchor);
- ArrayList<String> targetRef = new ArrayList<String>();
- targetRef.add(referencedShapeName);
- addReferenceContext.setNewObject(cref);
- addReferenceContext.setTargetContainer(cshape);
-
- IAddFeature addConnectionFeature = getFeatureProvider().getAddFeature(addReferenceContext);
- if (addConnectionFeature != null && addConnectionFeature.canAdd(addReferenceContext)) {
- addConnectionFeature.add(addReferenceContext);
- }
- }
- }
-
- }
}
}
}
@@ -40,11 +40,18 @@
*/
public class SCADiagramCreateComponentServiceFeature extends AbstractCreateFeature {
+ private boolean _hasDoneChanges;
+
/**
* @param fp the feature provider
*/
public SCADiagramCreateComponentServiceFeature(IFeatureProvider fp) {
- super(fp, "Component Service", "Create component service");
+ super(fp, "Component Service", "Create Component Service");
+ }
+
+ @Override
+ public boolean hasDoneChanges() {
+ return _hasDoneChanges;
}
@Override
@@ -73,6 +80,7 @@ public boolean canCreate(ICreateContext context) {
newClassName = wizard.getComponentServiceName();
newInterface = wizard.getInterface();
} else {
+ _hasDoneChanges = false;
return EMPTY;
}
@@ -102,6 +110,9 @@ public boolean canCreate(ICreateContext context) {
// activate direct editing after object creation
getFeatureProvider().getDirectEditingInfo().setActive(true);
+ // make sure we look like we actually did something.
+ _hasDoneChanges = true;
+
// return newly created business object(s)
return new Object[] {newCService };
}
@@ -27,18 +27,25 @@
/**
* @author bfitzpat
- *
+ *
*/
public class SCADiagramCreateCompositeFeature extends AbstractCreateFeature {
- private static final String TITLE = "Create composite";
+ private static final String TITLE = "Create Composite";
private static final String USER_QUESTION = "Enter new composite name";
+ private boolean _hasDoneChanges;
+
/**
* @param fp the feature provider
*/
public SCADiagramCreateCompositeFeature(IFeatureProvider fp) {
- super(fp, "Composite", "Create composite");
+ super(fp, "Composite", "Create Composite");
+ }
+
+ @Override
+ public boolean hasDoneChanges() {
+ return _hasDoneChanges;
}
@Override
@@ -51,6 +58,7 @@ public boolean canCreate(ICreateContext context) {
// ask user for EClass name
String newCompositeName = ExampleUtil.askString(TITLE, USER_QUESTION, "");
if (newCompositeName == null || newCompositeName.trim().length() == 0) {
+ _hasDoneChanges = false;
return EMPTY;
}
@@ -67,6 +75,9 @@ public boolean canCreate(ICreateContext context) {
// do the add
addGraphicalRepresentation(context, newComposite);
+ // make sure we look like we actually did something.
+ _hasDoneChanges = true;
+
// return newly created business object(s)
return new Object[] {newComposite };
}
@@ -37,10 +37,12 @@
/**
* @author bfitzpat
- *
+ *
*/
public class SCADiagramCreateCompositeReferenceFeature extends AbstractCreateFeature {
+ private boolean _hasDoneChanges;
+
/**
* @param fp feature provider
*/
@@ -49,6 +51,11 @@ public SCADiagramCreateCompositeReferenceFeature(IFeatureProvider fp) {
}
@Override
+ public boolean hasDoneChanges() {
+ return _hasDoneChanges;
+ }
+
+ @Override
public boolean canCreate(ICreateContext context) {
if (getBusinessObjectForPictogramElement(context.getTargetContainer()) instanceof Composite) {
return true;
@@ -70,6 +77,7 @@ public boolean canCreate(ICreateContext context) {
newRefName = wizard.getCompositeReferenceName();
newInterface = wizard.getInterface();
} else {
+ _hasDoneChanges = false;
return EMPTY;
}
@@ -99,6 +107,9 @@ public boolean canCreate(ICreateContext context) {
layoutPictogramElement(((Shape) pe).getContainer());
}
+ // make sure we look like we actually did something.
+ _hasDoneChanges = true;
+
// return newly created business object(s)
return new Object[] {newReference };
}
@@ -32,7 +32,7 @@
* @param fp the feature provider
*/
public SCADiagramCreateReferenceLinkFeature(IFeatureProvider fp) {
- super(fp, "Reference (dashed)", "Create Reference");
+ super(fp, "Wire Reference (dashed)", "Wire Reference");
}
@Override
Oops, something went wrong.

0 comments on commit 2222a88

Please sign in to comment.