[560597] Fix PackageImpl javajet template After the regen for bugzilla 559231, some regression have been detected by org.eclipse.gmf.tests.runtime.diagram.ui.ConnectorTests. After analysis, it seems that the line EPackage.Registry.INSTANCE.put(eNS_URI, theNotationPackage); from NotationPackageImpl.init() has been removed during the regen. It's normal because this line does not exist in the override of the template for this class (/org.eclipse.gmf.runtime.notation/templates/model/PackageClass.javajet). This line has been manually added in commit [1] ([275209] gmf_head aboyko 090505 [Tests] Runtime tests fail for M7). But the corresonding javajet has not been changed in the same time. This commit only added this line in javajet. A full update of the template according to EMF master branch would be better. [1] https://git.eclipse.org/c/gmf-notation/org.eclipse.gmf.notation.git/commit/?id=155272a4812a216a7c7db3d62011971a20114b55 Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=560597 Change-Id: I1396bc81648dab93a802fd23abe52e6863da8b77 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr> Also-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
diff --git a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NotationPackageImpl.java b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NotationPackageImpl.java index c6a96b8..852edd4 100644 --- a/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NotationPackageImpl.java +++ b/org.eclipse.gmf.runtime.notation/src/org/eclipse/gmf/runtime/notation/impl/NotationPackageImpl.java
@@ -780,9 +780,10 @@ return (NotationPackage) EPackage.Registry.INSTANCE.getEPackage(NotationPackage.eNS_URI); // Obtain or create and register package - NotationPackageImpl theNotationPackage = (NotationPackageImpl) (EPackage.Registry.INSTANCE - .getEPackage(eNS_URI) instanceof NotationPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) - : new NotationPackageImpl()); + Object registeredNotationPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + NotationPackageImpl theNotationPackage = registeredNotationPackage instanceof NotationPackageImpl + ? (NotationPackageImpl) registeredNotationPackage + : new NotationPackageImpl(); isInited = true; @@ -798,6 +799,8 @@ // Mark meta-data to indicate it can't be changed theNotationPackage.freeze(); + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(NotationPackage.eNS_URI, theNotationPackage); return theNotationPackage; }
diff --git a/org.eclipse.gmf.runtime.notation/templates/model/PackageClass.javajet b/org.eclipse.gmf.runtime.notation/templates/model/PackageClass.javajet index a68f172..6b76845 100644 --- a/org.eclipse.gmf.runtime.notation/templates/model/PackageClass.javajet +++ b/org.eclipse.gmf.runtime.notation/templates/model/PackageClass.javajet
@@ -253,7 +253,11 @@ if (isInited) return (<%=genPackage.getImportedPackageInterfaceName()%>)<%=genModel.getImportedName("org.eclipse.emf.ecore.EPackage")%>.Registry.INSTANCE.getEPackage(<%=genPackage.getImportedPackageInterfaceName()%>.eNS_URI); // Obtain or create and register package - <%=genPackage.getPackageClassName()%> the<%=genPackage.getPackageInterfaceName()%> = (<%=genPackage.getPackageClassName()%>)(<%=genModel.getImportedName("org.eclipse.emf.ecore.EPackage")%>.Registry.INSTANCE.getEPackage(eNS_URI) instanceof <%=genPackage.getPackageClassName()%> ? <%=genModel.getImportedName("org.eclipse.emf.ecore.EPackage")%>.Registry.INSTANCE.getEPackage(eNS_URI) : new <%=genPackage.getPackageClassName()%>()); + Object registered<%=genPackage.getBasicPackageName()%> = <%=genModel.getImportedName("org.eclipse.emf.ecore.EPackage")%>.Registry.INSTANCE.get(eNS_URI); + <%=genPackage.getPackageClassName()%> the<%=genPackage.getBasicPackageName()%> = registered<%=genPackage.getBasicPackageName()%> instanceof <%=genPackage.getPackageClassName()%> ? (<%=genPackage.getPackageClassName()%>)registered<%=genPackage.getBasicPackageName()%> : new <%=genPackage.getPackageClassName()%>(); + + + isInited = true; @@ -329,6 +333,8 @@ the<%=genPackage.getPackageInterfaceName()%>.freeze(); <%}%> + // Update the registry and return the package + <%=genModel.getImportedName("org.eclipse.emf.ecore.EPackage")%>.Registry.INSTANCE.put(<%=genPackage.getImportedPackageInterfaceName()%>.eNS_URI, the<%=genPackage.getPackageInterfaceName()%>); return the<%=genPackage.getPackageInterfaceName()%>; }