Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authornhauge2012-03-07 04:47:21 +0000
committernhauge2012-03-07 04:47:21 +0000
commitc84bd607922f64fa790291fc34215bf55420d536 (patch)
treec5803be2a90423b35ba20ddab47fbaca31073903 /jpa
parent25df3942e038bfe6d6e7a29984331ffda0a399dc (diff)
downloadwebtools.dali-c84bd607922f64fa790291fc34215bf55420d536.tar.gz
webtools.dali-c84bd607922f64fa790291fc34215bf55420d536.tar.xz
webtools.dali-c84bd607922f64fa790291fc34215bf55420d536.zip
188940 - Content assist for XML Mapping Files. Patch from Nan.
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaXmlStructureNode.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/MappingFileRoot.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlContextNode.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java69
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlAttributeMapping.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlBaseColumn.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlMultiRelationshipMapping.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlNamedColumn.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTable.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAssociationOverride.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeMapping.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeOverride.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlBaseColumn.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGeneratedValue.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGenerator.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlJoinColumn.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlMappedByMapping.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedColumn.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOneToOne.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOverride.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPersistenceUnitDefaults.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPrimaryKeyJoinColumn.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlSequenceGenerator.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTableGenerator.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTypeMapping.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlUniqueConstraint.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java51
80 files changed, 1739 insertions, 80 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaXmlStructureNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaXmlStructureNode.java
new file mode 100644
index 0000000000..7fdd2b9e60
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaXmlStructureNode.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.jpa.core;
+
+
+/**
+ * Implement this interface for XML objects that appear in the Structure view
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.2
+ * @since 3.2
+ */
+
+public interface JpaXmlStructureNode extends JpaStructureNode {
+
+ /**
+ * Return the content assist proposals for the specified position
+ * in the XML file.
+ */
+ Iterable<String> getXmlCompletionProposals(int pos);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/MappingFileRoot.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/MappingFileRoot.java
index 2335a4bd82..6a4aa3ed59 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/MappingFileRoot.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/MappingFileRoot.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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,7 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.JpaXmlStructureNode;
import org.eclipse.jpt.jpa.core.context.persistence.PersistentTypeContainer;
/**
@@ -25,7 +25,7 @@ import org.eclipse.jpt.jpa.core.context.persistence.PersistentTypeContainer;
* @since 2.1
*/
public interface MappingFileRoot
- extends XmlContextNode, JpaStructureNode, PersistentTypeContainer
+ extends XmlContextNode, JpaXmlStructureNode, PersistentTypeContainer
{
/**
* covariant override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlContextNode.java
index 5ff9c36b37..0291d113ed 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlContextNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -31,6 +31,12 @@ public interface XmlContextNode
extends JpaContextNode
{
// TODO bjv rename to XmlJpaContextNode
+
+ /**
+ * Return the content assist proposals for the specified position
+ * in the XML file.
+ */
+ Iterable<String> getXmlCompletionProposals(int pos);
/**
* Add to the list of current validation messages
*/
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java
index 80a3fddecd..df47dbee8c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java
@@ -10,7 +10,7 @@
package org.eclipse.jpt.jpa.core.context.persistence;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.JpaXmlStructureNode;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
@@ -29,7 +29,7 @@ import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
* @since 2.0
*/
public interface Persistence
- extends XmlContextNode, JpaStructureNode
+ extends XmlContextNode, JpaXmlStructureNode
{
/**
* Return the resource model object associated with this context model object
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
index 7485e99b95..9aa7b6e82b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
@@ -21,6 +21,7 @@ import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.Embeddable;
import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.Generator;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper;
@@ -699,6 +700,15 @@ public interface PersistenceUnit
boolean specifiesPersistentType(String typeName);
/**
+ * Return the persistence unit's Java persistent types, as specified by
+ * the class refs (both specified and implied) and jar files.
+ * There can be duplicate types, and any of them may be overridden by a
+ * mapping file persistence type.
+ * @see #getMappingFilePersistentTypes()
+ */
+ Iterable<PersistentType> getJavaPersistentTypes();
+
+ /**
* Return the persistence unit's entities.
*/
Iterable<Entity> getEntities();
@@ -732,8 +742,13 @@ public interface PersistenceUnit
* types in the project currently annotated.
*/
void synchronizeClasses(IProgressMonitor monitor);
-
-
+
+ /**
+ * Return the names of all the packages valid cross the persistence unit
+ * including the ones from jar files
+ */
+ Iterable<String> getPackageNames();
+
// ********** validation **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java
index 62314b55c8..0af1269cc8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -62,4 +62,27 @@ public abstract class AbstractXmlContextNode
protected TextRange getValidationTextRange(TextRange textRange) {
return (textRange != null) ? textRange : this.getValidationTextRange();
}
+
+ // *********** completion proposals ***********
+
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ if (this.connectionProfileIsActive()) {
+ Iterable<String> result = this.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This method is called if the database is connected, allowing us to
+ * get candidates from the various database tables etc.
+ * This method should <em>not</em> be cascaded to "child" objects; it should
+ * only return candidates for the current object. The cascading is
+ * handled by {@link #getXmlCompletionProposals(int)}.
+ */
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
index ec33318805..b8d6ebbd14 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
@@ -1264,7 +1264,8 @@ public abstract class AbstractJavaMultiRelationshipMapping<A extends Relationshi
}
public Table getReferencedColumnDbTable() {
- return AbstractJavaMultiRelationshipMapping.this.getResolvedMapKeyEntity().getPrimaryDbTable();
+ Entity entity = AbstractJavaMultiRelationshipMapping.this.getResolvedMapKeyEntity();
+ return entity != null ? entity.getPrimaryDbTable() : null;
}
public int getJoinColumnsSize() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
index 89839c64b9..7a5b3c585f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
@@ -56,6 +56,7 @@ import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTableGenerator;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
import org.eclipse.jpt.jpa.db.Catalog;
+import org.eclipse.jpt.jpa.db.Database;
import org.eclipse.jpt.jpa.db.Schema;
import org.eclipse.jpt.jpa.db.SchemaContainer;
import org.eclipse.text.edits.DeleteEdit;
@@ -1071,4 +1072,92 @@ public abstract class AbstractEntityMappings
new SingleElementIterable<ReplaceEdit>(this.xmlEntityMappings.createRenamePackageEdit(newName)) :
EmptyIterable.<ReplaceEdit>instance();
}
+
+ // ************ completion proposals**************
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.queryContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmTableGenerator tableGenerator : this.getTableGenerators()) {
+ result = tableGenerator.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ for (OrmSequenceGenerator seqGenerator : this.getSequenceGenerators()) {
+ result = seqGenerator.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ result = this.persistenceUnitMetadata.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.packageTouches(pos)) {
+ return this.getCandidatePackages();
+ }
+ for (OrmPersistentType persistentType : this.getPersistentTypes()) {
+ result = persistentType.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.schemaTouches(pos)) {
+ return this.getCandidateSchemata();
+ }
+ if (this.catalogTouches(pos)) {
+ return this.getCandidateCatalogs();
+ }
+ return null;
+ }
+
+ // ********** content assist: schema
+
+ protected boolean schemaTouches(int pos) {
+ return this.getXmlEntityMappings().schemaTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateSchemata() {
+ SchemaContainer schemaContainer = this.getDbSchemaContainer();
+ return (schemaContainer != null) ? schemaContainer.getSortedSchemaIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********** content assist: catalog
+
+ protected boolean catalogTouches(int pos) {
+ return this.getXmlEntityMappings().catalogTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateCatalogs() {
+ Database db = this.getDatabase();
+ return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********** content assist: package
+
+ private boolean packageTouches(int pos) {
+ return this.getXmlEntityMappings().packageTouches(pos);
+ }
+
+ private Iterable<String> getCandidatePackages() {
+ return this.getPersistenceUnit().getPackageNames();
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
index e5297023b6..6eb6425cd6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
@@ -14,6 +14,7 @@ import java.util.List;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.Transformer;
@@ -27,6 +28,7 @@ import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.Relationship;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
import org.eclipse.jpt.jpa.core.context.orm.OrmBaseEmbeddedMapping;
@@ -506,4 +508,34 @@ public abstract class AbstractOrmAttributeMapping<X extends XmlAttributeMapping>
);
}
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.attributeNameTouches(pos)) {
+ return this.getCandidateMappingNames();
+ }
+ return null;
+ }
+
+ /**
+ * @return all the attribute of corresponding Java persistent type
+ */
+ // Attributes of the corresponding XML persistent type include these
+ // that are already defined in XML so using these attributes as candidates
+ // could lead to multiple attribute mappings with the same name;
+ // thus using the attribute of the corresponding Java persistent type instead
+ private Iterable<String> getCandidateMappingNames() {
+ JavaPersistentType jpt = this.getTypeMapping().getPersistentType().getJavaPersistentType();
+ return jpt == null ? EmptyIterable.<String>instance() : CollectionTools.collection(jpt.getAttributeNames());
+ }
+
+ private boolean attributeNameTouches(int pos) {
+ return this.getXmlAttributeMapping().nameTouches(pos);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java
index a8aac5bb2e..5c215f88d2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -299,4 +299,23 @@ public abstract class AbstractOrmBaseColumn<X extends XmlBaseColumn, O extends O
protected NamedColumnTextRangeResolver buildTextRangeResolver() {
return new OrmTableColumnTextRangeResolver(this);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.tableTouches(pos)) {
+ return this.getCandidateTableNames();
+ }
+ return null;
+ }
+
+ protected boolean tableTouches(int pos) {
+ X xmlColumn = this.getXmlColumn();
+ return (xmlColumn != null) && (xmlColumn.tableTouches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
index b678c0b2a3..7e641415e8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
@@ -32,10 +32,10 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmBaseEmbeddedMapping;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideColumnValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
@@ -230,6 +230,20 @@ public abstract class AbstractOrmBaseEmbeddedMapping<X extends AbstractXmlEmbedd
this.attributeOverrideContainer.validate(messages, reporter);
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.attributeOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
// ********** attribute override container owner *********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java
index 5fbf5d1ae3..ab289fdc59 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 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.
@@ -26,9 +26,9 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmLobConverter;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmConverter;
@@ -368,4 +368,23 @@ public abstract class AbstractOrmBasicMapping<X extends XmlBasic>
public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
return new NamedColumnValidator(this.getPersistentAttribute(), (ReadOnlyBaseColumn) col, (TableColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.converter.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
index 7911d0f1ba..e2d748bc0b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
@@ -1918,6 +1918,48 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
return this.getValidationTextRange(this.xmlTypeMapping.getInheritanceStrategyTextRange());
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.table.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmSecondaryTable secondaryTable : this.getSpecifiedSecondaryTables()) {
+ result = secondaryTable.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ for (OrmPrimaryKeyJoinColumn pkJoinColumn : this.getSpecifiedPrimaryKeyJoinColumns()) {
+ result = pkJoinColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ result = this.attributeOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.associationOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.discriminatorColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.generatorContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
// ********** OrmOverrideContainer.Owner implementation **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
index 073bb28fab..238c9d9263 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -13,6 +13,7 @@ import java.util.List;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.Tools;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.orm.OrmGenerator;
@@ -20,6 +21,7 @@ import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.jpa.core.resource.orm.XmlGenerator;
import org.eclipse.jpt.jpa.db.Catalog;
+import org.eclipse.jpt.jpa.db.Database;
import org.eclipse.jpt.jpa.db.Schema;
import org.eclipse.jpt.jpa.db.SchemaContainer;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -192,6 +194,48 @@ public abstract class AbstractOrmGenerator<X extends XmlGenerator>
Tools.valuesAreEqual(this.getSpecifiedInitialValue(), generator.getSpecifiedInitialValue());
}
+ // ************* completion proposals *************
+ /**
+ * called if the database is connected:
+ * table, schema, catalog, pkColumnName, valueColumnName
+ */
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.schemaTouches(pos)) {
+ return this.getCandidateSchemata();
+ }
+ if (this.catalogTouches(pos)) {
+ return this.getCandidateCatalogs();
+ }
+ return null;
+ }
+
+ // ********** content assist: schema
+
+ protected boolean schemaTouches(int pos) {
+ return this.xmlGenerator.schemaTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateSchemata() {
+ SchemaContainer schemaContainer = this.getDbSchemaContainer();
+ return (schemaContainer != null) ? schemaContainer.getSortedSchemaIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********** content assist: catalog
+
+ protected boolean catalogTouches(int pos) {
+ return this.xmlGenerator.catalogTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateCatalogs() {
+ Database db = this.getDatabase();
+ return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance();
+ }
+
// ********** database stuff **********
public Schema getDbSchema() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java
index 3bb921d438..4fd92d485b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 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.
@@ -28,9 +28,9 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmConverter;
@@ -449,4 +449,33 @@ public abstract class AbstractOrmIdMapping<X extends XmlId>
public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
return new NamedColumnValidator(this.getPersistentAttribute(), (ReadOnlyBaseColumn) col, (TableColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.generatorContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.generatedValue != null) {
+ result = this.generatedValue.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ result = this.converter.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
index 2652f0f3bc..63ef3ad811 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -290,4 +290,21 @@ public abstract class AbstractOrmJoinColumnRelationshipStrategy
joinColumn.validate(messages, reporter);
}
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmJoinColumn joinColumn : this.getJoinColumns()) {
+ result = joinColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java
index a84fd271ba..bbd2c0b3e0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -126,6 +126,20 @@ public abstract class AbstractOrmJoinTableRelationshipStrategy
}
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.joinTable != null) {
+ result = this.joinTable.getXmlCompletionProposals(pos);
+ }
+ return result;
+ }
+
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
index 7e8727479f..8cc63ff444 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
@@ -1070,6 +1070,45 @@ public abstract class AbstractOrmMultiRelationshipMapping<X extends AbstractXmlM
return this.getValidationTextRange(this.xmlAttributeMapping.getMapKeyClassTextRange());
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.orderable.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.mapKeyNameTouches(pos)) {
+ return this.getCandidateMapKeyNames();
+ }
+ result = this.mapKeyColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mapKeyConverter.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mapKeyAttributeOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmJoinColumn joinColumn : this.getMapKeyJoinColumns()) {
+ result = joinColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ protected boolean mapKeyNameTouches(int pos) {
+ return this.xmlAttributeMapping.mapKeyNameTouches(pos);
+ }
// ********** abstract owner **********
@@ -1234,7 +1273,8 @@ public abstract class AbstractOrmMultiRelationshipMapping<X extends AbstractXmlM
}
public Table getReferencedColumnDbTable() {
- return AbstractOrmMultiRelationshipMapping.this.getResolvedMapKeyEntity().getPrimaryDbTable();
+ Entity entity = AbstractOrmMultiRelationshipMapping.this.getResolvedMapKeyEntity();
+ return entity != null ? entity.getPrimaryDbTable() : null;
}
public int getJoinColumnsSize() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java
index a908d3dc1e..99df4a66f6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.jpa.core.internal.context.orm;
import java.util.List;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.orm.OrmNamedColumn;
@@ -252,7 +253,30 @@ public abstract class AbstractOrmNamedColumn<X extends XmlNamedColumn, O extends
return (xmlColumn == null) ? null : xmlColumn.getNameTextRange();
}
+ // ********** completion proposals **********
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.columnNameTouches(pos)) {
+ return this.getCandidateColumnNames();
+ }
+ return null;
+ }
+
+ protected boolean columnNameTouches(int pos) {
+ X column = this.getXmlColumn();
+ return (column != null) && (column.columnNameTouches(pos));
+ }
+
+ protected Iterable<String> getCandidateColumnNames() {
+ Table dbTable = this.getDbTable();
+ return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
+ }
+
// ********** misc **********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
index 00084c9d5d..3af6e596e8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
@@ -441,5 +441,20 @@ public abstract class AbstractOrmRelationshipMapping<X extends AbstractXmlRelati
public String getMetamodelTypeName() {
return (this.fullyQualifiedTargetEntity != null) ? this.fullyQualifiedTargetEntity : MetamodelField.DEFAULT_TYPE_NAME;
}
+
+
+ // ********** completion proposals **********
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.relationship.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
index 8a3d5e5ce0..93610f28a7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -10,11 +10,13 @@
package org.eclipse.jpt.jpa.core.internal.context.orm;
import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.SequenceGenerator;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.orm.OrmSequenceGenerator;
import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator;
+import org.eclipse.jpt.jpa.db.Schema;
/**
* <code>orm.xml</code> sequence generator
@@ -104,4 +106,32 @@ public abstract class AbstractOrmSequenceGenerator
return super.isIdentical(generator) &&
StringTools.stringsAreEqual(this.getSpecifiedSequenceName(), ((SequenceGenerator)generator).getSpecifiedSequenceName());
}
+
+ // ********** completion proposals **********
+
+ /**
+ * called if the database is connected:
+ * sequenceName
+ */
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.sequenceNameTouches(pos)) {
+ return this.getCandidateSequences();
+ }
+ return null;
+ }
+
+ protected boolean sequenceNameTouches(int pos) {
+ return this.xmlGenerator.sequenceNameTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateSequences() {
+ Schema dbSchema = this.getDbSchema();
+ return (dbSchema != null) ? dbSchema.getSortedSequenceIdentifiers() : EmptyIterable.<String> instance();
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
index bde41315e5..40630ac2b4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 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.
@@ -138,4 +138,19 @@ public abstract class AbstractOrmSingleRelationshipMapping<X extends AbstractXml
super.validate(messages, reporter);
this.derivedIdentity.validate(messages, reporter);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.derivedIdentity.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java
index 3f764f759b..300920b453 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -28,6 +28,7 @@ import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlTable;
import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
import org.eclipse.jpt.jpa.core.resource.orm.XmlUniqueConstraint;
import org.eclipse.jpt.jpa.db.Catalog;
+import org.eclipse.jpt.jpa.db.Database;
import org.eclipse.jpt.jpa.db.Schema;
import org.eclipse.jpt.jpa.db.SchemaContainer;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -469,6 +470,82 @@ public abstract class AbstractOrmTable<X extends AbstractXmlTable>
return (xmlTable == null) ? null : xmlTable.getCatalogTextRange();
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmUniqueConstraint constraint : this.getUniqueConstraints()) {
+ result = constraint.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * called if the database is connected:
+ * name, schema, catalog
+ */
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.tableNameTouches(pos)) {
+ return this.getCandidateTableNames();
+ }
+ if (this.schemaTouches(pos)) {
+ return this.getCandidateSchemata();
+ }
+ if (this.catalogTouches(pos)) {
+ return this.getCandidateCatalogs();
+ }
+ return null;
+ }
+
+ // ********* content assist : table
+
+ protected boolean tableNameTouches(int pos) {
+ X table = this.getXmlTable();
+ return (table != null) && (table.nameTouches(pos));
+ }
+
+ protected Iterable<String> getCandidateTableNames() {
+ Schema dbSchema = this.getDbSchema();
+ return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********* content assist : schema
+
+ protected boolean schemaTouches(int pos) {
+ X table = this.getXmlTable();
+ return (table != null) && (table.schemaTouches(pos));
+ }
+
+ protected Iterable<String> getCandidateSchemata() {
+ if (this.getDbSchemaContainer() == null)
+ return EmptyIterable.<String>instance();
+ else
+ return this.getDbSchemaContainer().getSortedSchemaIdentifiers();
+ }
+
+ // ********* content assist : catalog
+
+ protected boolean catalogTouches(int pos) {
+ X table = this.getXmlTable();
+ return (table != null) && (table.catalogTouches(pos));
+ }
+
+ protected Iterable<String> getCandidateCatalogs() {
+ Database db = this.getDatabase();
+ return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance();
+ }
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
index cc1a48cb83..e080f292a3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
@@ -605,4 +605,58 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
//fix this problem. bug 358745
return (textRange != null) ? textRange : TextRange.Empty.instance();
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.classNameTouches(pos)) {
+ return this.getCandidateClassNames();
+ }
+ return null;
+ }
+
+ private Iterable<String> getCandidateClassNames() {
+ final String packageName = this.getEntityMappings().getPackage();
+ if (!StringTools.stringIsEmpty(packageName)) {
+ return new TransformationIterable<String, String>(this.getFilteredCandidateClassNames(packageName)) {
+ @Override
+ protected String transform(String className) {
+ return className.substring(packageName.length()+1);
+ }
+ };
+ }
+ return this.getCandidateFullQulifiedClassNames();
+ }
+
+ private Iterable<String> getFilteredCandidateClassNames(final String packageName) {
+ return new FilteringIterable<String>(this.getCandidateFullQulifiedClassNames()) {
+ @Override
+ protected boolean accept(String className) {
+ return className.startsWith(packageName);
+ }
+ };
+ }
+
+ /**
+ * @return names of the classes specified by class refs and jar files
+ */
+ // should return names of all the classes defined in the project?
+ private Iterable<String> getCandidateFullQulifiedClassNames() {
+ return new TransformationIterable<PersistentType, String>(
+ this.getPersistenceUnit().getJavaPersistentTypes()) {
+ @Override
+ protected String transform(PersistentType pType) {
+ return pType.getName();
+ }
+ };
+ }
+
+ private boolean classNameTouches(int pos) {
+ return this.getXmlTypeMapping().classNameTouches(pos);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java
index 7750709141..1e171a4207 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java
@@ -24,9 +24,9 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter;
import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmConverter;
@@ -291,4 +291,23 @@ public abstract class AbstractOrmVersionMapping<X extends XmlVersion>
public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
return new NamedColumnValidator(this.getPersistentAttribute(), (ReadOnlyBaseColumn) col, (TableColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.converter.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java
index 7ada92b093..793c82627e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -171,4 +171,23 @@ public class GenericOrmManyToManyRelationship
this.mappedByStrategy.validate(messages, reporter);
this.joinTableStrategy.validate(messages, reporter);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mappedByStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinTableStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java
index 5379388ee0..2aa0160f42 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -176,4 +176,23 @@ public class GenericOrmManyToOneRelationship
this.joinColumnStrategy.validate(messages, reporter);
this.joinTableStrategy.validate(messages, reporter);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinColumnStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinTableStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
index 751f3ce4de..e5141fd8a5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -222,4 +222,22 @@ public class GenericOrmMappedByRelationshipStrategy
TextRange textRange = this.getXmlMappedByMapping().getMappedByTextRange();
return (textRange != null) ? textRange : this.getRelationship().getValidationTextRange();
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.mappedByTouches(pos)) {
+ return this.getCandidateMappedByAttributeNames();
+ }
+ return null;
+ }
+
+ protected boolean mappedByTouches(int pos) {
+ return this.getXmlMappedByMapping().mappedByTouches(pos);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java
index 6331704dc9..deb9dc59d7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -241,4 +241,27 @@ public class GenericOrmOneToManyRelationship
this.joinTableStrategy.validate(messages, reporter);
this.joinColumnStrategy.validate(messages, reporter);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mappedByStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinTableStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinColumnStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java
index d01a46ca29..53a4c7eddb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -264,4 +264,31 @@ public class GenericOrmOneToOneRelationship
this.joinTableStrategy.validate(messages, reporter);
this.joinColumnStrategy.validate(messages, reporter);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mappedByStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.primaryKeyJoinColumnStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinTableStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.joinColumnStrategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java
index 06d5a08f57..053052e25d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java
@@ -238,6 +238,22 @@ public class GenericOrmPrimaryKeyJoinColumnRelationshipStrategy
}
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmPrimaryKeyJoinColumn column : this.getPrimaryKeyJoinColumns()) {
+ result = column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
// ********** join column owner **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
index 2a0b7f0ab0..62a378c3df 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
@@ -533,6 +533,20 @@ public abstract class SpecifiedOrmPersistentAttribute
JavaPersistentAttribute.JpaContainerDefinition.Null.instance();
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mapping.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
index 3ad40cc24b..6d0d60bee5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
@@ -1293,6 +1293,26 @@ public abstract class SpecifiedOrmPersistentType
return this.mapping.getValidationTextRange();
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mapping.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmPersistentAttribute attribute : this.getSpecifiedAttributes()) {
+ result = attribute.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
index ea833c7036..848ca619b2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -31,6 +31,7 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.BodySourceWriter;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
@@ -1657,15 +1658,8 @@ public abstract class AbstractPersistenceUnit
);
}
- /**
- * Return the persistence unit's Java persistent types, as specified by
- * the class refs (both specified and implied) and jar files.
- * There can be duplicate types, and any of them may be overridden by a
- * mapping file persistence type.
- * @see #getMappingFilePersistentTypes()
- */
@SuppressWarnings("unchecked")
- protected Iterable<PersistentType> getJavaPersistentTypes() {
+ public Iterable<PersistentType> getJavaPersistentTypes() {
return new CompositeIterable<PersistentType>(
this.getClassRefPersistentTypes(),
this.getJarFilePersistentTypes()
@@ -2043,6 +2037,14 @@ public abstract class AbstractPersistenceUnit
sb.append(this.name);
}
+ public Iterable<String> getPackageNames() {
+ Set<String> packageNames = new HashSet<String>();
+ for (PersistentType pType : this.getJavaPersistentTypes()) {
+ JavaResourceType jrt = ((JavaPersistentType)pType).getJavaResourceType();
+ packageNames.add(jrt.getPackageName());
+ }
+ return packageNames;
+ }
// ********** validation **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java
index f60f1c7e87..a1cb23f604 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java
@@ -220,6 +220,20 @@ public abstract class AbstractOrmEmbeddedMapping<X extends XmlEmbedded>
this.associationOverrideContainer.validate(messages, reporter);
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.associationOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
// ********** attribute override container owner *********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java
index 115c080e52..93c19b4866 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -13,14 +13,14 @@ import java.util.List;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn;
import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner;
+import org.eclipse.jpt.jpa.core.context.TypeMapping;
import org.eclipse.jpt.jpa.core.context.orm.OrmOverride;
import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverride;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOverrideTextRangeResolver;
import org.eclipse.jpt.jpa.core.resource.orm.XmlOverride;
@@ -170,4 +170,26 @@ public abstract class AbstractOrmOverride<C extends OrmOverrideContainer, X exte
public Iterable<String> getCandidateTableNames() {
return this.getContainer().getCandidateTableNames();
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.nameTouches(pos)) {
+ return this.getCandidateNames();
+ }
+ return null;
+ }
+
+ protected boolean nameTouches(int pos) {
+ return this.xmlOverride.nameTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateNames() {
+ return this.getContainer().getAllOverridableNames();
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java
index db17b45b9a..038e1f2e30 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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.
@@ -28,10 +28,10 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmOverride;
import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyOverride;
import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverride;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
import org.eclipse.jpt.jpa.core.resource.orm.XmlOverride;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -471,4 +471,21 @@ public abstract class AbstractOrmOverrideContainer<
this.specifiedOverrides.get(0).getValidationTextRange() :
this.owner.getValidationTextRange();
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (R override : this.getOverrides()) {
+ result = override.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java
index 77e8e7936e..0e7ab51c70 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
@@ -17,6 +18,7 @@ import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistenceUnitDefaults2_0;
import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitDefaults;
import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitMetadata;
import org.eclipse.jpt.jpa.db.Catalog;
+import org.eclipse.jpt.jpa.db.Database;
import org.eclipse.jpt.jpa.db.Schema;
import org.eclipse.jpt.jpa.db.SchemaContainer;
@@ -353,4 +355,43 @@ public abstract class AbstractOrmPersistenceUnitDefaults
XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults();
return (xmlDefaults == null) ? null : xmlDefaults.getValidationTextRange();
}
+
+ // ********** completion proposals *********
+
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.schemaTouches(pos)) {
+ return this.getCandidateSchemata();
+ }
+ if (this.catalogTouches(pos)) {
+ return this.getCandidateCatalogs();
+ }
+ return null;
+ }
+
+ // ********** content assist: schema
+
+ protected boolean schemaTouches(int pos) {
+ return (this.getXmlDefaults() != null) && this.getXmlDefaults().schemaTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateSchemata() {
+ SchemaContainer schemaContainer = this.getDbSchemaContainer();
+ return (schemaContainer != null) ? schemaContainer.getSortedSchemaIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********** content assist: catalog
+
+ protected boolean catalogTouches(int pos) {
+ return (this.getXmlDefaults() != null) && this.getXmlDefaults().catalogTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateCatalogs() {
+ Database db = this.getDatabase();
+ return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance();
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java
index f0d6f9963c..a7bd86e6ce 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 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.
@@ -187,4 +187,19 @@ public abstract class AbstractOrmPersistenceUnitMetadata
XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata();
return (xmlMetadata == null) ? null : xmlMetadata.getValidationTextRange();
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.persistenceUnitDefaults.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java
index 2ff662f8ff..af85f006d0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -116,4 +116,19 @@ public class GenericOrmAssociationOverride
public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
return this.getContainer2_0().buildJoinTableInverseJoinColumnValidator(this, column, owner, textRangeResolver);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.relationship.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java
index 8d75da74c8..22ea7a8b00 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -17,9 +17,9 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
@@ -152,4 +152,19 @@ public class GenericOrmAttributeOverride
protected boolean xmlColumnIsSpecified() {
return this.getXmlColumn() != null;
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java
index b97f0016de..049ec7fcbb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -189,4 +189,26 @@ public class GenericOrmGeneratedValue
public TextRange getGeneratorTextRange() {
return this.getValidationTextRange(this.xmlGeneratedValue.getGeneratorTextRange());
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.generatorTouches(pos)) {
+ return this.getCandidateGeneratorNames();
+ }
+ return null;
+ }
+
+ protected boolean generatorTouches(int pos) {
+ return this.xmlGeneratedValue.generatorTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateGeneratorNames() {
+ return this.getPersistenceUnit().getUniqueGeneratorNames();
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java
index 2631913089..0cf8af22e9 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -212,6 +212,28 @@ public class GenericOrmGeneratorContainer
return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.tableGenerator != null) {
+ result = this.tableGenerator.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ if (this.sequenceGenerator != null) {
+ result = this.sequenceGenerator.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java
index 0692d5e0c2..82c9b8b39a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
@@ -173,4 +174,28 @@ public class GenericOrmJoinColumn
protected NamedColumnTextRangeResolver buildTextRangeResolver() {
return new OrmJoinColumnTextRangeResolver(this);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.referencedColumnNameTouches(pos)) {
+ return this.getCandidateReferencedColumnNames();
+ }
+ return null;
+ }
+
+ protected boolean referencedColumnNameTouches(int pos) {
+ XmlJoinColumn joinColumn = this.getXmlColumn();
+ return (joinColumn != null) && (joinColumn.referencedColumnNameTouches(pos));
+ }
+
+ protected Iterable<String> getCandidateReferencedColumnNames() {
+ Table table = this.owner.getReferencedColumnDbTable();
+ return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java
index 0ff6c45307..6a69301767 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java
@@ -307,6 +307,22 @@ public class GenericOrmJoinTable
return this.getRelationshipStrategy().validatesAgainstDatabase();
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmJoinColumn column : this.getInverseJoinColumns()) {
+ result = column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
// ********** join column owners **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java
index 4f11bb8785..9f1dc107fe 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -400,7 +400,21 @@ public class GenericOrmOrderable
}
}
+ // ********** completion proposals **********
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.orderColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
+
// ********** order column owner (JPA 2.0) **********
protected class OrderColumnOwner
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java
index d9be83fc97..0f010df5af 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -15,13 +15,13 @@ import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
import org.eclipse.jpt.jpa.core.context.OverrideRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyOverrideRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship;
+import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner;
import org.eclipse.jpt.jpa.core.context.Relationship;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
@@ -29,9 +29,9 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride;
import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
+import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
import org.eclipse.jpt.jpa.core.internal.context.orm.GenericOrmOverrideJoinColumnRelationshipStrategy;
@@ -305,4 +305,19 @@ public class GenericOrmOverrideRelationship
public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
return this.getAssociationOverride2_0().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.strategy.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java
index c954cf5cb6..26c08d3df7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn;
@@ -169,4 +170,28 @@ public class GenericOrmPrimaryKeyJoinColumn
public TextRange getReferencedColumnNameTextRange() {
return this.getValidationTextRange(this.xmlColumn.getReferencedColumnNameTextRange());
}
+
+ // ********** completion proposals **********
+
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.referencedColumnNameTouches(pos)) {
+ return this.getCandidateReferencedColumnNames();
+ }
+ return null;
+ }
+
+ public boolean referencedColumnNameTouches(int pos) {
+ XmlPrimaryKeyJoinColumn column = this.getXmlColumn();
+ return (column != null) && (column.referencedColumnNameTouches(pos));
+ }
+
+ protected Iterable<String> getCandidateReferencedColumnNames() {
+ Table table = this.owner.getReferencedColumnDbTable();
+ return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java
index dedc4bdfd6..0c1005835b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -261,4 +261,21 @@ public abstract class GenericOrmReferenceTable<X extends AbstractXmlReferenceTab
protected void validateJoinColumns(List<IMessage> messages, IReporter reporter) {
this.validateNodes(this.getJoinColumns(), messages, reporter);
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmJoinColumn column : this.getJoinColumns()) {
+ result = column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java
index bb0d3df612..f91546bee1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java
@@ -317,6 +317,22 @@ public class GenericOrmSecondaryTable
}
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmPrimaryKeyJoinColumn column : this.getPrimaryKeyJoinColumns()) {
+ result = column.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
// ********** primary key join column owner adapter **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java
index f9ab4a1294..7826bd33a1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -450,4 +450,71 @@ public class GenericOrmTableGenerator
}
return isIdentical;
}
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmUniqueConstraint constraint : this.getUniqueConstraints()) {
+ result = constraint.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * called if the database is connected:
+ * table, schema, catalog, pkColumnName, valueColumnName
+ */
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.tableTouches(pos)) {
+ return this.getCandidateTables();
+ }
+ if (this.pkColumnNameTouches(pos)) {
+ return this.getCandidateColumnNames();
+ }
+ if (this.valueColumnNameTouches(pos)) {
+ return this.getCandidateColumnNames();
+ }
+ return null;
+ }
+
+ // ********** content assist: table
+
+ protected boolean tableTouches(int pos) {
+ return this.xmlGenerator.tableTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateTables() {
+ Schema dbSchema = this.getDbSchema();
+ return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********** content assist: pkColumnName
+
+ protected boolean pkColumnNameTouches(int pos) {
+ return this.xmlGenerator.pkColumnNameTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateColumnNames() {
+ Table table = this.getDbTable();
+ return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
+ }
+
+ // ********** content assist: valueColumnName
+
+ protected boolean valueColumnNameTouches(int pos) {
+ return this.xmlGenerator.valueColumnNameTouches(pos);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java
index d5641a7deb..2216c081bd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -105,6 +105,28 @@ public class GenericOrmUniqueConstraint
return isIdentical;
}
+ // ********** completion proposals **********
+
+ @Override
+ protected Iterable<String> getConnectedXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getConnectedXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.columnNamesTouches(pos)) {
+ return this.getCandidateColumnNames();
+ }
+ return null;
+ }
+
+ protected boolean columnNamesTouches(int pos) {
+ return this.xmlUniqueConstraint.columnNamesTouches(pos);
+ }
+
+ protected Iterable<String> getCandidateColumnNames() {
+ return this.owner.getCandidateUniqueConstraintColumnNames();
+ }
+
// ********** misc **********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
index b498afe0e0..bb60a432c7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
@@ -1743,6 +1743,65 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen
}
}
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.collectionTable.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.valueColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.converter.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.orderable.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.valueAttributeOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.valueAssociationOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.mapKeyNameTouches(pos)) {
+ return this.getCandidateMapKeyNames();
+ }
+ result = this.mapKeyColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mapKeyConverter.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ result = this.mapKeyAttributeOverrideContainer.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmJoinColumn joinColumn : this.getMapKeyJoinColumns()) {
+ result = joinColumn.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ protected boolean mapKeyNameTouches(int pos) {
+ return this.xmlAttributeMapping.mapKeyNameTouches(pos);
+ }
// ********** abstract owner **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java
index 11238fe493..70d8b5f36c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -170,4 +170,21 @@ public class GenericOrmDerivedIdentity2_0
public TextRange getValidationTextRange() {
return this.getMapping().getValidationTextRange();
}
+
+ // ************** completion proposals **********
+
+ @Override
+ public Iterable<String> getXmlCompletionProposals(int pos) {
+ Iterable<String> result = super.getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.strategy != null) {
+ result = ((XmlContextNode) this.strategy).getXmlCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlAttributeMapping.java
index c71beb6ea0..60d9290ae7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlAttributeMapping.java
@@ -279,4 +279,15 @@ public abstract class AbstractXmlAttributeMapping
protected static Translator buildAccessTranslator() {
return new Translator(JPA.ACCESS, OrmPackage.eINSTANCE.getXmlAccessHolder_Access(), Translator.DOM_ATTRIBUTE);
}
+
+ // *********** content assist ************
+
+ protected TextRange getNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.NAME);
+ }
+
+ public boolean nameTouches(int pos) {
+ TextRange textRange = this.getNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlBaseColumn.java
index 7e43b4110d..72d68fbe62 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlBaseColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlBaseColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -533,4 +533,15 @@ public abstract class AbstractXmlBaseColumn extends AbstractXmlNamedColumn imple
return new Translator(JPA.TABLE, OrmPackage.eINSTANCE.getXmlBaseColumn_Table(), Translator.DOM_ATTRIBUTE);
}
+ // ************ content assist ************
+
+ private TextRange getTableCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.TABLE);
+ }
+
+ public boolean tableTouches(int pos) {
+ TextRange textRange = this.getTableCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
} // AbstractXmlAbstractColumn
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlMultiRelationshipMapping.java
index 0c92678ebc..53a7fb2531 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlMultiRelationshipMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -1123,4 +1123,24 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
protected static Translator buildOrderColumnTranslator() {
return XmlOrderColumn.buildTranslator(JPA2_0.ORDER_COLUMN, OrmV2_0Package.eINSTANCE.getXmlOrderable_2_0_OrderColumn());
}
+
+ // ********** content assist ***************
+
+ public TextRange getMappedByCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.MAPPED_BY);
+ }
+
+ public TextRange getMapKeyNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.MAP_KEY);
+ }
+
+ public boolean mappedByTouches(int pos) {
+ TextRange textRange = this.getMappedByCodeAssistTextRange();
+ return (textRange!= null) && textRange.touches(pos);
+ }
+
+ public boolean mapKeyNameTouches(int pos) {
+ TextRange textRange = this.getMapKeyNameCodeAssistTextRange();
+ return (textRange != null) && textRange.touches(pos);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlNamedColumn.java
index 443a1384dd..961b31aaaa 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlNamedColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -274,4 +274,15 @@ public abstract class AbstractXmlNamedColumn extends AbstractJpaEObject implemen
return new Translator(JPA.COLUMN_DEFINITION, OrmPackage.eINSTANCE.getXmlNamedColumn_ColumnDefinition(), Translator.DOM_ATTRIBUTE);
}
+ // *********** content assist ***********
+
+ public TextRange getColumnNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.NAME);
+ }
+
+ public boolean columnNameTouches(int pos) {
+ TextRange textRange = this.getColumnNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
} // AbstractXmlNamedColumn
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTable.java
index 7169745166..f28ddccf69 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -436,4 +436,32 @@ public abstract class AbstractXmlTable extends AbstractJpaEObject implements Jpa
return XmlUniqueConstraint.buildTranslator(JPA.UNIQUE_CONSTRAINT, OrmPackage.eINSTANCE.getAbstractXmlTable_UniqueConstraints());
}
+ //***************** content assist ****************
+
+ public TextRange getNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.NAME);
+ }
+
+ public TextRange getSchemaCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.SCHEMA);
+ }
+
+ public TextRange getCatalogCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.CATALOG);
+ }
+
+ public boolean nameTouches(int pos) {
+ TextRange textRange = this.getNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean schemaTouches(int pos) {
+ TextRange textRange = this.getSchemaCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean catalogTouches(int pos) {
+ TextRange textRange = this.getCatalogCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
} // AbstractXmlBaseTable
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
index 59fa5a1c21..54f7b4b194 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
@@ -550,4 +550,14 @@ public abstract class AbstractXmlTypeMapping extends AbstractJpaEObject implemen
return new ReplaceEdit(offset, packageLength, newName);
}
+ // *********** content assist ************
+
+ protected TextRange getClassNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.CLASS);
+ }
+
+ public boolean classNameTouches(int pos) {
+ TextRange textRange = this.getClassNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
} // TypeMapping
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAssociationOverride.java
index 531c5a31a7..3ac33d4e50 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAssociationOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAssociationOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -518,4 +518,14 @@ public class XmlAssociationOverride extends AbstractJpaEObject implements XmlOve
protected static Translator buildJoinTableTranslator() {
return XmlJoinTable.buildTranslator(JPA.JOIN_TABLE, OrmPackage.eINSTANCE.getXmlJoinTableContainer_JoinTable());
}
+
+ // ************ content assist ***********
+ public TextRange getNameTextCodeAssistRange() {
+ return getAttributeCodeAssistTextRange(JPA.NAME);
+ }
+
+ public boolean nameTouches(int pos) {
+ TextRange textRange = this.getNameTextCodeAssistRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeMapping.java
index ba4995ae77..a2afd84ad4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -67,4 +67,5 @@ public interface XmlAttributeMapping extends XmlAttributeMapping_2_0
//TODO unsure about this api, might change soon
String getMappingKey();
+ boolean nameTouches(int pos);
} // XmlAttributeMapping
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeOverride.java
index b3bf1b2c12..97110e39ee 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlAttributeOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -437,4 +437,15 @@ public class XmlAttributeOverride extends AbstractJpaEObject implements XmlOverr
protected static Translator buildColumnTranslator() {
return XmlColumn.buildTranslator(JPA.COLUMN, OrmPackage.eINSTANCE.getXmlAttributeOverride_Column());
}
+
+ // ************* content assist ************
+
+ public TextRange getNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.NAME);
+ }
+
+ public boolean nameTouches(int pos) {
+ TextRange textRange = this.getNameTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlBaseColumn.java
index 6b3118602d..7adb900ba3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlBaseColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlBaseColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2012 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.
@@ -172,4 +172,6 @@ public interface XmlBaseColumn extends XmlNamedColumn
TextRange getTableTextRange();
+ boolean tableTouches(int pos);
+
} // XmlBaseColumn
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java
index deae50300e..9dc71dfa7c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle.
+ * Copyright (c) 2009, 2012 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
@@ -1684,4 +1684,15 @@ public class XmlElementCollection extends AbstractXmlAttributeMapping implements
return getMapKeyClass().createRenamePackageEdit(newName);
}
+ // ********** content assist ***************
+
+ public TextRange getMapKeyNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.MAP_KEY);
+ }
+
+ public boolean mapKeyNameTouches(int pos) {
+ TextRange textRange = this.getMapKeyNameCodeAssistTextRange();
+ return (textRange != null) && textRange.touches(pos);
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java
index f17c45e36a..03dac0193b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java
@@ -23,6 +23,7 @@ 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.common.core.internal.utility.translators.SimpleRootTranslator;
+import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.JPA2_0;
import org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject;
@@ -1116,4 +1117,21 @@ public class XmlEntityMappings extends AbstractJpaRootEObject implements XmlQuer
return new ReplaceEdit(offset, this.package_.length(), newName);
}
+ // *********** content assist *********
+
+ public boolean schemaTouches(int pos) {
+ TextRange textRange = this.getElementCodeAssistTextRange(JPA.SCHEMA);
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean catalogTouches(int pos) {
+ TextRange textRange = this.getElementCodeAssistTextRange(JPA.CATALOG);
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean packageTouches(int pos) {
+ TextRange textRange = this.getElementCodeAssistTextRange(JPA.PACKAGE);
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGeneratedValue.java
index 164f89a6dc..ba2ac38708 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGeneratedValue.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGeneratedValue.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -300,4 +300,14 @@ public class XmlGeneratedValue extends AbstractJpaEObject implements JpaEObject
protected static Translator buildGeneratorTranslator() {
return new Translator(JPA.GENERATOR, OrmPackage.eINSTANCE.getXmlGeneratedValue_Generator(), Translator.DOM_ATTRIBUTE);
}
+
+ // *********** content assist ************
+
+ protected TextRange getGeneratorCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.GENERATOR);
+ }
+ public boolean generatorTouches(int pos) {
+ TextRange textRange = this.getGeneratorCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
} // GeneratedValue
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGenerator.java
index 83bd5bd8cd..c3a1fab13f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -116,5 +116,13 @@ public interface XmlGenerator extends XmlGenerator_2_0
*/
void setAllocationSize(Integer value);
- public TextRange getNameTextRange();
+ TextRange getNameTextRange();
+
+ TextRange getSchemaCodeAssistTextRange();
+
+ TextRange getCatalogCodeAssistTextRange();
+
+ boolean schemaTouches(int pos);
+
+ boolean catalogTouches(int pos);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlJoinColumn.java
index 7f7c7f856a..3cf2d975f0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlJoinColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -263,4 +263,15 @@ public class XmlJoinColumn extends AbstractXmlBaseColumn implements XmlBaseJoinC
protected static Translator buildReferencedColumnNameTranslator() {
return new Translator(JPA.REFERENCED_COLUMN_NAME, OrmPackage.eINSTANCE.getXmlBaseJoinColumn_ReferencedColumnName(), Translator.DOM_ATTRIBUTE);
}
+
+ // ************ content assist **************
+
+ public TextRange getReferencedColumnNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.REFERENCED_COLUMN_NAME);
+ }
+
+ public boolean referencedColumnNameTouches(int pos) {
+ TextRange textRange = this.getReferencedColumnNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
} // JoinColumn
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlMappedByMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlMappedByMapping.java
index 3d520018c8..f1cb8c0d9f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlMappedByMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlMappedByMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2012 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
@@ -64,5 +64,7 @@ public interface XmlMappedByMapping extends JpaEObject
*/
void setMappedBy(String value);
- TextRange getMappedByTextRange();
+ TextRange getMappedByTextRange();
+
+ boolean mappedByTouches(int pos);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedColumn.java
index b6d407281a..ae411ae785 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2012 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.
@@ -92,4 +92,6 @@ public interface XmlNamedColumn extends JpaEObject
TextRange getNameTextRange();
+ boolean columnNameTouches(int pos);
+
} // XmlNamedColumn
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOneToOne.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOneToOne.java
index 890c2d073f..e11fe0f5cd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOneToOne.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOneToOne.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -464,4 +464,15 @@ public class XmlOneToOne extends AbstractXmlSingleRelationshipMapping implements
protected static Translator buildPrimaryKeyJoinColumnTranslator() {
return XmlPrimaryKeyJoinColumn.buildTranslator(JPA.PRIMARY_KEY_JOIN_COLUMN, OrmPackage.eINSTANCE.getXmlPrimaryKeyJoinColumnContainer_PrimaryKeyJoinColumns());
}
+
+ // ********** content assist ***************
+
+ public TextRange getMappedByCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.MAPPED_BY);
+ }
+
+ public boolean mappedByTouches(int pos) {
+ TextRange textRange = this.getMappedByCodeAssistTextRange();
+ return (textRange!= null) && textRange.touches(pos);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOverride.java
index 879c065560..2879591072 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2012 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.
@@ -64,4 +64,6 @@ public interface XmlOverride extends JpaEObject
void setName(String value);
TextRange getNameTextRange();
+
+ boolean nameTouches(int pos);
} // XmlOverride
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPersistenceUnitDefaults.java
index b9e3553237..ba54ef728f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPersistenceUnitDefaults.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPersistenceUnitDefaults.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jpt.common.core.internal.utility.translators.EmptyTagBooleanTranslator;
import org.eclipse.jpt.common.core.internal.utility.translators.SimpleTranslator;
+import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.JPA2_0;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.OrmV2_0Package;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlPersistenceUnitDefaults_2_0;
@@ -726,4 +727,16 @@ public class XmlPersistenceUnitDefaults extends AbstractJpaEObject implements Xm
protected static Translator buildEntityListenersTranslator() {
return EntityListeners.buildTranslator(JPA.ENTITY_LISTENERS, OrmPackage.eINSTANCE.getXmlPersistenceUnitDefaults_EntityListeners());
}
+
+ // *********** content assist *********
+
+ public boolean schemaTouches(int pos) {
+ TextRange textRange = this.getElementCodeAssistTextRange(JPA.SCHEMA);
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean catalogTouches(int pos) {
+ TextRange textRange = this.getElementCodeAssistTextRange(JPA.CATALOG);
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPrimaryKeyJoinColumn.java
index 2447652f28..dcaa86b651 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPrimaryKeyJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlPrimaryKeyJoinColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -259,4 +259,15 @@ public class XmlPrimaryKeyJoinColumn extends AbstractXmlNamedColumn implements X
return new Translator(JPA.REFERENCED_COLUMN_NAME, OrmPackage.eINSTANCE.getXmlBaseJoinColumn_ReferencedColumnName(), Translator.DOM_ATTRIBUTE);
}
+ // *********** content assist ***********
+
+ public TextRange getReferencedColumnNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.REFERENCED_COLUMN_NAME);
+ }
+
+ public boolean referencedColumnNameTouches(int pos) {
+ TextRange textRange = this.getReferencedColumnNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
} // XmlPrimaryKeyJoinColumnImpl
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlSequenceGenerator.java
index 8ec8b8ca5e..7d605837a6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlSequenceGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlSequenceGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -699,4 +699,33 @@ public class XmlSequenceGenerator extends AbstractJpaEObject implements XmlGener
protected static Translator buildSchemaTranslator() {
return new Translator(JPA.SCHEMA, OrmV2_0Package.eINSTANCE.getXmlSequenceGenerator_2_0_Schema(), Translator.DOM_ATTRIBUTE);
}
+
+ // *********** content assist ****************
+
+ public TextRange getSequenceNameCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.SEQUENCE_NAME);
+ }
+
+ public TextRange getSchemaCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.SCHEMA);
+ }
+
+ public TextRange getCatalogCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.CATALOG);
+ }
+
+ public boolean sequenceNameTouches(int pos) {
+ TextRange textRange = this.getSequenceNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean schemaTouches(int pos) {
+ TextRange textRange = this.getSchemaCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean catalogTouches(int pos) {
+ TextRange textRange = this.getCatalogCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTableGenerator.java
index 688ec44842..abcd7fe1fe 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTableGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTableGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -944,4 +944,51 @@ public class XmlTableGenerator extends AbstractJpaEObject implements XmlGenerato
protected static Translator buildDescriptionTranslator() {
return new Translator(JPA.DESCRIPTION, OrmV2_0Package.eINSTANCE.getXmlGenerator_2_0_Description());
}
+
+ // ************* content assist ***************
+
+ public TextRange getTableCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.TABLE);
+ }
+
+ public TextRange getSchemaCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.SCHEMA);
+ }
+
+ public TextRange getCatalogCodeAssistTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.CATALOG);
+ }
+
+ public TextRange getPKColumnNameTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.PK_COLUMN_NAME);
+ }
+
+ public TextRange getValueColumnNameTextRange() {
+ return getAttributeCodeAssistTextRange(JPA.VALUE_COLUMN_NAME);
+ }
+
+ public boolean tableTouches(int pos) {
+ TextRange textRange = this.getTableCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean schemaTouches(int pos) {
+ TextRange textRange = this.getSchemaCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean catalogTouches(int pos) {
+ TextRange textRange = this.getCatalogCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean pkColumnNameTouches(int pos) {
+ TextRange textRange = this.getPKColumnNameTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
+
+ public boolean valueColumnNameTouches(int pos) {
+ TextRange textRange = this.getValueColumnNameTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTypeMapping.java
index c43d64f357..79c3414c8d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlTypeMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -161,4 +161,7 @@ public interface XmlTypeMapping extends XmlAccessHolder
ReplaceEdit createRenamePackageEdit(String newName);
+ // ********** content assist *********
+
+ boolean classNameTouches(int pos);
} // XmlTypeMapping
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlUniqueConstraint.java
index 1d71e8a6ca..e0c0106e7f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlUniqueConstraint.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlUniqueConstraint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -17,6 +17,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EDataTypeEList;
import org.eclipse.jpt.common.core.internal.utility.translators.SimpleTranslator;
+import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.OrmV2_0Package;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlUniqueConstraint_2_0;
import org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaEObject;
@@ -271,4 +272,15 @@ public class XmlUniqueConstraint extends AbstractJpaEObject implements XmlUnique
protected static Translator buildColumnNameTranslator() {
return new Translator(JPA.COLUMN_NAME, OrmPackage.eINSTANCE.getXmlUniqueConstraint_ColumnNames());
}
+
+ // ************ content assist **********
+
+ protected TextRange getColumnNameCodeAssistTextRange() {
+ return this.getElementCodeAssistTextRange(JPA.COLUMN_NAME);
+ }
+
+ public boolean columnNamesTouches(int pos) {
+ TextRange textRange = getColumnNameCodeAssistTextRange();
+ return (textRange != null) && (textRange.touches(pos));
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java
index b37e695913..765994410e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 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.
@@ -260,6 +260,55 @@ public abstract class AbstractJpaEObject
}
+ // ********** content assist **********
+
+ /**
+ * Return a text range for the specified attribute node.
+ * If the attribute node does not exist, return null
+ *
+ * This is used for content assist to return the exact text range of an attribute.
+ * It is different from the text range used by validation which returns
+ * the parent's text range if the specified attribute node does not exist
+ */
+ protected TextRange getAttributeCodeAssistTextRange(String attributeName) {
+ IDOMNode attributeNode = this.getAttributeNode(attributeName);
+ return (attributeNode != null) ? this.buildTextRange(attributeNode) : null;
+ }
+
+ /**
+ * Return a text range for the specified element node.
+ * If the element node does not exist, return null
+ *
+ * This is used for content assist to return the exact text range of an element.
+ * It is different from the text range used by validation which returns
+ * the parent's text range if the specified element node does not exist
+ */
+ protected TextRange getElementCodeAssistTextRange(String elementName) {
+ IDOMNode elementNode = this.getElementNode(elementName);
+ return (elementNode != null) ? this.buildElementCodeAssistTextRange(elementNode) : null;
+ }
+
+ protected TextRange buildElementCodeAssistTextRange(IDOMNode domNode) {
+ return (domNode == null) ? null : this.buildElementCodeAssistTextRange(domNode, null);
+ }
+
+ protected TextRange buildElementCodeAssistTextRange(IDOMNode domNode, TextRange textRange) {
+ return (domNode == null) ? null : this.buildElementCodeAssistTextRange_(domNode, textRange);
+ }
+ /**
+ * pre-condition: the specified DOM node is not <code>null</code>
+ */
+ protected TextRange buildElementCodeAssistTextRange_(IDOMNode domNode, TextRange textRange) {
+ int offset = domNode.getStartOffset();
+ int length = (domNode.getNodeType() == Node.ELEMENT_NODE) ?
+ (((IDOMElement) domNode).getEndStartOffset() - offset) :
+ domNode.getLength();
+ int lineNumber = domNode.getStructuredDocument().getLineOfOffset(offset) + 1;
+ return (textRange == null) ?
+ new SimpleTextRange(offset, length, lineNumber) :
+ textRange.buildTextRange(offset, length, lineNumber);
+ }
+
// ********** Refactoring TextEdits **********
public DeleteEdit createDeleteEdit() {

Back to the top