Author: dgeraskov
Date: 2009-09-25 08:09:16 -0400 (Fri, 25 Sep 2009)
New Revision: 17727
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
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/context/java/HibernateJavaColumnImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmColumnImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4795
Some additions and changes for orm.xml-style mapping.
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-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -65,7 +65,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEmbeddable;
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.HibernateJavaIdMappingImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinColumnImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinTableImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping;
@@ -86,7 +86,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmBasicMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmColumnImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmEntityImpl;
-import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmIdMapping;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmIdMappingImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmJoinColumnImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmJoinTableImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmManyToManyMapping;
@@ -121,7 +121,7 @@
@Override
public JavaIdMapping buildJavaIdMapping(JavaPersistentAttribute parent) {
- return new HibernateJavaIdMapping(parent);
+ return new HibernateJavaIdMappingImpl(parent);
}
public JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent) {
@@ -217,7 +217,7 @@
@Override
public OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent,
XmlId resourceMapping) {
- return new HibernateOrmIdMapping(parent, resourceMapping);
+ return new HibernateOrmIdMappingImpl(parent, resourceMapping);
}
@Override
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateIdMapping.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateIdMapping.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 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.basic;
+
+import org.eclipse.jpt.core.context.IdMapping;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateIdMapping extends IdMapping {
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateIdMapping.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/HibernateJavaColumnImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumnImpl.java 2009-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumnImpl.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -93,7 +93,7 @@
}
public String getSpecifiedDBTableName() {
- if (getSpecifiedName() == null) return null;
+ if (getSpecifiedTable() == null) return null;
NamingStrategy ns = getJpaProject().getNamingStrategy();
if (getJpaProject().isNamingStrategyEnabled() && ns != null){
try {
@@ -104,7 +104,7 @@
HibernateJptPlugin.logException(m.getText(), e);
}
}
- return this.getName();
+ return this.getSpecifiedTable();
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -8,198 +8,18 @@
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-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.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaIdMapping;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-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.HibernateJpaProject;
-import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
+import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGeneratorHolder;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateJavaIdMapping extends GenericJavaIdMapping
-implements GenericGeneratorHolder {
-
- protected JavaGenericGenerator genericGenerator;
-
- /**
- * @param parent
- */
- public HibernateJavaIdMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
+public interface HibernateJavaIdMapping extends HibernateIdMapping,
+ JavaIdMapping, GenericGeneratorHolder {
- @Override
- protected void initialize() {
- super.initialize();
- this.initializeGenericGenerator();
- }
-
- @Override
- public HibernateJavaColumn getColumn() {
- return (HibernateJavaColumn) column;
- }
-
- @Override
- public String getPrimaryKeyColumnName() {
- return this.getColumn().getDBColumnName();
- }
-
- protected void initializeGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource != null) {
- this.genericGenerator = buildGenericGenerator(genericGeneratorResource);
- }
- }
-
- protected GenericGeneratorAnnotation getResourceGenericGenerator() {
- return (GenericGeneratorAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
- JavaGenericGenerator generator = ((HibernateJpaFactory)
getJpaFactory()).buildJavaGenericGenerator(this);
- generator.initialize(genericGeneratorResource);
- return generator;
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<JavaGenerator> generators() {
- return new CompositeIterator<JavaGenerator>(super.generators(),
- (getGenericGenerator() == null) ? EmptyIterator.instance()
- : new SingleElementIterator(getGenericGenerator()));
- }
-
- public JavaGenericGenerator addGenericGenerator(int index) {
- if (getGenericGenerator() != null) {
- throw new IllegalStateException("genericGenerator already exists");
//$NON-NLS-1$
- }
- this.genericGenerator =
((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(this);
- GenericGeneratorAnnotation genericGeneratorResource =
(GenericGeneratorAnnotation)getResourcePersistentAttribute()
- .addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- this.genericGenerator.initialize(genericGeneratorResource);
- firePropertyChanged(GENERIC_GENERATORS_LIST, null, this.genericGenerator);
- return this.genericGenerator;
- }
-
- private JavaGenericGenerator getGenericGenerator() {
- return genericGenerator;
- }
-
- private void removeGenericGenerator() {
- if (getGenericGenerator() == null) {
- throw new IllegalStateException("genericGenerator does not exist, cannot be
removed"); //$NON-NLS-1$
- }
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = null;
- this.getResourcePersistentAttribute().removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,null);
- }
-
- private void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = newGenericGenerator;
- firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,
newGenericGenerator);
- }
-
- @Override
- public void update() {
- super.update();
- updateGenericGenerator();
- }
-
- protected void updateGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource == null) {
- if (getGenericGenerator() != null) {
- setGenericGenerator(null);
- }
- }
- else {
- if (getGenericGenerator() == null) {
- setGenericGenerator(buildGenericGenerator(genericGeneratorResource));
- }
- else {
- getGenericGenerator().update(genericGeneratorResource);
- }
- }
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
- super.validate(messages, reporter, astRoot);
- validateGenericGenerator(messages, reporter, astRoot);
- }
-
- private void validateGenericGenerator(List<IMessage> messages, IReporter reporter,
CompilationUnit astRoot) {
- if (genericGenerator != null){
- 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;
- }
- if (this.getGenericGenerator() != null) {
- result = this.getGenericGenerator().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- public ListIterator<GenericGenerator> genericGenerators() {
- return genericGenerator == null ?
EmptyListIterator.<GenericGenerator>instance()
- : new SingleElementListIterator<GenericGenerator>(genericGenerator);
- }
-
- public int genericGeneratorsSize() {
- return genericGenerator == null ? 0 : 1;
- }
-
- public void moveGenericGenerator(int targetIndex, int sourceIndex) {
- throw new UnsupportedOperationException();
- }
-
- public void removeGenericGenerator(int index) {
- if (genericGeneratorsSize() < index + 1){
- throw new IndexOutOfBoundsException();
- }
- removeGenericGenerator();
- }
-
- public void removeGenericGenerator(GenericGenerator generator) {
- if (this.genericGenerator == generator){
- removeGenericGenerator();
- }
- }
-
- @Override
- public HibernateJpaProject getJpaProject() {
- return (HibernateJpaProject) super.getJpaProject();
- }
-
}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java
(from rev 17715,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 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.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.JavaPersistentAttribute;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaIdMapping;
+import org.eclipse.jpt.utility.Filter;
+import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
+import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
+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.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaIdMappingImpl extends GenericJavaIdMapping
+implements HibernateJavaIdMapping {
+
+ protected JavaGenericGenerator genericGenerator;
+
+ /**
+ * @param parent
+ */
+ public HibernateJavaIdMappingImpl(JavaPersistentAttribute parent) {
+ super(parent);
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.initializeGenericGenerator();
+ }
+
+ @Override
+ public HibernateJavaColumn getColumn() {
+ return (HibernateJavaColumn) column;
+ }
+
+ @Override
+ public String getPrimaryKeyColumnName() {
+ return this.getColumn().getDBColumnName();
+ }
+
+ protected void initializeGenericGenerator() {
+ GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
+ if (genericGeneratorResource != null) {
+ this.genericGenerator = buildGenericGenerator(genericGeneratorResource);
+ }
+ }
+
+ protected GenericGeneratorAnnotation getResourceGenericGenerator() {
+ return (GenericGeneratorAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ }
+
+ protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
+ JavaGenericGenerator generator = ((HibernateJpaFactory)
getJpaFactory()).buildJavaGenericGenerator(this);
+ generator.initialize(genericGeneratorResource);
+ return generator;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<JavaGenerator> generators() {
+ return new CompositeIterator<JavaGenerator>(super.generators(),
+ (getGenericGenerator() == null) ? EmptyIterator.instance()
+ : new SingleElementIterator(getGenericGenerator()));
+ }
+
+ public JavaGenericGenerator addGenericGenerator(int index) {
+ if (getGenericGenerator() != null) {
+ throw new IllegalStateException("genericGenerator already exists");
//$NON-NLS-1$
+ }
+ this.genericGenerator =
((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(this);
+ GenericGeneratorAnnotation genericGeneratorResource =
(GenericGeneratorAnnotation)getResourcePersistentAttribute()
+ .addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ this.genericGenerator.initialize(genericGeneratorResource);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, null, this.genericGenerator);
+ return this.genericGenerator;
+ }
+
+ private JavaGenericGenerator getGenericGenerator() {
+ return genericGenerator;
+ }
+
+ private void removeGenericGenerator() {
+ if (getGenericGenerator() == null) {
+ throw new IllegalStateException("genericGenerator does not exist, cannot be
removed"); //$NON-NLS-1$
+ }
+ JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
+ this.genericGenerator = null;
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,null);
+ }
+
+ private void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
+ JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
+ this.genericGenerator = newGenericGenerator;
+ firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,
newGenericGenerator);
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ updateGenericGenerator();
+ }
+
+ protected void updateGenericGenerator() {
+ GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
+ if (genericGeneratorResource == null) {
+ if (getGenericGenerator() != null) {
+ setGenericGenerator(null);
+ }
+ }
+ else {
+ if (getGenericGenerator() == null) {
+ setGenericGenerator(buildGenericGenerator(genericGeneratorResource));
+ }
+ else {
+ getGenericGenerator().update(genericGeneratorResource);
+ }
+ }
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
+ super.validate(messages, reporter, astRoot);
+ validateGenericGenerator(messages, reporter, astRoot);
+ }
+
+ private void validateGenericGenerator(List<IMessage> messages, IReporter reporter,
CompilationUnit astRoot) {
+ if (genericGenerator != null){
+ 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;
+ }
+ if (this.getGenericGenerator() != null) {
+ result = this.getGenericGenerator().javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public ListIterator<GenericGenerator> genericGenerators() {
+ return genericGenerator == null ?
EmptyListIterator.<GenericGenerator>instance()
+ : new SingleElementListIterator<GenericGenerator>(genericGenerator);
+ }
+
+ public int genericGeneratorsSize() {
+ return genericGenerator == null ? 0 : 1;
+ }
+
+ public void moveGenericGenerator(int targetIndex, int sourceIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeGenericGenerator(int index) {
+ if (genericGeneratorsSize() < index + 1){
+ throw new IndexOutOfBoundsException();
+ }
+ removeGenericGenerator();
+ }
+
+ public void removeGenericGenerator(GenericGenerator generator) {
+ if (this.genericGenerator == generator){
+ removeGenericGenerator();
+ }
+ }
+
+ @Override
+ public HibernateJpaProject getJpaProject() {
+ return (HibernateJpaProject) super.getJpaProject();
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmColumnImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmColumnImpl.java 2009-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmColumnImpl.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -85,7 +85,7 @@
}
public String getSpecifiedDBTableName() {
- if (getSpecifiedName() == null) return null;
+ if (getSpecifiedTable() == null) return null;
NamingStrategy ns = getJpaProject().getNamingStrategy();
if (getJpaProject().isNamingStrategyEnabled() && ns != null){
try {
@@ -96,7 +96,7 @@
HibernateJptPlugin.logException(m.getText(), e);
}
}
- return this.getName();
+ return this.getSpecifiedTable();
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java 2009-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -11,10 +11,12 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.orm;
+import java.util.Iterator;
import java.util.ListIterator;
import org.eclipse.jpt.core.context.BaseJoinColumn;
import org.eclipse.jpt.core.context.Entity;
+import org.eclipse.jpt.core.context.Table;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.orm.OrmBaseJoinColumn;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
@@ -22,6 +24,7 @@
import org.eclipse.jpt.core.resource.orm.XmlEntity;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.hibernate.cfg.NamingStrategy;
@@ -31,6 +34,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateTable;
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
@@ -51,40 +55,15 @@
return (HibernateJpaProject) super.getJpaProject();
}
-/*
- @Override
- protected String buildDefaultName() {
- NamingStrategy ns = getJpaProject().getNamingStrategy();
- if (!isMetadataComplete()) {
- JavaEntity javaEntity = getJavaEntity();
- if (javaEntity != null) {
- return javaEntity.getName();
- }
- }
- String className = getClass_();
- if (className != null) {
- try {
- String shortCalssName = ClassTools.shortNameForClassNamed(className);
- return ns == null ? shortCalssName : ns.classToTableName(shortCalssName);
- } catch (Exception e) {
- Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
- HibernateJptPlugin.logException(m.getText(), e);
- }
- }
- return null;
- }
-
-
@Override
public String getPrimaryTableName() {
return this.getTable().getDBTableName();
- }*/
-
+ }
+
/**
* Convert Table to it's DB name.
*/
-/* @Override
+ @Override
protected Iterator<String> tableNames(Iterator<Table> tables) {
return new TransformationIterator<Table, String>(tables) {
@Override
@@ -96,7 +75,7 @@
}
}
};
- }*/
+ }
@Override
protected OrmBaseJoinColumn.Owner createPrimaryKeyJoinColumnOwner() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2009-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -11,46 +11,14 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.orm;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.orm.GenericOrmIdMapping;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.hibernate.cfg.NamingStrategy;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
-import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.eclipse.jpt.core.context.orm.OrmIdMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateOrmIdMapping extends GenericOrmIdMapping<XmlId> {
+public interface HibernateOrmIdMapping extends HibernateIdMapping,
+ OrmIdMapping {
- public HibernateOrmIdMapping(OrmPersistentAttribute parent,
- XmlId resourceMapping) {
- super(parent, resourceMapping);
- }
-
- @Override
- public HibernateJpaProject getJpaProject() {
- return (HibernateJpaProject) super.getJpaProject();
- }
-
- @Override
- public String getDefaultColumnName() {
- NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
- if (getJpaProject().isNamingStrategyEnabled() && namingStrategy != null
&& getName() != null){
- try {
- return namingStrategy.propertyToColumnName(getName());
- } catch (Exception e) {
- Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
- HibernateJptPlugin.logException(m.getText(), e);
- }
- }
- return super.getDefaultColumnName();
- }
-
}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
(from rev 17715,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 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.orm;
+
+import java.util.List;
+
+import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmIdMapping;
+import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
+import org.eclipse.jpt.core.resource.orm.XmlId;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.hibernate.cfg.NamingStrategy;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateOrmIdMappingImpl extends GenericOrmIdMapping<XmlId>
+implements HibernateOrmIdMapping {
+
+ public HibernateOrmIdMappingImpl(OrmPersistentAttribute parent,
+ XmlId resourceMapping) {
+ super(parent, resourceMapping);
+ }
+
+ @Override
+ public HibernateJpaProject getJpaProject() {
+ return (HibernateJpaProject) super.getJpaProject();
+ }
+
+ @Override
+ public String getDefaultColumnName() {
+ NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
+ if (getJpaProject().isNamingStrategyEnabled() && namingStrategy != null
&& getName() != null){
+ try {
+ return namingStrategy.propertyToColumnName(getName());
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
+ }
+ return super.getDefaultColumnName();
+ }
+
+ @Override
+ public HibernateOrmColumn getColumn() {
+ return (HibernateOrmColumn) column;
+ }
+
+ @Override
+ public String getPrimaryKeyColumnName() {
+ return this.getColumn().getDBColumnName();
+ }
+
+ protected void validateColumn(List<IMessage> messages) {
+ OrmPersistentAttribute pa = this.getPersistentAttribute();
+ String tableName = this.column.getTable();
+ if (this.getTypeMapping().tableNameIsInvalid(tableName)) {
+ if (pa.isVirtual()) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_TABLE,
+ new String[] {pa.getName(), tableName, this.getColumn().getDBColumnName()},
+ this.column,
+ this.column.getTableTextRange()
+ )
+ );
+ } else {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.COLUMN_UNRESOLVED_TABLE,
+ new String[] {tableName, this.getColumn().getDBColumnName()},
+ this.column,
+ this.column.getTableTextRange()
+ )
+ );
+ }
+ return;
+ }
+
+ if ( ! this.column.isResolved() && this.column.getDbTable() != null) {
+ if (pa.isVirtual()) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME,
+ new String[] {pa.getName(), this.getColumn().getDBColumnName()},
+ this.column,
+ this.column.getNameTextRange()
+ )
+ );
+ } else {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.COLUMN_UNRESOLVED_NAME,
+ new String[] {this.getColumn().getDBColumnName()},
+ this.column,
+ this.column.getNameTextRange()
+ )
+ );
+ }
+ }
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java 2009-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -17,6 +17,7 @@
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaComposite;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.GenerationComposite;
import org.eclipse.jpt.ui.internal.mappings.details.TemporalTypeComposite;
import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
@@ -28,13 +29,14 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateColumn;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateIdMappingComposite extends FormPane<HibernateJavaIdMapping>
+public class HibernateIdMappingComposite extends FormPane<HibernateIdMapping>
implements JpaComposite{
/**
* Creates a new <code>HibernateIdMappingComposite</code>.
@@ -43,7 +45,7 @@
* @param parent The parent container
* @param widgetFactory The factory used to create various common widgets
*/
- public HibernateIdMappingComposite(PropertyValueModel<? extends
HibernateJavaIdMapping> subjectHolder,
+ public HibernateIdMappingComposite(PropertyValueModel<? extends
HibernateIdMapping> subjectHolder,
Composite parent,
WidgetFactory widgetFactory) {
@@ -59,6 +61,7 @@
};
}
+ @SuppressWarnings("unchecked")
@Override
protected void initializeLayout(Composite container) {
@@ -67,8 +70,13 @@
initializeTypePane(container);
- // Generation pane
- new HibernateGenerationComposite(this, addSubPane(container, 10));
+ if (getSubject() instanceof HibernateJavaIdMapping) {
+ // Generic Generator required only for Java.
+ new HibernateGenerationComposite((FormPane<? extends HibernateJavaIdMapping>)
this, addSubPane(container, 10));
+ } else {
+ new GenerationComposite(this, addSubPane(container, 10));
+ }
+
}
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-09-25
11:34:43 UTC (rev 17726)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-09-25
12:09:16 UTC (rev 17727)
@@ -17,7 +17,9 @@
import org.eclipse.jpt.core.context.java.JavaBasicMapping;
import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.core.context.java.JavaIdMapping;
+import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
import org.eclipse.jpt.core.context.orm.OrmEntity;
+import org.eclipse.jpt.core.context.orm.OrmIdMapping;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaComposite;
@@ -34,6 +36,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmEntity;
+import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmIdMapping;
import
org.jboss.tools.hibernate.jpt.ui.internal.java.details.HibernateJavaEntityComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateBasicMappingComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateIdMappingComposite;
@@ -116,5 +119,22 @@
WidgetFactory widgetFactory) {
return new HibernateBasicMappingComposite(subjectHolder, parent, widgetFactory);
}
+
+ @Override
+ public JpaComposite createOrmBasicMappingComposite(
+ PropertyValueModel<OrmBasicMapping> subjectHolder,
+ Composite parent, WidgetFactory widgetFactory) {
+ return new HibernateBasicMappingComposite(subjectHolder, parent,
+ widgetFactory);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public JpaComposite createOrmIdMappingComposite(
+ PropertyValueModel<OrmIdMapping> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+ return new HibernateIdMappingComposite((PropertyValueModel<? extends
HibernateOrmIdMapping>) subjectHolder, parent, widgetFactory);
+ }
}
\ No newline at end of file