Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2017-06-29 14:50:33 +0000
committerAnsgar Radermacher2017-07-19 11:25:15 +0000
commit562963bdf71f032121d0c6f9528fd25975c4e081 (patch)
tree58c1bf989600256e1f3ba21ccd1fe8ecf720af18 /plugins/developer/org.eclipse.papyrus.dev.types
parent53718e4ee3ad425a38fe9a256cf5690c416cca3f (diff)
downloadorg.eclipse.papyrus-562963bdf71f032121d0c6f9528fd25975c4e081.tar.gz
org.eclipse.papyrus-562963bdf71f032121d0c6f9528fd25975c4e081.tar.xz
org.eclipse.papyrus-562963bdf71f032121d0c6f9528fd25975c4e081.zip
Bug 518761 - [ElementTypes] Migration tool does handle references defined in other models (elementTypeId must be defined in local file)
- Try to get element type from registry, if not found locally. This requires that referenced element types must have been already registered. Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.dev.types')
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/handlers/MigrateSpecializations.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/handlers/MigrateSpecializations.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/handlers/MigrateSpecializations.java
index 9ebedb73a51..258976c9bc3 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/handlers/MigrateSpecializations.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/handlers/MigrateSpecializations.java
@@ -41,8 +41,13 @@ import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.dev.types.Activator;
+import org.eclipse.papyrus.infra.types.ElementTypeConfiguration;
+import org.eclipse.papyrus.infra.types.core.IConfiguredHintedElementType;
import org.eclipse.ui.handlers.HandlerUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -165,7 +170,7 @@ public class MigrateSpecializations extends AbstractHandler {
Document doc = builder.parse(file);
Element root = doc.getDocumentElement();
- // Update namespaces
+ // update namespaces
root.setAttribute(ELEMENTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE, ELEMENTTYPECONFIGURATION_NAMESPACE_NEW);
NodeList elementTypeConfigurations = root.getElementsByTagName(ELEMENTTYPECONFIGURATIONS);
@@ -208,15 +213,25 @@ public class MigrateSpecializations extends AbstractHandler {
specializedTypes.setAttribute(HREF_ATTRIBUTE, mapSpecializationMigration.get(specialized));
elementTypeConfiguration.appendChild(specializedTypes);
} else {
- System.err.println("Couldn't find : " + specialized);
+ // handle case that the referenced element-type ID is not in this file, but defined
+ // in the registry
+ IElementType elementType = ElementTypeRegistry.getInstance().getType(specialized);
+ if (elementType instanceof IConfiguredHintedElementType) {
+ ElementTypeConfiguration etc = ((IConfiguredHintedElementType) elementType).getConfiguration();
+ if (etc != null) {
+ specializedTypes.setAttribute(TYPE_ATTRIBUTE, ELEMENTTYPESCONFIGURATIONS_SPECIALIZATIONTYPECONFIGURATION);
+ specializedTypes.setAttribute(HREF_ATTRIBUTE,
+ etc.eResource().getURI().toString() + "#" + etc.eResource().getURIFragment(etc)); //$NON-NLS-1$
+ elementTypeConfiguration.appendChild(specializedTypes);
+ }
+ }
+ else {
+ Activator.log.debug("Couldn't find : " + specialized); //$NON-NLS-1$
+ }
}
-
-
}
- // }
}
-
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
Result output = new StreamResult(file);
@@ -224,11 +239,9 @@ public class MigrateSpecializations extends AbstractHandler {
transformer.transform(input, output);
-
selectedFile.touch(new NullProgressMonitor());
-
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -255,12 +268,8 @@ public class MigrateSpecializations extends AbstractHandler {
}
}
-
return null;
}
-
-
-
}

Back to the top