Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenn Hussey2012-03-14 01:25:59 +0000
committerKenn Hussey2012-03-14 01:25:59 +0000
commit43d7204a03f464eba9bb6532554b4baae24be0d6 (patch)
treedf7b1178dc9323c4caf0f68f538ef44fd0f60bca /plugins
parent03fb56e21ee537f8fa55cb08be0a7d6b69ec4dad (diff)
downloadorg.eclipse.uml2.test-43d7204a03f464eba9bb6532554b4baae24be0d6.tar.gz
org.eclipse.uml2.test-43d7204a03f464eba9bb6532554b4baae24be0d6.tar.xz
org.eclipse.uml2.test-43d7204a03f464eba9bb6532554b4baae24be0d6.zip
[364419] Adding a utility to initialize resource sets for UML2 use.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/UMLImporter.java63
-rw-r--r--plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java61
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java84
3 files changed, 89 insertions, 119 deletions
diff --git a/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/UMLImporter.java b/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/UMLImporter.java
index 637af61c..1d0063ba 100644
--- a/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/UMLImporter.java
+++ b/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/UMLImporter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2011 IBM Corporation, Embarcadero Technologies, CEA, and others.
+ * Copyright (c) 2006, 2012 IBM Corporation, Embarcadero Technologies, CEA, 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM - initial API and implementation
* Kenn Hussey (Embarcadero Technologies) - 156879, 220552, 226102
- * Kenn Hussey (CEA) - 327039, 351774
+ * Kenn Hussey (CEA) - 327039, 351774, 364419
*
*/
package org.eclipse.uml2.uml.ecore.importer;
@@ -41,19 +41,9 @@ import org.eclipse.uml2.common.util.UML2Util;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.resource.CMOF202UMLResource;
-import org.eclipse.uml2.uml.resource.CMOF2UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.CMOF2UMLResource;
-import org.eclipse.uml2.uml.resource.UML212UMLExtendedMetaData;
-import org.eclipse.uml2.uml.resource.UML212UMLResource;
-import org.eclipse.uml2.uml.resource.UML22UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.UML22UMLResource;
-import org.eclipse.uml2.uml.resource.UML302UMLExtendedMetaData;
-import org.eclipse.uml2.uml.resource.UML302UMLResource;
import org.eclipse.uml2.uml.resource.UMLResource;
-import org.eclipse.uml2.uml.resource.XMI212UMLResource;
-import org.eclipse.uml2.uml.resource.XMI222UMLResource;
-import org.eclipse.uml2.uml.resource.XMI2UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.XMI2UMLResource;
import org.eclipse.uml2.uml.util.UMLUtil;
@@ -322,54 +312,7 @@ public class UMLImporter
@Override
public ResourceSet createResourceSet() {
- ResourceSet resourceSet = super.createResourceSet();
-
- Map<String, Object> contentTypeToFactoryMap = resourceSet
- .getResourceFactoryRegistry().getContentTypeToFactoryMap();
-
- contentTypeToFactoryMap.put(
- UML302UMLResource.UML_3_0_0_CONTENT_TYPE_IDENTIFIER,
- UML302UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- UML212UMLResource.UML_2_1_0_CONTENT_TYPE_IDENTIFIER,
- UML212UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- UML22UMLResource.UML2_CONTENT_TYPE_IDENTIFIER,
- UML22UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI2UMLResource.UML_CONTENT_TYPE_IDENTIFIER,
- XMI2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI2UMLResource.UML_2_4_CONTENT_TYPE_IDENTIFIER,
- XMI2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI222UMLResource.UML_2_2_CONTENT_TYPE_IDENTIFIER,
- XMI222UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI212UMLResource.UML_2_1_1_CONTENT_TYPE_IDENTIFIER,
- XMI212UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI212UMLResource.UML_2_1_CONTENT_TYPE_IDENTIFIER,
- XMI212UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- CMOF2UMLResource.CMOF_CONTENT_TYPE_IDENTIFIER,
- CMOF2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- CMOF2UMLResource.CMOF_2_4_CONTENT_TYPE_IDENTIFIER,
- CMOF2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- CMOF202UMLResource.CMOF_CONTENT_TYPE_IDENTIFIER,
- CMOF202UMLResource.Factory.INSTANCE);
-
- Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
-
- uriMap.putAll(UML302UMLExtendedMetaData.getURIMap());
- uriMap.putAll(UML212UMLExtendedMetaData.getURIMap());
- uriMap.putAll(UML22UMLExtendedMetaData.getURIMap());
- uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
- uriMap.putAll(CMOF2UMLExtendedMetaData.getURIMap());
-
- return resourceSet;
+ return UMLUtil.init(super.createResourceSet());
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java b/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java
index 2e2bcd8a..62da997d 100644
--- a/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java
+++ b/plugins/org.eclipse.uml2.uml.editor/src/org/eclipse/uml2/uml/editor/presentation/UMLEditor.java
@@ -9,7 +9,7 @@
* IBM - initial API and implementation
* Kenn Hussey (Embarcadero Technologies) - 204200, 215418, 156879, 227392, 226178, 232332, 247980
* Kenn Hussey - 286329, 323181
- * Kenn Hussey (CEA) - 327039, 351774
+ * Kenn Hussey (CEA) - 327039, 351774, 364419
*
*/
package org.eclipse.uml2.uml.editor.presentation;
@@ -186,20 +186,11 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.uml2.uml.editor.UMLEditorPlugin;
-import org.eclipse.uml2.uml.resource.CMOF202UMLResource;
-import org.eclipse.uml2.uml.resource.CMOF2UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.CMOF2UMLResource;
-import org.eclipse.uml2.uml.resource.UML212UMLExtendedMetaData;
-import org.eclipse.uml2.uml.resource.UML212UMLResource;
-import org.eclipse.uml2.uml.resource.UML22UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.UML22UMLResource;
-import org.eclipse.uml2.uml.resource.UML302UMLExtendedMetaData;
-import org.eclipse.uml2.uml.resource.UML302UMLResource;
import org.eclipse.uml2.uml.resource.UMLResource;
-import org.eclipse.uml2.uml.resource.XMI212UMLResource;
-import org.eclipse.uml2.uml.resource.XMI222UMLResource;
-import org.eclipse.uml2.uml.resource.XMI2UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.XMI2UMLResource;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
* This is an example of a UML model editor.
@@ -943,56 +934,12 @@ public class UMLEditor
}
public void createModel() {
- ResourceSet resourceSet = editingDomain.getResourceSet();
-
- Map<String, Object> contentTypeToFactoryMap = resourceSet
- .getResourceFactoryRegistry().getContentTypeToFactoryMap();
-
- contentTypeToFactoryMap.put(
- UML302UMLResource.UML_3_0_0_CONTENT_TYPE_IDENTIFIER,
- UML302UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- UML212UMLResource.UML_2_1_0_CONTENT_TYPE_IDENTIFIER,
- UML212UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- UML22UMLResource.UML2_CONTENT_TYPE_IDENTIFIER,
- UML22UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI2UMLResource.UML_CONTENT_TYPE_IDENTIFIER,
- XMI2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI2UMLResource.UML_2_4_CONTENT_TYPE_IDENTIFIER,
- XMI2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI222UMLResource.UML_2_2_CONTENT_TYPE_IDENTIFIER,
- XMI222UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI212UMLResource.UML_2_1_1_CONTENT_TYPE_IDENTIFIER,
- XMI212UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- XMI212UMLResource.UML_2_1_CONTENT_TYPE_IDENTIFIER,
- XMI212UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- CMOF2UMLResource.CMOF_CONTENT_TYPE_IDENTIFIER,
- CMOF2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- CMOF2UMLResource.CMOF_2_4_CONTENT_TYPE_IDENTIFIER,
- CMOF2UMLResource.Factory.INSTANCE);
- contentTypeToFactoryMap.put(
- CMOF202UMLResource.CMOF_2_0_CONTENT_TYPE_IDENTIFIER,
- CMOF202UMLResource.Factory.INSTANCE);
-
- Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
-
- uriMap.putAll(UML302UMLExtendedMetaData.getURIMap());
- uriMap.putAll(UML212UMLExtendedMetaData.getURIMap());
- uriMap.putAll(UML22UMLExtendedMetaData.getURIMap());
- uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
- uriMap.putAll(CMOF2UMLExtendedMetaData.getURIMap());
+ ResourceSet resourceSet = UMLUtil.init(editingDomain.getResourceSet());
createModelGen();
boolean saveNeeded = false;
+ Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
Map<Resource, URI> resourceToURIMap = new HashMap<Resource, URI>();
EList<Resource> resources = resourceSet.getResources();
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
index e6d8756d..5302b748 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011 IBM Corporation, Embarcadero Technologies, CEA, and others.
+ * Copyright (c) 2005, 2012 IBM Corporation, Embarcadero Technologies, CEA, 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
@@ -10,7 +10,7 @@
* Kenn Hussey (Embarcadero Technologies) - 199624, 184249, 204406, 208125, 204200, 213218, 213903, 220669, 208016, 226396, 271470
* Nicolas Rouquette (JPL) - 260120, 313837
* Kenn Hussey - 286329, 313601, 314971, 344907, 236184
- * Kenn Hussey (CEA) - 327039, 358792
+ * Kenn Hussey (CEA) - 327039, 358792, 364419
* Yann Tanguy (CEA) - 350402
*
*/
@@ -63,6 +63,7 @@ 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.URIConverter;
import org.eclipse.emf.ecore.util.EcoreSwitch;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
@@ -124,7 +125,20 @@ import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.ValueSpecification;
import org.eclipse.uml2.uml.VisibilityKind;
+import org.eclipse.uml2.uml.resource.CMOF202UMLResource;
+import org.eclipse.uml2.uml.resource.CMOF2UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.CMOF2UMLResource;
+import org.eclipse.uml2.uml.resource.UML212UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.UML212UMLResource;
+import org.eclipse.uml2.uml.resource.UML22UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.UML22UMLResource;
+import org.eclipse.uml2.uml.resource.UML302UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.UML302UMLResource;
import org.eclipse.uml2.uml.resource.UMLResource;
+import org.eclipse.uml2.uml.resource.XMI212UMLResource;
+import org.eclipse.uml2.uml.resource.XMI222UMLResource;
+import org.eclipse.uml2.uml.resource.XMI2UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.XMI2UMLResource;
/**
* Utilities for working with UML elements and resources.
@@ -10265,4 +10279,70 @@ public class UMLUtil
return packages;
}
+ /**
+ * Initializes the registries for the specified resource set (or the global
+ * registries if <code>null</code>) with the content type and extended
+ * metadata registrations needed to work with the various supported versions
+ * of UML, XMI, and CMOF.
+ *
+ * @param resourceSet
+ * The resource set whose registries to initialize, or
+ * <code>null</code>.
+ * @return The resource set (or <code>null</code>).
+ *
+ * @since 4.0
+ */
+ public static ResourceSet init(ResourceSet resourceSet) {
+ Map<String, Object> contentTypeToFactoryMap = (resourceSet == null
+ ? Resource.Factory.Registry.INSTANCE
+ : resourceSet.getResourceFactoryRegistry())
+ .getContentTypeToFactoryMap();
+
+ contentTypeToFactoryMap.put(
+ UML302UMLResource.UML_3_0_0_CONTENT_TYPE_IDENTIFIER,
+ UML302UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ UML212UMLResource.UML_2_1_0_CONTENT_TYPE_IDENTIFIER,
+ UML212UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ UML22UMLResource.UML2_CONTENT_TYPE_IDENTIFIER,
+ UML22UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ XMI2UMLResource.UML_CONTENT_TYPE_IDENTIFIER,
+ XMI2UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ XMI2UMLResource.UML_2_4_CONTENT_TYPE_IDENTIFIER,
+ XMI2UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ XMI222UMLResource.UML_2_2_CONTENT_TYPE_IDENTIFIER,
+ XMI222UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ XMI212UMLResource.UML_2_1_1_CONTENT_TYPE_IDENTIFIER,
+ XMI212UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ XMI212UMLResource.UML_2_1_CONTENT_TYPE_IDENTIFIER,
+ XMI212UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ CMOF2UMLResource.CMOF_CONTENT_TYPE_IDENTIFIER,
+ CMOF2UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ CMOF2UMLResource.CMOF_2_4_CONTENT_TYPE_IDENTIFIER,
+ CMOF2UMLResource.Factory.INSTANCE);
+ contentTypeToFactoryMap.put(
+ CMOF202UMLResource.CMOF_2_0_CONTENT_TYPE_IDENTIFIER,
+ CMOF202UMLResource.Factory.INSTANCE);
+
+ Map<URI, URI> uriMap = resourceSet == null
+ ? URIConverter.URI_MAP
+ : resourceSet.getURIConverter().getURIMap();
+
+ uriMap.putAll(UML302UMLExtendedMetaData.getURIMap());
+ uriMap.putAll(UML212UMLExtendedMetaData.getURIMap());
+ uriMap.putAll(UML22UMLExtendedMetaData.getURIMap());
+ uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
+ uriMap.putAll(CMOF2UMLExtendedMetaData.getURIMap());
+
+ return resourceSet;
+ }
+
}

Back to the top