Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54732 Details for
Bug 150154
[Plan Item] XML Primitive Types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated patch
150154.patch (text/plain), 34.08 KB, created by
Kenn Hussey
on 2006-11-29 13:43:13 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Kenn Hussey
Created:
2006-11-29 13:43:13 EST
Size:
34.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.uml2.examples.uml.ui >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/examples/org.eclipse.uml2.examples.uml.ui/plugin.properties,v >retrieving revision 1.5 >diff -u -r1.5 plugin.properties >--- plugin.properties 10 Jun 2006 20:29:47 -0000 1.5 >+++ plugin.properties 29 Nov 2006 18:33:07 -0000 >@@ -48,6 +48,8 @@ > > _UI_PrimitiveTypesMenu_label = &Primitive Types > >+_UI_DataTypesMenu_label = &Data Types >+ > _UI_StereotypesMenu_label = &Stereotypes > > _UI_EcoreAction_label = &Ecore >@@ -66,6 +68,9 @@ > _UI_UMLAction_label = &UML > _UI_GenerateUMLPrimitiveTypesActionCommand_label = Generate UML Primitive Types into Model {0} > >+_UI_XMLAction_label = &XML >+_UI_GenerateXMLDataTypesActionCommand_label = Generate XML Data Types into Model {0} >+ > _UI_ExternalizeMenu_label = E&xternalize > > _UI_KeywordsAction_label = &Keywords >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/examples/org.eclipse.uml2.examples.uml.ui/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 25 Apr 2006 20:58:28 -0000 1.4 >+++ plugin.xml 29 Nov 2006 18:33:07 -0000 >@@ -127,6 +127,18 @@ > </objectClass> > </enablement> > </action> >+ <action >+ label="%_UI_XMLAction_label" >+ class="org.eclipse.uml2.examples.uml.ui.actions.GenerateXMLDataTypesAction" >+ menubarPath="org.eclipse.uml2.umlMenuID/org.eclipse.uml2.examples.uml.ui.GenerateMenuID/org.eclipse.uml2.examples.uml.ui.DataTypesMenuID/additions" >+ enablesFor="1" >+ id="org.eclipse.uml2.examples.uml.ui.GenerateXMLDataTypesActionID"> >+ <enablement> >+ <objectClass >+ name="org.eclipse.uml2.uml.Model"> >+ </objectClass> >+ </enablement> >+ </action> > <menu > label="%_UI_ExternalizeMenu_label" > path="org.eclipse.uml2.umlMenuID/additions-end" >@@ -199,6 +211,14 @@ > </objectClass> > </enablement> > </action> >+ <menu >+ id="org.eclipse.uml2.examples.uml.ui.DataTypesMenuID" >+ label="%_UI_DataTypesMenu_label" >+ path="org.eclipse.uml2.umlMenuID/org.eclipse.uml2.examples.uml.ui.GenerateMenuID/additions"> >+ <separator >+ name="additions"> >+ </separator> >+ </menu> > </editorContribution> > </extension> > >Index: src/org/eclipse/uml2/examples/uml/ui/actions/GenerateEcoreStereotypesAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/examples/org.eclipse.uml2.examples.uml.ui/src/org/eclipse/uml2/examples/uml/ui/actions/GenerateEcoreStereotypesAction.java,v >retrieving revision 1.3 >diff -u -r1.3 GenerateEcoreStereotypesAction.java >--- src/org/eclipse/uml2/examples/uml/ui/actions/GenerateEcoreStereotypesAction.java 10 Oct 2006 20:40:47 -0000 1.3 >+++ src/org/eclipse/uml2/examples/uml/ui/actions/GenerateEcoreStereotypesAction.java 29 Nov 2006 18:33:07 -0000 >@@ -42,33 +42,33 @@ > profile, UMLPackage.Literals.PACKAGE); > generateExtension(ePackageStereotype, packageMetaclass, > false); >- PrimitiveType stringPrimitiveType = getImportedUMLPrimitiveType( >+ PrimitiveType stringUMLPrimitiveType = getImportedUMLPrimitiveType( > profile, "String"); //$NON-NLS-1$ > generateOwnedAttribute(ePackageStereotype, > "packageName", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > generateOwnedAttribute(ePackageStereotype, "nsPrefix", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > generateOwnedAttribute(ePackageStereotype, "nsURI", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > generateOwnedAttribute(ePackageStereotype, > "basePackage", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > generateOwnedAttribute(ePackageStereotype, "prefix", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > > Stereotype eNamedElementStereotype = generateOwnedStereotype( > profile, "ENamedElement", true); //$NON-NLS-1$ > generateOwnedAttribute(eNamedElementStereotype, > "xmlName", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > > Stereotype eClassifierStereotype = generateOwnedStereotype( > profile, "EClassifier", true); //$NON-NLS-1$ > generateGeneralization(eClassifierStereotype, > eNamedElementStereotype); > generateOwnedAttribute(eClassifierStereotype, >- "instanceClassName", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "instanceClassName", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > > Enumeration contentKindEnumeration = generateOwnedEnumeration( > profile, "ContentKind"); //$NON-NLS-1$ >@@ -88,14 +88,18 @@ > profile, UMLPackage.Literals.CLASS); > org.eclipse.uml2.uml.Class interfaceMetaclass = getReferencedUMLMetaclass( > profile, UMLPackage.Literals.INTERFACE); >+ org.eclipse.uml2.uml.Class dataTypeMetaclass = getReferencedUMLMetaclass( >+ profile, UMLPackage.Literals.DATA_TYPE); > generateExtension(eClassStereotype, classMetaclass, > false); > generateExtension(eClassStereotype, interfaceMetaclass, > false); >+ generateExtension(eClassStereotype, dataTypeMetaclass, >+ false); > generateGeneralization(eClassStereotype, > eClassifierStereotype); > generateOwnedAttribute(eClassStereotype, "className", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > generateOwnedAttribute(eClassStereotype, > "xmlContentKind", //$NON-NLS-1$ > contentKindEnumeration, 0, 1); >@@ -112,7 +116,7 @@ > eClassifierStereotype); > generateOwnedAttribute(eDataTypeStereotype, > "dataTypeName", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > > Stereotype eEnumStereotype = generateOwnedStereotype( > profile, "EEnum", false); //$NON-NLS-1$ >@@ -125,7 +129,7 @@ > generateGeneralization(eEnumStereotype, > eNamedElementStereotype); > generateOwnedAttribute(eEnumStereotype, "enumName", //$NON-NLS-1$ >- stringPrimitiveType, 0, 1); >+ stringUMLPrimitiveType, 0, 1); > > Stereotype eEnumLiteralStereotype = generateOwnedStereotype( > profile, "EEnumLiteral", false); //$NON-NLS-1$ >@@ -138,7 +142,7 @@ > generateGeneralization(eEnumLiteralStereotype, > eNamedElementStereotype); > generateOwnedAttribute(eEnumLiteralStereotype, >- "enumLiteralName", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "enumLiteralName", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > > Stereotype eOperationStereotype = generateOwnedStereotype( > profile, "EOperation", false); //$NON-NLS-1$ >@@ -149,7 +153,7 @@ > generateExtension(eOperationStereotype, > operationMetaclass, false); > generateOwnedAttribute(eOperationStereotype, >- "operationName", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "operationName", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > > Stereotype eParameterStereotype = generateOwnedStereotype( > profile, "EParameter", false); //$NON-NLS-1$ >@@ -160,7 +164,7 @@ > generateExtension(eParameterStereotype, > parameterMetaclass, false); > generateOwnedAttribute(eParameterStereotype, >- "parameterName", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "parameterName", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > > Enumeration featureKindEnumeration = generateOwnedEnumeration( > profile, "FeatureKind"); //$NON-NLS-1$ >@@ -203,7 +207,7 @@ > generateOwnedAttribute(eStructuralFeatureStereotype, > "isUnsettable", booleanPrimitiveType, 0, 1); //$NON-NLS-1$ > generateOwnedAttribute(eStructuralFeatureStereotype, >- "xmlNamespace", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "xmlNamespace", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > generateOwnedAttribute(eStructuralFeatureStereotype, > "xmlFeatureKind", featureKindEnumeration, 0, 1); //$NON-NLS-1$ > generateOwnedAttribute(eStructuralFeatureStereotype, >@@ -220,7 +224,7 @@ > generateGeneralization(eAttributeStereotype, > eStructuralFeatureStereotype); > generateOwnedAttribute(eAttributeStereotype, >- "attributeName", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "attributeName", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > generateOwnedAttribute(eAttributeStereotype, > "isID", booleanPrimitiveType, 0, 1); //$NON-NLS-1$ > >@@ -233,7 +237,7 @@ > generateGeneralization(eReferenceStereotype, > eStructuralFeatureStereotype); > generateOwnedAttribute(eReferenceStereotype, >- "referenceName", stringPrimitiveType, 0, 1); //$NON-NLS-1$ >+ "referenceName", stringUMLPrimitiveType, 0, 1); //$NON-NLS-1$ > generateOwnedAttribute(eReferenceStereotype, > "isResolveProxies", booleanPrimitiveType, 0, 1) //$NON-NLS-1$ > .setBooleanDefaultValue(true); >Index: src/org/eclipse/uml2/examples/uml/ui/actions/GenerateXMLPrimitiveTypesAction.java >=================================================================== >RCS file: src/org/eclipse/uml2/examples/uml/ui/actions/GenerateXMLPrimitiveTypesAction.java >diff -N src/org/eclipse/uml2/examples/uml/ui/actions/GenerateXMLPrimitiveTypesAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/examples/uml/ui/actions/GenerateXMLPrimitiveTypesAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/* >+ * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - initial API and implementation >+ * >+ * $Id: GenerateXMLDataTypesAction.java,v 1.2 2006/10/10 20:40:47 khussey Exp $ >+ */ >+package org.eclipse.uml2.examples.uml.ui.actions; >+ >+import java.util.Iterator; >+ >+import org.eclipse.emf.common.command.UnexecutableCommand; >+import org.eclipse.emf.ecore.EDataType; >+import org.eclipse.emf.ecore.EEnum; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.util.EcoreSwitch; >+import org.eclipse.emf.ecore.util.ExtendedMetaData; >+import org.eclipse.emf.ecore.xml.type.XMLTypePackage; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.uml2.common.edit.command.ChangeCommand; >+import org.eclipse.uml2.examples.uml.ui.UMLExamplesUIPlugin; >+import org.eclipse.uml2.uml.Model; >+import org.eclipse.uml2.uml.PrimitiveType; >+ >+public class GenerateXMLPrimitiveTypesAction >+ extends GenerateModelAction { >+ >+ public void run(IAction action) { >+ >+ if (command != UnexecutableCommand.INSTANCE) { >+ final Model model = (Model) collection.iterator().next(); >+ >+ editingDomain.getCommandStack().execute( >+ new ChangeCommand(editingDomain, new Runnable() { >+ >+ public void run() { >+ >+ new EcoreSwitch() { >+ >+ public Object caseEDataType(EDataType eDataType) { >+ PrimitiveType ownedPrimitiveType = generateOwnedPrimitiveType( >+ model, eDataType.getName()); >+ >+ EDataType baseType = ExtendedMetaData.INSTANCE >+ .getBaseType(eDataType); >+ >+ if (baseType != null) { >+ ownedPrimitiveType.getGeneralization( >+ (PrimitiveType) doSwitch(baseType), >+ true); >+ } >+ >+ return ownedPrimitiveType; >+ } >+ >+ public Object caseEEnum(EEnum eEnum) { >+ return eEnum; >+ } >+ >+ public Object defaultCase(EObject eObject) { >+ >+ for (Iterator eContents = eObject.eContents() >+ .iterator(); eContents.hasNext();) { >+ >+ doSwitch((EObject) eContents.next()); >+ } >+ >+ return eObject; >+ } >+ }.doSwitch(XMLTypePackage.eINSTANCE); >+ } >+ }, UMLExamplesUIPlugin.INSTANCE.getString( >+ "_UI_GenerateXMLPrimitiveTypesActionCommand_label", //$NON-NLS-1$ >+ new Object[]{getLabelProvider().getText(model)}))); >+ } >+ } >+ >+} >#P org.eclipse.uml2.uml >Index: src/org/eclipse/uml2/uml/util/UMLUtil.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java,v >retrieving revision 1.39 >diff -u -r1.39 UMLUtil.java >--- src/org/eclipse/uml2/uml/util/UMLUtil.java 21 Nov 2006 22:37:51 -0000 1.39 >+++ src/org/eclipse/uml2/uml/util/UMLUtil.java 29 Nov 2006 18:33:09 -0000 >@@ -2239,6 +2239,9 @@ > > eType = EcorePackage.eINSTANCE.getEClassifier(type > .getName()); >+ } else if (qualifiedName.startsWith("XMLPrimitiveTypes::")) { //$NON-NLS-1$ >+ eType = XMLTypePackage.eINSTANCE.getEClassifier(type >+ .getName()); > } > } > >@@ -2496,6 +2499,19 @@ > } > } > } >+ } else if (specificEClassifier instanceof EDataType) { >+ EDataType specificEDataType = (EDataType) specificEClassifier; >+ Classifier general = generalization.getGeneral(); >+ >+ if (general != null) { >+ EClassifier generalEClassifier = (EClassifier) doSwitch(general); >+ >+ if (generalEClassifier instanceof EDataType) { >+ ExtendedMetaData.INSTANCE.setBaseType( >+ specificEDataType, >+ (EDataType) generalEClassifier); >+ } >+ } > } > } > >@@ -2755,6 +2771,32 @@ > /* > * (non-Javadoc) > * >+ * @see org.eclipse.uml2.uml.util.UMLSwitch#caseDataType(org.eclipse.uml2.uml.DataType) >+ */ >+ public Object caseDataType(DataType dataType) { >+ org.eclipse.uml2.uml.Package package_ = dataType >+ .getNearestPackage(); >+ >+ if (package_ != null) { >+ EClass eClass = EcoreFactory.eINSTANCE.createEClass(); >+ elementToEModelElementMap.put(dataType, eClass); >+ >+ EPackage ePackage = (EPackage) doSwitch(package_); >+ ePackage.getEClassifiers().add(eClass); >+ >+ setName(eClass, dataType); >+ >+ defaultCase(dataType); >+ >+ return eClass; >+ } >+ >+ return super.caseDataType(dataType); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.uml2.uml.util.UMLSwitch#caseProperty(org.eclipse.uml2.uml.Property) > */ > public Object caseProperty(Property property) { >@@ -5008,6 +5050,24 @@ > return null; > } > >+ protected Model getXMLPrimitiveTypesLibrary(EModelElement eModelElement) { >+ Resource eResource = eModelElement.eResource(); >+ >+ if (eResource != null) { >+ ResourceSet resourceSet = eResource.getResourceSet(); >+ >+ if (resourceSet != null) { >+ return (Model) load( >+ resourceSet, >+ URI >+ .createURI(UMLResource.XML_PRIMITIVE_TYPES_LIBRARY_URI), >+ UMLPackage.Literals.MODEL); >+ } >+ } >+ >+ return null; >+ } >+ > protected PrimitiveType getEcorePrimitiveType( > EModelElement eModelElement, String name) { > Model ecorePrimitiveTypesLibrary = getEcorePrimitiveTypesLibrary(eModelElement); >@@ -5017,6 +5077,15 @@ > : null; > } > >+ protected PrimitiveType getXMLPrimitiveType( >+ EModelElement eModelElement, String name) { >+ Model xmlPrimitiveTypesLibrary = getXMLPrimitiveTypesLibrary(eModelElement); >+ >+ return xmlPrimitiveTypesLibrary != null >+ ? (PrimitiveType) xmlPrimitiveTypesLibrary.getOwnedType(name) >+ : null; >+ } >+ > protected Type getType(EModelElement eModelElement, EClassifier eType) { > Type type = null; > >@@ -5030,80 +5099,7 @@ > String nsURI = ePackage.getNsURI(); > > if (XMLTypePackage.eNS_URI.equals(nsURI)) { >- String instanceClassName = eType >- .getInstanceClassName(); >- >- if ("java.math.BigDecimal".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBIG_DECIMAL >- .getName()); >- } else if ("java.math.BigInteger".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBIG_INTEGER >- .getName()); >- } else if ("boolean".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBOOLEAN.getName()); >- } else if ("java.lang.Boolean".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBOOLEAN_OBJECT >- .getName()); >- } else if ("byte".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBYTE.getName()); >- } else if ("byte[]".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBYTE_ARRAY.getName()); >- } else if ("java.lang.Byte".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EBYTE_OBJECT >- .getName()); >- } else if ("double".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EDOUBLE.getName()); >- } else if ("java.lang.Double".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EDOUBLE_OBJECT >- .getName()); >- } else if ("java.util.List".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EE_LIST.getName()); >- } else if ("float".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EFLOAT.getName()); >- } else if ("java.lang.Float".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EFLOAT_OBJECT >- .getName()); >- } else if ("int".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EINT.getName()); >- } else if ("java.lang.Integer".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EINTEGER_OBJECT >- .getName()); >- } else if ("java.lang.Object".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.EJAVA_OBJECT >- .getName()); >- } else if ("long".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.ELONG.getName()); >- } else if ("java.lang.Long".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.ELONG_OBJECT >- .getName()); >- } else if ("short".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.ESHORT.getName()); >- } else if ("java.lang.Short".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.ESHORT_OBJECT >- .getName()); >- } else if ("java.lang.String".equals(instanceClassName)) { //$NON-NLS-1$ >- type = getEcorePrimitiveType(eModelElement, >- EcorePackage.Literals.ESTRING.getName()); >- } >+ type = getXMLPrimitiveType(eModelElement, name); > } else if (EcorePackage.eNS_URI.equals(nsURI)) { > type = getEcorePrimitiveType(eModelElement, name); > } >@@ -5162,8 +5158,10 @@ > > if (ePackage != null) { > Classifier classifier = eClass.isInterface() >- ? (Classifier) UMLFactory.eINSTANCE.createInterface() >- : (Classifier) UMLFactory.eINSTANCE.createClass(); >+ ? UMLFactory.eINSTANCE.createInterface() >+ : (ExtendedMetaData.INSTANCE.getSimpleFeature(eClass) == null >+ ? UMLFactory.eINSTANCE.createClass() >+ : UMLFactory.eINSTANCE.createDataType()); > eModelElementToElementMap.put(eClass, classifier); > > org.eclipse.uml2.uml.Package package_ = (org.eclipse.uml2.uml.Package) doSwitch(ePackage); >@@ -5222,6 +5220,17 @@ > > primitiveType.setName(eDataType.getName()); > >+ EDataType baseType = ExtendedMetaData.INSTANCE >+ .getBaseType(eDataType); >+ >+ if (baseType != null) { >+ Classifier generalClassifier = (Classifier) doSwitch(baseType); >+ >+ if (!primitiveType.allParents().contains(generalClassifier)) { >+ primitiveType.createGeneralization(generalClassifier); >+ } >+ } >+ > defaultCase(eDataType); > > return primitiveType; >Index: src/org/eclipse/uml2/uml/resource/UMLResource.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/UMLResource.java,v >retrieving revision 1.5 >diff -u -r1.5 UMLResource.java >--- src/org/eclipse/uml2/uml/resource/UMLResource.java 26 Apr 2006 15:48:53 -0000 1.5 >+++ src/org/eclipse/uml2/uml/resource/UMLResource.java 29 Nov 2006 18:33:08 -0000 >@@ -66,6 +66,8 @@ > > String ECORE_PRIMITIVE_TYPES_LIBRARY_URI = LIBRARIES_PATHMAP + "EcorePrimitiveTypes." + LIBRARY_FILE_EXTENSION; //$NON-NLS-1$ > >+ String XML_PRIMITIVE_TYPES_LIBRARY_URI = LIBRARIES_PATHMAP + "XMLPrimitiveTypes." + LIBRARY_FILE_EXTENSION; //$NON-NLS-1$ >+ > String JAVA_PRIMITIVE_TYPES_LIBRARY_URI = LIBRARIES_PATHMAP + "JavaPrimitiveTypes." + LIBRARY_FILE_EXTENSION; //$NON-NLS-1$ > > String UML_PRIMITIVE_TYPES_LIBRARY_URI = LIBRARIES_PATHMAP + "UMLPrimitiveTypes." + LIBRARY_FILE_EXTENSION; //$NON-NLS-1$ >#P org.eclipse.uml2.uml.editor >Index: src/org/eclipse/uml2/uml/editor/actions/ImportPrimitiveTypeAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/actions/ImportPrimitiveTypeAction.java,v >retrieving revision 1.2 >diff -u -r1.2 ImportPrimitiveTypeAction.java >--- src/org/eclipse/uml2/uml/editor/actions/ImportPrimitiveTypeAction.java 10 Oct 2006 20:40:49 -0000 1.2 >+++ src/org/eclipse/uml2/uml/editor/actions/ImportPrimitiveTypeAction.java 29 Nov 2006 18:33:09 -0000 >@@ -12,157 +12,37 @@ > */ > package org.eclipse.uml2.uml.editor.actions; > >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Collections; > import java.util.Iterator; > import java.util.List; > >-import org.eclipse.emf.common.command.Command; >-import org.eclipse.emf.common.command.IdentityCommand; >-import org.eclipse.emf.common.command.UnexecutableCommand; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.edit.domain.EditingDomain; >-import org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.uml2.common.edit.command.ChangeCommand; >+import org.eclipse.uml2.uml.Package; > import org.eclipse.uml2.uml.PrimitiveType; >-import org.eclipse.uml2.uml.UMLPackage; >-import org.eclipse.uml2.uml.VisibilityKind; > import org.eclipse.uml2.uml.editor.UMLEditorPlugin; >-import org.eclipse.uml2.uml.resource.UMLResource; > > public class ImportPrimitiveTypeAction >- extends UMLCommandAction { >+ extends ImportTypeAction { > > public ImportPrimitiveTypeAction() { > super(); > } > >- protected Command createActionCommand(EditingDomain editingDomain, >- Collection collection) { >+ protected List getChoiceOfValues(Package package_) { >+ List choiceOfValues = super.getChoiceOfValues(package_); > >- if (collection.size() == 1 >- && collection.iterator().next() instanceof org.eclipse.uml2.uml.Package) { >+ for (Iterator cov = choiceOfValues.iterator(); cov.hasNext();) { >+ Object type = cov.next(); > >- return IdentityCommand.INSTANCE; >+ if (!(type instanceof PrimitiveType)) { >+ cov.remove(); >+ } > } > >- return UnexecutableCommand.INSTANCE; >+ return choiceOfValues; > } > >- public void run(IAction action) { >- >- if (command != UnexecutableCommand.INSTANCE) { >- final org.eclipse.uml2.uml.Package package_ = (org.eclipse.uml2.uml.Package) collection >- .iterator().next(); >- >- List choiceOfValues = new ArrayList(); >- >- Resource eResource = package_.eResource(); >- ResourceSet resourceSet = eResource == null >- ? null >- : eResource.getResourceSet(); >- >- if (resourceSet != null) { >- >- try { >- Resource resource = resourceSet >- .getResource( >- URI >- .createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), >- true); >- >- for (Iterator contents = resource.getAllContents(); contents >- .hasNext();) { >- >- Object object = contents.next(); >- >- if (object instanceof PrimitiveType >- && !package_.getImportedElements().contains(object)) { >- >- choiceOfValues.add(object); >- } >- } >- } catch (Exception e) { >- // ignore >- } >- >- try { >- Resource resource = resourceSet >- .getResource( >- URI >- .createURI(UMLResource.JAVA_PRIMITIVE_TYPES_LIBRARY_URI), >- true); >- >- for (Iterator contents = resource.getAllContents(); contents >- .hasNext();) { >- >- Object object = contents.next(); >- >- if (object instanceof PrimitiveType >- && !package_.getImportedElements().contains(object)) { >- >- choiceOfValues.add(object); >- } >- } >- } catch (Exception e) { >- // ignore >- } >- >- try { >- Resource resource = resourceSet >- .getResource( >- URI >- .createURI(UMLResource.ECORE_PRIMITIVE_TYPES_LIBRARY_URI), >- true); >- >- for (Iterator contents = resource.getAllContents(); contents >- .hasNext();) { >- >- Object object = contents.next(); >- >- if (object instanceof PrimitiveType >- && !package_.getImportedElements().contains(object)) { >- >- choiceOfValues.add(object); >- } >- } >- } catch (Exception e) { >- // ignore >- } >- } >- >- Collections.sort(choiceOfValues, new TextComparator()); >- >- String label = UMLEditorPlugin.INSTANCE >- .getString("_UI_ImportPrimitiveTypeActionCommand_label"); //$NON-NLS-1$ >- >- final FeatureEditorDialog dialog = new FeatureEditorDialog( >- workbenchPart.getSite().getShell(), getLabelProvider(), >- package_, UMLPackage.Literals.PACKAGEABLE_ELEMENT, >- Collections.EMPTY_LIST, label, choiceOfValues); >- dialog.open(); >- >- if (dialog.getReturnCode() == FeatureEditorDialog.OK) { >- editingDomain.getCommandStack().execute( >- new ChangeCommand(editingDomain, new Runnable() { >- >- public void run() { >- >- for (Iterator primitiveTypes = dialog.getResult() >- .iterator(); primitiveTypes.hasNext();) { >- >- package_.createElementImport( >- (PrimitiveType) primitiveTypes.next(), >- VisibilityKind.PUBLIC_LITERAL); >- } >- } >- }, label)); >- } >- } >+ protected String getActionCommandLabel() { >+ return UMLEditorPlugin.INSTANCE >+ .getString("_UI_ImportPrimitiveTypeActionCommand_label"); //$NON-NLS-1$ > } > > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml.editor/plugin.xml,v >retrieving revision 1.8 >diff -u -r1.8 plugin.xml >--- plugin.xml 2 May 2006 21:42:26 -0000 1.8 >+++ plugin.xml 29 Nov 2006 18:33:09 -0000 >@@ -142,11 +142,11 @@ > </enablement> > </action> > <action >- label="%_UI_ImportPrimitiveTypeAction_label" >- class="org.eclipse.uml2.uml.editor.actions.ImportPrimitiveTypeAction" >+ label="%_UI_ImportTypeAction_label" >+ class="org.eclipse.uml2.uml.editor.actions.ImportTypeAction" > menubarPath="org.eclipse.uml2.umlMenuID/org.eclipse.uml2.uml.editor.PackageMenuID/additions" > enablesFor="1" >- id="org.eclipse.uml2.uml.editor.ImportPrimitiveTypeActionID"> >+ id="org.eclipse.uml2.uml.editor.ImportTypeActionID"> > <enablement> > <objectClass > name="org.eclipse.uml2.uml.Package"> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml.editor/plugin.properties,v >retrieving revision 1.9 >diff -u -r1.9 plugin.properties >--- plugin.properties 10 Jun 2006 20:29:51 -0000 1.9 >+++ plugin.properties 29 Nov 2006 18:33:09 -0000 >@@ -136,3 +136,6 @@ > # %%% END OF TRANSLATED PROPERTIES %%% > # The above properties have been shipped for translation. > # ==================================================================== >+ >+_UI_ImportTypeAction_label = &Import Type... >+_UI_ImportTypeActionCommand_label = Import Type(s) >Index: src/org/eclipse/uml2/uml/editor/actions/ImportTypeAction.java >=================================================================== >RCS file: src/org/eclipse/uml2/uml/editor/actions/ImportTypeAction.java >diff -N src/org/eclipse/uml2/uml/editor/actions/ImportTypeAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/uml/editor/actions/ImportTypeAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - initial API and implementation >+ * >+ * $Id$ >+ */ >+package org.eclipse.uml2.uml.editor.actions; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.common.command.IdentityCommand; >+import org.eclipse.emf.common.command.UnexecutableCommand; >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.edit.domain.EditingDomain; >+import org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.uml2.common.edit.command.ChangeCommand; >+import org.eclipse.uml2.uml.PrimitiveType; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.UMLPackage; >+import org.eclipse.uml2.uml.VisibilityKind; >+import org.eclipse.uml2.uml.editor.UMLEditorPlugin; >+import org.eclipse.uml2.uml.resource.UMLResource; >+ >+public class ImportTypeAction >+ extends UMLCommandAction { >+ >+ public ImportTypeAction() { >+ super(); >+ } >+ >+ protected Command createActionCommand(EditingDomain editingDomain, >+ Collection collection) { >+ >+ if (collection.size() == 1 >+ && collection.iterator().next() instanceof org.eclipse.uml2.uml.Package) { >+ >+ return IdentityCommand.INSTANCE; >+ } >+ >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ protected List getChoiceOfValues(org.eclipse.uml2.uml.Package package_) { >+ List choiceOfValues = new ArrayList(); >+ >+ Resource eResource = package_.eResource(); >+ ResourceSet resourceSet = eResource == null >+ ? null >+ : eResource.getResourceSet(); >+ >+ if (resourceSet != null) { >+ >+ try { >+ Resource resource = resourceSet.getResource(URI >+ .createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), >+ true); >+ } catch (Exception e) { >+ // ignore >+ } >+ >+ try { >+ Resource resource = resourceSet.getResource(URI >+ .createURI(UMLResource.JAVA_PRIMITIVE_TYPES_LIBRARY_URI), >+ true); >+ } catch (Exception e) { >+ // ignore >+ } >+ >+ try { >+ Resource resource = resourceSet.getResource(URI >+ .createURI(UMLResource.ECORE_PRIMITIVE_TYPES_LIBRARY_URI), >+ true); >+ } catch (Exception e) { >+ // ignore >+ } >+ >+ try { >+ Resource resource = resourceSet.getResource(URI >+ .createURI(UMLResource.XML_PRIMITIVE_TYPES_LIBRARY_URI), >+ true); >+ } catch (Exception e) { >+ // ignore >+ } >+ } >+ >+ if (eResource != null) { >+ EList members = package_.getMembers(); >+ Iterator allContents = resourceSet == null >+ ? eResource.getAllContents() >+ : resourceSet.getAllContents(); >+ >+ while (allContents.hasNext()) { >+ Object object = allContents.next(); >+ >+ if (object instanceof Type && !members.contains(object)) { >+ choiceOfValues.add(object); >+ } >+ } >+ } >+ >+ Collections.sort(choiceOfValues, new TextComparator()); >+ >+ return choiceOfValues; >+ } >+ >+ protected String getActionCommandLabel() { >+ return UMLEditorPlugin.INSTANCE >+ .getString("_UI_ImportTypeActionCommand_label"); //$NON-NLS-1$ >+ } >+ >+ public void run(IAction action) { >+ >+ if (command != UnexecutableCommand.INSTANCE) { >+ final org.eclipse.uml2.uml.Package package_ = (org.eclipse.uml2.uml.Package) collection >+ .iterator().next(); >+ String label = getActionCommandLabel(); >+ >+ final FeatureEditorDialog dialog = new FeatureEditorDialog( >+ workbenchPart.getSite().getShell(), getLabelProvider(), >+ package_, UMLPackage.Literals.PACKAGEABLE_ELEMENT, >+ Collections.EMPTY_LIST, label, getChoiceOfValues(package_)); >+ dialog.open(); >+ >+ if (dialog.getReturnCode() == FeatureEditorDialog.OK) { >+ editingDomain.getCommandStack().execute( >+ new ChangeCommand(editingDomain, new Runnable() { >+ >+ public void run() { >+ >+ for (Iterator primitiveTypes = dialog.getResult() >+ .iterator(); primitiveTypes.hasNext();) { >+ >+ package_.createElementImport( >+ (PrimitiveType) primitiveTypes.next(), >+ VisibilityKind.PUBLIC_LITERAL); >+ } >+ } >+ }, label)); >+ } >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 150154
:
54660
|
54661
|
54662
|
54663
| 54732 |
54749