Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2013-06-28 21:03:00 +0000
committerBrian Vosburgh2013-07-02 15:45:40 +0000
commit249e318f47bcd136caa55bf7b7fa751e3ebc5e21 (patch)
tree70044eb31da6670ba7ebf287709686afb9043885
parentcd53a9c9dd7daeed91eac4fd2eade772225b69d9 (diff)
downloadwebtools.dali-249e318f47bcd136caa55bf7b7fa751e3ebc5e21.tar.gz
webtools.dali-249e318f47bcd136caa55bf7b7fa751e3ebc5e21.tar.xz
webtools.dali-249e318f47bcd136caa55bf7b7fa751e3ebc5e21.zip
[411815] fix NPE in JavaElementAdapterFactory
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java
index 308b9e65d4..d3a2f5a265 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. 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.
@@ -9,8 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.platform;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jpt.jpa.core.JpaPlatform;
/**
@@ -36,11 +38,21 @@ public class JavaElementAdapterFactory
}
return null;
}
-
+
private Object getAdapter(IJavaElement javaElement, Class<?> adapterType) {
if (adapterType == JpaPlatform.Config.class) {
- return javaElement.getResource().getAdapter(JpaPlatform.Config.class);
+ return this.getJpaPlatformConfig(javaElement);
}
return null;
}
+
+ private Object getJpaPlatformConfig(IJavaElement javaElement) {
+ IJavaProject javaProject = javaElement.getJavaProject();
+ if (javaProject == null) {
+ return null; // IJavaModel does not have an IProject
+ }
+ IProject project = javaProject.getProject();
+ // not sure an IJavaProject can have no IProject...
+ return (project == null) ? null : project.getAdapter(JpaPlatform.Config.class);
+ }
}

Back to the top