Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2008-12-09 17:19:56 +0000
committerpfullbright2008-12-09 17:19:56 +0000
commitef39799e9c4dc6a0572eea61e5c242332cf1dc8b (patch)
treec986d3f3502266a6354f346709a8f33b25cc0918
parentd0571d5bd5482dd6e6a2fd1d5f766e7957aa83e8 (diff)
downloadwebtools.dali-ef39799e9c4dc6a0572eea61e5c242332cf1dc8b.tar.gz
webtools.dali-ef39799e9c4dc6a0572eea61e5c242332cf1dc8b.tar.xz
webtools.dali-ef39799e9c4dc6a0572eea61e5c242332cf1dc8b.zip
[257989] - changed adapting from IResource to IResourcePart
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/plugin.xml6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/IResourcePart.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaNode.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ResourcePartAdapterFactory.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java3
6 files changed, 71 insertions, 12 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
index 6b1c46922b..ffa1828bff 100644
--- a/jpa/plugins/org.eclipse.jpt.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
@@ -65,6 +65,12 @@
<adapter type="org.eclipse.jpt.core.JpaProject"/>
</factory>
+ <factory
+ class="org.eclipse.jpt.core.internal.ResourcePartAdapterFactory"
+ adaptableType="org.eclipse.core.resources.IResource">
+ <adapter type="org.eclipse.jpt.core.IResourcePart"/>
+ </factory>
+
</extension>
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/IResourcePart.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/IResourcePart.java
new file mode 100644
index 0000000000..c27da6860d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/IResourcePart.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.core;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Represents an object that can be described as being part of an {@link IResource}
+ */
+public interface IResourcePart
+{
+ /**
+ * Return the resource of which this object is a part
+ */
+ IResource getResource();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaNode.java
index 1122f07f91..b85d89c3cf 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaNode.java
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.core;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jpt.utility.model.Model;
@@ -24,7 +23,7 @@ import org.eclipse.jpt.utility.model.Model;
* will almost certainly be broken (repeatedly) as the API evolves.
*/
public interface JpaNode
- extends Model, IAdaptable
+ extends Model, IAdaptable, IResourcePart
{
/**
* Return the JPA project the node belongs to.
@@ -32,12 +31,6 @@ public interface JpaNode
JpaProject getJpaProject();
/**
- * Return the resource that most directly contains the node.
- * This is used by JpaHelper.
- */
- IResource getResource();
-
- /**
* Return the JPA node's parent. The JPA project will not have a parent.
*/
JpaNode getParent();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java
index 2d0a331135..f5f31e8d77 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java
@@ -78,9 +78,6 @@ public abstract class AbstractJpaNode
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
- if (adapter == IResource.class) {
- return getResource();
- }
return Platform.getAdapterManager().getAdapter(this, adapter);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ResourcePartAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ResourcePartAdapterFactory.java
new file mode 100644
index 0000000000..a7b9c38b01
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ResourcePartAdapterFactory.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.core.internal;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jpt.core.IResourcePart;
+
+public class ResourcePartAdapterFactory implements IAdapterFactory
+{
+ private static Class[] PROPERTIES= new Class[] {
+ IResourcePart.class
+ };
+
+ public Class[] getAdapterList() {
+ return PROPERTIES;
+ }
+
+ public Object getAdapter(final Object adaptableObject, Class adapterType) {
+ if (adapterType == IResourcePart.class) {
+ // assume adaptableObject is an instance of IResource - see extension
+ return new IResourcePart() {
+ public IResource getResource() {
+ return (IResource) adaptableObject;
+ }
+ };
+ }
+ return null;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
index 308b38030f..43b3958305 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
@@ -16,6 +16,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jpt.core.IResourcePart;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
@@ -108,7 +109,7 @@ public class JpaValidator extends AbstractValidator implements IValidator {
private IMessage adjustMessage(IMessage message) {
IAdaptable targetObject = (IAdaptable) message.getTargetObject();
- IResource targetResource = (IResource) targetObject.getAdapter(IResource.class);
+ IResource targetResource = ((IResourcePart) targetObject.getAdapter(IResourcePart.class)).getResource();
message.setTargetObject(targetResource);
if (message.getLineNumber() == IMessage.LINENO_UNSET) {
message.setAttribute(IMarker.LOCATION, " ");

Back to the top