*** empty log message ***
diff --git a/deprecated/examples/org.eclipse.uml2.examples/src/org/eclipse/uml2/examples/uml22ecore/UML22Ecore.java b/deprecated/examples/org.eclipse.uml2.examples/src/org/eclipse/uml2/examples/uml22ecore/UML22Ecore.java
index 28bced1..a7c7fec 100644
--- a/deprecated/examples/org.eclipse.uml2.examples/src/org/eclipse/uml2/examples/uml22ecore/UML22Ecore.java
+++ b/deprecated/examples/org.eclipse.uml2.examples/src/org/eclipse/uml2/examples/uml22ecore/UML22Ecore.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: UML22Ecore.java,v 1.3 2004/05/26 18:12:15 khussey Exp $
+ * $Id: UML22Ecore.java,v 1.4 2004/06/21 19:25:02 khussey Exp $
*/
package org.eclipse.uml2.examples.uml22ecore;
@@ -29,7 +29,6 @@
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
@@ -164,12 +163,21 @@
}
}
- protected void setXMLName(NamedElement namedElement, Stereotype stereotype,
- ENamedElement eNamedElement) {
- String xmlName = (String) namedElement.getValue(stereotype, "xmlName"); //$NON-NLS-1$
+ protected void setXMLName(Classifier classifier, Stereotype stereotype,
+ EClassifier eClassifier) {
+ String xmlName = (String) classifier.getValue(stereotype, "xmlName"); //$NON-NLS-1$
if (null != xmlName && 0 != xmlName.length()) {
- ExtendedMetaData.INSTANCE.setName(eNamedElement, xmlName);
+ ExtendedMetaData.INSTANCE.setName(eClassifier, xmlName);
+ }
+ }
+
+ protected void setXMLName(Property property, Stereotype stereotype,
+ EStructuralFeature eStructuralFeature) {
+ String xmlName = (String) property.getValue(stereotype, "xmlName"); //$NON-NLS-1$
+
+ if (null != xmlName && 0 != xmlName.length()) {
+ ExtendedMetaData.INSTANCE.setName(eStructuralFeature, xmlName);
}
}
@@ -231,12 +239,14 @@
}
return elementMap.containsKey(theEObject)
- ? elementMap.get(theEObject) : super.doSwitch(theEObject);
+ ? elementMap.get(theEObject)
+ : super.doSwitch(theEObject);
}
public Object doSwitch(Resource resource) {
return modelMap.containsKey(resource)
- ? modelMap.get(resource) : caseResource(resource);
+ ? modelMap.get(resource)
+ : caseResource(resource);
}
public Object caseResource(Resource object) {
@@ -299,7 +309,7 @@
if (null != eClassStereotype) {
setName(object, eClassStereotype, eClass);
-
+
setXMLName(object, eClassStereotype, eClass);
EnumerationLiteral xmlContentKind = (EnumerationLiteral) object
@@ -325,8 +335,8 @@
eClass.getESuperTypes().add(
null == object.getAppliedStereotype("Ecore" //$NON-NLS-1$
+ NamedElement.SEPARATOR + "Extend") //$NON-NLS-1$
- ? eClass.getESuperTypes().size() : 0,
- doSwitch(generalization.getGeneral()));
+ ? eClass.getESuperTypes().size()
+ : 0, doSwitch(generalization.getGeneral()));
}
}
@@ -407,8 +417,6 @@
if (null != enumLiteralName && 0 != enumLiteralName.length()) {
eEnumLiteral.setName(enumLiteralName);
}
-
- setXMLName(object, eEnumLiteralStereotype, eEnumLiteral);
}
setAnnotations(object, eEnumLiteral);
@@ -504,12 +512,13 @@
*/
public Object casePackage(org.eclipse.uml2.Package object) {
EPackage ePackage = null == object.getNestingPackage()
- ? (EPackage) doSwitch(object.eResource()) : EcoreFactory.eINSTANCE
- .createEPackage();
+ ? (EPackage) doSwitch(object.eResource())
+ : EcoreFactory.eINSTANCE.createEPackage();
elementMap.put(object, ePackage);
EPackage eSuperPackage = (EPackage) (null == object.getNestingPackage()
- ? null : doSwitch(object.getNestingPackage()));
+ ? null
+ : doSwitch(object.getNestingPackage()));
if (null != eSuperPackage) {
eSuperPackage.getESubpackages().add(ePackage);
@@ -521,16 +530,19 @@
+ NamedElement.SEPARATOR + "EPackage"); //$NON-NLS-1$
String packageName = (String) (null == ePackageStereotype
- ? null : object.getValue(ePackageStereotype, "packageName")); //$NON-NLS-1$
+ ? null
+ : object.getValue(ePackageStereotype, "packageName")); //$NON-NLS-1$
if (null != packageName && 0 != packageName.length()) {
ePackage.setName(packageName);
}
String basePackage = (String) (null == ePackageStereotype
- ? null : object.getValue(ePackageStereotype, "basePackage")); //$NON-NLS-1$
+ ? null
+ : object.getValue(ePackageStereotype, "basePackage")); //$NON-NLS-1$
String nsPrefix = (String) (null == ePackageStereotype
- ? null : object.getValue(ePackageStereotype, "nsPrefix")); //$NON-NLS-1$
+ ? null
+ : object.getValue(ePackageStereotype, "nsPrefix")); //$NON-NLS-1$
if (null == nsPrefix || 0 == nsPrefix.length()) {
nsPrefix = ePackage.getName();
@@ -545,7 +557,8 @@
ePackage.setNsPrefix(nsPrefix);
String nsURI = (String) (null == ePackageStereotype
- ? null : object.getValue(ePackageStereotype, "nsURI")); //$NON-NLS-1$
+ ? null
+ : object.getValue(ePackageStereotype, "nsURI")); //$NON-NLS-1$
if (null == nsURI || 0 == nsURI.length()) {
nsURI = "http:///" + nsPrefix.replace('.', '/') + ".ecore"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -710,7 +723,8 @@
}
eStructuralFeature.setName(null == eStructuralFeature.getName()
- ? object.getName() : eStructuralFeature.getName());
+ ? object.getName()
+ : eStructuralFeature.getName());
eStructuralFeature.setChangeable(!object.isReadOnly());
eStructuralFeature.setDerived(object.isDerived());
@@ -726,7 +740,8 @@
eStructuralFeature.setUnique(object.isUnique());
eStructuralFeature.setEType(null == object.getType()
- ? EcorePackage.eINSTANCE.getEObject() : getEClassifier(object));
+ ? EcorePackage.eINSTANCE.getEObject()
+ : getEClassifier(object));
if (null != eStructuralFeatureStereotype) {
eStructuralFeature.setTransient(Boolean.TRUE.equals(object
diff --git a/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/internal/provider/UML2ItemPropertyDescriptor.java b/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/internal/provider/UML2ItemPropertyDescriptor.java
index eb1f263..a4ac455 100644
--- a/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/internal/provider/UML2ItemPropertyDescriptor.java
+++ b/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/internal/provider/UML2ItemPropertyDescriptor.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: UML2ItemPropertyDescriptor.java,v 1.3 2004/06/19 02:53:34 khussey Exp $
+ * $Id: UML2ItemPropertyDescriptor.java,v 1.4 2004/06/21 19:25:03 khussey Exp $
*/
package org.eclipse.uml2.edit.internal.provider;
@@ -22,7 +22,6 @@
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.UniqueEList;
-import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
@@ -192,23 +191,4 @@
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.edit.provider.IItemPropertyDescriptor#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object object) {
-
- if (EAttribute.class.isInstance(feature)) {
- Object result = ((EObject) object).eGet(feature);
-
- if (null == result) {
- return getDefaultValue(feature.getEType());
- } else {
- return createPropertyValueWrapper(object, result);
- }
- } else {
- return super.getPropertyValue(object);
- }
- }
}
\ No newline at end of file
diff --git a/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/util/ChangeCommand.java b/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/util/ChangeCommand.java
index 011b3a0..76f8216 100644
--- a/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/util/ChangeCommand.java
+++ b/deprecated/plugins/org.eclipse.uml2.edit/src/org/eclipse/uml2/edit/util/ChangeCommand.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: ChangeCommand.java,v 1.3 2004/06/17 19:49:16 khussey Exp $
+ * $Id: ChangeCommand.java,v 1.4 2004/06/21 19:25:03 khussey Exp $
*/
package org.eclipse.uml2.edit.util;
@@ -17,17 +17,14 @@
import java.util.ListIterator;
import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.change.ChangeDescription;
import org.eclipse.emf.ecore.change.ChangeKind;
import org.eclipse.emf.ecore.change.FeatureChange;
import org.eclipse.emf.ecore.change.ListChange;
import org.eclipse.emf.ecore.change.impl.ListChangeImpl;
import org.eclipse.emf.ecore.change.util.ChangeRecorder;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
/**
@@ -92,111 +89,42 @@
private static final ChangeRecorder CHANGE_RECORDER = new ChangeRecorder() {
- protected ListChange createUniqueListChange(EList changesList,
+ private boolean featureIsUnique = false;
+
+ protected ListChange createListChange(EList changesList,
ChangeKind kind, int index) {
- ListChange listChange = new UniqueListChangeImpl();
- listChange.setKind(kind);
- listChange.setIndex(index);
+ if (featureIsUnique) {
+ ListChange listChange = new UniqueListChangeImpl();
- changesList.add(listChange);
+ listChange.setKind(kind);
+ listChange.setIndex(index);
- return listChange;
+ changesList.add(listChange);
+
+ return listChange;
+ } else {
+ return super.createListChange(changesList, kind, index);
+ }
}
- protected void createUniqueListChanges(EList oldList, EList newList,
- EList changesList) {
- int index = 0;
+ protected void createRemoveListChange(EList oldList, EList changesList,
+ Object newObject, int index, int targetIndex) {
- for (Iterator objects = newList.iterator(); objects.hasNext(); ++index) {
- Object newObject = objects.next();
-
- if (oldList.size() <= index) {
- ListChange listChange = createUniqueListChange(changesList,
- ChangeKind.ADD_LITERAL, index);
- listChange.getValues().add(newObject);
- oldList.add(newObject);
- } else {
- boolean done;
-
- do {
- done = true;
- Object targetObject = oldList.get(index);
-
- if (null == targetObject
- ? null != newObject
- : !targetObject.equals(newObject)) {
-
- int position = EcoreUtil.indexOf(oldList,
- newObject, index);
-
- if (-1 != position) {
- int targetIndex = EcoreUtil.indexOf(newList,
- targetObject, index);
-
- if (-1 == targetIndex) {
- ListChange listChange = createUniqueListChange(
- changesList, ChangeKind.REMOVE_LITERAL,
- index);
- listChange.getValues().add(
- oldList.remove(index));
- done = false;
- } else if (targetIndex > position) {
-
- if (oldList.size() <= targetIndex) {
- targetIndex = oldList.size() - 1;
- }
-
- ListChange listChange = createUniqueListChange(
- changesList, ChangeKind.MOVE_LITERAL,
- index);
- listChange.setMoveToIndex(targetIndex);
- oldList.move(targetIndex, index);
- done = false;
- } else {
- ListChange listChange = createUniqueListChange(
- changesList, ChangeKind.MOVE_LITERAL,
- position);
- listChange.setMoveToIndex(index);
- oldList.move(index, position);
- }
- } else {
- ListChange listChange = createUniqueListChange(
- changesList, ChangeKind.ADD_LITERAL, index);
- listChange.getValues().add(newObject);
- oldList.add(index, newObject);
- }
- }
- } while (!done);
- }
- }
-
- for (int i = oldList.size(); i > index;) {
- ListChange listChange = createUniqueListChange(changesList,
- ChangeKind.REMOVE_LITERAL, --i);
- listChange.getValues().add(oldList.remove(i));
+ if (featureIsUnique) {
+ ListChange listChange = createListChange(changesList,
+ ChangeKind.REMOVE_LITERAL, index);
+ listChange.getValues().add(oldList.remove(index));
+ } else {
+ super.createRemoveListChange(oldList, changesList, newObject,
+ index, targetIndex);
}
}
protected void finalizeChange(FeatureChange change, EObject eObject) {
+ featureIsUnique = change.getFeature().isUnique();
- if (change.isSet()) {
- EStructuralFeature feature = change.getFeature();
-
- if (feature.isMany()) {
- EList oldList = new BasicEList((EList) eObject
- .eGet(feature));
- EList newList = (EList) change.getValue();
-
- if (feature.isUnique()) {
- createUniqueListChanges(oldList, newList, change
- .getListChanges());
- } else {
- createListChanges(oldList, newList, change
- .getListChanges());
- }
- }
- }
+ super.finalizeChange(change, eObject);
}
};
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ClassImpl.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ClassImpl.java
index 4ca7f3f..e9eeb16 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ClassImpl.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ClassImpl.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: ClassImpl.java,v 1.20 2004/06/18 17:44:12 khussey Exp $
+ * $Id: ClassImpl.java,v 1.21 2004/06/21 19:25:06 khussey Exp $
*/
package org.eclipse.uml2.impl;
@@ -25,17 +25,13 @@
import org.eclipse.emf.common.util.BasicEList;
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.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreEList;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
-import org.eclipse.uml2.Association;
import org.eclipse.uml2.Behavior;
import org.eclipse.uml2.Classifier;
import org.eclipse.uml2.CollaborationOccurrence;
@@ -503,39 +499,7 @@
UML2Package.eINSTANCE.getClass_Extension());
if (null == result) {
- List extensions = new ArrayList();
-
- if (isMetaclass()) {
-
- ResourceSet resourceSet = null == eResource()
- ? null
- : eResource().getResourceSet();
-
- if (null != resourceSet) {
-
- for (Iterator settings = EcoreUtil.UsageCrossReferencer
- .find(this, resourceSet).iterator(); settings.hasNext();) {
-
- EStructuralFeature.Setting setting = (EStructuralFeature.Setting) settings
- .next();
-
- if (UML2Package.eINSTANCE.getTypedElement_Type() == setting
- .getEStructuralFeature()) {
-
- EObject eObject = setting.getEObject();
-
- if (Property.class.isInstance(eObject)) {
- Association association = ((Property) eObject)
- .getAssociation();
-
- if (Extension.class.isInstance(association)) {
- extensions.add(association);
- }
- }
- }
- }
- }
- }
+ Set extensions = ClassOperations.getExtensions(this);
result = new EcoreEList.UnmodifiableEList(this,
UML2Package.eINSTANCE.getClass_Extension(), extensions.size(),
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java
index 9f4768d..629451b 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: ClassOperations.java,v 1.3 2004/05/13 03:16:20 khussey Exp $
+ * $Id: ClassOperations.java,v 1.4 2004/06/21 19:25:06 khussey Exp $
*/
package org.eclipse.uml2.internal.operation;
@@ -16,8 +16,12 @@
import java.util.Iterator;
import java.util.Set;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.uml2.NamedElement;
import org.eclipse.uml2.RedefinableElement;
+import org.eclipse.uml2.UML2Package;
/**
* A static utility class that provides operations related to classes.
@@ -36,7 +40,7 @@
public static Set inherit(org.eclipse.uml2.Class class_, Set inhs) {
Set inherit = new HashSet();
- iLoop: for (Iterator i = inhs.iterator(); i.hasNext();) {
+ iLoop : for (Iterator i = inhs.iterator(); i.hasNext();) {
NamedElement inh = (NamedElement) i.next();
for (Iterator ownedMembers = class_.getOwnedMembers().iterator(); ownedMembers
@@ -71,4 +75,35 @@
+ NamedElement.SEPARATOR + "Metaclass"); //$NON-NLS-1$
}
+ public static Set getExtensions(org.eclipse.uml2.Class class_) {
+ Set extensions = new HashSet();
+
+ if (null != class_ && class_.isMetaclass()) {
+ Resource resource = class_.eResource();
+
+ if (null != resource) {
+ FilteredUsageCrossReferencer.Filter filter = new FilteredUsageCrossReferencer.Filter() {
+
+ public boolean accept(EStructuralFeature eStructuralFeature) {
+ return UML2Package.eINSTANCE.getExtension_Metaclass() == eStructuralFeature;
+ }
+ };
+
+ ResourceSet resourceSet = resource.getResourceSet();
+
+ Iterator settings = null == resourceSet
+ ? FilteredUsageCrossReferencer.find(class_, resource,
+ filter).iterator()
+ : FilteredUsageCrossReferencer.find(class_, resourceSet,
+ filter).iterator();
+
+ while (settings.hasNext()) {
+ extensions.add(((EStructuralFeature.Setting) settings
+ .next()).getEObject());
+ }
+ }
+ }
+
+ return extensions;
+ }
}
\ No newline at end of file
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ElementOperations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ElementOperations.java
index 0c5aed9..bb35c19 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ElementOperations.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ElementOperations.java
@@ -8,16 +8,13 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: ElementOperations.java,v 1.7 2004/05/18 21:00:48 khussey Exp $
+ * $Id: ElementOperations.java,v 1.8 2004/06/21 19:25:06 khussey Exp $
*/
package org.eclipse.uml2.internal.operation;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
@@ -27,18 +24,14 @@
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EContentsEList;
-import org.eclipse.emf.ecore.util.ECrossReferenceEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.uml2.Element;
import org.eclipse.uml2.Model;
-import org.eclipse.uml2.util.UML2Validator;
import org.eclipse.uml2.UML2Plugin;
+import org.eclipse.uml2.util.UML2Validator;
/**
* A static utility class that provides operations related to elements.
@@ -46,160 +39,6 @@
public final class ElementOperations
extends UML2Operations {
- protected static class ChangeableECrossReferenceEList
- extends ECrossReferenceEList {
-
- protected static class ChangeableFeatureIteratorImpl
- extends ECrossReferenceEList.FeatureIteratorImpl {
-
- public ChangeableFeatureIteratorImpl(EObject eObject) {
- super(eObject);
- }
-
- public ChangeableFeatureIteratorImpl(EObject eObject,
- EStructuralFeature[] eStructuralFeatures) {
- super(eObject, eStructuralFeatures);
- }
-
- protected boolean isIncluded(EStructuralFeature eStructuralFeature) {
- return super.isIncluded(eStructuralFeature)
- && eStructuralFeature.isChangeable();
- }
-
- protected boolean isIncludedEntry(
- EStructuralFeature eStructuralFeature) {
- return super.isIncludedEntry(eStructuralFeature)
- && eStructuralFeature.isChangeable();
- }
- }
-
- protected static class ChangeableResolvingFeatureIteratorImpl
- extends ChangeableFeatureIteratorImpl {
-
- public ChangeableResolvingFeatureIteratorImpl(EObject eObject) {
- super(eObject);
- }
-
- public ChangeableResolvingFeatureIteratorImpl(EObject eObject,
- EStructuralFeature[] eStructuralFeatures) {
- super(eObject, eStructuralFeatures);
- }
-
- protected boolean resolve() {
- return true;
- }
- }
-
- protected ChangeableECrossReferenceEList(EObject eObject) {
- super(eObject);
- }
-
- protected ChangeableECrossReferenceEList(EObject eObject,
- EStructuralFeature[] eStructuralFeatures) {
- super(eObject, eStructuralFeatures);
- }
-
- protected boolean isIncluded(EStructuralFeature eStructuralFeature) {
- return super.isIncluded(eStructuralFeature)
- && eStructuralFeature.isChangeable();
- }
-
- protected ListIterator newListIterator() {
- return this.resolve()
- ? new ChangeableResolvingFeatureIteratorImpl(eObject,
- eStructuralFeatures)
- : new ChangeableFeatureIteratorImpl(eObject,
- eStructuralFeatures);
- }
-
- public List basicList() {
- return new ChangeableECrossReferenceEList(eObject,
- eStructuralFeatures) {
-
- protected boolean resolve() {
- return false;
- }
- };
- }
-
- public Iterator basicIterator() {
-
- if (eStructuralFeatures == null) {
- return ChangeableFeatureIteratorImpl.EMPTY_ITERATOR;
- }
-
- return new ChangeableFeatureIteratorImpl(eObject,
- eStructuralFeatures);
- }
-
- public ListIterator basicListIterator() {
-
- if (eStructuralFeatures == null) {
- return FeatureIteratorImpl.EMPTY_ITERATOR;
- }
-
- return new ChangeableFeatureIteratorImpl(eObject,
- eStructuralFeatures);
- }
-
- public ListIterator basicListIterator(int index) {
-
- if (eStructuralFeatures == null) {
-
- if (index < 0 || index > 1) {
- throw new IndexOutOfBoundsException("index = " + index //$NON-NLS-1$
- + ", size = 0"); //$NON-NLS-1$
- }
-
- return ChangeableFeatureIteratorImpl.EMPTY_ITERATOR;
- }
-
- ListIterator result = new ChangeableFeatureIteratorImpl(eObject,
- eStructuralFeatures);
-
- for (int i = 0; i < index; ++i) {
- result.next();
- }
-
- return result;
- }
-
- }
-
- public static class ChangeableUsageCrossReferencer
- extends EcoreUtil.UsageCrossReferencer {
-
- public static Collection find(EObject eObject, ResourceSet resourceSet) {
- return new ChangeableUsageCrossReferencer(resourceSet)
- .findUsage(eObject);
- }
-
- protected ChangeableUsageCrossReferencer(ResourceSet resourceSet) {
- super(resourceSet);
- }
-
- protected void handleCrossReference(EObject eObject) {
- InternalEList eCrossReferences = new ChangeableECrossReferenceEList(
- eObject);
-
- EContentsEList.FeatureIterator crossReferences = (EContentsEList.FeatureIterator) (resolve()
- ? eCrossReferences.iterator() : eCrossReferences
- .basicIterator());
-
- while (crossReferences.hasNext()) {
- EObject crossReferencedEObject = (EObject) crossReferences
- .next();
- EReference eReference = (EReference) crossReferences.feature();
-
- if (crossReference(eObject, eReference, crossReferencedEObject)) {
- getCollection(crossReferencedEObject).add(
- ((InternalEObject) eObject).eSetting(eReference));
- }
- }
- }
-
- }
-
/**
* The source for the keywords annotation on elements.
*/
@@ -246,8 +85,10 @@
}
return Model.class.isInstance(element)
- ? (Model) element : (Element.class.isInstance(element.eContainer())
- ? getModel((Element) element.eContainer()) : null);
+ ? (Model) element
+ : (Element.class.isInstance(element.eContainer())
+ ? getModel((Element) element.eContainer())
+ : null);
}
/**
@@ -267,9 +108,10 @@
}
return org.eclipse.uml2.Package.class.isInstance(element)
- ? (org.eclipse.uml2.Package) element : (Element.class
- .isInstance(element.eContainer())
- ? getNearestPackage((Element) element.eContainer()) : null);
+ ? (org.eclipse.uml2.Package) element
+ : (Element.class.isInstance(element.eContainer())
+ ? getNearestPackage((Element) element.eContainer())
+ : null);
}
/**
@@ -291,10 +133,18 @@
throw new IllegalArgumentException(String.valueOf(element));
}
- ResourceSet resourceSet = null == element.eResource()
- ? null : element.eResource().getResourceSet();
+ Resource resource = element.eResource();
- if (null != resourceSet) {
+ if (null != resource) {
+ ResourceSet resourceSet = resource.getResourceSet();
+
+ FilteredUsageCrossReferencer.Filter filter = new FilteredUsageCrossReferencer.Filter() {
+
+ public boolean accept(EStructuralFeature eStructuralFeature) {
+ return eStructuralFeature.isChangeable();
+ }
+ };
+
TreeIterator eAllContents = new AbstractTreeIterator(element, true) {
public Iterator getChildren(Object parent) {
@@ -305,13 +155,18 @@
while (eAllContents.hasNext()) {
EObject eObject = (EObject) eAllContents.next();
- for (Iterator settings = ChangeableUsageCrossReferencer.find(
- eObject, resourceSet).iterator(); settings.hasNext();) {
+ Iterator settings = null == resourceSet
+ ? FilteredUsageCrossReferencer.find(eObject, resource,
+ filter).iterator()
+ : FilteredUsageCrossReferencer.find(eObject, resourceSet,
+ filter).iterator();
+ while (settings.hasNext()) {
EcoreUtil.remove((EStructuralFeature.Setting) settings
.next(), eObject);
}
}
+
}
EcoreUtil.remove(element);
@@ -419,12 +274,11 @@
if (null != diagnostics) {
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING,
- UML2Validator.DIAGNOSTIC_SOURCE,
- UML2Validator.ELEMENT__NOT_OWN_SELF,
- UML2Plugin.INSTANCE.getString(
- "_UI_Element_NotOwnSelf_diagnostic", //$NON-NLS-1$
+ UML2Validator.DIAGNOSTIC_SOURCE,
+ UML2Validator.ELEMENT__NOT_OWN_SELF, UML2Plugin.INSTANCE
+ .getString("_UI_Element_NotOwnSelf_diagnostic", //$NON-NLS-1$
getMessageSubstitutions(context, element)),
- new Object[] {element}));
+ new Object[]{element}));
}
}
@@ -433,7 +287,7 @@
/**
* Elements that must be owned must have an owner.
- *
+ *
*/
public static boolean validateHasOwner(Element element,
DiagnosticChain diagnostics, Map context) {
@@ -444,12 +298,11 @@
if (null != diagnostics) {
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING,
- UML2Validator.DIAGNOSTIC_SOURCE,
- UML2Validator.ELEMENT__HAS_OWNER,
- UML2Plugin.INSTANCE.getString(
- "_UI_Element_HasOwner_diagnostic", //$NON-NLS-1$
+ UML2Validator.DIAGNOSTIC_SOURCE,
+ UML2Validator.ELEMENT__HAS_OWNER, UML2Plugin.INSTANCE
+ .getString("_UI_Element_HasOwner_diagnostic", //$NON-NLS-1$
getMessageSubstitutions(context, element)),
- new Object[] {element}));
+ new Object[]{element}));
}
}
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java
index d0e68cd..f980bce 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java
@@ -8,12 +8,15 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: UML2Operations.java,v 1.6 2004/05/21 20:20:27 khussey Exp $
+ * $Id: UML2Operations.java,v 1.7 2004/06/21 19:25:06 khussey Exp $
*/
package org.eclipse.uml2.internal.operation;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
@@ -22,10 +25,17 @@
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EContentsEList;
+import org.eclipse.emf.ecore.util.ECrossReferenceEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.uml2.Artifact;
import org.eclipse.uml2.DataType;
import org.eclipse.uml2.Element;
@@ -41,6 +51,190 @@
*/
class UML2Operations {
+ protected static class FilteredECrossReferenceEList
+ extends ECrossReferenceEList {
+
+ private final FilteredUsageCrossReferencer.Filter filter;
+
+ protected static class FilteredFeatureIteratorImpl
+ extends ECrossReferenceEList.FeatureIteratorImpl {
+
+ private final FilteredUsageCrossReferencer.Filter filter;
+
+ public FilteredFeatureIteratorImpl(EObject eObject,
+ EStructuralFeature[] eStructuralFeatures,
+ FilteredUsageCrossReferencer.Filter filter) {
+ super(eObject, eStructuralFeatures);
+
+ this.filter = filter;
+ }
+
+ protected boolean isIncluded(EStructuralFeature eStructuralFeature) {
+ return super.isIncluded(eStructuralFeature)
+ && filter.accept(eStructuralFeature);
+ }
+
+ protected boolean isIncludedEntry(
+ EStructuralFeature eStructuralFeature) {
+ return super.isIncludedEntry(eStructuralFeature)
+ && filter.accept(eStructuralFeature);
+ }
+ }
+
+ protected static class FilteredResolvingFeatureIteratorImpl
+ extends FilteredFeatureIteratorImpl {
+
+ public FilteredResolvingFeatureIteratorImpl(EObject eObject,
+ EStructuralFeature[] eStructuralFeatures,
+ FilteredUsageCrossReferencer.Filter filter) {
+ super(eObject, eStructuralFeatures, filter);
+ }
+
+ protected boolean resolve() {
+ return true;
+ }
+ }
+
+ protected FilteredECrossReferenceEList(EObject eObject,
+ FilteredUsageCrossReferencer.Filter filter) {
+ super(eObject);
+
+ this.filter = filter;
+ }
+
+ protected FilteredECrossReferenceEList(EObject eObject,
+ EStructuralFeature[] eStructuralFeatures,
+ FilteredUsageCrossReferencer.Filter filter) {
+ super(eObject, eStructuralFeatures);
+
+ this.filter = filter;
+ }
+
+ protected boolean isIncluded(EStructuralFeature eStructuralFeature) {
+ return super.isIncluded(eStructuralFeature)
+ && filter.accept(eStructuralFeature);
+ }
+
+ protected ListIterator newListIterator() {
+ return this.resolve()
+ ? new FilteredResolvingFeatureIteratorImpl(eObject,
+ eStructuralFeatures, filter)
+ : new FilteredFeatureIteratorImpl(eObject, eStructuralFeatures,
+ filter);
+ }
+
+ public List basicList() {
+ return new FilteredECrossReferenceEList(eObject,
+ eStructuralFeatures, filter) {
+
+ protected boolean resolve() {
+ return false;
+ }
+ };
+ }
+
+ public Iterator basicIterator() {
+
+ if (null == eStructuralFeatures) {
+ return FilteredFeatureIteratorImpl.EMPTY_ITERATOR;
+ }
+
+ return new FilteredFeatureIteratorImpl(eObject,
+ eStructuralFeatures, filter);
+ }
+
+ public ListIterator basicListIterator() {
+
+ if (null == eStructuralFeatures) {
+ return FeatureIteratorImpl.EMPTY_ITERATOR;
+ }
+
+ return new FilteredFeatureIteratorImpl(eObject,
+ eStructuralFeatures, filter);
+ }
+
+ public ListIterator basicListIterator(int index) {
+
+ if (null == eStructuralFeatures) {
+
+ if (0 > index || 1 < index) {
+ throw new IndexOutOfBoundsException("index = " + index //$NON-NLS-1$
+ + ", size = 0"); //$NON-NLS-1$
+ }
+
+ return FilteredFeatureIteratorImpl.EMPTY_ITERATOR;
+ }
+
+ ListIterator result = new FilteredFeatureIteratorImpl(eObject,
+ eStructuralFeatures, filter);
+
+ for (int i = 0; i < index; i++) {
+ result.next();
+ }
+
+ return result;
+ }
+
+ }
+
+ public static class FilteredUsageCrossReferencer
+ extends EcoreUtil.UsageCrossReferencer {
+
+ public static interface Filter {
+
+ boolean accept(EStructuralFeature eStructuralFeature);
+
+ }
+
+ private final Filter filter;
+
+ public static Collection find(EObject eObject, ResourceSet resourceSet,
+ Filter filter) {
+ return new FilteredUsageCrossReferencer(resourceSet, filter)
+ .findUsage(eObject);
+ }
+
+ public static Collection find(EObject eObject, Resource resource,
+ Filter filter) {
+ return new FilteredUsageCrossReferencer(resource, filter)
+ .findUsage(eObject);
+ }
+
+ protected FilteredUsageCrossReferencer(ResourceSet resourceSet,
+ Filter filter) {
+ super(resourceSet);
+
+ this.filter = filter;
+ }
+
+ protected FilteredUsageCrossReferencer(Resource resource, Filter filter) {
+ super(resource);
+
+ this.filter = filter;
+ }
+
+ protected void handleCrossReference(EObject eObject) {
+ InternalEList filteredCrossReferences = new FilteredECrossReferenceEList(
+ eObject, filter);
+
+ EContentsEList.FeatureIterator crossReferences = (EContentsEList.FeatureIterator) (resolve()
+ ? filteredCrossReferences.iterator()
+ : filteredCrossReferences.basicIterator());
+
+ while (crossReferences.hasNext()) {
+ EObject crossReferencedEObject = (EObject) crossReferences
+ .next();
+ EReference eReference = (EReference) crossReferences.feature();
+
+ if (crossReference(eObject, eReference, crossReferencedEObject)) {
+ getCollection(crossReferencedEObject).add(
+ ((InternalEObject) eObject).eSetting(eReference));
+ }
+ }
+ }
+
+ }
+
/**
* The empty string.
*/
@@ -72,7 +266,8 @@
EAnnotation eAnnotation = eModelElement.getEAnnotation(source);
return null == eAnnotation
- ? createEAnnotation(source, eModelElement) : eAnnotation;
+ ? createEAnnotation(source, eModelElement)
+ : eAnnotation;
}
protected static EAnnotation getEAnnotation(String source,
@@ -80,12 +275,14 @@
EAnnotation eAnnotation = eModelElement.getEAnnotation(source);
return null == eAnnotation
- ? EcoreFactory.eINSTANCE.createEAnnotation() : eAnnotation;
+ ? EcoreFactory.eINSTANCE.createEAnnotation()
+ : eAnnotation;
}
protected static boolean safeEquals(Object thisObject, Object thatObject) {
return null == thisObject
- ? null == thatObject : thisObject.equals(thatObject);
+ ? null == thatObject
+ : thisObject.equals(thatObject);
}
protected static boolean isEmpty(String string) {
@@ -161,18 +358,18 @@
protected static Object[] getMessageSubstitutions(Map context,
Object object0) {
- return new Object[] {getMessageSubstitution(context, object0)};
+ return new Object[]{getMessageSubstitution(context, object0)};
}
protected static Object[] getMessageSubstitutions(Map context,
Object object0, Object object1) {
- return new Object[] {getMessageSubstitution(context, object0),
+ return new Object[]{getMessageSubstitution(context, object0),
getMessageSubstitution(context, object1)};
}
protected static Object[] getMessageSubstitutions(Map context,
Object object0, Object object1, Object object2) {
- return new Object[] {getMessageSubstitution(context, object0),
+ return new Object[]{getMessageSubstitution(context, object0),
getMessageSubstitution(context, object1),
getMessageSubstitution(context, object2)};
}