[533249] Minimize code regions with "@generated NOT"
The classes BasicDecorationNodeImpl and DecorationNodeImpl completely
hand-written. These classes and their subclasses are missing the data
fields for a number of features, so the generator generates wrong code
for the eIsSetGen() methods.
I addressed the compile errors with a trick. To all of the five
offending eIsSetGen() methods I added "@generated NOT_CDO". To the
EMF generator that is exactly the same as "@generated NOT", but later
I can simply have the "NOT_CDO" removed by an Ant script and the
generator will generate correct code for CDO
(with reflective feature delegation).
Change-Id: I45ae10a82388319207f0f37dafe77794a0cfc8e5
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=533249
Signed-off-by: Eike Stepper <stepper@esc-net.de>
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicCompartmentImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicCompartmentImpl.java
index 641ef84..8cdd367 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicCompartmentImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicCompartmentImpl.java
@@ -272,6 +272,21 @@
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case NotationPackage.BASIC_COMPARTMENT__SOURCE_EDGES:
+ case NotationPackage.BASIC_COMPARTMENT__TARGET_EDGES:
+ return false;
+ default:
+ return eIsSetGen(featureID);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT_CDO
+ */
+ public boolean eIsSetGen(int featureID) {
+ switch (featureID) {
case NotationPackage.BASIC_COMPARTMENT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case NotationPackage.BASIC_COMPARTMENT__VISIBLE:
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicDecorationNodeImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicDecorationNodeImpl.java
index c92ce42..b48791f 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicDecorationNodeImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicDecorationNodeImpl.java
@@ -73,7 +73,7 @@
*/
protected BasicDecorationNodeImpl() {
super();
- eFlags |= VISIBLE_EFLAG;
+ setVisible(VISIBLE_EDEFAULT);
}
/**
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicSemanticCompartmentImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicSemanticCompartmentImpl.java
index f35f05b..af157d1 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicSemanticCompartmentImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/BasicSemanticCompartmentImpl.java
@@ -287,6 +287,24 @@
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__SOURCE_EDGES:
+ case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__TARGET_EDGES:
+ case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__PERSISTED_CHILDREN:
+ case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__STYLES:
+ case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__TRANSIENT_CHILDREN:
+ return false;
+ default:
+ return eIsSetGen(featureID);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT_CDO
+ */
+ public boolean eIsSetGen(int featureID) {
+ switch (featureID) {
case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case NotationPackage.BASIC_SEMANTIC_COMPARTMENT__VISIBLE:
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/CompartmentImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/CompartmentImpl.java
index b43ff94..d65653a 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/CompartmentImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/CompartmentImpl.java
@@ -332,6 +332,21 @@
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case NotationPackage.COMPARTMENT__SOURCE_EDGES:
+ case NotationPackage.COMPARTMENT__TARGET_EDGES:
+ return false;
+ default:
+ return eIsSetGen(featureID);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT_CDO
+ */
+ public boolean eIsSetGen(int featureID) {
+ switch (featureID) {
case NotationPackage.COMPARTMENT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case NotationPackage.COMPARTMENT__VISIBLE:
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DecorationNodeImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DecorationNodeImpl.java
index 7525bbe..8ba3c78 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DecorationNodeImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DecorationNodeImpl.java
@@ -17,7 +17,6 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EContentsEList;
@@ -28,7 +27,6 @@
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Style;
-import org.eclipse.gmf.runtime.notation.View;
/**
* <!-- begin-user-doc -->
@@ -40,7 +38,7 @@
* @generated NOT
* @since 1.2
*/
-public class DecorationNodeImpl extends BasicDecorationNodeImpl implements DecorationNode, View, Node {
+public class DecorationNodeImpl extends BasicDecorationNodeImpl implements DecorationNode {
protected LayoutConstraint layoutConstraint;
@@ -53,10 +51,6 @@
// EATM
// private EContentsEList allChildren = null;
- protected static final EStructuralFeature[] childrenFeatures = new EStructuralFeature[] {
- NotationPackage.Literals.VIEW__PERSISTED_CHILDREN,
- NotationPackage.Literals.VIEW__TRANSIENT_CHILDREN};
-
protected DecorationNodeImpl() {
super();
}
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DiagramImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DiagramImpl.java
index e76410e..cedfed2 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DiagramImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/DiagramImpl.java
@@ -200,14 +200,27 @@
return MEASUREMENT_UNIT_EFLAG_VALUES[(eFlags & MEASUREMENT_UNIT_EFLAG) >>> MEASUREMENT_UNIT_EFLAG_OFFSET];
}
- /**
+ /**
* <!-- begin-user-doc --> Set the Measurement Unit for this Diagram, the
- * Measure ment unit can be set only once, the set method will not set the
- * value if it was already set <!-- end-user-doc -->
+ * Measurement unit can be set only once, the set method will not set the
+ * value if it was already set <!-- end-user-doc -->
* @generated NOT
*/
- public void setMeasurementUnit(MeasurementUnit newMeasurementUnit) {
- if (!isSetMeasurementUnit()) {
+ public void setMeasurementUnit(MeasurementUnit newMeasurementUnit) {
+ if (!isSetMeasurementUnit()) {
+ setMeasurementUnitGen(newMeasurementUnit);
+ } /*else {
+ throw new UnsupportedOperationException();
+ }*/
+ }
+
+ /**
+ * <!-- begin-user-doc --> Set the Measurement Unit for this Diagram, the
+ * Measurement unit can be set only once, the set method will not set the
+ * value if it was already set <!-- end-user-doc -->
+ * @generated
+ */
+ public void setMeasurementUnitGen(MeasurementUnit newMeasurementUnit) {
MeasurementUnit oldMeasurementUnit = MEASUREMENT_UNIT_EFLAG_VALUES[(eFlags & MEASUREMENT_UNIT_EFLAG) >>> MEASUREMENT_UNIT_EFLAG_OFFSET];
if (newMeasurementUnit == null) newMeasurementUnit = MEASUREMENT_UNIT_EDEFAULT;
eFlags = eFlags & ~MEASUREMENT_UNIT_EFLAG | MeasurementUnit.VALUES.indexOf(newMeasurementUnit) << MEASUREMENT_UNIT_EFLAG_OFFSET;
@@ -215,9 +228,6 @@
eFlags |= MEASUREMENT_UNIT_ESETFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.DIAGRAM__MEASUREMENT_UNIT, oldMeasurementUnit, newMeasurementUnit, !oldMeasurementUnitESet));
- } /*else {
- throw new UnsupportedOperationException();
- }*/
}
/**
@@ -548,9 +558,9 @@
* <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public void persistEdges() {
- if (transientEdges != null && transientEdges.size() > 0) {
- List edges = new ArrayList(transientEdges);
- getPersistedEdges().addAll(transientEdges);
+ if (eIsSet(NotationPackage.DIAGRAM__TRANSIENT_EDGES)) {
+ List edges = new ArrayList(getTransientEdges());
+ getPersistedEdges().addAll(edges);
for (Iterator iterator = edges.iterator(); iterator.hasNext();) {
Edge edge = (Edge) iterator.next();
View sourceView = edge.getSource();
@@ -589,18 +599,14 @@
* <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public void removeEdge(Edge edge) {
- if (edge.eContainingFeature() == NotationPackage.Literals
- .DIAGRAM__TRANSIENT_EDGES) {
- if (transientEdges != null && transientEdges.size() > 0) {
- transientEdges.remove(edge);
- }
- } else if (edge.eContainingFeature() == NotationPackage.Literals
- .DIAGRAM__PERSISTED_EDGES) {
- if (persistedEdges != null && persistedEdges.size() > 0) {
- persistedEdges.remove(edge);
- }
- }
-
+ if (edge.eContainer() == this) {
+ EStructuralFeature eContainingFeature = edge.eContainingFeature();
+ if (eContainingFeature == NotationPackage.Literals.DIAGRAM__TRANSIENT_EDGES) {
+ getTransientEdges().remove(edge);
+ } else if (eContainingFeature == NotationPackage.Literals.DIAGRAM__PERSISTED_EDGES) {
+ getPersistedEdges().remove(edge);
+ }
+ }
}
} // DiagramImpl
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/EdgeImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/EdgeImpl.java
index 9f918b8..c6764ae 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/EdgeImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/EdgeImpl.java
@@ -127,7 +127,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated Not
+ * @generated NOT
*/
public NotificationChain basicSetSource(View newSource, NotificationChain msgs) {
if (eContainingFeature() == NotationPackage.eINSTANCE.getDiagram_PersistedEdges()){
@@ -139,14 +139,24 @@
}
}
}
- View oldSource = source;
- source = newSource;
- if (eNotificationRequired()) {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NotationPackage.EDGE__SOURCE, oldSource, newSource);
- if (msgs == null) msgs = notification; else msgs.add(notification);
- }
- return msgs;
+ return basicSetSourceGen(newSource, msgs);
}
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetSourceGen(View newSource, NotificationChain msgs) {
+ View oldSource = source;
+ source = newSource;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NotationPackage.EDGE__SOURCE, oldSource, newSource);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -178,7 +188,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated Not
+ * @generated NOT
*/
public NotificationChain basicSetTarget(View newTarget, NotificationChain msgs) {
if (eContainingFeature() == NotationPackage.eINSTANCE.getDiagram_PersistedEdges()){
@@ -190,15 +200,24 @@
}
}
}
- View oldTarget = target;
- target = newTarget;
- if (eNotificationRequired()) {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NotationPackage.EDGE__TARGET, oldTarget, newTarget);
- if (msgs == null) msgs = notification; else msgs.add(notification);
- }
- return msgs;
+ return basicSetTargetGen(newTarget, msgs);
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetTargetGen(View newTarget, NotificationChain msgs) {
+ View oldTarget = target;
+ target = newTarget;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NotationPackage.EDGE__TARGET, oldTarget, newTarget);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/FilteringStyleImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/FilteringStyleImpl.java
index 8cf6b0e..60af260 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/FilteringStyleImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/FilteringStyleImpl.java
@@ -177,21 +177,29 @@
* @generated NOT
*/
public List getFilteringKeys() {
- return Collections.unmodifiableList(filteringKeys);
+ return Collections.unmodifiableList(getFilteringKeysGen());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ * @generated
+ */
+ public List getFilteringKeysGen() {
+ return filteringKeys;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
* @generated NOT
*/
public void setFilteringKeys(List newFilteringKeys) {
- List oldFilteringKeys = filteringKeys;
-
if (newFilteringKeys == null )
throw new NullPointerException("the 'newFilteringKeys' parameter is null"); //$NON-NLS-1$
- else if (newFilteringKeys.isEmpty())
- filteringKeys = FILTERING_KEYS_EDEFAULT;
+
+ if (newFilteringKeys.isEmpty())
+ setFilteringKeysGen(FILTERING_KEYS_EDEFAULT);
else {
List tempList = new ArrayList(newFilteringKeys.size());
for (Iterator i = newFilteringKeys.iterator(); i.hasNext();) {
@@ -200,9 +208,18 @@
throw new IllegalArgumentException("One or more objects in the list is not of type java.lang.String"); //$NON-NLS-1$
tempList.add(key);
}
- filteringKeys = tempList;
+ setFilteringKeysGen(tempList);
}
-
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setFilteringKeysGen(List newFilteringKeys) {
+ List oldFilteringKeys = filteringKeys;
+ filteringKeys = newFilteringKeys;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.FILTERING_STYLE__FILTERING_KEYS, oldFilteringKeys, filteringKeys));
}
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListCompartmentImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListCompartmentImpl.java
index add224f..f8e6479 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListCompartmentImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListCompartmentImpl.java
@@ -613,6 +613,20 @@
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case NotationPackage.LIST_COMPARTMENT__SOURCE_EDGES:
+ case NotationPackage.LIST_COMPARTMENT__TARGET_EDGES:
+ return false;
+ default:
+ return eIsSetGen(featureID);
+ }
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT_CDO
+ */
+ public boolean eIsSetGen(int featureID) {
+ switch (featureID) {
case NotationPackage.LIST_COMPARTMENT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case NotationPackage.LIST_COMPARTMENT__VISIBLE:
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListValueStyleImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListValueStyleImpl.java
index 33d45f0..f9159ec 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListValueStyleImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ListValueStyleImpl.java
@@ -11,10 +11,12 @@
package org.eclipse.gmf.runtime.notation.impl;
import java.util.Collection;
+import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.util.DelegatingEcoreEList;
import org.eclipse.emf.ecore.util.EDataTypeEList;
import org.eclipse.gmf.runtime.notation.ListValueStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
@@ -66,25 +68,53 @@
* @generated NOT
*/
public EList getRawValuesList() {
- if (rawValuesList == null) {
- rawValuesList = new EDataTypeEList(String.class, this, NotationPackage.LIST_VALUE_STYLE__RAW_VALUES_LIST) {
-
- private static final long serialVersionUID = -7769354624338385073L;
-
- protected Object validate(int index, Object object) {
- Object validated = super.validate(index, object);
- if (validated != null && !isInstance(validated))
- throw new ArrayStoreException();
- try {
- getObjectFromString((String)validated);
- } catch (Exception e) {
- throw new IllegalArgumentException("Value <" + validated//$NON-NLS-1$
- + "> cannot be associated with Data type <"//$NON-NLS-1$
- + getInstanceType().toString() + ">: " + e.getMessage());//$NON-NLS-1$
- }
- return validated;
+ if (rawValuesList instanceof DelegatingEcoreEList) {
+ return rawValuesList;
+ }
+ final EList delegate = getRawValuesListGen();
+ rawValuesList = new DelegatingEcoreEList(this) {
+ private static final long serialVersionUID = -7769354624338385073L;
+
+ /**
+ * Overridden as per JavaDoc of {@link DelegatingEcoreEList}.
+ */
+ public int getFeatureID() {
+ return NotationPackage.LIST_VALUE_STYLE__RAW_VALUES_LIST;
+ }
+
+ protected boolean isNotificationRequired() {
+ // Never notify. The delegate list does so already.
+ return false;
+ }
+
+ protected List delegateList() {
+ return delegate;
+ }
+
+ protected Object validate(int index, Object object) {
+ Object validated = super.validate(index, object);
+ if (validated != null && !isInstance(validated))
+ throw new ArrayStoreException();
+ try {
+ getObjectFromString((String)validated);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Value <" + validated//$NON-NLS-1$
+ + "> cannot be associated with Data type <"//$NON-NLS-1$
+ + getInstanceType().toString() + ">: " + e.getMessage());//$NON-NLS-1$
}
- };
+ return validated;
+ }};
+ return rawValuesList;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList getRawValuesListGen() {
+ if (rawValuesList == null) {
+ rawValuesList = new EDataTypeEList(String.class, this, NotationPackage.LIST_VALUE_STYLE__RAW_VALUES_LIST);
}
return rawValuesList;
}
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NodeEntryImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NodeEntryImpl.java
index 7843f69..621a254 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NodeEntryImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NodeEntryImpl.java
@@ -149,7 +149,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated NOT
+ * @generated
*/
public Node getTypedKey() {
if (key != null && key.eIsProxy()) {
@@ -172,15 +172,14 @@
return key;
}
- /**
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated NOT
+ * @generated
*/
public void setTypedKey(Node newKey) {
Node oldKey = key;
key = newKey;
-
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.NODE_ENTRY__KEY, oldKey, key));
}
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertiesSetStyleImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertiesSetStyleImpl.java
index 15cd059..7d8dc85 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertiesSetStyleImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertiesSetStyleImpl.java
@@ -82,8 +82,9 @@
* @generated NOT
*/
public Object getProperty(String propertyName) {
- if (hasProperty(propertyName)) {
- return ((PropertyValue)getPropertiesMap().get(propertyName)).getValue();
+ PropertyValue propertyValue = (PropertyValue)getPropertiesMap().get(propertyName);
+ if (propertyValue != null) {
+ return propertyValue.getValue();
}
return null;
}
@@ -94,8 +95,9 @@
* @generated NOT
*/
public boolean setProperty(String propertyName, Object newValue) {
- if (hasProperty(propertyName)) {
- ((PropertyValue)getPropertiesMap().get(propertyName)).setValue(newValue);
+ PropertyValue propertyValue = (PropertyValue)getPropertiesMap().get(propertyName);
+ if (propertyValue != null) {
+ propertyValue.setValue(newValue);
return true;
}
return false;
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertyValueImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertyValueImpl.java
index b05b185..d7f9977 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertyValueImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/PropertyValueImpl.java
@@ -107,12 +107,21 @@
+ getInstanceType().toString() + ">: " + e.getMessage()); //$NON-NLS-1$
}
}
+ setRawValueGen(newRawValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setRawValueGen(String newRawValue) {
String oldRawValue = rawValue;
rawValue = newRawValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.PROPERTY_VALUE__RAW_VALUE, oldRawValue, rawValue));
}
-
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/RelativeBendpointsImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/RelativeBendpointsImpl.java
index e1e1e0c..9ebd626 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/RelativeBendpointsImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/RelativeBendpointsImpl.java
@@ -85,21 +85,29 @@
* @generated NOT
*/
public List getPoints() {
- return Collections.unmodifiableList(points);
+ return Collections.unmodifiableList(getPointsGen());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ * @generated
+ */
+ public List getPointsGen() {
+ return points;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
* @generated NOT
*/
public void setPoints(List newPoints) {
- List oldPoints = points;
-
if (newPoints == null )
throw new NullPointerException("the 'newPoints' parameter is null"); //$NON-NLS-1$
- else if (newPoints.isEmpty())
- points = POINTS_EDEFAULT;
+
+ if (newPoints.isEmpty())
+ setPointsGen(POINTS_EDEFAULT);
else {
List tempList = new ArrayList(newPoints.size());
for (Iterator i = newPoints.iterator(); i.hasNext();) {
@@ -108,13 +116,22 @@
throw new IllegalArgumentException("One or more objects in the list is not of type org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint"); //$NON-NLS-1$
tempList.add(point);
}
- points = tempList;
+ setPointsGen(tempList);
}
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setPointsGen(List newPoints) {
+ List oldPoints = points;
+ points = newPoints;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.RELATIVE_BENDPOINTS__POINTS, Collections.unmodifiableList(oldPoints), Collections.unmodifiableList(points)));
}
-
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SemanticListCompartmentImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SemanticListCompartmentImpl.java
index d778c78..36b62af 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SemanticListCompartmentImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SemanticListCompartmentImpl.java
@@ -618,6 +618,24 @@
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case NotationPackage.SEMANTIC_LIST_COMPARTMENT__SOURCE_EDGES:
+ case NotationPackage.SEMANTIC_LIST_COMPARTMENT__TARGET_EDGES:
+ case NotationPackage.SEMANTIC_LIST_COMPARTMENT__PERSISTED_CHILDREN:
+ case NotationPackage.SEMANTIC_LIST_COMPARTMENT__STYLES:
+ case NotationPackage.SEMANTIC_LIST_COMPARTMENT__TRANSIENT_CHILDREN:
+ return false;
+ default:
+ return eIsSetGen(featureID);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT_CDO
+ */
+ public boolean eIsSetGen(int featureID) {
+ switch (featureID) {
case NotationPackage.SEMANTIC_LIST_COMPARTMENT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case NotationPackage.SEMANTIC_LIST_COMPARTMENT__VISIBLE:
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeImpl.java
index 8741255..33893dd 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeImpl.java
@@ -394,12 +394,21 @@
* @generated NOT
*/
public void setFontName(String newFontName) {
+ setFontNameGen(newFontName == null ? null : newFontName.intern());
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setFontNameGen(String newFontName) {
String oldFontName = fontName;
- fontName = newFontName == null ? null : newFontName.intern();
+ fontName = newFontName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.SHAPE__FONT_NAME, oldFontName, fontName));
}
-
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeStyleImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeStyleImpl.java
index 5268ac8..9968a6e 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeStyleImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ShapeStyleImpl.java
@@ -212,12 +212,21 @@
* @generated NOT
*/
public void setFontName(String newFontName) {
+ setFontNameGen(newFontName == null ? null : newFontName.intern());
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setFontNameGen(String newFontName) {
String oldFontName = fontName;
- fontName = newFontName == null ? null : newFontName.intern();
+ fontName = newFontName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.SHAPE_STYLE__FONT_NAME, oldFontName, fontName));
}
-
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SingleValueStyleImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SingleValueStyleImpl.java
index 1a9d6e4..11cf0ff 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SingleValueStyleImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SingleValueStyleImpl.java
@@ -93,12 +93,21 @@
+ getInstanceType().toString() + ">: " + e.getMessage());//$NON-NLS-1$
}
}
+ setRawValueGen(newRawValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setRawValueGen(String newRawValue) {
String oldRawValue = rawValue;
rawValue = newRawValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.SINGLE_VALUE_STYLE__RAW_VALUE, oldRawValue, rawValue));
}
-
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SortingStyleImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SortingStyleImpl.java
index 36a751d..2daa66f 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SortingStyleImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/SortingStyleImpl.java
@@ -178,21 +178,29 @@
* @generated NOT
*/
public Map getSortingKeys() {
- return Collections.unmodifiableMap(sortingKeys);
+ return Collections.unmodifiableMap(getSortingKeysGen());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ * @generated
+ */
+ public Map getSortingKeysGen() {
+ return sortingKeys;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
* @generated NOT
*/
public void setSortingKeys(Map newSortingKeys) {
- Map oldSortingKeys = sortingKeys;
-
if (newSortingKeys == null )
throw new NullPointerException("the 'newSortingKeys' parameter is null"); //$NON-NLS-1$
- else if (newSortingKeys.isEmpty())
- sortingKeys = SORTING_KEYS_EDEFAULT;
+
+ if (newSortingKeys.isEmpty())
+ setSortingKeysGen(SORTING_KEYS_EDEFAULT);
else {
Map tempMap = new LinkedHashMap(newSortingKeys.size());
for (Iterator i = newSortingKeys.keySet().iterator(); i.hasNext();) {
@@ -204,13 +212,22 @@
throw new IllegalArgumentException("One or more values in the map is not of type org.eclipse.gmf.runtime.notation.SortingDirection"); //$NON-NLS-1$
tempMap.put(key, value);
}
- sortingKeys = tempMap;
+ setSortingKeysGen(tempMap);
}
-
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSortingKeysGen(Map newSortingKeys) {
+ Map oldSortingKeys = sortingKeys;
+ sortingKeys = newSortingKeys;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.SORTING_STYLE__SORTING_KEYS, oldSortingKeys, sortingKeys));
}
-
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java
index 38cc953..5f258d0 100644
--- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java
+++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/ViewImpl.java
@@ -340,23 +340,33 @@
EObject container = eContainer();
if (container instanceof View) {
View view = (View) container;
- element = view.getElement();
+ return view.getElement();
}
}
- if (element != null && element.eIsProxy()) {
- EObject oldElement = element;
- element = eResolveProxy((InternalEObject) element);
- if (element != oldElement) {
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.RESOLVE,
- NotationPackage.VIEW__ELEMENT, oldElement, element));
- }
- }
-
- return element;
+
+ return getElementGen();
}
/**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EObject getElementGen() {
+ if (element != null && element.eIsProxy()) {
+ EObject oldElement = element;
+ element = eResolveProxy((InternalEObject) element);
+ if (element != oldElement) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE,
+ NotationPackage.VIEW__ELEMENT, oldElement, element));
+ }
+ }
+
+ return element;
+ }
+
+ /**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@@ -702,8 +712,8 @@
* <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public void persistChildren() {
- if (transientChildren != null && transientChildren.size() > 0) {
- getPersistedChildren().addAll(transientChildren);
+ if (eIsSet(NotationPackage.VIEW__TRANSIENT_CHILDREN)) {
+ getPersistedChildren().addAll(getTransientChildren());
}
}
@@ -741,28 +751,27 @@
* <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public void removeChild(View child) {
- if (child.eContainingFeature() == NotationPackage.Literals
- .VIEW__TRANSIENT_CHILDREN) {
- if (transientChildren != null && transientChildren.size() > 0) {
- transientChildren.remove(child);
- }
- } else if (child.eContainingFeature() == NotationPackage.Literals
- .VIEW__PERSISTED_CHILDREN) {
- if (persistedChildren != null && persistedChildren.size() > 0) {
- persistedChildren.remove(child);
- }
- }
+ if (child.eContainer() == this) {
+ EStructuralFeature eContainingFeature = child.eContainingFeature();
+ if (eContainingFeature == NotationPackage.Literals.VIEW__TRANSIENT_CHILDREN) {
+ getTransientChildren().remove(child);
+ } else if (eContainingFeature == NotationPackage.Literals.VIEW__PERSISTED_CHILDREN) {
+ getPersistedChildren().remove(child);
+ }
+ }
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public void persist() {
- EStructuralFeature eContaingFeature = eContainingFeature();
- if (eContainer != null && eContaingFeature != null
- && eContainer instanceof View && eContaingFeature.isTransient()) {
- View vContainer = (View) eContainer;
- vContainer.persistChildren();
+ EObject eContainer = eContainer();
+ if (eContainer instanceof View) {
+ EStructuralFeature eContaingFeature = eContainingFeature();
+ if (eContaingFeature != null && eContaingFeature.isTransient()) {
+ View vContainer = (View) eContainer;
+ vContainer.persistChildren();
+ }
}
}
@@ -770,13 +779,16 @@
* <!-- begin-user-doc --> <!-- end-user-doc -->
*/
public EList getVisibleChildren() {
- if ((persistedChildren == null || persistedChildren.isEmpty())
- && (transientChildren == null || transientChildren.isEmpty())) {
+ boolean persistedChildrenSet = eIsSet(NotationPackage.VIEW__PERSISTED_CHILDREN);
+ boolean transientChildrenSet = eIsSet(NotationPackage.VIEW__TRANSIENT_CHILDREN);
+
+ if (persistedChildrenSet && transientChildrenSet) {
return ECollections.EMPTY_ELIST;
}
List _children = new ArrayList();
- if (persistedChildren != null && persistedChildren.size() > 0) {
+ if (persistedChildrenSet) {
+ EList persistedChildren = getPersistedChildren();
for (Iterator iter = persistedChildren.iterator(); iter
.hasNext();) {
View view = (View) iter.next();
@@ -785,7 +797,8 @@
}
}
- if (transientChildren != null && transientChildren.size() > 0) {
+ if (transientChildrenSet) {
+ EList transientChildren = getTransientChildren();
for (Iterator iter = transientChildren.iterator(); iter
.hasNext();) {
View view = (View) iter.next();
diff --git a/org.eclipse.gmf.tests.runtime.notation/src/org/eclipse/gmf/tests/runtime/notation/NotationTest.java b/org.eclipse.gmf.tests.runtime.notation/src/org/eclipse/gmf/tests/runtime/notation/NotationTest.java
index 24569c1..0cd88f6 100755
--- a/org.eclipse.gmf.tests.runtime.notation/src/org/eclipse/gmf/tests/runtime/notation/NotationTest.java
+++ b/org.eclipse.gmf.tests.runtime.notation/src/org/eclipse/gmf/tests/runtime/notation/NotationTest.java
@@ -11,36 +11,47 @@
package org.eclipse.gmf.tests.runtime.notation;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
+
import java.io.IOException;
import java.util.Collections;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.ListValueStyle;
+import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.ShapeStyle;
import org.eclipse.gmf.runtime.notation.Style;
+import org.eclipse.gmf.runtime.notation.impl.DiagramImpl;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
/**
* A minimal smoke test to verify that the GMF Notation build works.
*
@@ -48,11 +59,6 @@
*/
public class NotationTest extends TestCase {
- private static final String PROJECT_NAME = "tests"; //$NON-NLS-1$
- private static final String NOTATION_RESOURCE_NAME = "/" + PROJECT_NAME + "/tests.notation"; //$NON-NLS-1$//$NON-NLS-2$
- private static final String WELCOME = "org.eclipse.ui.internal.introview"; //$NON-NLS-1$
- private static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
-
public static void main(String[] args) {
TestRunner.run(suite());
}
@@ -65,40 +71,55 @@
super(name);
}
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Close the annoying "Welcome to Eclipse" view.
+ IWorkbenchPage[] pages = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages();
+ for (int i = 0; i < pages.length; i++) {
+ IViewReference[] viewRefs = pages[i].getViewReferences();
+ for (int j = 0; j < viewRefs.length; j++) {
+ if ("org.eclipse.ui.internal.introview".equals(viewRefs[j].getId()))
+ pages[i].hideView(viewRefs[j]);
+ }
+ }
+ }
+
+ private IProject getTestProject() throws CoreException {
+ String projectName = getName();
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (!project.exists()) {
+ project.create(null);
+ }
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+ return project;
+ }
+
+ private String getTestProjectName() throws CoreException {
+ IProject project = getTestProject();
+ return project.getName();
+ }
+
/**
- * A minimal smoke test to verify that the GMF Notation build works. Create
- * a simple notation model and open it in a text editor.
+ * A minimal smoke test to verify that the GMF Notation build works. Create a
+ * simple notation model and open it in a text editor.
*
* @throws Exception
*/
public void test_notation() throws Exception {
- // Close the annoying "Welcome to Eclipse" view.
- IWorkbenchPage[] pages = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getPages();
- for (int i = 0; i < pages.length; i++) {
- IViewReference[] viewRefs = pages[i].getViewReferences();
- for (int j = 0; j < viewRefs.length; j++) {
- if (WELCOME.equals(viewRefs[j].getId()))
- pages[i].hideView(viewRefs[j]);
- }
- }
-
- // Create the test project.
- IProject project = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(PROJECT_NAME);
- if (!project.exists()) {
- project.create(null);
- }
- project.open(null);
+ IProject project = getTestProject();
// Create the test notation model.
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = workspaceRoot.getFile(new Path(NOTATION_RESOURCE_NAME));
+ IFile file = project.getFile("tests.notation");
String fullPath = file.getFullPath().toOSString();
ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI
- .createPlatformResourceURI(fullPath, true));
+ Resource resource = resourceSet.createResource(URI.createPlatformResourceURI(fullPath, true));
// Create the diagram in the test notation model.
Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
@@ -119,20 +140,141 @@
}
// Refresh the new file in the workspace.
- ResourcesPlugin
- .getWorkspace()
- .getRoot()
- .refreshLocal(IResource.DEPTH_INFINITE,
- new NullProgressMonitor());
+ file.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
// Open the new file in a text editor.
- IWorkbenchPage page = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
assertNotNull("Workbench page is null", page);
assertNotNull("Workspace file is null", file);
- IEditorDescriptor defaultEditor = PlatformUI.getWorkbench()
- .getEditorRegistry().findEditor(DEFAULT_TEXT_EDITOR_ID);
+ IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry()
+ .findEditor("org.eclipse.ui.DefaultTextEditor");
assertNotNull("Default Editor is null", defaultEditor);
page.openEditor(new FileEditorInput(file), defaultEditor.getId());
}
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void test_ListValueStyleImpl_getRawValuesList() throws Exception {
+ ListValueStyle listValueStyle = NotationFactory.eINSTANCE.createListValueStyle();
+ listValueStyle.setName(getName());
+
+ EList rawValuesList = listValueStyle.getRawValuesList();
+
+ // ======================================================
+ // Verify element validation with NO instance type set...
+ // ======================================================
+
+ rawValuesList.add(null); // Valid element.
+ rawValuesList.add("valid element");
+
+ try {
+ rawValuesList.add(new Object());
+ fail("ArrayStoreException expected");
+ } catch (ArrayStoreException expected) {
+ // Success.
+ }
+
+ assertEquals(2, rawValuesList.size());
+ rawValuesList.clear();
+
+ // ==============================================================
+ // Verify element validation with instance type set to EDOUBLE...
+ // ==============================================================
+
+ listValueStyle.setInstanceType(EcorePackage.Literals.EDOUBLE);
+
+ rawValuesList.add(null); // Valid element. Questionable because instance type is primitive!
+ rawValuesList.add("4711.0815d"); // Valid element.
+
+ try {
+ rawValuesList.add("invalid element");
+ fail("IllegalArgumentException expected");
+ } catch (IllegalArgumentException expected) {
+ // Success.
+ }
+
+ try {
+ rawValuesList.add(4711.0815d); // Invalid element.
+ fail("ArrayStoreException expected");
+ } catch (ArrayStoreException expected) {
+ // Success.
+ }
+
+ try {
+ rawValuesList.add(new Object());
+ fail("ArrayStoreException expected");
+ } catch (ArrayStoreException expected) {
+ // Success.
+ }
+
+ assertEquals(2, rawValuesList.size());
+ rawValuesList.clear();
+
+ // =======================================================
+ // Verify that no duplicate notifications are delivered...
+ // =======================================================
+
+ final int[] notifications = { 0 };
+ listValueStyle.eAdapters().add(new AdapterImpl() {
+ @Override
+ public void notifyChanged(Notification msg) {
+ ++notifications[0];
+ }
+ });
+
+ rawValuesList.add("4711.0815d"); // Produce 1 notification.
+ assertEquals(1, notifications[0]);
+
+ // =======================================================
+ // Verify that the exact same list instance is returned...
+ // =======================================================
+
+ EList rawValuesList2 = listValueStyle.getRawValuesList();
+ assertSame(rawValuesList, rawValuesList2);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void test_ViewImpl_getElement() throws Exception {
+ String fullPath1 = "/" + getTestProjectName() + "/test1.notation";
+ String fullPath2 = "/" + getTestProjectName() + "/test2.ecore";
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource1 = resourceSet.createResource(URI.createPlatformResourceURI(fullPath1, true));
+ Resource resource2 = resourceSet.createResource(URI.createPlatformResourceURI(fullPath2, true));
+
+ // ===========================================
+ // Save a diagram with a controlled element...
+ // ===========================================
+
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ diagram.setName(getName());
+ resource1.getContents().add(diagram);
+
+ Node node = NotationFactory.eINSTANCE.createNode();
+ diagram.getPersistedChildren().add(node);
+
+ EClass diagramElement = EcoreFactory.eINSTANCE.createEClass();
+ diagramElement.setName("DiagramElement");
+ diagram.setElement(diagramElement);
+ resource2.getContents().add(diagramElement);
+
+ try {
+ resource1.save(Collections.EMPTY_MAP);
+ resource2.save(Collections.EMPTY_MAP);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ // ===========================================================================================
+ // Load the diagram into a new resource set and verify that the element proxy gets resolved...
+ // ===========================================================================================
+
+ resourceSet = new ResourceSetImpl();
+ resource1 = resourceSet.getResource(URI.createPlatformResourceURI(fullPath1, true), true);
+ diagram = (Diagram) resource1.getContents().get(0);
+ assumeTrue(((DiagramImpl)diagram).basicGetElement().eIsProxy());
+
+ node = (Node) diagram.getChildren().get(0);
+ EObject element = node.getElement();
+ assumeFalse(element.eIsProxy());
+ }
}