Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2007-07-16 15:33:45 +0000
committerkmoore2007-07-16 15:33:45 +0000
commit61b3587da4435022863f51891b9c5d03fe06d8cb (patch)
treedde0080b354ef3fb36f83a70510246d8d53cde93
parent41c6ef08d52cb37664894f8840f5e9a9dbd237d5 (diff)
downloadwebtools.dali-61b3587da4435022863f51891b9c5d03fe06d8cb.tar.gz
webtools.dali-61b3587da4435022863f51891b9c5d03fe06d8cb.tar.xz
webtools.dali-61b3587da4435022863f51891b9c5d03fe06d8cb.zip
194807 - applied patch - Need a way to add persistence.xml editing in the JPA Details and Structure View for extenders
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/Persistence.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java12
7 files changed, 43 insertions, 10 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore b/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore
index b26c36781e..2cc54004f3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore
+++ b/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore
@@ -7,7 +7,7 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="persistence" eType="#//Persistence"
eOpposite="#//Persistence/root"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="Persistence" eSuperTypes="core.ecore#//XmlEObject">
+ <eClassifiers xsi:type="ecore:EClass" name="Persistence" eSuperTypes="core.ecore#//XmlEObject core.ecore#//IJpaContentNode">
<eStructuralFeatures xsi:type="ecore:EReference" name="persistenceUnits" upperBound="-1"
eType="#//PersistenceUnit" containment="true" resolveProxies="false"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="version" unique="false"
@@ -16,7 +16,7 @@
lowerBound="1" eType="#//PersistenceXmlRootContentNode" resolveProxies="false"
eOpposite="#//PersistenceXmlRootContentNode/persistence"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="PersistenceUnit" eSuperTypes="core.ecore#//XmlEObject">
+ <eClassifiers xsi:type="ecore:EClass" name="PersistenceUnit" eSuperTypes="core.ecore#//XmlEObject core.ecore#//IJpaContentNode">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" unique="false"
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="provider" unique="false"
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/Persistence.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/Persistence.java
index da6e45768c..f78bb27b36 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/Persistence.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/Persistence.java
@@ -9,6 +9,7 @@
package org.eclipse.jpt.core.internal.content.persistence;
import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
@@ -17,9 +18,11 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.jpt.core.internal.IJpaContentNode;
import org.eclipse.jpt.core.internal.IJpaFile;
import org.eclipse.jpt.core.internal.IJpaProject;
import org.eclipse.jpt.core.internal.XmlEObject;
+import org.eclipse.jpt.core.internal.content.persistence.resource.IPersistenceXmlContentNodes;
/**
* <!-- begin-user-doc -->
@@ -39,7 +42,7 @@ import org.eclipse.jpt.core.internal.XmlEObject;
* @model kind="class"
* @generated
*/
-public class Persistence extends XmlEObject
+public class Persistence extends XmlEObject implements IJpaContentNode
{
/**
* The cached value of the '{@link #getPersistenceUnits() <em>Persistence Units</em>}' containment reference list.
@@ -345,4 +348,18 @@ public class Persistence extends XmlEObject
IJpaFile file = getJpaFile();
return (file == null) ? null : file.getJpaProject();
}
+
+ public IJpaContentNode getContentNode(int offset) {
+ for (Iterator<PersistenceUnit> i = getPersistenceUnits().iterator(); i.hasNext();) {
+ PersistenceUnit persistenceUnit = i.next();
+ if (persistenceUnit.getNode().contains(offset)) {
+ return persistenceUnit;
+ }
+ }
+ return this;
+ }
+
+ public Object getId() {
+ return IPersistenceXmlContentNodes.PERSISTENCEXML_ROOT_ID;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java
index 92f9870d35..6c9dea2b53 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java
@@ -1056,7 +1056,9 @@ public class PersistencePackage extends EPackageImpl
persistenceXmlRootContentNodeEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject());
persistenceXmlRootContentNodeEClass.getESuperTypes().add(theJpaCorePackage.getIJpaRootContentNode());
persistenceEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject());
+ persistenceEClass.getESuperTypes().add(theJpaCorePackage.getIJpaContentNode());
persistenceUnitEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject());
+ persistenceUnitEClass.getESuperTypes().add(theJpaCorePackage.getIJpaContentNode());
mappingFileRefEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject());
javaClassRefEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject());
propertiesEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject());
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java
index b0e2df65b8..e4bb36c638 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java
@@ -18,7 +18,9 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EDataTypeEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.jpt.core.internal.IJpaContentNode;
import org.eclipse.jpt.core.internal.XmlEObject;
+import org.eclipse.jpt.core.internal.content.persistence.resource.IPersistenceXmlContentNodes;
/**
* <!-- begin-user-doc -->
@@ -46,7 +48,7 @@ import org.eclipse.jpt.core.internal.XmlEObject;
* @model kind="class"
* @generated
*/
-public class PersistenceUnit extends XmlEObject
+public class PersistenceUnit extends XmlEObject implements IJpaContentNode
{
/**
* The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
@@ -874,4 +876,8 @@ public class PersistenceUnit extends XmlEObject
result.append(')');
return result.toString();
}
+
+ public Object getId() {
+ return IPersistenceXmlContentNodes.PERSISTENCE_UNIT_ID;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java
index 77bd8ad516..f19b7294a3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java
@@ -346,8 +346,10 @@ public class PersistenceXmlRootContentNode extends XmlEObject
}
public IJpaContentNode getContentNode(int offset) {
- // TODO Auto-generated method stub
- return null;
+ if (getPersistence() == null || !getPersistence().getNode().contains(offset)) {
+ return this;
+ }
+ return getPersistence().getContentNode(offset);
}
public Object getId() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java
index 699518b3bb..3c389ad3e0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java
@@ -14,4 +14,6 @@ public interface IPersistenceXmlContentNodes
{
String PERSISTENCEXML_ROOT_ID = JptCorePlugin.PLUGIN_ID + ".persistencexml.Root";
+ String PERSISTENCE_UNIT_ID = JptCorePlugin.PLUGIN_ID + ".persistencexml.PersistenceUnit";
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java
index 0d2cb561a1..d115ee55dd 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java
@@ -127,14 +127,16 @@ public class PersistenceSwitch<T>
if (result == null)
result = caseXmlEObject(persistence);
if (result == null)
+ result = caseIJpaContentNode(persistence);
+ if (result == null)
result = caseJpaEObject(persistence);
if (result == null)
result = caseIXmlEObject(persistence);
if (result == null)
- result = caseIJpaEObject(persistence);
- if (result == null)
result = caseIJpaSourceObject(persistence);
if (result == null)
+ result = caseIJpaEObject(persistence);
+ if (result == null)
result = defaultCase(theEObject);
return result;
}
@@ -144,14 +146,16 @@ public class PersistenceSwitch<T>
if (result == null)
result = caseXmlEObject(persistenceUnit);
if (result == null)
+ result = caseIJpaContentNode(persistenceUnit);
+ if (result == null)
result = caseJpaEObject(persistenceUnit);
if (result == null)
result = caseIXmlEObject(persistenceUnit);
if (result == null)
- result = caseIJpaEObject(persistenceUnit);
- if (result == null)
result = caseIJpaSourceObject(persistenceUnit);
if (result == null)
+ result = caseIJpaEObject(persistenceUnit);
+ if (result == null)
result = defaultCase(theEObject);
return result;
}

Back to the top