summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2013-03-11 15:53:28 (EDT)
committerNeil Hauge2013-03-11 15:53:28 (EDT)
commitc1f0927c251167a6a9b6464840b68ce3e8c590a3 (patch)
treebacb53986de849da69d0f5aaaf8b393d5f177ea2
parent5878dc5a4950a75e60d2d920403b7a891d6cb388 (diff)
downloadwebtools.dali-c1f0927c251167a6a9b6464840b68ce3e8c590a3.zip
webtools.dali-c1f0927c251167a6a9b6464840b68ce3e8c590a3.tar.gz
webtools.dali-c1f0927c251167a6a9b6464840b68ce3e8c590a3.tar.bz2
397925 - fix NPE in New Dynamic Entity wizard when opening via Quick
Access with no selection.
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/jpt_jpa_eclipselink_ui.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/JptJpaEclipseLinkUiMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/entity/data/model/DynamicEntityDataModelProvider.java36
3 files changed, 28 insertions, 12 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/jpt_jpa_eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/jpt_jpa_eclipselink_ui.properties
index 97bfbbe..279b5a8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/jpt_jpa_eclipselink_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/jpt_jpa_eclipselink_ui.properties
@@ -416,7 +416,7 @@ ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_DYNAMIC_TYPE_WITH_DIFF_CASE_EXISTS_ERROR=Dynam
ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_INVALID_ARGUMENT=Invalid argument ''{0}''
ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_INVALID_PK_TYPE=''{0}'' is not a valid simple primary key type
ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_MULTIPLE_EMBEDDED_IDS_DEFINED_ERROR=Multiple Embedded ID mappings defined
-ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_PERSISTENCE_UNIT_NOT_FOUND_ERROR=No persistence unit is found
+ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_ECLIPSELINK_PROJECT_NOT_FOUND_ERROR=An EclipseLink JPA project must be selected
ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_TITLE=New Dynamic Entity
ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_TYPE_EXISTS_WARNING=Type ''{0}'' already exists
ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_TYPE_NOT_IN_PROJECT_CLASSPATH=Type ''{0}'' does not exist on the project classpath
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/JptJpaEclipseLinkUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/JptJpaEclipseLinkUiMessages.java
index 7f72e5c..dec6392 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/JptJpaEclipseLinkUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/JptJpaEclipseLinkUiMessages.java
@@ -425,7 +425,7 @@ public class JptJpaEclipseLinkUiMessages {
public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_INVALID_ARGUMENT;
public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_INVALID_PK_TYPE;
public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_MULTIPLE_EMBEDDED_IDS_DEFINED_ERROR;
- public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_PERSISTENCE_UNIT_NOT_FOUND_ERROR;
+ public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_ECLIPSELINK_PROJECT_NOT_FOUND_ERROR;
public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_TITLE;
public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_TYPE_EXISTS_WARNING;
public static String ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_TYPE_NOT_IN_PROJECT_CLASSPATH;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/entity/data/model/DynamicEntityDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/entity/data/model/DynamicEntityDataModelProvider.java
index 25790b7..19cb861 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/entity/data/model/DynamicEntityDataModelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/entity/data/model/DynamicEntityDataModelProvider.java
@@ -36,6 +36,7 @@ import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import org.eclipse.jpt.jpa.core.JpaPlatform;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.JpaContextModelRoot;
@@ -45,7 +46,9 @@ import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
+import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkJpaProject;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.ui.JptJpaEclipseLinkUiMessages;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.entity.data.operation.NewDynamicEntityClassOperation;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.plugin.JptJpaEclipseLinkUiPlugin;
@@ -585,7 +588,8 @@ public class DynamicEntityDataModelProvider extends NewJavaClassDataModelProvide
}
PersistenceUnit pu = this.getPersistenceUnit();
if (pu != null) {
- for (String name : ((EclipseLinkPersistenceUnit)this.getPersistenceUnit()).getEclipseLinkDynamicPersistentTypeNames()) {
+ // getJpaProject() returns an EclipseLink project to ensure safe cast here - bug 397926
+ for (String name : ((EclipseLinkPersistenceUnit) pu).getEclipseLinkDynamicPersistentTypeNames()) {
if (ObjectTools.equals(name, fullyQualifiedName)) {
return JptJpaEclipseLinkUiPlugin.instance().buildErrorStatus(JptJpaEclipseLinkUiMessages.ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_DYNAMIC_TYPE_EXISTS_ERROR, fullyQualifiedName);
@@ -594,7 +598,7 @@ public class DynamicEntityDataModelProvider extends NewJavaClassDataModelProvide
}
}
} else {
- return JptJpaEclipseLinkUiPlugin.instance().buildErrorStatus(JptJpaEclipseLinkUiMessages.ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_PERSISTENCE_UNIT_NOT_FOUND_ERROR);
+ return JptJpaEclipseLinkUiPlugin.instance().buildErrorStatus(JptJpaEclipseLinkUiMessages.ECLIPSELINK_DYNAMIC_ENTITY_WIZARD_ECLIPSELINK_PROJECT_NOT_FOUND_ERROR);
}
return Status.OK_STATUS;
}
@@ -633,15 +637,24 @@ public class DynamicEntityDataModelProvider extends NewJavaClassDataModelProvide
// ****************** misc ***********************
- protected JpaProject getJpaProject() {
+ protected EclipseLinkJpaProject getJpaProject() {
IProject project = getTargetProject();
- return ((project != null) && ProjectTools.hasFacet(project, JpaProject.FACET)) ?
- this.getJpaProject(project) :
- null;
+ return (project != null) && isEclipseLinkProject(project) ? this.getJpaProject(project) : null;
}
- protected JpaProject getJpaProject(IProject project) {
- return (JpaProject) project.getAdapter(JpaProject.class);
+ protected boolean isEclipseLinkProject(IProject project) {
+ return this.getJpaPlatformConfig(project) == null ?
+ false:
+ ProjectTools.hasFacet(project, JpaProject.FACET) &&
+ this.getJpaPlatformConfig(project).getGroupConfig().getId().equals(EclipseLinkJpaPlatformFactory.GROUP_ID);
+ }
+
+ protected EclipseLinkJpaProject getJpaProject(IProject project) {
+ return (EclipseLinkJpaProject) project.getAdapter(JpaProject.class);
+ }
+
+ protected JpaPlatform.Config getJpaPlatformConfig(IProject project) {
+ return (JpaPlatform.Config) project.getAdapter(JpaPlatform.Config.class);
}
protected PersistenceUnit getPersistenceUnit() {
@@ -659,8 +672,11 @@ public class DynamicEntityDataModelProvider extends NewJavaClassDataModelProvide
}
protected PersistenceXml getPersistenceXml() {
- JpaContextModelRoot rcn = this.getJpaProject().getContextModelRoot();
- return (rcn == null) ? null : rcn.getPersistenceXml();
+ if (this.getJpaProject() != null) {
+ JpaContextModelRoot rcn = this.getJpaProject().getContextModelRoot();
+ return (rcn == null) ? null : rcn.getPersistenceXml();
+ }
+ return null;
}
protected OrmAttributeMappingDefinition getAttributeMappingDefinition(String mappingKey) {