Author: dgeraskov
Date: 2009-07-29 10:14:03 -0400 (Wed, 29 Jul 2009)
New Revision: 16874
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/DiscriminatorFormula.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormula.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormulaImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NullDiscriminatorFormulaAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateAbstractInheritanceComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateDiscriminatorColumnComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaInheritanceComposite.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
Log:
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -19,6 +19,7 @@
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotationDefinition;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotationImpl.DiscriminatorFormulaAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceGenericGeneratorsAnnotation.GenericGeneratorsAnnotationDefinition;
@@ -57,6 +58,7 @@
definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
definitions.add(HibernateNamedNativeQueriesAnnotationDefinition.instance());
+ definitions.add(DiscriminatorFormulaAnnotationDefinition.instance());
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -21,12 +21,15 @@
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntityImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryImpl;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaDiscriminatorFormula;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaDiscriminatorFormulaImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
@@ -45,7 +48,7 @@
@Override
public JavaEntity buildJavaEntity(JavaPersistentType parent) {
- return new HibernateJavaEntity(parent);
+ return new HibernateJavaEntityImpl(parent);
}
@Override
@@ -69,4 +72,9 @@
return new HibernateJavaParameter(javaGenericGeneratorImpl);
}
+ public JavaDiscriminatorFormula buildJavaDiscriminatorFormula(
+ HibernateJavaEntity hibernateJavaEntity) {
+ return new JavaDiscriminatorFormulaImpl(hibernateJavaEntity);
+ }
+
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateEntity.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateEntity.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateEntity.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context;
+
+import org.eclipse.jpt.core.context.Entity;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.DiscriminatorFormula;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryContainer;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateEntity extends Entity,
+ GenericGeneratorHolder, HibernateQueryContainer {
+
+ DiscriminatorFormula getDiscriminatorFormula();
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateEntity.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -86,5 +86,7 @@
String CACHE_MODE_TYPE__PUT = CACHE_MODE_TYPE_ + "PUT"; //$NON-NLS-1$
String CACHE_MODE_TYPE__REFRESH = CACHE_MODE_TYPE_ + "REFRESH";
//$NON-NLS-1$
+ String DISCRIMINATOR_FORMULA = PACKAGE_ + "DiscriminatorFormula";
//$NON-NLS-1$
+ String DISCRIMINATOR_FORMULA__VALUE = "value"; //$NON-NLS-1$
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/DiscriminatorFormula.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/DiscriminatorFormula.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/DiscriminatorFormula.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.JpaContextNode;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface DiscriminatorFormula extends JpaContextNode {
+
+ String getValue();
+ void setValue(String value);
+ String VALUE_PROPERTY = "value"; //$NON-NLS-1$
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/DiscriminatorFormula.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -10,370 +10,15 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
+import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateEntity;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaGenerator;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaQuery;
-import org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorsAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
-
/**
* @author Dmitry Geraskov
- *
+ *
*/
-public class HibernateJavaEntity extends AbstractJavaEntity
-implements GenericGeneratorHolder, HibernateQueryContainer {
+public interface HibernateJavaEntity extends HibernateEntity, JavaEntity {
- protected final List<JavaGenericGenerator> genericGenerators;
+ JavaDiscriminatorFormula getDiscriminatorFormula();
- protected final List<HibernateNamedQuery> hibernateNamedQueries;
-
- protected final List<HibernateNamedNativeQuery> hibernateNamedNativeQueries;
-
- public HibernateJavaEntity(JavaPersistentType parent) {
- super(parent);
- this.genericGenerators = new ArrayList<JavaGenericGenerator>();
- this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
- this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
- }
-
- @Override
- public void initialize(JavaResourcePersistentType resourcePersistentType) {
- super.initialize(resourcePersistentType);
- this.initializeGenericGenerators();
- this.initializeHibernateNamedQueries();
- this.initializeHibernateNamedNativeQueries();
- }
-
- @Override
- public void update(JavaResourcePersistentType resourcePersistentType) {
- super.update(resourcePersistentType);
- this.updateGenericGenerators();
- this.updateHibernateNamedQueries();
- this.updateHibernateNamedNativeQueries();
- }
-
- protected HibernateJpaFactory getJpaFactory() {
- return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterator<JavaQuery> queries() {
- return new CompositeIterator<JavaQuery>(
- super.queries(),
- this.hibernateNamedQueries(),
- this.hibernateNamedNativeQueries());
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterator<String> correspondingAnnotationNames() {
- return new CompositeIterator<String>(
- new ArrayIterator<String>(
- Hibernate.GENERIC_GENERATOR,
- Hibernate.GENERIC_GENERATORS,
- Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES,
- Hibernate.NAMED_NATIVE_QUERY,
- Hibernate.NAMED_NATIVE_QUERIES),
- super.correspondingAnnotationNames());
- }
-
- // ********************* GenericGenerators **************
-
- public GenericGenerator addGenericGenerator(int index) {
- JavaGenericGenerator newGenericGenerator =
getJpaFactory().buildJavaGenericGenerator(this);
- this.genericGenerators.add(newGenericGenerator);
- GenericGeneratorAnnotation genericGeneratorAnnotation =
(GenericGeneratorAnnotation)this.javaResourcePersistentType
- .addSupportingAnnotation(index, GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
- newGenericGenerator.initialize(genericGeneratorAnnotation);
- fireItemAdded(GENERIC_GENERATORS_LIST, index, newGenericGenerator);
- return newGenericGenerator;
- }
-
- protected void addGenericGenerator(JavaGenericGenerator genericGenerator) {
- this.addGenericGenerator(genericGeneratorsSize(), genericGenerator);
- }
-
- protected void addGenericGenerator(int index, JavaGenericGenerator genericGenerator) {
- addItemToList(index, genericGenerator, this.genericGenerators,
GENERIC_GENERATORS_LIST);
- }
-
- @SuppressWarnings("unchecked")
- public ListIterator<JavaGenericGenerator> genericGenerators() {
- return new CloneListIterator<JavaGenericGenerator>(genericGenerators);
- }
-
- public int genericGeneratorsSize() {
- return this.genericGenerators.size();
- }
-
- public void moveGenericGenerator(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.genericGenerators, targetIndex, sourceIndex);
- this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
GenericGeneratorAnnotation.ANNOTATION_NAME);
- fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
- }
-
- public void removeGenericGenerator(int index) {
- JavaGenericGenerator removedGenericGenerator = this.genericGenerators.remove(index);
- this.javaResourcePersistentType.removeSupportingAnnotation(index,
GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME);
- fireItemRemoved(GENERIC_GENERATORS_LIST, index, removedGenericGenerator);
- }
-
- public void removeGenericGenerator(GenericGenerator generator) {
- removeGenericGenerator(this.genericGenerators.indexOf(generator));
- }
-
- protected void removeGenericGenerator_(JavaGenericGenerator generator) {
- removeItemFromList(generator, this.genericGenerators, GENERIC_GENERATORS_LIST);
- }
-
- protected void initializeGenericGenerators() {
- for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
- this.genericGenerators.add(buildGenericGenerator((GenericGeneratorAnnotation)
stream.next()));
- }
- }
-
- protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
- JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
- generator.initialize(genericGeneratorResource);
- return generator;
- }
-
- @Override
- protected void addGeneratorsTo(ArrayList<JavaGenerator> generators) {
- super.addGeneratorsTo(generators);
- for (JavaGenericGenerator genericGenerator : genericGenerators) {
- generators.add(genericGenerator);
- }
- }
-
- protected void updateGenericGenerators() {
- ListIterator<JavaGenericGenerator> genericGenerators = genericGenerators();
- ListIterator<NestableAnnotation> resourceGenericGenerators =
this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
-
- while (genericGenerators.hasNext()) {
- JavaGenericGenerator genericGenerator = genericGenerators.next();
- if (resourceGenericGenerators.hasNext()) {
- genericGenerator.update((GenericGeneratorAnnotation)
resourceGenericGenerators.next());
- }
- else {
- removeGenericGenerator_(genericGenerator);
- }
- }
-
- while (resourceGenericGenerators.hasNext()) {
- addGenericGenerator(buildGenericGenerator((GenericGeneratorAnnotation)
resourceGenericGenerators.next()));
- }
- }
- // ********************* NamedQuery **************
- public ListIterator<HibernateNamedQuery> hibernateNamedQueries() {
- return new CloneListIterator<HibernateNamedQuery>(this.hibernateNamedQueries);
- }
-
- public int hibernateNamedQueriesSize() {
- return this.hibernateNamedQueries.size();
- }
-
- protected void initializeHibernateNamedQueries() {
- for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
- this.hibernateNamedQueries.add(buildHibernateNamedQuery((HibernateNamedQueryAnnotation)
stream.next()));
- }
- }
-
- protected HibernateNamedQuery buildHibernateNamedQuery(HibernateNamedQueryAnnotation
namedQueryResource) {
- HibernateNamedQuery hibernateNamedQuery =
getJpaFactory().buildHibernateNamedQuery(this);
- hibernateNamedQuery.initialize(namedQueryResource);
- return hibernateNamedQuery;
- }
-
- protected void updateHibernateNamedQueries() {
- ListIterator<HibernateNamedQuery> queries = hibernateNamedQueries();
- ListIterator<NestableAnnotation> resourceNamedQueries =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
-
- while (queries.hasNext()) {
- HibernateNamedQuery hibernateNamedQuery = queries.next();
- if (resourceNamedQueries.hasNext()) {
- hibernateNamedQuery.update((HibernateNamedQueryAnnotation)
resourceNamedQueries.next());
- }
- else {
- removeHibernateNamedQuery_(hibernateNamedQuery);
- }
- }
-
- while (resourceNamedQueries.hasNext()) {
- addHibernateNamedQuery(buildHibernateNamedQuery((HibernateNamedQueryAnnotation)
resourceNamedQueries.next()));
- }
- }
-
- public HibernateNamedQuery addHibernateNamedQuery(int index) {
- HibernateNamedQuery hibernateNamedQuery =
getJpaFactory().buildHibernateNamedQuery(this);
- this.hibernateNamedQueries.add(index, hibernateNamedQuery);
- HibernateNamedQueryAnnotation hibernateNamedQueryAnnotation =
(HibernateNamedQueryAnnotation) this.javaResourcePersistentType
- .addSupportingAnnotation(index, HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- hibernateNamedQuery.initialize(hibernateNamedQueryAnnotation);
- fireItemAdded(HIBERNATE_NAMED_QUERIES_LIST, index, hibernateNamedQuery);
- return hibernateNamedQuery;
- }
-
- protected void addHibernateNamedQuery(int index, HibernateNamedQuery
hibernateNamedQuery) {
- addItemToList(index, hibernateNamedQuery, this.hibernateNamedQueries,
HIBERNATE_NAMED_QUERIES_LIST);
- }
-
- protected void addHibernateNamedQuery(HibernateNamedQuery hibernateNamedQuery) {
- this.addHibernateNamedQuery(this.hibernateNamedQueries.size(), hibernateNamedQuery);
- }
-
- public void removeHibernateNamedQuery(HibernateNamedQuery hibernateNamedQuery) {
- removeHibernateNamedQuery(this.hibernateNamedQueries.indexOf(hibernateNamedQuery));
- }
-
- public void removeHibernateNamedQuery(int index) {
- HibernateNamedQuery removedHibernateNamedQuery =
this.hibernateNamedQueries.remove(index);
- this.javaResourcePersistentType.removeSupportingAnnotation(index,
HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- fireItemRemoved(HIBERNATE_NAMED_QUERIES_LIST, index, removedHibernateNamedQuery);
- }
-
- protected void removeHibernateNamedQuery_(HibernateNamedQuery hibernateNamedQuery) {
- removeItemFromList(hibernateNamedQuery, this.hibernateNamedQueries,
HIBERNATE_NAMED_QUERIES_LIST);
- }
-
- public void moveHibernateNamedQuery(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.hibernateNamedQueries, targetIndex, sourceIndex);
- this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- fireItemMoved(HIBERNATE_NAMED_QUERIES_LIST, targetIndex, sourceIndex);
- }
-
- // ********************* NamedNativeQuery **************
- public ListIterator<HibernateNamedNativeQuery> hibernateNamedNativeQueries() {
- return new
CloneListIterator<HibernateNamedNativeQuery>(this.hibernateNamedNativeQueries);
- }
-
- public int hibernateNamedNativeQueriesSize() {
- return this.hibernateNamedNativeQueries.size();
- }
-
- protected void initializeHibernateNamedNativeQueries() {
- for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
- this.hibernateNamedNativeQueries.add(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
stream.next()));
- }
- }
-
- protected HibernateNamedNativeQuery
buildHibernateNamedNativeQuery(HibernateNamedNativeQueryAnnotation namedQueryResource) {
- HibernateNamedNativeQuery hibernateNamedNativeQuery =
getJpaFactory().buildHibernateNamedNativeQuery(this);
- hibernateNamedNativeQuery.initialize(namedQueryResource);
- return hibernateNamedNativeQuery;
- }
-
- protected void updateHibernateNamedNativeQueries() {
- ListIterator<HibernateNamedNativeQuery> queries = hibernateNamedNativeQueries();
- ListIterator<NestableAnnotation> resourceNamedNativeQueries =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
-
- while (queries.hasNext()) {
- HibernateNamedNativeQuery hibernateNamedNativeQuery = queries.next();
- if (resourceNamedNativeQueries.hasNext()) {
- hibernateNamedNativeQuery.update((HibernateNamedNativeQueryAnnotation)
resourceNamedNativeQueries.next());
- }
- else {
- removeHibernateNamedNativeQuery_(hibernateNamedNativeQuery);
- }
- }
-
- while (resourceNamedNativeQueries.hasNext()) {
- Object test = resourceNamedNativeQueries.next();
- if (!(test instanceof HibernateNamedNativeQueryAnnotation)){
- System.out.println("error!");//$NON-NLS-1$
- }
- addHibernateNamedNativeQuery(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
test));
- }
- }
-
- public HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index) {
- HibernateNamedNativeQuery hibernateNamedNativeQuery =
getJpaFactory().buildHibernateNamedNativeQuery(this);
- this.hibernateNamedNativeQueries.add(index, hibernateNamedNativeQuery);
- HibernateNamedNativeQueryAnnotation hibernateNamedNativeQueryAnnotation =
(HibernateNamedNativeQueryAnnotation) this.javaResourcePersistentType
- .addSupportingAnnotation(index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- hibernateNamedNativeQuery.initialize(hibernateNamedNativeQueryAnnotation);
- fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, hibernateNamedNativeQuery);
- return hibernateNamedNativeQuery;
- }
-
- protected void addHibernateNamedNativeQuery(int index, HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
- addItemToList(index, hibernateNamedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
- }
-
- protected void addHibernateNamedNativeQuery(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
- this.addHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size(),
hibernateNamedNativeQuery);
- }
-
- public void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
- removeHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.indexOf(hibernateNamedNativeQuery));
- }
-
- public void removeHibernateNamedNativeQuery(int index) {
- HibernateNamedNativeQuery removedHibernateNamedNativeQuery =
this.hibernateNamedNativeQueries.remove(index);
- this.javaResourcePersistentType.removeSupportingAnnotation(index,
HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index,
removedHibernateNamedNativeQuery);
- }
-
- protected void removeHibernateNamedNativeQuery_(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
- removeItemFromList(hibernateNamedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
- }
-
- public void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex, sourceIndex);
- this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
- }
-
- // ************************* validation ***********************
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
- super.validate(messages, reporter, astRoot);
- validateGenericGenerator(messages, reporter, astRoot);
- }
-
- protected void validateGenericGenerator(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
- for (JavaGenericGenerator genericGenerator : genericGenerators) {
- genericGenerator.validate(messages, reporter, astRoot);
- }
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String>
filter,
- CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaGenericGenerator genericGenerator : genericGenerators) {
- result = genericGenerator.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
(from rev 16747,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,400 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaGenerator;
+import org.eclipse.jpt.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.core.context.java.JavaQuery;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.utility.Filter;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorsAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaEntityImpl extends AbstractJavaEntity
+implements HibernateJavaEntity {
+
+ protected JavaDiscriminatorFormula discriminatorFormula;
+
+ protected final List<JavaGenericGenerator> genericGenerators;
+
+ protected final List<HibernateNamedQuery> hibernateNamedQueries;
+
+ protected final List<HibernateNamedNativeQuery> hibernateNamedNativeQueries;
+
+ public HibernateJavaEntityImpl(JavaPersistentType parent) {
+ super(parent);
+ this.discriminatorFormula = getJpaFactory().buildJavaDiscriminatorFormula(this);
+ this.genericGenerators = new ArrayList<JavaGenericGenerator>();
+ this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
+ this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
+ }
+
+ @Override
+ public void initialize(JavaResourcePersistentType resourcePersistentType) {
+ super.initialize(resourcePersistentType);
+ this.discriminatorFormula.initialize(getDiscriminatorFormulaResource(resourcePersistentType));
+ this.initializeGenericGenerators();
+ this.initializeHibernateNamedQueries();
+ this.initializeHibernateNamedNativeQueries();
+ }
+
+ @Override
+ public void update(JavaResourcePersistentType resourcePersistentType) {
+ super.update(resourcePersistentType);
+ this.updateDiscriminatorFormula();
+ this.updateGenericGenerators();
+ this.updateHibernateNamedQueries();
+ this.updateHibernateNamedNativeQueries();
+ }
+
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator<JavaQuery> queries() {
+ return new CompositeIterator<JavaQuery>(
+ super.queries(),
+ this.hibernateNamedQueries(),
+ this.hibernateNamedNativeQueries());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator<String> correspondingAnnotationNames() {
+ return new CompositeIterator<String>(
+ new ArrayIterator<String>(
+ Hibernate.GENERIC_GENERATOR,
+ Hibernate.GENERIC_GENERATORS,
+ Hibernate.NAMED_QUERY,
+ Hibernate.NAMED_QUERIES,
+ Hibernate.NAMED_NATIVE_QUERY,
+ Hibernate.NAMED_NATIVE_QUERIES,
+ Hibernate.DISCRIMINATOR_FORMULA),
+ super.correspondingAnnotationNames());
+ }
+
+ // ********************* DiscriminatorFormula **************
+
+ public JavaDiscriminatorFormula getDiscriminatorFormula() {
+ return this.discriminatorFormula;
+ }
+
+ private void updateDiscriminatorFormula() {
+ getDiscriminatorFormula().update(getDiscriminatorFormulaResource(this.javaResourcePersistentType));
+ }
+
+ public DiscriminatorFormulaAnnotation
getDiscriminatorFormulaResource(JavaResourcePersistentType resourcePersistentType) {
+ return (DiscriminatorFormulaAnnotation)
resourcePersistentType.getNonNullSupportingAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
+ }
+
+ // ********************* GenericGenerators **************
+
+ public GenericGenerator addGenericGenerator(int index) {
+ JavaGenericGenerator newGenericGenerator =
getJpaFactory().buildJavaGenericGenerator(this);
+ this.genericGenerators.add(newGenericGenerator);
+ GenericGeneratorAnnotation genericGeneratorAnnotation =
(GenericGeneratorAnnotation)this.javaResourcePersistentType
+ .addSupportingAnnotation(index, GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
+ newGenericGenerator.initialize(genericGeneratorAnnotation);
+ fireItemAdded(GENERIC_GENERATORS_LIST, index, newGenericGenerator);
+ return newGenericGenerator;
+ }
+
+ protected void addGenericGenerator(JavaGenericGenerator genericGenerator) {
+ this.addGenericGenerator(genericGeneratorsSize(), genericGenerator);
+ }
+
+ protected void addGenericGenerator(int index, JavaGenericGenerator genericGenerator) {
+ addItemToList(index, genericGenerator, this.genericGenerators,
GENERIC_GENERATORS_LIST);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ListIterator<JavaGenericGenerator> genericGenerators() {
+ return new CloneListIterator<JavaGenericGenerator>(genericGenerators);
+ }
+
+ public int genericGeneratorsSize() {
+ return this.genericGenerators.size();
+ }
+
+ public void moveGenericGenerator(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.genericGenerators, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
GenericGeneratorAnnotation.ANNOTATION_NAME);
+ fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
+ }
+
+ public void removeGenericGenerator(int index) {
+ JavaGenericGenerator removedGenericGenerator = this.genericGenerators.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index,
GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(GENERIC_GENERATORS_LIST, index, removedGenericGenerator);
+ }
+
+ public void removeGenericGenerator(GenericGenerator generator) {
+ removeGenericGenerator(this.genericGenerators.indexOf(generator));
+ }
+
+ protected void removeGenericGenerator_(JavaGenericGenerator generator) {
+ removeItemFromList(generator, this.genericGenerators, GENERIC_GENERATORS_LIST);
+ }
+
+ protected void initializeGenericGenerators() {
+ for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.genericGenerators.add(buildGenericGenerator((GenericGeneratorAnnotation)
stream.next()));
+ }
+ }
+
+ protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
+ JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
+ generator.initialize(genericGeneratorResource);
+ return generator;
+ }
+
+ @Override
+ protected void addGeneratorsTo(ArrayList<JavaGenerator> generators) {
+ super.addGeneratorsTo(generators);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ generators.add(genericGenerator);
+ }
+ }
+
+ protected void updateGenericGenerators() {
+ ListIterator<JavaGenericGenerator> genericGenerators = genericGenerators();
+ ListIterator<NestableAnnotation> resourceGenericGenerators =
this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
+
+ while (genericGenerators.hasNext()) {
+ JavaGenericGenerator genericGenerator = genericGenerators.next();
+ if (resourceGenericGenerators.hasNext()) {
+ genericGenerator.update((GenericGeneratorAnnotation)
resourceGenericGenerators.next());
+ }
+ else {
+ removeGenericGenerator_(genericGenerator);
+ }
+ }
+
+ while (resourceGenericGenerators.hasNext()) {
+ addGenericGenerator(buildGenericGenerator((GenericGeneratorAnnotation)
resourceGenericGenerators.next()));
+ }
+ }
+ // ********************* NamedQuery **************
+ public ListIterator<HibernateNamedQuery> hibernateNamedQueries() {
+ return new CloneListIterator<HibernateNamedQuery>(this.hibernateNamedQueries);
+ }
+
+ public int hibernateNamedQueriesSize() {
+ return this.hibernateNamedQueries.size();
+ }
+
+ protected void initializeHibernateNamedQueries() {
+ for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.hibernateNamedQueries.add(buildHibernateNamedQuery((HibernateNamedQueryAnnotation)
stream.next()));
+ }
+ }
+
+ protected HibernateNamedQuery buildHibernateNamedQuery(HibernateNamedQueryAnnotation
namedQueryResource) {
+ HibernateNamedQuery hibernateNamedQuery =
getJpaFactory().buildHibernateNamedQuery(this);
+ hibernateNamedQuery.initialize(namedQueryResource);
+ return hibernateNamedQuery;
+ }
+
+ protected void updateHibernateNamedQueries() {
+ ListIterator<HibernateNamedQuery> queries = hibernateNamedQueries();
+ ListIterator<NestableAnnotation> resourceNamedQueries =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
+
+ while (queries.hasNext()) {
+ HibernateNamedQuery hibernateNamedQuery = queries.next();
+ if (resourceNamedQueries.hasNext()) {
+ hibernateNamedQuery.update((HibernateNamedQueryAnnotation)
resourceNamedQueries.next());
+ }
+ else {
+ removeHibernateNamedQuery_(hibernateNamedQuery);
+ }
+ }
+
+ while (resourceNamedQueries.hasNext()) {
+ addHibernateNamedQuery(buildHibernateNamedQuery((HibernateNamedQueryAnnotation)
resourceNamedQueries.next()));
+ }
+ }
+
+ public HibernateNamedQuery addHibernateNamedQuery(int index) {
+ HibernateNamedQuery hibernateNamedQuery =
getJpaFactory().buildHibernateNamedQuery(this);
+ this.hibernateNamedQueries.add(index, hibernateNamedQuery);
+ HibernateNamedQueryAnnotation hibernateNamedQueryAnnotation =
(HibernateNamedQueryAnnotation) this.javaResourcePersistentType
+ .addSupportingAnnotation(index, HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
+ hibernateNamedQuery.initialize(hibernateNamedQueryAnnotation);
+ fireItemAdded(HIBERNATE_NAMED_QUERIES_LIST, index, hibernateNamedQuery);
+ return hibernateNamedQuery;
+ }
+
+ protected void addHibernateNamedQuery(int index, HibernateNamedQuery
hibernateNamedQuery) {
+ addItemToList(index, hibernateNamedQuery, this.hibernateNamedQueries,
HIBERNATE_NAMED_QUERIES_LIST);
+ }
+
+ protected void addHibernateNamedQuery(HibernateNamedQuery hibernateNamedQuery) {
+ this.addHibernateNamedQuery(this.hibernateNamedQueries.size(), hibernateNamedQuery);
+ }
+
+ public void removeHibernateNamedQuery(HibernateNamedQuery hibernateNamedQuery) {
+ removeHibernateNamedQuery(this.hibernateNamedQueries.indexOf(hibernateNamedQuery));
+ }
+
+ public void removeHibernateNamedQuery(int index) {
+ HibernateNamedQuery removedHibernateNamedQuery =
this.hibernateNamedQueries.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index,
HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(HIBERNATE_NAMED_QUERIES_LIST, index, removedHibernateNamedQuery);
+ }
+
+ protected void removeHibernateNamedQuery_(HibernateNamedQuery hibernateNamedQuery) {
+ removeItemFromList(hibernateNamedQuery, this.hibernateNamedQueries,
HIBERNATE_NAMED_QUERIES_LIST);
+ }
+
+ public void moveHibernateNamedQuery(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.hibernateNamedQueries, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
+ fireItemMoved(HIBERNATE_NAMED_QUERIES_LIST, targetIndex, sourceIndex);
+ }
+
+ // ********************* NamedNativeQuery **************
+ public ListIterator<HibernateNamedNativeQuery> hibernateNamedNativeQueries() {
+ return new
CloneListIterator<HibernateNamedNativeQuery>(this.hibernateNamedNativeQueries);
+ }
+
+ public int hibernateNamedNativeQueriesSize() {
+ return this.hibernateNamedNativeQueries.size();
+ }
+
+ protected void initializeHibernateNamedNativeQueries() {
+ for (ListIterator<NestableAnnotation> stream =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.hibernateNamedNativeQueries.add(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
stream.next()));
+ }
+ }
+
+ protected HibernateNamedNativeQuery
buildHibernateNamedNativeQuery(HibernateNamedNativeQueryAnnotation namedQueryResource) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery =
getJpaFactory().buildHibernateNamedNativeQuery(this);
+ hibernateNamedNativeQuery.initialize(namedQueryResource);
+ return hibernateNamedNativeQuery;
+ }
+
+ protected void updateHibernateNamedNativeQueries() {
+ ListIterator<HibernateNamedNativeQuery> queries = hibernateNamedNativeQueries();
+ ListIterator<NestableAnnotation> resourceNamedNativeQueries =
this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+
+ while (queries.hasNext()) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery = queries.next();
+ if (resourceNamedNativeQueries.hasNext()) {
+ hibernateNamedNativeQuery.update((HibernateNamedNativeQueryAnnotation)
resourceNamedNativeQueries.next());
+ }
+ else {
+ removeHibernateNamedNativeQuery_(hibernateNamedNativeQuery);
+ }
+ }
+
+ while (resourceNamedNativeQueries.hasNext()) {
+ Object test = resourceNamedNativeQueries.next();
+ if (!(test instanceof HibernateNamedNativeQueryAnnotation)){
+ System.out.println("error!");//$NON-NLS-1$
+ }
+ addHibernateNamedNativeQuery(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
test));
+ }
+ }
+
+ public HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery =
getJpaFactory().buildHibernateNamedNativeQuery(this);
+ this.hibernateNamedNativeQueries.add(index, hibernateNamedNativeQuery);
+ HibernateNamedNativeQueryAnnotation hibernateNamedNativeQueryAnnotation =
(HibernateNamedNativeQueryAnnotation) this.javaResourcePersistentType
+ .addSupportingAnnotation(index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ hibernateNamedNativeQuery.initialize(hibernateNamedNativeQueryAnnotation);
+ fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, hibernateNamedNativeQuery);
+ return hibernateNamedNativeQuery;
+ }
+
+ protected void addHibernateNamedNativeQuery(int index, HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ addItemToList(index, hibernateNamedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ }
+
+ protected void addHibernateNamedNativeQuery(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ this.addHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size(),
hibernateNamedNativeQuery);
+ }
+
+ public void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ removeHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.indexOf(hibernateNamedNativeQuery));
+ }
+
+ public void removeHibernateNamedNativeQuery(int index) {
+ HibernateNamedNativeQuery removedHibernateNamedNativeQuery =
this.hibernateNamedNativeQueries.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index,
HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index,
removedHibernateNamedNativeQuery);
+ }
+
+ protected void removeHibernateNamedNativeQuery_(HibernateNamedNativeQuery
hibernateNamedNativeQuery) {
+ removeItemFromList(hibernateNamedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ }
+
+ public void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
+ }
+
+ // ************************* validation ***********************
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
+ super.validate(messages, reporter, astRoot);
+ validateGenericGenerator(messages, reporter, astRoot);
+ }
+
+ protected void validateGenericGenerator(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ genericGenerator.validate(messages, reporter, astRoot);
+ }
+ }
+
+ @Override
+ public Iterator<String> javaCompletionProposals(int pos, Filter<String>
filter,
+ CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ result = genericGenerator.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormula.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormula.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormula.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaDiscriminatorFormula extends DiscriminatorFormula {
+
+ void initialize(DiscriminatorFormulaAnnotation dfResource);
+
+ /**
+ * Update the JavaParameter context model object to match the
DiscriminatorFormulaAnnotation
+ * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
+ */
+ void update(DiscriminatorFormulaAnnotation dfResource);
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormula.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormulaImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormulaImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormulaImpl.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.JpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.core.utility.TextRange;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class JavaDiscriminatorFormulaImpl extends AbstractJavaJpaContextNode implements
JavaDiscriminatorFormula {
+
+ protected String value;
+
+ protected DiscriminatorFormulaAnnotation dfResource;
+
+ public JavaDiscriminatorFormulaImpl(JpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(DiscriminatorFormulaAnnotation dfResource) {
+ this.dfResource = dfResource;
+ this.value = dfResource.getValue();
+ }
+
+ public void update(DiscriminatorFormulaAnnotation dfResource) {
+ this.dfResource = dfResource;
+ this.setValue(dfResource.getValue());
+ }
+
+ //******************* value *********************
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String newValue) {
+ String oldValue = this.value;
+ this.value = newValue;
+ this.dfResource.setValue(newValue);
+ firePropertyChanged(Parameter.VALUE_PROPERTY, oldValue, newValue);
+ }
+
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.dfResource.getTextRange(astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.value);
+ }
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaDiscriminatorFormulaImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotation.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface DiscriminatorFormulaAnnotation extends Annotation {
+ String ANNOTATION_NAME = Hibernate.DISCRIMINATOR_FORMULA;
+
+ /**
+ * Corresponds to the 'value' element of the DiscriminatorFormulaAnnotation
annotation.
+ * Return null if the element does not exist in the annotation
+ */
+ String getValue();
+ String VALUE_PROPERTY = Hibernate.DISCRIMINATOR_FORMULA__VALUE;
+
+ /**
+ * Corresponds to the 'value' element of the DiscriminatorFormulaAnnotation
annotation.
+ * Setting to null will remove the element.
+ */
+ void setValue(String value);
+
+ /**
+ * Return the {@link TextRange} for the 'value' element.
+ */
+ TextRange getValueTextRange(CompilationUnit astRoot);
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotationImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotationImpl.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.core.utility.jdt.Type;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class DiscriminatorFormulaAnnotationImpl extends SourceAnnotation<Type>
implements
+ DiscriminatorFormulaAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER =
buildValueAdapter(DECLARATION_ANNOTATION_ADAPTER);
+ private final AnnotationElementAdapter<String> valueAdapter;
+ private String value;
+
+ protected DiscriminatorFormulaAnnotationImpl(JavaResourceNode parent, Type type) {
+ super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
+ this.valueAdapter = this.buildAdapter(VALUE_ADAPTER);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.value = this.buildValue(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setValue(this.buildValue(astRoot));
+ }
+
+ // ***** value
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ if (this.attributeValueHasNotChanged(this.value, value)) {
+ return;
+ }
+ String old = this.value;
+ this.value = value;
+ this.valueAdapter.setValue(value);
+ this.firePropertyChanged(VALUE_PROPERTY, old, value);
+ }
+
+ private String buildValue(CompilationUnit astRoot) {
+ return this.valueAdapter.getValue(astRoot);
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(VALUE_ADAPTER, astRoot);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ AnnotationElementAdapter<String>
buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ private static DeclarationAnnotationElementAdapter<String>
buildValueAdapter(DeclarationAnnotationAdapter adapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter,
VALUE_PROPERTY);
+ }
+
+
+ public static class DiscriminatorFormulaAnnotationDefinition implements
AnnotationDefinition
+ {
+ // singleton
+ private static final DiscriminatorFormulaAnnotationDefinition INSTANCE = new
DiscriminatorFormulaAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private DiscriminatorFormulaAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member type) {
+ return new DiscriminatorFormulaAnnotationImpl(parent, (Type) type);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Type type)
{
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return DiscriminatorFormulaAnnotation.ANNOTATION_NAME;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember arg0,
+ IAnnotation arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ return new NullDiscriminatorFormulaAnnotation((JavaResourcePersistentType) parent);
+ }
+
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotationImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NullDiscriminatorFormulaAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NullDiscriminatorFormulaAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NullDiscriminatorFormulaAnnotation.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.NullAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class NullDiscriminatorFormulaAnnotation extends NullAnnotation implements
+ DiscriminatorFormulaAnnotation {
+
+ public NullDiscriminatorFormulaAnnotation(JavaResourcePersistentType parent) {
+ super(parent);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ protected DiscriminatorFormulaAnnotation buildSupportingAnnotation() {
+ return (DiscriminatorFormulaAnnotation) super.buildSupportingAnnotation();
+ }
+
+ // ***** value
+ public String getValue() {
+ return null;
+ }
+
+ public void setValue(String value) {
+ if (value != null) {
+ this.buildSupportingAnnotation().setValue(value);
+ }
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NullDiscriminatorFormulaAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -28,7 +28,7 @@
/**
* Return the {@link TextRange} for the 'name' element. If the element
- * does not exist return the {@link TextRange} for the QueryHint annotation.
+ * does not exist return the {@link TextRange} for the ParameterAnnotation annotation.
*/
TextRange getNameTextRange(CompilationUnit astRoot);
@@ -48,7 +48,7 @@
/**
* Return the {@link TextRange} for the 'value' element. If the element
- * does not exist return the {@link TextRange} for the QueryHint annotation.
+ * does not exist return the {@link TextRange} for the ParameterAnnotation annotation.
*/
TextRange getValueTextRange(CompilationUnit astRoot);
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateAbstractInheritanceComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateAbstractInheritanceComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateAbstractInheritanceComposite.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ * Code copied from
org.eclipse.jpt.ui.internal.mappings.details.AbstractInheritanceComposite
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.core.context.Entity;
+import org.eclipse.jpt.core.context.InheritanceType;
+import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.db.ColumnCombo;
+import org.eclipse.jpt.ui.internal.mappings.details.AbstractEntityComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.AbstractInheritanceComposite;
+import org.eclipse.jpt.ui.internal.util.ControlEnabler;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
+import org.eclipse.jpt.utility.internal.StringConverter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateEntity;
+
+/**
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | ---------------------------------------------------- |
+ * | Strategy: | EnumComboViewer |v| |
+ * | ---------------------------------------------------- |
+ * | ---------------------------------------------------- |
+ * | Value: | I |v| |
+ * | ---------------------------------------------------- |
+ * | |
+ * | > Discriminator Column |
+ * | |
+ * | ---------------------------------------------------- |
+ * | Name: | ColumnCombo |v| |
+ * | ---------------------------------------------------- |
+ * | ---------------------------------------------------- |
+ * | Formula: | Text |v| |
+ * | ---------------------------------------------------- |
+ * | ---------------------------------------------------- |
+ * | Type: | EnumComboViewer |v| |
+ * | ---------------------------------------------------- |
+ * | ---------------------------------------------------- |
+ * | Column Definition: | I | |
+ * | ---------------------------------------------------- |
+ * | ------------- |
+ * | Length: | I |I| |
+ * | ------------- |
+ * | ------------------------------------------------------------------------- |
+ * | | | |
+ * | | PrimaryKeyJoinColumnsComposite | |
+ * | | | |
+ * | ------------------------------------------------------------------------- |
+ *
-----------------------------------------------------------------------------</pre>
+ *
+ * @see Entity
+ * @see AbstractEntityComposite - The parent container
+ * @see ColumnCombo
+ * @see EnumComboViewer
+ * @see PrimaryKeyJoinColumnsComposite
+ *
+ * @version 2.0
+ * @since 2.0
+ */
+@SuppressWarnings("nls")
+public abstract class HibernateAbstractInheritanceComposite<T extends
HibernateEntity> extends FormPane<T> {
+
+ /**
+ * A key used to represent the default value, this is required to convert
+ * the selected item from a combo to <code>null</code>. This key is most
+ * likely never typed the user and it will help to convert the value to
+ * <code>null</code> when it's time to set the new selected value into
the
+ * model.
+ */
+ protected static String DEFAULT_KEY = "?!#!?#?#?default?#?!#?!#?";
+
+ protected static String NONE_KEY = "?!#!?#?#?none?#?!#?!#?";
+
+ /**
+ * Creates a new <code>InheritanceComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public HibernateAbstractInheritanceComposite(FormPane<? extends T> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent, false);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ int groupBoxMargin = getGroupBoxMargin();
+
+ Composite subPane = addSubPane(
+ container, 0, groupBoxMargin, 0, groupBoxMargin
+ );
+
+ // Strategy widgets
+ addLabeledComposite(
+ subPane,
+ JptUiMappingsMessages.InheritanceComposite_strategy,
+ addStrategyCombo(subPane),
+ JpaHelpContextIds.ENTITY_INHERITANCE_STRATEGY
+ );
+
+ // Discrinator Value widgets
+ CCombo discriminatorValueCombo = addEditableCCombo(
+ subPane,
+ buildDiscriminatorValueListHolder(),
+ buildDiscriminatorValueHolder(),
+ buildDiscriminatorValueConverter()
+ );
+ Label discriminatorValueLabel = addLabel(
+ subPane,
+ JptUiMappingsMessages.InheritanceComposite_discriminatorValue
+ );
+ addLabeledComposite(
+ subPane,
+ discriminatorValueLabel,
+ discriminatorValueCombo.getParent(),
+ null,
+ JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_VALUE
+ );
+
+ new ControlEnabler(buildDiscriminatorValueEnabledHolder(), discriminatorValueCombo,
discriminatorValueLabel);
+
+ new HibernateDiscriminatorColumnComposite<HibernateEntity>(this, container);
+
+ // Primary Key Join Columns widgets
+ addPrimaryKeyJoinColumnsComposite(addSubPane(container, 5));
+ }
+
+ protected WritablePropertyValueModel<Boolean>
buildDiscriminatorValueEnabledHolder() {
+ return new PropertyAspectAdapter<Entity, Boolean>(getSubjectHolder(),
Entity.SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.specifiedDiscriminatorValueIsAllowed());
+ }
+ };
+ }
+
+ private ListValueModel<String> buildDefaultDiscriminatorListValueHolder() {
+ return new PropertyListValueModelAdapter<String>(
+ buildDefaultDiscriminatorValueHolder()
+ );
+ }
+
+ private WritablePropertyValueModel<String> buildDefaultDiscriminatorValueHolder()
{
+ return new PropertyAspectAdapter<Entity, String>(getSubjectHolder(),
Entity.DEFAULT_DISCRIMINATOR_VALUE_PROPERTY,
Entity.DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ String value = this.subject.getDefaultDiscriminatorValue();
+ if (value == null && this.subject.discriminatorValueIsUndefined()) {
+ return NONE_KEY;
+ }
+
+ if (value == null) {
+ value = DEFAULT_KEY;
+ }
+ else {
+ value = DEFAULT_KEY + value;
+ }
+
+ return value;
+ }
+ };
+ }
+
+ private StringConverter<String> buildDiscriminatorValueConverter() {
+ return new StringConverter<String>() {
+ public String convertToString(String value) {
+
+ if (getSubject() == null) {
+ return null;
+ }
+
+ if (value == null) {
+ value = getSubject().getDefaultDiscriminatorValue();
+ if (value == null && getSubject().discriminatorValueIsUndefined()) {
+ value = NONE_KEY;
+ }
+ else {
+ value = (value != null) ?
+ DEFAULT_KEY + value
+ :
+ DEFAULT_KEY;
+ }
+ }
+ if (value.startsWith(DEFAULT_KEY)) {
+ String defaultName = value.substring(DEFAULT_KEY.length());
+
+ if (defaultName.length() > 0) {
+ value = NLS.bind(
+ JptUiMappingsMessages.DefaultWithOneParam,
+ defaultName
+ );
+ }
+ else {
+ value = JptUiMappingsMessages.ProviderDefault;
+ }
+ }
+ if (value.startsWith(NONE_KEY)) {
+ value = JptUiMappingsMessages.NoneSelected;
+ }
+ return value;
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildDiscriminatorValueHolder() {
+ return new PropertyAspectAdapter<Entity, String>(getSubjectHolder(),
Entity.SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getSpecifiedDiscriminatorValue();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+
+ // Convert the default value or an empty string to null
+ if ((value != null) &&
+ ((value.length() == 0) || value.startsWith(DEFAULT_KEY) ||
value.startsWith(NONE_KEY))) {
+
+ value = null;
+ }
+
+ this.subject.setSpecifiedDiscriminatorValue(value);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildDiscriminatorValueListHolder() {
+ return buildDefaultDiscriminatorListValueHolder();
+ }
+
+ private EnumFormComboViewer<Entity, InheritanceType> addStrategyCombo(Composite
container) {
+
+ return new EnumFormComboViewer<Entity, InheritanceType>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(Entity.DEFAULT_INHERITANCE_STRATEGY_PROPERTY);
+ propertyNames.add(Entity.SPECIFIED_INHERITANCE_STRATEGY_PROPERTY);
+ }
+
+ @Override
+ protected InheritanceType[] getChoices() {
+ return InheritanceType.values();
+ }
+
+ @Override
+ protected InheritanceType getDefaultValue() {
+ return getSubject().getDefaultInheritanceStrategy();
+ }
+
+ @Override
+ protected String displayString(InheritanceType value) {
+ return buildDisplayString(
+ JptUiMappingsMessages.class,
+ AbstractInheritanceComposite.class,
+ value
+ );
+ }
+
+ @Override
+ protected InheritanceType getValue() {
+ return getSubject().getSpecifiedInheritanceStrategy();
+ }
+
+ @Override
+ protected void setValue(InheritanceType value) {
+ getSubject().setSpecifiedInheritanceStrategy(value);
+ }
+ };
+ }
+
+ protected abstract void addPrimaryKeyJoinColumnsComposite(Composite container);
+}
\ No newline at end of file
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateAbstractInheritanceComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateDiscriminatorColumnComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateDiscriminatorColumnComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateDiscriminatorColumnComposite.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.core.context.DiscriminatorColumn;
+import org.eclipse.jpt.core.context.DiscriminatorType;
+import org.eclipse.jpt.core.context.Entity;
+import org.eclipse.jpt.core.context.NamedColumn;
+import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.db.ColumnCombo;
+import org.eclipse.jpt.ui.internal.mappings.details.AbstractEntityComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.DiscriminatorColumnComposite;
+import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
+import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.util.PaneEnabler;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateEntity;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.DiscriminatorFormula;
+import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateUIMappingMessages;
+
+/**
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | > Discriminator Column |
+ * | |
+ * | ---------------------------------------------------- |
+ * | Name: | ColumnCombo |v| |
+ * | ---------------------------------------------------- |
+ * | ---------------------------------------------------- |
+ * | Formula: | Text |v| |
+ * | ---------------------------------------------------- |
+ * | ---------------------------------------------------- |
+ * | Type: | EnumComboViewer |v| |
+ * | ---------------------------------------------------- |
+ * | > Details
+ * | ---------------------------------------------------- |
+ * | Column Definition: | I | |
+ * | ---------------------------------------------------- |
+ * | ------------- |
+ * | Length: | I |I| |
+ * | ------------- |
+ *
-----------------------------------------------------------------------------</pre>
+ *
+ * @see Entity
+ * @see AbstractEntityComposite - The parent container
+ * @see ColumnCombo
+ * @see EnumComboViewer
+ * @see PrimaryKeyJoinColumnsComposite
+ *
+ * @version 2.0
+ * @since 2.0
+ */
+public class HibernateDiscriminatorColumnComposite <T extends HibernateEntity>
extends FormPane<T> {
+
+ /**
+ * Creates a new <code>InheritanceComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public HibernateDiscriminatorColumnComposite(FormPane<? extends T> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent, false);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ // Discriminator Column sub-pane
+ Composite discriminatorColumnContainer = addTitledGroup(
+ addSubPane(container, 10),
+ JptUiMappingsMessages.InheritanceComposite_discriminatorColumnGroupBox
+ );
+
+ PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder =
+ buildDiscriminatorColumnHolder();
+
+ // Name widgets
+ addLabeledComposite(
+ discriminatorColumnContainer,
+ JptUiMappingsMessages.DiscriminatorColumnComposite_name,
+ addDiscriminatorColumnCombo(container, discriminatorColumnHolder),
+ JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_COLUMN
+ );
+
+ // Formula widgets
+ addLabeledMultiLineText(
+ discriminatorColumnContainer,
+ HibernateUIMappingMessages.HibernateDiscriminatorColumnComposite_formula,
+ buildDiscriminatorFormulaHolder(),
+ 2,
+ null//TODO help
+ );
+
+ // Discriminator Type widgets
+ addLabeledComposite(
+ discriminatorColumnContainer,
+ JptUiMappingsMessages.DiscriminatorColumnComposite_discriminatorType,
+ addDiscriminatorTypeCombo(container, discriminatorColumnHolder),
+ JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_TYPE
+ );
+
+ container = addCollapsableSubSection(
+ discriminatorColumnContainer,
+ JptUiMappingsMessages.InheritanceComposite_detailsGroupBox,
+ new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
+ );
+
+ new DetailsComposite(this, discriminatorColumnHolder, addSubPane(container, 0, 16));
+
+ new PaneEnabler(buildDiscriminatorColumnEnabledHolder(), this);
+ }
+
+
+ private ColumnCombo<DiscriminatorColumn> addDiscriminatorColumnCombo(
+ Composite container,
+ PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) {
+
+ return new ColumnCombo<DiscriminatorColumn>(
+ this,
+ discriminatorColumnHolder,
+ container)
+ {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(NamedColumn.SPECIFIED_NAME_PROPERTY);
+ propertyNames.add(NamedColumn.DEFAULT_NAME_PROPERTY);
+ }
+
+ @Override
+ protected String getDefaultValue() {
+ return getSubject().getDefaultName();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ getSubject().setSpecifiedName(value);
+ }
+
+ @Override
+ protected Table getDbTable_() {
+ return getSubject().getDbTable();
+ }
+
+ @Override
+ protected String getValue() {
+ return getSubject().getSpecifiedName();
+ }
+
+ @Override
+ protected String buildNullDefaultValueEntry() {
+ return JptUiMappingsMessages.NoneSelected;
+ }
+ };
+ }
+
+
+ private PropertyValueModel<DiscriminatorColumn> buildDiscriminatorColumnHolder()
{
+ return new PropertyAspectAdapter<Entity, DiscriminatorColumn>(getSubjectHolder())
{
+ @Override
+ protected DiscriminatorColumn buildValue_() {
+ return this.subject.getDiscriminatorColumn();
+ }
+ };
+ }
+
+
+ private WritablePropertyValueModel<String> buildDiscriminatorFormulaHolder() {
+ return new PropertyAspectAdapter<HibernateEntity, String>(getSubjectHolder(),
DiscriminatorFormula.VALUE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getDiscriminatorFormula().getValue();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ this.subject.getDiscriminatorFormula().setValue(value);
+ }
+ };
+ }
+
+ private EnumFormComboViewer<DiscriminatorColumn, DiscriminatorType>
addDiscriminatorTypeCombo(
+ Composite container,
+ PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) {
+
+ return new EnumFormComboViewer<DiscriminatorColumn, DiscriminatorType>(
+ this,
+ discriminatorColumnHolder,
+ container)
+ {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE_PROPERTY);
+ propertyNames.add(DiscriminatorColumn.SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY);
+ }
+
+ @Override
+ protected DiscriminatorType[] getChoices() {
+ return DiscriminatorType.values();
+ }
+
+ @Override
+ protected DiscriminatorType getDefaultValue() {
+ return getSubject().getDefaultDiscriminatorType();
+ }
+
+ @Override
+ protected String displayString(DiscriminatorType value) {
+ return buildDisplayString(
+ JptUiMappingsMessages.class,
+ DiscriminatorColumnComposite.class,
+ value
+ );
+ }
+
+ @Override
+ protected String nullDisplayString() {
+ return JptUiMappingsMessages.NoneSelected;
+ }
+
+ @Override
+ protected DiscriminatorType getValue() {
+ return getSubject().getSpecifiedDiscriminatorType();
+ }
+
+ @Override
+ protected void setValue(DiscriminatorType value) {
+ getSubject().setSpecifiedDiscriminatorType(value);
+ }
+ };
+ }
+
+ protected WritablePropertyValueModel<Boolean>
buildDiscriminatorColumnEnabledHolder() {
+ return new PropertyAspectAdapter<Entity, Boolean>(getSubjectHolder(),
Entity.SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.specifiedDiscriminatorColumnIsAllowed());
+ }
+ };
+ }
+
+ protected class DetailsComposite extends FormPane<DiscriminatorColumn> {
+ public DetailsComposite(FormPane<?> parentPane,
+ PropertyValueModel<? extends DiscriminatorColumn> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent, false);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ // Length widgets
+ Spinner lengthSpinner = addLabeledSpinner(
+ container,
+ JptUiMappingsMessages.ColumnComposite_length,
+ buildLengthHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ addDefaultLengthLabel(container),
+ JpaHelpContextIds.MAPPING_COLUMN_LENGTH
+ );
+
+ updateGridData(container, lengthSpinner);
+
+ // Column Definition widgets
+ addLabeledText(
+ container,
+ JptUiMappingsMessages.ColumnComposite_columnDefinition,
+ buildColumnDefinitionHolder(getSubjectHolder())
+ );
+ }
+
+ private WritablePropertyValueModel<Integer> buildLengthHolder() {
+
+ return new PropertyAspectAdapter<DiscriminatorColumn,
Integer>(getSubjectHolder(), DiscriminatorColumn.SPECIFIED_LENGTH_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedLength();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value.intValue() == -1) {
+ value = null;
+ }
+ this.subject.setSpecifiedLength(value);
+ }
+ };
+ }
+
+ private Control addDefaultLengthLabel(Composite container) {
+
+ Label label = addLabel(
+ container,
+ JptUiMappingsMessages.DefaultEmpty
+ );
+
+ new LabeledControlUpdater(
+ new LabeledLabel(label),
+ buildDefaultLengthLabelHolder()
+ );
+
+ return label;
+ }
+
+ private PropertyValueModel<String> buildDefaultLengthLabelHolder() {
+
+ return new TransformationPropertyValueModel<Integer,
String>(buildDefaultLengthHolder()) {
+
+ @Override
+ protected String transform(Integer value) {
+
+ int defaultValue = (getSubject() != null) ? getSubject().getDefaultLength() :
+ DiscriminatorColumn.DEFAULT_LENGTH;
+
+ return NLS.bind(
+ JptUiMappingsMessages.DefaultWithOneParam,
+ Integer.valueOf(defaultValue)
+ );
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Integer> buildDefaultLengthHolder() {
+ return new PropertyAspectAdapter<DiscriminatorColumn,
Integer>(getSubjectHolder(), DiscriminatorColumn.DEFAULT_LENGTH_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultLength());
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Integer.valueOf(Integer.MIN_VALUE), newValue);
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String>
buildColumnDefinitionHolder(PropertyValueModel<DiscriminatorColumn>
discriminatorColumnHolder) {
+
+ return new PropertyAspectAdapter<DiscriminatorColumn,
String>(discriminatorColumnHolder, NamedColumn.COLUMN_DEFINITION_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getColumnDefinition();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setColumnDefinition(value);
+ }
+ };
+ }
+
+ /**
+ * Changes the layout of the given container by changing which widget will
+ * grab the excess of horizontal space. By default, the center control grabs
+ * the excess space, we change it to be the right control.
+ *
+ * @param container The container containing the controls needing their
+ * <code>GridData</code> to be modified from the default values
+ * @param spinner The spinner that got created
+ */
+ private void updateGridData(Composite container, Spinner spinner) {
+
+ // It is possible the spinner's parent is not the container of the
+ // label, spinner and right control (a pane is sometimes required for
+ // painting the spinner's border)
+ Composite paneContainer = spinner.getParent();
+
+ while (container != paneContainer.getParent()) {
+ paneContainer = paneContainer.getParent();
+ }
+
+ Control[] controls = paneContainer.getChildren();
+
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = false;
+ gridData.horizontalAlignment = GridData.BEGINNING;
+ controls[1].setLayoutData(gridData);
+
+ controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeAlignRight(controls[2]);
+ }
+
+ }
+}
\ No newline at end of file
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateDiscriminatorColumnComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -10,13 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
-import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.internal.java.details.JavaEntityComposite;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryContainer;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGeneratorsComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateQueriesComposite;
@@ -25,14 +25,14 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateJavaEntityComposite<HibernateJavaEntity> extends
JavaEntityComposite {
+public class HibernateJavaEntityComposite extends JavaEntityComposite {
/**
* @param subjectHolder
* @param parent
* @param widgetFactory
*/
- public HibernateJavaEntityComposite(PropertyValueModel<? extends JavaEntity>
subjectHolder,
+ public HibernateJavaEntityComposite(PropertyValueModel<? extends
HibernateJavaEntity> subjectHolder,
Composite parent, WidgetFactory widgetFactory) {
super(subjectHolder, parent, widgetFactory);
}
@@ -57,5 +57,10 @@
new HibernateGeneratorsComposite(this, container);
}
+
+ @Override
+ protected void addInheritanceComposite(Composite container) {
+ new HibernateJavaInheritanceComposite(this, container);
+ }
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaInheritanceComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaInheritanceComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaInheritanceComposite.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
+
+import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.eclipse.jpt.ui.internal.java.details.JavaPrimaryKeyJoinColumnsComposite;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaInheritanceComposite extends
HibernateAbstractInheritanceComposite<HibernateJavaEntity> {
+
+ @SuppressWarnings("unchecked")
+ public HibernateJavaInheritanceComposite(FormPane<? extends JavaEntity>
parentPane,
+ Composite parent) {
+ super((FormPane<? extends HibernateJavaEntity>) parentPane, parent);
+ }
+
+ protected void addPrimaryKeyJoinColumnsComposite(Composite container) {
+ new JavaPrimaryKeyJoinColumnsComposite(this, container);
+ }
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaInheritanceComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -43,6 +43,7 @@
public static String NameStateObject_nameAlreadyExists;
public static String HibernateIdMappingComposite_genericGeneratorSection;
public static String HibernateIdMappingComposite_genericGeneratorCheckBox;
+ public static String HibernateDiscriminatorColumnComposite_formula;
private HibernateUIMappingMessages() {}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-07-29
14:14:03 UTC (rev 16874)
@@ -20,4 +20,5 @@
NameStateObject_nameMustBeSpecified=A name must be specified
NameStateObject_nameAlreadyExists=The name already exists.
HibernateIdMappingComposite_genericGeneratorSection=Generic Generator
-HibernateIdMappingComposite_genericGeneratorCheckBox=Generic generator
\ No newline at end of file
+HibernateIdMappingComposite_genericGeneratorCheckBox=Generic generator
+HibernateDiscriminatorColumnComposite_formula=Formula:
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-07-29
13:24:09 UTC (rev 16873)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-07-29
14:14:03 UTC (rev 16874)
@@ -70,10 +70,11 @@
return new HibernateIdMappingComposite((PropertyValueModel<? extends
HibernateJavaIdMapping>) subjectHolder, parent, widgetFactory);
}
+ @SuppressWarnings("unchecked")
@Override
public JpaComposite createJavaEntityComposite(PropertyValueModel<JavaEntity>
subjectHolder,
Composite parent, WidgetFactory widgetFactory) {
- return new HibernateJavaEntityComposite<HibernateJavaEntity>(subjectHolder,
parent, widgetFactory);
+ return new HibernateJavaEntityComposite((PropertyValueModel<? extends
HibernateJavaEntity>) subjectHolder, parent, widgetFactory);
}
private PropertyValueModel<BasicHibernateProperties> buildBasicHolder(