Author: dgeraskov
Date: 2010-05-26 09:13:34 -0400 (Wed, 26 May 2010)
New Revision: 22326
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKeyImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/GenericGeneratorHolder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateQueryContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Index.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
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.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGenerationComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateGeneratorContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernatePersistenceUnitProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableJoiningStrategy.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyRelationshipReference.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyRelationshipReference.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainerImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/IndexImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaIndex.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmXmlContextNodeFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiFactory.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
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/HibernateJpaPlatform.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java
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/HibernatePersistenceUnit.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.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/HibernateJavaDiscriminatorColumnImpl.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/context/java/HibernateJavaEntityImpl.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/java/HibernateJavaIdMappingImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnJoiningStrategy.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaSecondaryTableImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTableImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.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.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnJoiningStrategy.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinTableImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToManyMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToManyMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToOneMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.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/ForeignKeyAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
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/HibernateJavaInheritanceComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GeneratedComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAbstractInheritanceComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateColumnComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.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/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateTableComposite.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/IndexHolderComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.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/mappings/db/xpl/ColumnCombo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/DatabaseObjectCombo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/TableCombo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/orm/details/HibernateOrmEntityComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUi.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUiFactory.java
Log:
Revert Dali2.3 changes
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -43,7 +43,7 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.core.internal.JpaModelManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -72,6 +72,7 @@
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
+@SuppressWarnings("restriction")
public class HibernatePropertyPage extends PropertyPage {
Control[] settings;
@@ -340,7 +341,7 @@
final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor)
throws CoreException {
- JptCorePlugin.rebuildJpaProject(getProject());
+ JpaModelManager.instance().rebuildJpaProject(getProject());
getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
}
};
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,16 +13,16 @@
import java.util.List;
import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider;
-import org.eclipse.jpt.core.internal.AbstractJpaAnnotationDefintionProvider;
+import org.eclipse.jpt.core.internal.platform.AbstractJpaAnnotationDefintionProvider;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotationDefinition;
+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.ForeignKeyAnnotationImpl.ForeignKeyAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GeneratedAnnotationImpl.GeneratedAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotationDefinition;
-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.IndexAnnotationImpl.IndexAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceGenericGeneratorsAnnotation.GenericGeneratorsAnnotationDefinition;
@@ -50,7 +50,11 @@
}
@Override
- protected void addTypeAnnotationDefinitionsTo(List<AnnotationDefinition>
definitions) {
+ protected void addTypeMappingAnnotationDefinitionsTo(List<AnnotationDefinition>
definitions) {
+ }
+
+ @Override
+ protected void addTypeSupportingAnnotationDefinitionsTo(List<AnnotationDefinition>
definitions) {
definitions.add(GenericGeneratorAnnotationDefinition.instance());
definitions.add(GenericGeneratorsAnnotationDefinition.instance());
definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
@@ -62,7 +66,11 @@
}
@Override
- protected void addAttributeAnnotationDefinitionsTo(List<AnnotationDefinition>
definitions) {
+ protected void
addAttributeMappingAnnotationDefinitionsTo(List<AnnotationDefinition> definitions)
{
+ }
+
+ @Override
+ protected void
addAttributeSupportingAnnotationDefinitionsTo(List<AnnotationDefinition>
definitions) {
definitions.add(GenericGeneratorAnnotationDefinition.instance());
definitions.add(GeneratedAnnotationDefinition.instance());
definitions.add(IndexAnnotationDefinition.instance());
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Red Hat, Inc.
+ * Copyright (c) 2008-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,
@@ -10,14 +10,14 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
+import org.eclipse.jpt.core.context.XmlContextNode;
import org.eclipse.jpt.core.context.java.JavaBasicMapping;
import org.eclipse.jpt.core.context.java.JavaColumn;
import org.eclipse.jpt.core.context.java.JavaDiscriminatorColumn;
import org.eclipse.jpt.core.context.java.JavaEmbeddable;
import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.eclipse.jpt.core.context.java.JavaJoinColumn;
import org.eclipse.jpt.core.context.java.JavaJoinTable;
@@ -29,29 +29,48 @@
import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaQueryContainer;
import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
+import org.eclipse.jpt.core.context.java.JavaColumn.Owner;
+import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
+import org.eclipse.jpt.core.context.orm.OrmColumn;
+import org.eclipse.jpt.core.context.orm.OrmEntity;
+import org.eclipse.jpt.core.context.orm.OrmIdMapping;
+import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
+import org.eclipse.jpt.core.context.orm.OrmJoinTable;
+import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping;
import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.AbstractJpaFactory;
+import org.eclipse.jpt.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.core.context.orm.OrmTable;
+import org.eclipse.jpt.core.context.persistence.Persistence;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.internal.platform.GenericJpaFactory;
+import org.eclipse.jpt.core.resource.orm.XmlBasic;
+import org.eclipse.jpt.core.resource.orm.XmlEntity;
+import org.eclipse.jpt.core.resource.orm.XmlId;
+import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
+import org.eclipse.jpt.core.resource.orm.XmlJoinTableMapping;
import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
+import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
+import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyImpl;
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.java.ForeignKeyImpl;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Index;
+import org.jboss.tools.hibernate.jpt.core.internal.context.IndexImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaBasicMappingImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumnImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaDiscriminatorColumnImpl;
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.HibernateJavaGeneratorContainerImpl;
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;
@@ -60,36 +79,46 @@
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToManyMapping;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaOneToOneMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainerImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaSecondaryTableImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTable;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTableImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryImpl;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.IndexImpl;
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.JavaIndex;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
+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.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;
import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmManyToOneMapping;
import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmOneToManyMapping;
import
org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmOneToOneMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmTableImpl;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateJpaFactory extends AbstractJpaFactory {
+public class HibernateJpaFactory extends GenericJpaFactory {
// ********** Core Model **********
- public JpaProject buildJpaProject(JpaProject.Config config){
+ public JpaProject buildJpaProject(JpaProject.Config config) throws CoreException {
return new HibernateJpaProject(config);
}
+ // ********** Persistence Context Model **********
+ @Override
+ public PersistenceUnit buildPersistenceUnit(Persistence parent, XmlPersistenceUnit
persistenceUnit) {
+ return new HibernatePersistenceUnit(parent, persistenceUnit);
+ }
+
// ********** Java Context Model **********
@Override
public JavaEntity buildJavaEntity(JavaPersistentType parent) {
@@ -112,11 +141,11 @@
return new HibernateJavaDiscriminatorColumnImpl(parent, owner);
}
- public HibernateNamedQuery buildHibernateJavaNamedQuery(JavaJpaContextNode parent) {
+ public HibernateNamedQuery buildHibernateNamedQuery(JavaJpaContextNode parent) {
return new HibernateNamedQueryImpl(parent);
}
- public HibernateNamedNativeQuery buildHibernateJavaNamedNativeQuery(JavaJpaContextNode
parent) {
+ public HibernateNamedNativeQuery buildHibernateNamedNativeQuery(JavaJpaContextNode
parent) {
return new HibernateNamedNativeQueryImpl(parent);
}
@@ -134,7 +163,7 @@
}
@Override
- public JavaColumn buildJavaColumn(JavaJpaContextNode parent, JavaBaseColumn.Owner owner)
{
+ public JavaColumn buildJavaColumn(JavaJpaContextNode parent, Owner owner) {
return new HibernateJavaColumnImpl(parent, owner);
}
@@ -187,17 +216,50 @@
return new HibernateJavaBasicMappingImpl(parent);
}
- public JavaQueryContainer buildJavaQueryContainer(JavaJpaContextNode parent) {
- return new HibernateJavaQueryContainerImpl(parent);
+ // ********** ORM Context Model **********
+
+ @Override
+ public OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent,
+ XmlBasic resourceMapping) {
+ return new HibernateOrmBasicMapping(parent, resourceMapping);
}
- public JavaGeneratorContainer buildJavaGeneratorContainer(JavaJpaContextNode parent) {
- return new HibernateJavaGeneratorContainerImpl(parent);
+ @Override
+ public OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent,
+ XmlId resourceMapping) {
+ return new HibernateOrmIdMappingImpl(parent, resourceMapping);
}
- // ********** ORM Context Model **********
+ @Override
+ public OrmEntity buildOrmEntity(OrmPersistentType parent,
+ XmlEntity resourceMapping) {
+ return new HibernateOrmEntityImpl(parent, resourceMapping);
+ }
+
+ @Override
+ public OrmTable buildOrmTable(OrmEntity parent) {
+ return new HibernateOrmTableImpl(parent);
+ }
+
+ @Override
+ public OrmJoinTable buildOrmJoinTable(OrmJoinTableJoiningStrategy parent,
+ XmlJoinTableMapping resourceMapping) {
+ return new HibernateOrmJoinTableImpl(parent, resourceMapping);
+ }
+ @Override
+ public OrmColumn buildOrmColumn(XmlContextNode parent,
+ org.eclipse.jpt.core.context.orm.OrmColumn.Owner owner) {
+ return new HibernateOrmColumnImpl(parent, owner);
+ }
+ @Override
+ public OrmJoinColumn buildOrmJoinColumn(XmlContextNode parent,
+ org.eclipse.jpt.core.context.orm.OrmJoinColumn.Owner owner,
+ XmlJoinColumn resourceJoinColumn) {
+ return new HibernateOrmJoinColumnImpl(parent, owner, resourceJoinColumn);
+ }
+
@SuppressWarnings("unchecked")
public OrmManyToManyMapping buildOrmManyToManyMapping(OrmPersistentAttribute parent,
XmlManyToMany resourceMapping) {
return new HibernateOrmManyToManyMapping(parent, resourceMapping);
@@ -218,7 +280,7 @@
return new HibernateOrmOneToOneMapping(parent, resourceMapping);
}
- public JavaIndex buildIndex(JavaJpaContextNode parent) {
+ public Index buildIndex(JavaJpaContextNode parent) {
return new IndexImpl(parent);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatform.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatform.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatform.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,11 +13,8 @@
import org.eclipse.jpt.core.JpaAnnotationProvider;
import org.eclipse.jpt.core.JpaFactory;
import org.eclipse.jpt.core.JpaPlatformProvider;
-import org.eclipse.jpt.core.JpaPlatformVariation;
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.ResourceDefinition;
-import org.eclipse.jpt.core.internal.GenericJpaPlatform;
-import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.core.JpaValidation;
+import org.eclipse.jpt.core.internal.platform.GenericJpaPlatform;
/**
* @author Dmitry Geraskov
@@ -26,19 +23,9 @@
public class HibernateJpaPlatform extends GenericJpaPlatform {
public static final String ID = "hibernate"; //$NON-NLS-1$
-
- @Override
- public ResourceDefinition getResourceDefinition(JpaResourceType resourceType) {
- for (ResourceDefinition resourceDefinition :
CollectionTools.iterable(resourceDefinitions())) {
- if (resourceDefinition.getResourceType().equals(resourceType)) {
- return resourceDefinition;
- }
- }
- return super.getResourceDefinition(resourceType);
- }
- public HibernateJpaPlatform(String id, Version jpaVersion, JpaFactory jpaFactory,
JpaAnnotationProvider jpaAnnotationProvider, JpaPlatformProvider platformProvider,
JpaPlatformVariation jpaVariation) {
- super(id, jpaVersion, jpaFactory, jpaAnnotationProvider, platformProvider,
jpaVariation);
+ public HibernateJpaPlatform(String id, JpaFactory jpaFactory, JpaAnnotationProvider
jpaAnnotationProvider, JpaValidation jpaValidation, JpaPlatformProvider...
platformProviders) {
+ super(id, jpaFactory, jpaAnnotationProvider, jpaValidation, platformProviders);
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformFactory.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformFactory.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -14,10 +14,10 @@
import org.eclipse.jpt.core.JpaFactory;
import org.eclipse.jpt.core.JpaPlatform;
import org.eclipse.jpt.core.JpaPlatformFactory;
-import org.eclipse.jpt.core.JpaPlatformVariation;
-import org.eclipse.jpt.core.internal.GenericJpaAnnotationDefinitionProvider;
-import org.eclipse.jpt.core.internal.GenericJpaAnnotationProvider;
-import org.eclipse.jpt.core.internal.GenericJpaPlatformFactory.SimpleVersion;
+import org.eclipse.jpt.core.JpaValidation;
+import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationDefinitionProvider;
+import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider;
+import org.eclipse.jpt.core.internal.platform.GenericJpaPlatformProvider;
/**
* @author Dmitry Geraskov
@@ -35,19 +35,12 @@
public JpaPlatform buildJpaPlatform(String id) {
return new HibernateJpaPlatform(
id,
- this.buildJpaVersion(),
buildJpaFactory(),
buildJpaAnnotationProvider(),
- HibernateJpaPlatformProvider.instance(),
- this.buildJpaPlatformVariation());
+ buildJpaValidation(),
+ GenericJpaPlatformProvider.instance());
}
-
-
- private JpaPlatform.Version buildJpaVersion() {
- return new SimpleVersion(HibernateJptPlugin.JPA_FACET_VERSION_1_0);
- }
-
protected JpaFactory buildJpaFactory() {
return new HibernateJpaFactory();
}
@@ -58,14 +51,11 @@
HibernateJpaAnnotationDefinitionProvider.instance());
}
- protected JpaPlatformVariation buildJpaPlatformVariation() {
- return new JpaPlatformVariation() {
+ protected JpaValidation buildJpaValidation() {
+ return new JpaValidation() {
public Supported getTablePerConcreteClassInheritanceIsSupported() {
- return Supported.YES;
+ return Supported.MAYBE;
}
- public boolean isJoinTableOverridable() {
- return false;
- }
};
}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 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;
-
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jpt.core.JpaPlatformProvider;
-import org.eclipse.jpt.core.JpaResourceModelProvider;
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.ResourceDefinition;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.internal.AbstractJpaPlatformProvider;
-import org.eclipse.jpt.core.internal.JarResourceModelProvider;
-import org.eclipse.jpt.core.internal.JavaResourceModelProvider;
-import org.eclipse.jpt.core.internal.OrmResourceModelProvider;
-import org.eclipse.jpt.core.internal.PersistenceResourceModelProvider;
-import org.eclipse.jpt.core.internal.context.java.JavaBasicMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaEmbeddableDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaEmbeddedMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaEntityDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaIdMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaManyToManyMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaManyToOneMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaMappedSuperclassDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaOneToManyMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaOneToOneMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaTransientMappingDefinition;
-import org.eclipse.jpt.core.internal.context.java.JavaVersionMappingDefinition;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistenceXmlDefinition;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJpaPlatformProvider extends AbstractJpaPlatformProvider {
-
-public static final String ID = "hibernate"; //$NON-NLS-1$
-
- // singleton
- private static final JpaPlatformProvider INSTANCE =
- new HibernateJpaPlatformProvider();
-
-
- /**
- * Return the singleton.
- */
- public static JpaPlatformProvider instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private HibernateJpaPlatformProvider() {
- super();
- }
-
-
- // ********** resource models **********
-
- public JpaResourceType getMostRecentSupportedResourceType(IContentType contentType) {
- if (contentType.equals(JptCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
- return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
- }
- else if (contentType.equals(JptCorePlugin.JAR_CONTENT_TYPE)) {
- return JptCorePlugin.JAR_RESOURCE_TYPE;
- }
- else if (contentType.equals(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) {
- return JptCorePlugin.PERSISTENCE_XML_1_0_RESOURCE_TYPE;
- }
- else if (contentType.equals(JptCorePlugin.ORM_XML_CONTENT_TYPE)) {
- return JptCorePlugin.ORM_XML_1_0_RESOURCE_TYPE;
- }
- else {
- throw new IllegalArgumentException(contentType.toString());
- }
- }
-
- @Override
- protected JpaResourceModelProvider[] buildResourceModelProviders() {
- // order should not be important here
- return new JpaResourceModelProvider[] {
- JavaResourceModelProvider.instance(),
- JarResourceModelProvider.instance(),
- PersistenceResourceModelProvider.instance(),
- OrmResourceModelProvider.instance()};
- }
-
-
- // ********** Java type mappings **********
-
- @Override
- protected JavaTypeMappingDefinition[] buildNonNullJavaTypeMappingDefinitions() {
- // order determined by analyzing order that reference implementation (toplink) uses
- return new JavaTypeMappingDefinition[] {
- JavaEntityDefinition.instance(),
- JavaEmbeddableDefinition.instance(),
- JavaMappedSuperclassDefinition.instance()};
- }
-
-
- // ********** Java attribute mappings **********
-
- @Override
- protected JavaAttributeMappingDefinition[]
buildNonNullDefaultJavaAttributeMappingDefinitions() {
- // order determined by analyzing order that reference implementation (toplink) uses
- return new JavaAttributeMappingDefinition[] {
- JavaEmbeddedMappingDefinition.instance(),
- JavaBasicMappingDefinition.instance()};
- }
-
- @Override
- protected JavaAttributeMappingDefinition[]
buildNonNullSpecifiedJavaAttributeMappingDefinitions() {
- // order determined by analyzing order that reference implementation (eclipselink)
uses
- return new JavaAttributeMappingDefinition[] {
- JavaTransientMappingDefinition.instance(),
- JavaIdMappingDefinition.instance(),
- JavaVersionMappingDefinition.instance(),
- JavaBasicMappingDefinition.instance(),
- JavaEmbeddedMappingDefinition.instance(),
- JavaEmbeddedIdMappingDefinition.instance(),
- JavaManyToManyMappingDefinition.instance(),
- JavaManyToOneMappingDefinition.instance(),
- JavaOneToManyMappingDefinition.instance(),
- JavaOneToOneMappingDefinition.instance()};
- }
-
-
- // ********** Mapping Files **********
-
- @Override
- protected ResourceDefinition[] buildResourceDefinitions() {
- return new ResourceDefinition[] {
- HibernatePersistenceXmlDefinition.instance(),
- GenericOrmXmlDefinition.instance()};
- }
-
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,6 +12,7 @@
package org.jboss.tools.hibernate.jpt.core.internal;
import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.internal.AbstractJpaProject;
@@ -28,9 +29,10 @@
*/
public class HibernateJpaProject extends AbstractJpaProject {
- private Boolean cachedNamingStrategyEnable;
+ private Boolean cachedNamingStrategyEnable;
+
- public HibernateJpaProject(JpaProject.Config config){
+ public HibernateJpaProject(JpaProject.Config config) throws CoreException {
super(config);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -25,7 +25,7 @@
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.core.internal.JpaModelManager;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.KnownConfigurationsAdapter;
@@ -39,8 +39,6 @@
public static final String ID = "org.jboss.tools.hibernate.jpt.core";
//$NON-NLS-1$
- public static final String JPA_FACET_VERSION_1_0 = "1.0"; //$NON-NLS-1$
-
private static HibernateJptPlugin inst = null;
public static HibernateJptPlugin getDefault() {
@@ -104,17 +102,21 @@
KnownConfigurations.getInstance().addConsoleConfigurationListener(new
KnownConfigurationsAdapter(){
private void revalidateProjects(ConsoleConfiguration ccfg){
- //INFO: should revalidate project to calculate correct naming strategy's values
- Iterator<JpaProject> jpaProjects =
JptCorePlugin.getJpaProjectManager().getJpaProjects().iterator();
- while (jpaProjects.hasNext()) {
- JpaProject jpaProject = (JpaProject) jpaProjects.next();
- if (jpaProject instanceof HibernateJpaProject) {
- String ccName =
((HibernateJpaProject)jpaProject).getDefaultConsoleConfigurationName();
- if (ccfg.getName().equals(ccName)){
- rebuildJpaProject(jpaProject.getJavaProject().getProject());
- //jpaProject.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD,
null);
+ //FIXME: call only Dali's validator
+ try {
+ Iterator<JpaProject> jpaProjects =
JpaModelManager.instance().getJpaModel().jpaProjects();
+ while (jpaProjects.hasNext()) {
+ JpaProject jpaProject = (JpaProject) jpaProjects.next();
+ if (jpaProject instanceof HibernateJpaProject) {
+ String ccName =
((HibernateJpaProject)jpaProject).getDefaultConsoleConfigurationName();
+ if (ccfg.getName().equals(ccName)){
+ rebuildJpaProject(jpaProject.getJavaProject().getProject());
+ //jpaProject.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD,
null);
+ }
}
}
+ } catch (CoreException e) {
+ logException(e);
}
}
@@ -145,7 +147,7 @@
final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor)
throws CoreException {
- JptCorePlugin.rebuildJpaProject(project);
+ JpaModelManager.instance().rebuildJpaProject(project);
project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
}
};
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKeyImpl.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKeyImpl.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKeyImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/ForeignKeyImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.ForeignKeyAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ForeignKeyImpl extends AbstractJavaJpaContextNode implements ForeignKey {
+
+ private ForeignKeyAnnotation foreignKeyResource;
+
+ private String name;
+
+ private String inverseName;
+
+ public ForeignKeyImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(ForeignKeyAnnotation foreignKeyResource) {
+ this.foreignKeyResource = foreignKeyResource;
+ this.name = foreignKeyResource.getName();
+ this.inverseName = foreignKeyResource.getInverseName();
+ }
+
+ public void update(ForeignKeyAnnotation foreignKeyResource) {
+ this.foreignKeyResource = foreignKeyResource;
+ this.setName_(foreignKeyResource.getName());
+ this.setInverseName_(foreignKeyResource.getInverseName());
+ }
+
+ private ForeignKeyAnnotation getResourceForeignKey() {
+ return foreignKeyResource;
+ }
+
+ // ***** name
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ String old = this.name;
+ this.name = name;
+ this.getResourceForeignKey().setName(name);
+ this.firePropertyChanged(FOREIGN_KEY_NAME, old, name);
+ }
+
+ public void setName_(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(FOREIGN_KEY_NAME, old, name);
+ }
+
+ // ***** inverseName
+
+ public String getInverseName() {
+ return inverseName;
+ }
+
+ public void setInverseName(String inverseName) {
+ String old = this.inverseName;
+ this.inverseName = inverseName;
+ this.getResourceForeignKey().setInverseName(inverseName);
+ this.firePropertyChanged(FOREIGN_KEY_INVERSE_NAME, old, inverseName);
+ }
+
+ public void setInverseName_(String inverseName) {
+ String old = this.inverseName;
+ this.inverseName = inverseName;
+ this.firePropertyChanged(FOREIGN_KEY_INVERSE_NAME, old, inverseName);
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.foreignKeyResource.getTextRange(astRoot);
+ }
+
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/GenericGeneratorHolder.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/GenericGeneratorHolder.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/GenericGeneratorHolder.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/GenericGeneratorHolder.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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 java.util.ListIterator;
+
+import org.eclipse.jpt.core.context.GeneratorHolder;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface GenericGeneratorHolder extends GeneratorHolder {
+
+ String GENERIC_GENERATORS_LIST = "genericGenerators"; //$NON-NLS-1$
+
+ /**
+ * Return a list iterator of the generic generators.
+ * This will not be null.
+ */
+ <T extends GenericGenerator> ListIterator<T> genericGenerators();
+
+ /**
+ * Return the number of generic generators.
+ */
+ int genericGeneratorsSize();
+
+ /**
+ * Add a generic generator to the entity return the object representing it.
+ */
+ GenericGenerator addGenericGenerator(int index);
+
+ /**
+ * Remove the generic generator at the index from the entity.
+ */
+ void removeGenericGenerator(int index);
+
+ /**
+ * Remove the generic generator from the entity.
+ */
+ void removeGenericGenerator(GenericGenerator generator);
+
+ /**
+ * Move the generic generator from the source index to the target index.
+ */
+ void moveGenericGenerator(int targetIndex, int sourceIndex);
+
+}
Modified:
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateEntity.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -16,14 +16,13 @@
* @author Dmitry Geraskov
*
*/
-public interface HibernateEntity extends Entity {
+public interface HibernateEntity extends Entity,
+ GenericGeneratorHolder, HibernateQueryContainer {
String DISCRIMINATOR_FORMULA_PROPERTY = "discriminatorFormula"; //$NON-NLS-1$
HibernateTable getTable();
- //HibernateGeneratorContainer getGeneratorContainer();
-
//Column getPrimaryIdColumn();
//String getDefaultDBTableName();
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateGeneratorContainer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateGeneratorContainer.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateGeneratorContainer.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,44 +0,0 @@
-package org.jboss.tools.hibernate.jpt.core.internal.context;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.core.context.GeneratorContainer;
-
-public interface HibernateGeneratorContainer extends GeneratorContainer {
-
- //******************** generic generator *****************
-
- String GENERIC_GENERATORS_LIST = "genericGenerators"; //$NON-NLS-1$
-
- /**
- * Return a list iterator of the generic generators.
- * This will not be null.
- */
- ListIterator<? extends GenericGenerator> genericGenerators();
-
- /**
- * Return the number of generic generators.
- */
- int genericGeneratorsSize();
-
- /**
- * Add a generic generator to the entity return the object representing it.
- */
- GenericGenerator addGenericGenerator(int index);
-
- /**
- * Remove the generic generator at the index from the entity.
- */
- void removeGenericGenerator(int index);
-
- /**
- * Remove the generic generator from the entity.
- */
- void removeGenericGenerator(GenericGenerator generator);
-
- /**
- * Move the generic generator from the source index to the target index.
- */
- void moveGenericGenerator(int targetIndex, int sourceIndex);
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateIdMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateIdMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.IdMapping;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public interface HibernateIdMapping extends IdMapping {
-
-}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008-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 java.util.ListIterator;
+
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit.Property;
+import org.eclipse.jpt.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateBasic;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJpaProperties extends AbstractModel {
+
+ private PersistenceUnit persistenceUnit;
+
+ private BasicHibernateProperties basicHibernateProperties;
+
+ private ListValueModel<Property> propertiesAdapter;
+ private ListValueModel<Property> propertyListAdapter;
+
+ public HibernateJpaProperties(PersistenceUnit parent) {
+ super();
+ this.initialize(parent);
+ }
+
+ protected void initialize(PersistenceUnit parent) {
+ this.persistenceUnit = parent;
+ PropertyValueModel<PersistenceUnit> persistenceUnitHolder =
+ new SimplePropertyValueModel<PersistenceUnit>(this.persistenceUnit);
+
+ this.propertiesAdapter = this.buildPropertiesAdapter(persistenceUnitHolder);
+ this.propertyListAdapter = this.buildPropertyListAdapter(this.propertiesAdapter);
+
+ this.basicHibernateProperties = this.buildBasicProperties();
+ }
+
+ private ListValueModel<Property>
buildPropertyListAdapter(ListValueModel<Property> propertiesAdapter) {
+ return new ItemPropertyListValueModelAdapter<Property>(propertiesAdapter,
Property.VALUE_PROPERTY, Property.NAME_PROPERTY);
+ }
+
+ private ListValueModel<Property>
buildPropertiesAdapter(PropertyValueModel<PersistenceUnit> subjectHolder) {
+ return new ListAspectAdapter<PersistenceUnit, Property>(subjectHolder,
PersistenceUnit.PROPERTIES_LIST) {
+ @Override
+ protected ListIterator<Property> listIterator_() {
+ return this.subject.properties();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.propertiesSize();
+ }
+ };
+ }
+
+ // ******** Behavior *********
+ public BasicHibernateProperties getBasicHibernate() {
+ return this.basicHibernateProperties;
+ }
+
+ private BasicHibernateProperties buildBasicProperties() {
+ return new HibernateBasic(this.persistenceUnit(), this.propertyListAdapter());
+ }
+
+ public ListValueModel<Property> propertyListAdapter() {
+ return this.propertyListAdapter;
+ }
+
+ public PersistenceUnit persistenceUnit() {
+ return this.persistenceUnit;
+ }
+
+ public JpaProject getJpaProject() {
+ return this.persistenceUnit.getJpaProject();
+ }
+
+}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -22,7 +22,7 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.core.context.persistence.Persistence;
-import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnit;
+import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -30,17 +30,15 @@
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistenceXmlContextNodeFactory;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernatePersistenceUnit extends AbstractPersistenceUnit
+public class HibernatePersistenceUnit extends GenericPersistenceUnit
implements Messages, Hibernate {
- private HibernatePersistenceUnitProperties hibernateProperties;
+ private HibernateJpaProperties hibernateProperties;
/**
* @param parent
@@ -49,34 +47,12 @@
public HibernatePersistenceUnit(Persistence parent,
XmlPersistenceUnit persistenceUnit) {
super(parent, persistenceUnit);
+ this.hibernateProperties = new HibernateJpaProperties(this);
}
-
- @Override
- public HibernatePersistenceXmlContextNodeFactory getContextNodeFactory() {
- return (HibernatePersistenceXmlContextNodeFactory) super.getContextNodeFactory();
- }
-
- @Override
- protected void initializeProperties() {
- super.initializeProperties();
- this.hibernateProperties =
this.getContextNodeFactory().buildHibernatePersistenceUnitProperties(this);
- }
-
- @Override
- public void propertyRemoved(String propertyName) {
- super.propertyRemoved(propertyName);
- this.hibernateProperties.propertyRemoved(propertyName);
- }
-
- @Override
- public void propertyValueChanged(String propertyName, String newValue) {
- super.propertyValueChanged(propertyName, newValue);
- this.hibernateProperties.propertyValueChanged(propertyName, newValue);
- }
// ******** Behavior *********
- public HibernatePersistenceUnitProperties getHibernatePersistenceUnitProperties() {
- return this.hibernateProperties;
+ public BasicHibernateProperties getBasicProperties() {
+ return this.hibernateProperties.getBasicHibernate();
}
// ********** Validation ***********************************************
@@ -87,7 +63,7 @@
}
protected void validateHibernateConfigurationFileExists(List<IMessage> messages,
IReporter reporter) {
- String configFile = hibernateProperties.getConfigurationFile();
+ String configFile = getBasicProperties().getConfigurationFile();
if (configFile != null && configFile.length() > 0){
IPath path = new Path(configFile);
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2008-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 java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit.Property;
+import org.eclipse.jpt.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public abstract class HibernatePersistenceUnitProperties extends AbstractModel
implements PersistenceUnitProperties {
+
+ private PersistenceUnit persistenceUnit;
+
+ private PersistenceUnitPropertyListListener propertyListListener;
+
+ private Map<String, String> propertyNames;
+
+ protected HibernatePersistenceUnitProperties(
+ PersistenceUnit parent,
+ ListValueModel<Property> propertyListAdapter) {
+ super();
+ this.initialize(parent, propertyListAdapter);
+ }
+
+ protected void initialize(
+ PersistenceUnit parent,
+ ListValueModel<Property> propertyListAdapter) {
+ this.persistenceUnit = parent;
+
+ this.propertyListListener = new PersistenceUnitPropertyListListener(this);
+ propertyListAdapter.addListChangeListener(ListValueModel.LIST_VALUES,
this.propertyListListener);
+
+ this.initializePropertyNames();
+ this.initializeProperties();
+ }
+
+ protected void initializePropertyNames() {
+ this.propertyNames = new HashMap<String, String>();
+ this.addPropertyNames(this.propertyNames);
+ }
+
+ /**
+ * Initializes properties with values from the persistence unit.
+ */
+ protected abstract void initializeProperties();
+
+ // ********** behavior **********
+ public PersistenceUnit persistenceUnit() {
+ return this.persistenceUnit;
+ }
+
+ public JpaProject getJpaProject() {
+ return this.persistenceUnit.getJpaProject();
+ }
+
+ public PersistenceUnitPropertyListListener propertyListListener() {
+ return this.propertyListListener;
+ }
+
+ private Map<String, String> propertyNames() {
+ return this.propertyNames;
+ }
+
+ /**
+ * Adds property names key/value pairs, used by the methods: itemIsProperty
+ * and propertyIdFor.
+ *
+ * key = EclipseLink property key; value = property id
+ */
+ protected abstract void addPropertyNames(Map<String, String> propertyNames);
+
+ /**
+ * Method used for identifying the given property.
+ */
+ public boolean itemIsProperty(Property item) {
+ if (item == null) {
+ throw new IllegalArgumentException("Property is null"); //$NON-NLS-1$
+ }
+ return this.propertyNames().keySet().contains(item.getName());
+ }
+
+ /**
+ * Returns the property name used for change notification of the given
+ * property.
+ */
+ public String propertyIdFor(Property property) {
+ String propertyId = this.propertyNames().get(property.getName());
+ if (propertyId == null) {
+ throw new IllegalArgumentException("Illegal property: " +
property.toString()); //$NON-NLS-1$
+ }
+ return propertyId;
+ }
+
+ protected String hibernateKeyFor(String propertyId) {
+ for (String hibernateKey : this.propertyNames().keySet()) {
+ if (this.propertyNames().get(hibernateKey).equals(propertyId)) {
+ return hibernateKey;
+ }
+ }
+ throw new IllegalArgumentException("Illegal property: " + propertyId);
//$NON-NLS-1$
+ }
+
+ // ****** get/set String convenience methods *******
+ /**
+ * Returns the String value of the given Property from the PersistenceXml.
+ */
+ protected String getStringValue(String key) {
+ return this.getStringValue(key, null);
+ }
+
+ protected String getStringValue(String key, String keySuffix) {
+ String elKey = (keySuffix == null) ? key : key + keySuffix;
+ if (this.persistenceUnit().getProperty(elKey) != null) {
+ // TOREVIEW - handle incorrect String in persistence.xml
+ return this.persistenceUnit().getProperty(elKey).getValue();
+ }
+ return null;
+ }
+
+ /**
+ * Put the given String value into the PersistenceXml.
+ * @param key
+ * EclipseLink Key
+ * @param keySuffix
+ * e.g. entity name
+ * @param newValue
+ * value to be associated with the key
+ * @param allowDuplicate
+ */
+ protected void putStringValue(String key, String keySuffix, String newValue, boolean
allowDuplicate) {
+ String elKey = (keySuffix == null) ? key : key + keySuffix;
+ if (newValue == null) {
+ this.persistenceUnit().removeProperty(elKey);
+ }
+ else {
+ this.persistenceUnit().setProperty(elKey, newValue, allowDuplicate);
+ }
+ }
+
+ // ******** Convenience methods ********
+ /**
+ * Put into persistenceUnit properties.
+ *
+ * @param key -
+ * property name
+ * @param value -
+ * property value
+ */
+ protected void putProperty(String key, Object value) {
+ String elKey = this.hibernateKeyFor(key);
+ if (value == null)
+ this.removeProperty(elKey);
+ else
+ this.putProperty_(elKey, value);
+ }
+
+ private void putProperty_(String key, Object value) {
+ this.persistenceUnit().setProperty(key, value.toString(), false);
+ }
+
+ /**
+ * Removes a property with the given key.
+ */
+ protected void removeProperty(String key) {
+ if(this.persistenceUnit().getProperty(key) != null) {
+ this.persistenceUnit().removeProperty(key);
+ }
+ }
+
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2008-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.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateProperties extends PersistenceUnitProperties {
+
+ BasicHibernateProperties getBasicHibernate();
+
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateQueryContainer.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateQueryContainer.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateQueryContainer.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateQueryContainer.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ListIterator;
+
+import org.eclipse.jpt.core.context.QueryContainer;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateQueryContainer extends QueryContainer {
+
+ String HIBERNATE_NAMED_QUERIES_LIST = "hibernateNamedQueries"; //$NON-NLS-1$
+
+ String HIBERNATE_NAMED_NATIVE_QUERIES_LIST = "hibernateNamedNativeQueries";
//$NON-NLS-1$
+ // ********** named queries **********
+
+ /**
+ * Return a list iterator of the named queries.
+ * This will not be null.
+ */
+ <T extends HibernateNamedQuery> ListIterator<T> hibernateNamedQueries();
+
+ /**
+ * Return the number of named queries.
+ */
+ int hibernateNamedQueriesSize();
+
+ /**
+ * Add a named query to the entity return the object representing it.
+ */
+ HibernateNamedQuery addHibernateNamedQuery(int index);
+
+ /**
+ * Remove the named query at the index from the entity.
+ */
+ void removeHibernateNamedQuery(int index);
+
+ /**
+ * Remove the named query at from the entity.
+ */
+ void removeHibernateNamedQuery(HibernateNamedQuery namedQuery);
+
+ /**
+ * Move the named query from the source index to the target index.
+ */
+ void moveHibernateNamedQuery(int targetIndex, int sourceIndex);
+
+ // ********** named native queries **********
+
+ /**
+ * Return a list iterator of the specified named native queries.
+ * This will not be null.
+ */
+ <T extends HibernateNamedNativeQuery> ListIterator<T>
hibernateNamedNativeQueries();
+
+ /**
+ * Return the number of named native queries.
+ */
+ int hibernateNamedNativeQueriesSize();
+
+ /**
+ * Add a named native query to the entity return the object representing it.
+ */
+ HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index);
+
+ /**
+ * Remove the named native query at the index from the entity.
+ */
+ void removeHibernateNamedNativeQuery(int index);
+
+ /**
+ * Remove the named native query at from the entity.
+ */
+ void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery namedNativeQuery);
+
+ /**
+ * Move the named native query from the source index to the target index.
+ */
+ void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex);
+
+
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Index.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Index.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Index.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Index.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jpt.core.context.JpaContextNode;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.IndexAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface Index extends JpaContextNode {
+
+ String getName();
+ void setName(String name);
+ String INDEX_NAME = "name"; //$NON-NLS-1$
+
+ String[] getColumnNames();
+ void addColumn(String columnName);
+ void removeColumn(String columnName);
+ String INDEX_COLUMN_NAMES = "ColumnNames"; //$NON-NLS-1$
+
+
+ public void initialize(IndexAnnotation indexResource);
+
+ public void update(IndexAnnotation indexResource);
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,7 +12,6 @@
package org.jboss.tools.hibernate.jpt.core.internal.context;
import org.eclipse.jpt.core.context.JpaContextNode;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaIndex;
/**
* @author Dmitry Geraskov
@@ -24,9 +23,9 @@
String INDEX_PROPERTY = "index"; //$NON-NLS-1$
- JavaIndex getIndex();
+ Index getIndex();
- JavaIndex addIndex();
+ Index addIndex();
void removeIndex();
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexImpl.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexImpl.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+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.IndexAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class IndexImpl extends AbstractJavaJpaContextNode implements Index {
+
+ private IndexAnnotation indexResource;
+
+ private String name;
+
+ private String[] columnNames = new String[0];
+
+ public IndexImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(IndexAnnotation indexResource) {
+ this.indexResource = indexResource;
+ this.name = indexResource.getName();
+ this.columnNames = indexResource.getColumnNames();
+ }
+
+ public void update(IndexAnnotation indexResource) {
+ this.indexResource = indexResource;
+ this.setName_(indexResource.getName());
+ this.setColumnNames_(indexResource.getColumnNames());
+ }
+
+ // ***** name
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ String old = this.name;
+ this.name = name;
+ this.getResourceIndex().setName(name);
+ this.firePropertyChanged(INDEX_NAME, old, name);
+ }
+
+ public void setName_(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(INDEX_NAME, old, name);
+ }
+
+ // ***** columnNames
+
+ public String[] getColumnNames() {
+ return columnNames;
+ }
+
+ public void setColumnNames(String[] columnNames) {
+ if (columnNames == null) columnNames = new String[0];
+ String[] old = this.columnNames;
+ this.columnNames = columnNames;
+ this.getResourceIndex().setColumnNames(columnNames);
+ this.firePropertyChanged(INDEX_COLUMN_NAMES, old, columnNames);
+ }
+
+ public void setColumnNames_(String[] columnNames) {
+ String[] old = this.columnNames;
+ this.columnNames = columnNames;
+ this.firePropertyChanged(INDEX_COLUMN_NAMES, old, columnNames);
+ }
+
+ private IndexAnnotation getResourceIndex() {
+ return indexResource;
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.indexResource.getTextRange(astRoot);
+ }
+
+ public void addColumn(String columnName) {
+ String[] old = this.columnNames;
+ String[] newColumns = new String[old.length + 1];
+ System.arraycopy(old, 0, newColumns, 0, old.length);
+ newColumns[newColumns.length - 1] = columnName;
+ this.setColumnNames(newColumns);
+ }
+
+ public void removeColumn(String columnName) {
+ String[] old = this.columnNames;
+ List<String> newColumns = new ArrayList<String>();
+ for (String column : old) {
+ if (!column.equals(columnName)) newColumns.add(column);
+ }
+ this.setColumnNames(newColumns.toArray(new String[newColumns.size()]));
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,19 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2010 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
- ******************************************************************************/
+ * 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;
+import org.eclipse.jpt.core.context.Column;
+import org.eclipse.jpt.core.context.ColumnMapping;
import org.eclipse.jpt.core.context.Entity;
import org.eclipse.jpt.core.context.JoinColumn;
+import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.RelationshipReference;
+import org.eclipse.jpt.core.internal.context.MappingTools;
import org.eclipse.jpt.db.Table;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -26,73 +30,55 @@
* @author Dmitry Geraskov
*
*/
-public class NamingStrategyMappingTools {
+public class NamingStrategyMappingTools extends MappingTools {
- public static String buildJoinTableDefaultName(RelationshipReference
relationshipReference) {
- if (relationshipReference.getJpaProject().getDataSource().connectionProfileIsActive())
{
- return buildDbJoinTableDefaultName(relationshipReference);
+ public static String buildJoinTableDefaultName(RelationshipMapping relationshipMapping)
{
+ if (relationshipMapping.getJpaProject().getDataSource().connectionProfileIsActive()) {
+ return buildDbJoinTableDefaultName(relationshipMapping);
}
-
- RelationshipMapping relationshipMapping =
relationshipReference.getRelationshipMapping();
- if (relationshipMapping == null) {
+ // continue with a "best effort":
+ String owningTableName = relationshipMapping.getTypeMapping().getPrimaryTableName();
+ if (owningTableName == null) {
return null;
}
- Entity ownerEntity = (Entity) relationshipReference.getTypeMapping();
- org.eclipse.jpt.core.context.Table ownerTable = ownerEntity.getTable();
- if (ownerTable == null) {
- return null;
- }
-
Entity targetEntity = relationshipMapping.getResolvedTargetEntity();
if (targetEntity == null) {
return null;
}
-
- org.eclipse.jpt.core.context.Table targetTable = targetEntity.getTable();
- if (targetTable == null) {
+ String targetTableName = targetEntity.getPrimaryTableName();
+ if (targetTableName == null) {
return null;
}
-
- NamingStrategy ns = getJpaProject(relationshipReference).getNamingStrategy();
- if (getJpaProject(relationshipReference).isNamingStrategyEnabled() && ns !=
null){
- /*
- * By testing generated DDL I have found for JPA console configuration:
- * 1) first parameter of the method is always fully qualified owner entity class name
- * 2) second and forth parameters of the method are always fully qualified target
entity class name
- * 3) third parameter of the method is name attribute of @Table annotation,
- * if it is not specified, then it is *unqualified* name attribute of @Entity
annotation
- * if @Entity annotation not specified it is *unqualified* name of the target entity
class.
- * 4) fifth parameter is owner entity field name (even if @Column annotation set
different name)
- *
- */
- try {
- String targetEntityName = targetEntity.getPersistentType().getName();
- String ownerEntityName = ownerEntity.getPersistentType().getName();
- String propName = relationshipMapping.getPersistentAttribute().getName();
- return ns.collectionTableName(ownerEntityName, targetTable.getName(),
- targetEntityName, targetTable.getName(), propName);
+
+ HibernateJpaProject hibernateJpaProject =
(HibernateJpaProject)targetEntity.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (ns != null && hibernateJpaProject.isNamingStrategyEnabled()){
+ try{
+ String name = ns.collectionTableName(
+ relationshipMapping.getEntity().getPersistentType().getName(),//+
+ relationshipMapping.getEntity().getTable().getName(),//+
+ targetEntity.getPersistentType().getName(),//+
+ targetEntity.getTable().getName(),//+
+ relationshipMapping.getName()//+
+ );
+ /*Table primaryTable = relationshipMapping.getTypeMapping().getPrimaryDbTable();
+ return primaryTable != null ?
primaryTable.getDatabase().convertNameToIdentifier(name)
+ : name;*/
+ return name;
} catch (Exception e) {
- Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
HibernateJptPlugin.logException(m.getText(), e);
}
}
- return ownerTable.getName() + '_' + targetTable.getName();
+ return owningTableName + '_' + targetTableName;
}
- public static HibernateJpaProject getJpaProject(RelationshipReference
relationshipReference){
- return (HibernateJpaProject)relationshipReference.getJpaProject();
- }
-
- protected static String buildDbJoinTableDefaultName(RelationshipReference
relationshipReference) {
- Table owningTable = relationshipReference.getTypeMapping().getPrimaryDbTable();
+ protected static String buildDbJoinTableDefaultName(RelationshipMapping
relationshipMapping) {
+ Table owningTable = relationshipMapping.getTypeMapping().getPrimaryDbTable();
if (owningTable == null) {
return null;
}
- RelationshipMapping relationshipMapping =
relationshipReference.getRelationshipMapping();
- if (relationshipMapping == null) {
- return null;
- }
Entity targetEntity = relationshipMapping.getResolvedTargetEntity();
if (targetEntity == null) {
return null;
@@ -101,22 +87,45 @@
if (targetTable == null) {
return null;
}
+
+ HibernateJpaProject hibernateJpaProject =
(HibernateJpaProject)targetEntity.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (ns != null && hibernateJpaProject.isNamingStrategyEnabled()){
+ try {
+ String name = ns.collectionTableName(
+ relationshipMapping.getEntity().getPersistentType().getName(),//+
+ relationshipMapping.getEntity().getTable().getName(),//+
+ targetEntity.getPersistentType().getName(),//+
+ targetEntity.getTable().getName(),//+
+ relationshipMapping.getName()//+
+ );
+ //return owningTable.getDatabase().convertNameToIdentifier(name);
+ return name;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
+ }
String name = owningTable.getName() + '_' + targetTable.getName();
return owningTable.getDatabase().convertNameToIdentifier(name);
}
- public static String buildJoinColumnDefaultName(JoinColumn joinColumn, JoinColumn.Owner
owner) {
+ public static String buildJoinColumnDefaultName(HibernateJoinColumn joinColumn) {
+ JoinColumn.Owner owner = joinColumn.getOwner();
+ RelationshipMapping relationshipMapping = owner.getRelationshipMapping();
+ if (relationshipMapping == null) {
+ return null;
+ }
if (owner.joinColumnsSize() != 1) {
return null;
}
String prefix = owner.getAttributeName();
- if (prefix == null) {
- Entity targetEntity = owner.getTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- prefix = targetEntity.getName();
+ Entity targetEntity = owner.getTargetEntity();
+ if (targetEntity == null) {
+ return null;
}
+ String targetEntityName = targetEntity.getName();
// not sure which of these is correct...
// (the spec implies that the referenced column is always the
// primary key column of the target entity)
@@ -125,6 +134,40 @@
if (targetColumnName == null) {
return null;
}
+ HibernateJpaProject hibernateJpaProject =
(HibernateJpaProject)targetEntity.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (ns != null && hibernateJpaProject.isNamingStrategyEnabled()){
+ String logicalTargetColumnName = null;
+ String name = null;
+ try {
+ if (joinColumn.getSpecifiedName() != null){
+ name = ns.columnName(joinColumn.getSpecifiedName());
+ } else {
+ PersistentAttribute pattr = joinColumn.getReferencedPersistentAttribute();
+ if (pattr != null && pattr.getMapping() instanceof ColumnMapping){
+ Column column = ((ColumnMapping)pattr.getMapping()).getColumn();
+ if (column != null){
+ logicalTargetColumnName = ns.logicalColumnName(column.getSpecifiedName(),
pattr.getName());
+ } else {
+ logicalTargetColumnName = ns.logicalColumnName(null, pattr.getName());
+ }
+ }
+
+ name = ns.foreignKeyColumnName(prefix,
+ targetEntity.getPersistentType().getName(),//+
+ targetEntity.getTable().getName(),//+
+ logicalTargetColumnName);//+
+ }
+ return name;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
+ }
+ if (prefix == null) {
+ prefix = targetEntityName;
+ }
String name = prefix + '_' + targetColumnName;
// not sure which of these is correct...
// converting the name to an identifier will result in the identifier
@@ -133,5 +176,6 @@
// return targetColumn.getDatabase().convertNameToIdentifier(name);
return name;
}
+
}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008-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.JpaProject;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit.Property;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface PersistenceUnitProperties extends Model, PropertyChangeListener {
+
+ /**
+ * Method used for identifying the given property.
+ */
+ boolean itemIsProperty(Property item);
+
+ /**
+ * Returns the property name used for change notification of the given property.
+ */
+ String propertyIdFor(Property property);
+
+ /**
+ * Return the PersistenceUnit of this Properties.
+ */
+ PersistenceUnit persistenceUnit();
+
+ /**
+ * Return the JPA project the PersistenceUnit belongs to.
+ */
+ JpaProject getJpaProject();
+
+ void updateProperties();
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2008-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.utility.model.event.ListChangeEvent;
+import org.eclipse.jpt.utility.model.listener.ListChangeListener;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class PersistenceUnitPropertyListListener implements ListChangeListener
+{
+ private PersistenceUnitProperties parent;
+
+ // ********** constructors / initialization **********
+ public PersistenceUnitPropertyListListener(PersistenceUnitProperties parent) {
+ this.parent = parent;
+ }
+
+ // ********** ListChangeListener implementation **********
+ public void itemsAdded(ListChangeEvent e) {
+ model().updateProperties();
+ }
+
+ public void itemsRemoved(ListChangeEvent e) {
+ model().updateProperties();
+ }
+
+ public void itemsReplaced(ListChangeEvent e) {
+ model().updateProperties();
+ }
+
+ public void itemsMoved(ListChangeEvent e) {
+ model().updateProperties();
+ }
+
+ public void listCleared(ListChangeEvent e) {
+ model().updateProperties();
+ }
+
+ public void listChanged(ListChangeEvent e) {
+ model().updateProperties();
+ }
+
+ // ********** internal methods **********
+ private PersistenceUnitProperties model() {
+ return this.parent;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -10,13 +10,14 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.basic;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitProperties;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
/**
* @author Dmitry Geraskov
*
*/
-public interface BasicHibernateProperties extends PersistenceUnitProperties {
+public interface BasicHibernateProperties extends Model, PropertyChangeListener {
String getDefaultConfigurationFile();
String getConfigurationFile();
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,326 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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 java.util.Map;
+
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit.Property;
+import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnitProperties;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateBasic extends HibernatePersistenceUnitProperties
+ implements BasicHibernateProperties {
+
+ // ********** Hibernate properties **********
+ private String configFile;
+ private String dialect;
+ private String driver;
+ private String url;
+ private String schemaDefault;
+ private String catalogDefault;
+ private String username;
+ private String password;
+
+ // ********** constructors **********
+ public HibernateBasic(PersistenceUnit parent, ListValueModel<Property>
propertyListAdapter) {
+ super(parent, propertyListAdapter);
+ }
+
+ // ********** initialization **********
+ /**
+ * Initializes properties with values from the persistence unit.
+ */
+ @Override
+ protected void initializeProperties() {
+ this.configFile =
+ this.getStringValue(HIBERNATE_CONFIG_FILE);
+ this.dialect =
+ this.getStringValue(HIBERNATE_DIALECT);
+ this.driver =
+ this.getStringValue(HIBERNATE_DRIVER);
+ this.url =
+ this.getStringValue(HIBERNATE_URL);
+ this.schemaDefault =
+ this.getStringValue(HIBERNATE_SCHEMA_DEFAULT);
+ this.catalogDefault =
+ this.getStringValue(HIBERNATE_CATALOG);
+ this.username =
+ this.getStringValue(HIBERNATE_USERNAME);
+ this.password =
+ this.getStringValue(HIBERNATE_PASSWORD);
+ }
+
+
+ // ********** behavior **********
+ @Override
+ protected void addPropertyNames(Map<String, String> propertyNames) {
+ propertyNames.put(
+ HIBERNATE_CONFIG_FILE,
+ CONFIG_FILE_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_DIALECT,
+ DIALECT_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_DRIVER,
+ DRIVER_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_URL,
+ URL_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_SCHEMA_DEFAULT,
+ SCHEMA_DEFAULT_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_CATALOG,
+ CATALOG_DEFAULT_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_USERNAME,
+ USERNAME_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_PASSWORD,
+ PASSWORD_PROPERTY);
+ }
+
+ public void propertyChanged(PropertyChangeEvent event) {
+ String aspectName = event.getAspectName();
+ if (aspectName.equals(CONFIG_FILE_PROPERTY)) {
+ this.configurationFileChanged(event);
+ } else if (aspectName.equals(DIALECT_PROPERTY)) {
+ this.dialectChanged(event);
+ } else if (aspectName.equals(DRIVER_PROPERTY)) {
+ this.driverChanged(event);
+ } else if (aspectName.equals(URL_PROPERTY)) {
+ this.urlChanged(event);
+ } else if (aspectName.equals(SCHEMA_DEFAULT_PROPERTY)) {
+ this.schemaDefaultChanged(event);
+ } else if (aspectName.equals(CATALOG_DEFAULT_PROPERTY)) {
+ this.catalogDefaultChanged(event);
+ } else if (aspectName.equals(USERNAME_PROPERTY)) {
+ this.usernameChanged(event);
+ } else if (aspectName.equals(PASSWORD_PROPERTY)) {
+ this.passwordChanged(event);
+ }
+ }
+
+ // ********** Configuration File **********
+ public String getDefaultConfigurationFile() {
+ return DEFAULT_CONFIG_FILE;
+ }
+
+ public String getConfigurationFile() {
+ return this.configFile;
+ }
+
+ public void setConfigurationFile(String newConfigFile) {
+ if (!valueWasChanged(configFile, newConfigFile)) return;
+ String old = this.configFile;
+ this.configFile = newConfigFile;
+ this.putProperty(CONFIG_FILE_PROPERTY, newConfigFile);
+ this.firePropertyChanged(CONFIG_FILE_PROPERTY, old, newConfigFile);
+ }
+
+ private void configurationFileChanged(PropertyChangeEvent event) {
+ String newFile = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.configFile;
+ this.configFile = newFile;
+ this.firePropertyChanged(event.getAspectName(), old, newFile);
+ }
+
+ // ********** Dialect **********
+ public String getDefaultDialect() {
+ return DEFAULT_DIALECT;
+ }
+
+ public String getDialect() {
+ return this.dialect;
+ }
+
+ public void setDialect(String newDialect) {
+ if (!valueWasChanged(dialect, newDialect)) return;
+ String old = this.dialect;
+ this.dialect = newDialect;
+ this.putProperty(DIALECT_PROPERTY, newDialect);
+ this.firePropertyChanged(DIALECT_PROPERTY, old, newDialect);
+ }
+
+ private void dialectChanged(PropertyChangeEvent event) {
+ String newDialect = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.dialect;
+ this.dialect = newDialect;
+ this.firePropertyChanged(event.getAspectName(), old, newDialect);
+ }
+
+ // ********** Driver **********
+ public String getDefaultDriver() {
+ return DEFAULT_DRIVER;
+ }
+
+ public String getDriver() {
+ return this.driver;
+ }
+
+ public void setDriver(String newDriver) {
+ if (!valueWasChanged(driver, newDriver)) return;
+ String old = this.driver;
+ this.driver = newDriver;
+ this.putProperty(DRIVER_PROPERTY, newDriver);
+ this.firePropertyChanged(DRIVER_PROPERTY, old, newDriver);
+ }
+
+ private void driverChanged(PropertyChangeEvent event) {
+ String newDriver = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.driver;
+ this.driver = newDriver;
+ this.firePropertyChanged(event.getAspectName(), old, newDriver);
+ }
+
+ // ********** Url **********
+ public String getDefaultUrl() {
+ return DEFAULT_URL;
+ }
+
+ public String getUrl() {
+ return this.url;
+ }
+
+ public void setUrl(String newUrl) {
+ if (!valueWasChanged(url, newUrl)) return;
+ String old = this.url;
+ this.url = newUrl;
+ this.putProperty(URL_PROPERTY, newUrl);
+ this.firePropertyChanged(URL_PROPERTY, old, newUrl);
+ }
+
+ private void urlChanged(PropertyChangeEvent event) {
+ String newUrl = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.url;
+ this.url = newUrl;
+ this.firePropertyChanged(event.getAspectName(), old, newUrl);
+ }
+
+ // ********** Default schema **********
+ public String getDefaultSchemaDefault() {
+ return DEFAULT_SCHEMA_DEFAULT;
+ }
+
+ public String getSchemaDefault() {
+ return schemaDefault;
+ }
+
+ public void setSchemaDefault(String newSchemaDefault) {
+ if (!valueWasChanged(schemaDefault, newSchemaDefault)) return;
+ String old = this.schemaDefault;
+ this.schemaDefault = newSchemaDefault;
+ this.putProperty(SCHEMA_DEFAULT_PROPERTY, newSchemaDefault);
+ this.firePropertyChanged(SCHEMA_DEFAULT_PROPERTY, old, newSchemaDefault);
+ }
+
+ private void schemaDefaultChanged(PropertyChangeEvent event) {
+ String newSchemaDefault = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.schemaDefault;
+ this.schemaDefault = newSchemaDefault;
+ this.firePropertyChanged(event.getAspectName(), old, newSchemaDefault);
+ }
+
+ // ********** Default catalog **********
+ public String getDefaultCatalogDefault() {
+ return DEFAULT_CATALOG_DEFAULT;
+ }
+
+ public String getCatalogDefault() {
+ return catalogDefault;
+ }
+
+ public void setCatalogDefault(String newCatalogDefault) {
+ if (!valueWasChanged(catalogDefault, newCatalogDefault)) return;
+ String old = this.catalogDefault;
+ this.catalogDefault = newCatalogDefault;
+ this.putProperty(CATALOG_DEFAULT_PROPERTY, newCatalogDefault);
+ this.firePropertyChanged(CATALOG_DEFAULT_PROPERTY, old, newCatalogDefault);
+ }
+
+ private void catalogDefaultChanged(PropertyChangeEvent event) {
+ String newCatalogDefault = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.catalogDefault;
+ this.catalogDefault = newCatalogDefault;
+ this.firePropertyChanged(event.getAspectName(), old, newCatalogDefault);
+ }
+
+ // ********** Username **********
+ public String getDefaultUsername() {
+ return DEFAULT_USERNAME;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String newUsername) {
+ if (!valueWasChanged(username, newUsername)) return;
+ String old = this.username;
+ this.username = newUsername;
+ this.putProperty(USERNAME_PROPERTY, newUsername);
+ this.firePropertyChanged(USERNAME_PROPERTY, old, newUsername);
+ }
+
+ private void usernameChanged(PropertyChangeEvent event) {
+ String newUsername = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.username;
+ this.username = newUsername;
+ this.firePropertyChanged(event.getAspectName(), old, newUsername);
+ }
+
+ // ********** Password **********
+ public String getDefaultPassword() {
+ return DEFAULT_PASSWORD;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String newPassword) {
+ if (!valueWasChanged(password, newPassword)) return;
+ String old = this.password;
+ this.password = newPassword;
+ this.putProperty(PASSWORD_PROPERTY, newPassword);
+ this.firePropertyChanged(PASSWORD_PROPERTY, old, newPassword);
+ }
+
+ private void passwordChanged(PropertyChangeEvent event) {
+ String newPassword = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.password;
+ this.password = newPassword;
+ this.firePropertyChanged(event.getAspectName(), old, newPassword);
+ }
+
+ public void updateProperties() {
+ setConfigurationFile(this.getStringValue(HIBERNATE_CONFIG_FILE));
+ setDialect(this.getStringValue(HIBERNATE_DIALECT));
+ setDriver(this.getStringValue(HIBERNATE_DRIVER));
+ setUrl(this.getStringValue(HIBERNATE_URL));
+ setSchemaDefault(this.getStringValue(HIBERNATE_SCHEMA_DEFAULT));
+ setCatalogDefault(this.getStringValue(HIBERNATE_CATALOG));
+ setUsername(this.getStringValue(HIBERNATE_USERNAME));
+ setPassword(this.getStringValue(HIBERNATE_PASSWORD));
+ }
+
+ private boolean valueWasChanged(String oldValue, String newValue){
+ return oldValue == null ? newValue != null
+ : !oldValue.equals(newValue);
+ }
+
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateIdMapping.java
(from rev 22306,
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 2010-05-26
13:13:34 UTC (rev 22326)
@@ -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 {
+
+
+}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernatePersistenceUnitProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernatePersistenceUnitProperties.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernatePersistenceUnitProperties.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,309 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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 java.util.Map;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import
org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnitProperties;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernatePersistenceUnitProperties extends AbstractPersistenceUnitProperties
- implements BasicHibernateProperties {
-
- // ********** Hibernate properties **********
- private String configFile;
- private String dialect;
- private String driver;
- private String url;
- private String schemaDefault;
- private String catalogDefault;
- private String username;
- private String password;
-
- // ********** constructors **********
- public HibernatePersistenceUnitProperties(PersistenceUnit parent) {
- super(parent);
- }
-
- // ********** initialization **********
- /**
- * Initializes properties with values from the persistence unit.
- */
- @Override
- protected void initializeProperties() {
- this.configFile =
- this.getStringValue(HIBERNATE_CONFIG_FILE);
- this.dialect =
- this.getStringValue(HIBERNATE_DIALECT);
- this.driver =
- this.getStringValue(HIBERNATE_DRIVER);
- this.url =
- this.getStringValue(HIBERNATE_URL);
- this.schemaDefault =
- this.getStringValue(HIBERNATE_SCHEMA_DEFAULT);
- this.catalogDefault =
- this.getStringValue(HIBERNATE_CATALOG);
- this.username =
- this.getStringValue(HIBERNATE_USERNAME);
- this.password =
- this.getStringValue(HIBERNATE_PASSWORD);
- }
-
- public void propertyValueChanged(String propertyName, String newValue) {
- if (propertyName.equals(HIBERNATE_CONFIG_FILE)) {
- this.configurationFileChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_DIALECT)) {
- this.dialectChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_DRIVER)) {
- this.driverChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_URL)) {
- this.urlChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_SCHEMA_DEFAULT)) {
- this.schemaDefaultChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_CATALOG)) {
- this.catalogDefaultChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_USERNAME)) {
- this.usernameChanged(newValue);
- } else if (propertyName.equals(HIBERNATE_PASSWORD)) {
- this.passwordChanged(newValue);
- }
- }
-
- public void propertyRemoved(String propertyName) {
- if (propertyName.equals(CONFIG_FILE_PROPERTY)) {
- this.configurationFileChanged(null);
- } else if (propertyName.equals(DIALECT_PROPERTY)) {
- this.dialectChanged(null);
- } else if (propertyName.equals(DRIVER_PROPERTY)) {
- this.driverChanged(null);
- } else if (propertyName.equals(URL_PROPERTY)) {
- this.urlChanged(null);
- } else if (propertyName.equals(SCHEMA_DEFAULT_PROPERTY)) {
- this.schemaDefaultChanged(null);
- } else if (propertyName.equals(CATALOG_DEFAULT_PROPERTY)) {
- this.catalogDefaultChanged(null);
- } else if (propertyName.equals(USERNAME_PROPERTY)) {
- this.usernameChanged(null);
- } else if (propertyName.equals(PASSWORD_PROPERTY)) {
- this.passwordChanged(null);
- }
- }
-
- @Override
- protected void addPropertyNames(Map<String, String> propertyNames) {
- propertyNames.put(
- HIBERNATE_CONFIG_FILE,
- CONFIG_FILE_PROPERTY);
- propertyNames.put(
- HIBERNATE_DIALECT,
- DIALECT_PROPERTY);
- propertyNames.put(
- HIBERNATE_DRIVER,
- DRIVER_PROPERTY);
- propertyNames.put(
- HIBERNATE_URL,
- URL_PROPERTY);
- propertyNames.put(
- HIBERNATE_SCHEMA_DEFAULT,
- SCHEMA_DEFAULT_PROPERTY);
- propertyNames.put(
- HIBERNATE_CATALOG,
- CATALOG_DEFAULT_PROPERTY);
- propertyNames.put(
- HIBERNATE_USERNAME,
- USERNAME_PROPERTY);
- propertyNames.put(
- HIBERNATE_PASSWORD,
- PASSWORD_PROPERTY);
- }
-
-
- // ********** Configuration File **********
- public String getDefaultConfigurationFile() {
- return DEFAULT_CONFIG_FILE;
- }
-
- public String getConfigurationFile() {
- return this.configFile;
- }
-
- public void setConfigurationFile(String newConfigFile) {
- String old = this.configFile;
- this.configFile = newConfigFile;
- this.putProperty(CONFIG_FILE_PROPERTY, newConfigFile);
- this.firePropertyChanged(CONFIG_FILE_PROPERTY, old, newConfigFile);
- }
-
- private void configurationFileChanged(String newFile) {
- String old = this.configFile;
- this.configFile = newFile;
- this.firePropertyChanged(CONFIG_FILE_PROPERTY, old, newFile);
- }
-
- // ********** Dialect **********
- public String getDefaultDialect() {
- return DEFAULT_DIALECT;
- }
-
- public String getDialect() {
- return this.dialect;
- }
-
- public void setDialect(String newDialect) {
- String old = this.dialect;
- this.dialect = newDialect;
- this.putProperty(DIALECT_PROPERTY, newDialect);
- this.firePropertyChanged(DIALECT_PROPERTY, old, newDialect);
- }
-
- private void dialectChanged(String newDialect) {
- String old = this.dialect;
- this.dialect = newDialect;
- this.firePropertyChanged(DIALECT_PROPERTY, old, newDialect);
- }
-
- // ********** Driver **********
- public String getDefaultDriver() {
- return DEFAULT_DRIVER;
- }
-
- public String getDriver() {
- return this.driver;
- }
-
- public void setDriver(String newDriver) {
- String old = this.driver;
- this.driver = newDriver;
- this.putProperty(DRIVER_PROPERTY, newDriver);
- this.firePropertyChanged(DRIVER_PROPERTY, old, newDriver);
- }
-
- private void driverChanged(String newDriver) {
- String old = this.driver;
- this.driver = newDriver;
- this.firePropertyChanged(DRIVER_PROPERTY, old, newDriver);
- }
-
- // ********** Url **********
- public String getDefaultUrl() {
- return DEFAULT_URL;
- }
-
- public String getUrl() {
- return this.url;
- }
-
- public void setUrl(String newUrl) {
- String old = this.url;
- this.url = newUrl;
- this.putProperty(URL_PROPERTY, newUrl);
- this.firePropertyChanged(URL_PROPERTY, old, newUrl);
- }
-
- private void urlChanged(String newUrl) {
- String old = this.url;
- this.url = newUrl;
- this.firePropertyChanged(URL_PROPERTY, old, newUrl);
- }
-
- // ********** Default schema **********
- public String getDefaultSchemaDefault() {
- return DEFAULT_SCHEMA_DEFAULT;
- }
-
- public String getSchemaDefault() {
- return schemaDefault;
- }
-
- public void setSchemaDefault(String newSchemaDefault) {
- String old = this.schemaDefault;
- this.schemaDefault = newSchemaDefault;
- this.putProperty(SCHEMA_DEFAULT_PROPERTY, newSchemaDefault);
- this.firePropertyChanged(SCHEMA_DEFAULT_PROPERTY, old, newSchemaDefault);
- }
-
- private void schemaDefaultChanged(String newSchemaDefault) {
- String old = this.schemaDefault;
- this.schemaDefault = newSchemaDefault;
- this.firePropertyChanged(SCHEMA_DEFAULT_PROPERTY, old, newSchemaDefault);
- }
-
- // ********** Default catalog **********
- public String getDefaultCatalogDefault() {
- return DEFAULT_CATALOG_DEFAULT;
- }
-
- public String getCatalogDefault() {
- return catalogDefault;
- }
-
- public void setCatalogDefault(String newCatalogDefault) {
- String old = this.catalogDefault;
- this.catalogDefault = newCatalogDefault;
- this.putProperty(CATALOG_DEFAULT_PROPERTY, newCatalogDefault);
- this.firePropertyChanged(CATALOG_DEFAULT_PROPERTY, old, newCatalogDefault);
- }
-
- private void catalogDefaultChanged(String newCatalogDefault) {
- String old = this.catalogDefault;
- this.catalogDefault = newCatalogDefault;
- this.firePropertyChanged(CATALOG_DEFAULT_PROPERTY, old, newCatalogDefault);
- }
-
- // ********** Username **********
- public String getDefaultUsername() {
- return DEFAULT_USERNAME;
- }
-
- public String getUsername() {
- return this.username;
- }
-
- public void setUsername(String newUsername) {
- String old = this.username;
- this.username = newUsername;
- this.putProperty(USERNAME_PROPERTY, newUsername);
- this.firePropertyChanged(USERNAME_PROPERTY, old, newUsername);
- }
-
- private void usernameChanged(String newUsername) {
- String old = this.username;
- this.username = newUsername;
- this.firePropertyChanged(USERNAME_PROPERTY, old, newUsername);
- }
-
- // ********** Password **********
- public String getDefaultPassword() {
- return DEFAULT_PASSWORD;
- }
-
- public String getPassword() {
- return this.password;
- }
-
- public void setPassword(String newPassword) {
- String old = this.password;
- this.password = newPassword;
- this.putProperty(PASSWORD_PROPERTY, newPassword);
- this.firePropertyChanged(PASSWORD_PROPERTY, old, newPassword);
- }
-
- private void passwordChanged(String newPassword) {
- String old = this.password;
- this.password = newPassword;
- this.firePropertyChanged(PASSWORD_PROPERTY, old, newPassword);
- }
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/ForeignKeyImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class ForeignKeyImpl extends AbstractJavaJpaContextNode implements ForeignKey {
-
- private ForeignKeyAnnotation foreignKeyResource;
-
- private String name;
-
- private String inverseName;
-
- public ForeignKeyImpl(JavaJpaContextNode parent) {
- super(parent);
- }
-
- public void initialize(ForeignKeyAnnotation foreignKeyResource) {
- this.foreignKeyResource = foreignKeyResource;
- this.name = foreignKeyResource.getName();
- this.inverseName = foreignKeyResource.getInverseName();
- }
-
- public void update(ForeignKeyAnnotation foreignKeyResource) {
- this.foreignKeyResource = foreignKeyResource;
- this.setName_(foreignKeyResource.getName());
- this.setInverseName_(foreignKeyResource.getInverseName());
- }
-
- private ForeignKeyAnnotation getResourceForeignKey() {
- return foreignKeyResource;
- }
-
- // ***** name
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.getResourceForeignKey().setName(name);
- this.firePropertyChanged(FOREIGN_KEY_NAME, old, name);
- }
-
- public void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(FOREIGN_KEY_NAME, old, name);
- }
-
- // ***** inverseName
-
- public String getInverseName() {
- return inverseName;
- }
-
- public void setInverseName(String inverseName) {
- String old = this.inverseName;
- this.inverseName = inverseName;
- this.getResourceForeignKey().setInverseName(inverseName);
- this.firePropertyChanged(FOREIGN_KEY_INVERSE_NAME, old, inverseName);
- }
-
- public void setInverseName_(String inverseName) {
- String old = this.inverseName;
- this.inverseName = inverseName;
- this.firePropertyChanged(FOREIGN_KEY_INVERSE_NAME, old, inverseName);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.foreignKeyResource.getTextRange(astRoot);
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,13 +11,16 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-import java.util.Vector;
+import java.util.Iterator;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaBasicMapping;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.Generated;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenerationTime;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Index;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GeneratedAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.IndexAnnotation;
@@ -31,16 +34,20 @@
protected GenerationTime specifiedGenerationTime;
- protected JavaIndex index;
+ protected Index index;
public HibernateJavaBasicMappingImpl(JavaPersistentAttribute parent) {
super(parent);
}
- @Override
- public void addSupportingAnnotationNamesTo(Vector<String> names) {
- names.add(Hibernate.GENERATED);
- names.add(Hibernate.INDEX);
+ public Iterator<String> supportingAnnotationNames() {
+ return new ArrayIterator<String>(
+ JPA.COLUMN,
+ JPA.LOB,
+ JPA.TEMPORAL,
+ JPA.ENUMERATED,
+ Hibernate.GENERATED,
+ Hibernate.INDEX);
}
@Override
@@ -63,15 +70,15 @@
}
public GeneratedAnnotation getResourceGenerated() {
- return (GeneratedAnnotation)
getResourcePersistentAttribute().getAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
+ return (GeneratedAnnotation)
getResourcePersistentAttribute().getSupportingAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
}
public GeneratedAnnotation addResourceGenerated() {
- return (GeneratedAnnotation)
getResourcePersistentAttribute().addAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
+ return (GeneratedAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
}
public void removeResourceGenerated() {
- getResourcePersistentAttribute().removeAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
+ getResourcePersistentAttribute().removeSupportingAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
}
protected GenerationTime getResourceGenerationTime(){
@@ -102,9 +109,11 @@
this.specifiedGenerationTime = newGenerationTime;
firePropertyChanged(Generated.GENERATION_TIME_PROPERTY, oldValue, newGenerationTime);
}
+
+
public void removeResourceIndex() {
- getResourcePersistentAttribute().removeAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ getResourcePersistentAttribute().removeSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
}
// *** index
@@ -133,23 +142,23 @@
}
}
- public JavaIndex addIndex() {
+ public Index addIndex() {
if (getIndex() != null) {
throw new IllegalStateException("index already exists"); //$NON-NLS-1$
}
this.index = getJpaFactory().buildIndex(this);
- IndexAnnotation indexResource = (IndexAnnotation)
getResourcePersistentAttribute().addAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ IndexAnnotation indexResource = (IndexAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
this.index.initialize(indexResource);
firePropertyChanged(INDEX_PROPERTY, null, this.index);
return this.index;
}
- public JavaIndex getIndex() {
+ public Index getIndex() {
return this.index;
}
- protected void setIndex(JavaIndex newIndex) {
- JavaIndex oldIndex = this.index;
+ protected void setIndex(Index newIndex) {
+ Index oldIndex = this.index;
this.index = newIndex;
firePropertyChanged(INDEX_PROPERTY, oldIndex, newIndex);
}
@@ -158,20 +167,20 @@
if (getIndex() == null) {
throw new IllegalStateException("index does not exist, cannot be removed");
//$NON-NLS-1$
}
- JavaIndex oldIndex = this.index;
+ Index oldIndex = this.index;
this.index = null;
- this.getResourcePersistentAttribute().removeAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
firePropertyChanged(INDEX_PROPERTY, oldIndex, null);
}
- protected JavaIndex buildIndex(IndexAnnotation indexResource) {
- JavaIndex index = getJpaFactory().buildIndex(this);
+ protected Index buildIndex(IndexAnnotation indexResource) {
+ Index index = getJpaFactory().buildIndex(this);
index.initialize(indexResource);
return index;
}
protected IndexAnnotation getResourceIndex() {
- return (IndexAnnotation)
this.getResourcePersistentAttribute().getAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ return (IndexAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
}
}
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumnImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -10,9 +10,9 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
+import org.eclipse.jpt.core.context.java.JavaColumn;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaColumn;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaColumn;
import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
import org.eclipse.jpt.db.Column;
import org.eclipse.jpt.db.Table;
@@ -21,8 +21,8 @@
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
@@ -30,7 +30,7 @@
*/
public class HibernateJavaColumnImpl extends GenericJavaColumn implements
HibernateJavaColumn {
- public HibernateJavaColumnImpl(JavaJpaContextNode parent, JavaBaseColumn.Owner owner) {
+ public HibernateJavaColumnImpl(JavaJpaContextNode parent, JavaColumn.Owner owner) {
super(parent, owner);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaDiscriminatorColumnImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaDiscriminatorColumnImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaDiscriminatorColumnImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -16,7 +16,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaDiscriminatorColumn;
import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaDiscriminatorColumn;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaDiscriminatorColumn;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.Column;
@@ -27,8 +27,8 @@
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -20,8 +20,6 @@
*/
public interface HibernateJavaEntity extends JavaEntity,
HibernateEntity, ForeignKeyHolder{
-
- HibernateJavaGeneratorContainer getGeneratorContainer();
JavaDiscriminatorFormula getDiscriminatorFormula();
Modified:
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/HibernateJavaEntityImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -10,39 +10,50 @@
******************************************************************************/
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.BaseJoinColumn;
import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
import org.eclipse.jpt.core.context.Table;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.java.JavaBaseJoinColumn;
+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.context.java.JavaBaseJoinColumn.Owner;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaCacheable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCacheable2_0;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
+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.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.hibernate.cfg.NamingStrategy;
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.HibernateJptPlugin;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+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;
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
@@ -52,24 +63,29 @@
implements HibernateJavaEntity {
protected JavaDiscriminatorFormula discriminatorFormula;
+
+ protected final List<JavaGenericGenerator> genericGenerators;
- protected JavaCacheable2_0 cachable;
+ protected final List<HibernateNamedQuery> hibernateNamedQueries;
+ protected final List<HibernateNamedNativeQuery> hibernateNamedNativeQueries;
+
protected ForeignKey foreignKey;
public HibernateJavaEntityImpl(JavaPersistentType parent) {
super(parent);
- this.cachable = buildJavaCachable();
+ this.genericGenerators = new ArrayList<JavaGenericGenerator>();
+ this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
+ this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
}
- protected JavaCacheable2_0 buildJavaCachable() {
- return new NullJavaCacheable2_0(this);
- }
-
@Override
public void initialize(JavaResourcePersistentType resourcePersistentType) {
super.initialize(resourcePersistentType);
this.initializeDiscriminatorFormula();
+ this.initializeGenericGenerators();
+ this.initializeHibernateNamedQueries();
+ this.initializeHibernateNamedNativeQueries();
this.initializeForeignKey();
}
@@ -77,8 +93,11 @@
public void update(JavaResourcePersistentType resourcePersistentType) {
super.update(resourcePersistentType);
this.updateDiscriminatorFormula();
+ this.updateGenericGenerators();
+ this.updateHibernateNamedQueries();
+ this.updateHibernateNamedNativeQueries();
this.updateForeignKey();
- }
+ }
protected HibernateJpaFactory getJpaFactory() {
return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
@@ -89,26 +108,29 @@
return (HibernateJpaProject) super.getJpaProject();
}
- protected static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY2 = new String[] {
- Hibernate.GENERIC_GENERATOR,
- Hibernate.GENERIC_GENERATORS,
- Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES,
- Hibernate.NAMED_NATIVE_QUERY,
- Hibernate.NAMED_NATIVE_QUERIES,
- Hibernate.DISCRIMINATOR_FORMULA,
- Hibernate.FOREIGN_KEY
- };
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterator<JavaQuery> queries() {
+ return new CompositeIterator<JavaQuery>(
+ super.queries(),
+ this.hibernateNamedQueries(),
+ this.hibernateNamedNativeQueries());
+ }
- protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES2 = new
ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY2);
-
-
@SuppressWarnings("unchecked")
@Override
- public Iterable<String> getSupportingAnnotationNames() {
- return new CompositeIterable<String>(
- SUPPORTING_ANNOTATION_NAMES2,
- super.getSupportingAnnotationNames());
+ 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,
+ Hibernate.FOREIGN_KEY),
+ super.correspondingAnnotationNames());
}
public HibernateJavaTable getTable() {
@@ -131,7 +153,7 @@
throw new IllegalStateException("discriminatorFormula already exists");
//$NON-NLS-1$
}
this.discriminatorFormula = getJpaFactory().buildJavaDiscriminatorFormula(this);
- DiscriminatorFormulaAnnotation discriminatorFormulaResource =
(DiscriminatorFormulaAnnotation)
this.javaResourcePersistentType.addAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
+ DiscriminatorFormulaAnnotation discriminatorFormulaResource =
(DiscriminatorFormulaAnnotation)
this.javaResourcePersistentType.addSupportingAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
this.discriminatorFormula.initialize(discriminatorFormulaResource);
firePropertyChanged(DISCRIMINATOR_FORMULA_PROPERTY, null, this.discriminatorFormula);
return this.discriminatorFormula;
@@ -143,7 +165,7 @@
}
JavaDiscriminatorFormula oldDiscriminatorFormula = this.discriminatorFormula;
this.discriminatorFormula = null;
- this.javaResourcePersistentType.removeAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
+ this.javaResourcePersistentType.removeSupportingAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
firePropertyChanged(DISCRIMINATOR_FORMULA_PROPERTY, oldDiscriminatorFormula,null);
}
@@ -172,7 +194,7 @@
}
public DiscriminatorFormulaAnnotation getDiscriminatorFormulaResource() {
- return (DiscriminatorFormulaAnnotation)
this.javaResourcePersistentType.getAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
+ return (DiscriminatorFormulaAnnotation)
this.javaResourcePersistentType.getSupportingAnnotation(DiscriminatorFormulaAnnotation.ANNOTATION_NAME);
}
protected JavaDiscriminatorFormula
buildDiscriminatorFormula(DiscriminatorFormulaAnnotation discriminatorFormulaResource) {
@@ -180,7 +202,253 @@
discriminatorFormula.initialize(discriminatorFormulaResource);
return discriminatorFormula;
}
+ // ********************* 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);
+ }
+
// ********************* foreignKey **************
protected void initializeForeignKey() {
@@ -212,7 +480,7 @@
throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
}
this.foreignKey = getJpaFactory().buildForeignKey(this);
- ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
javaResourcePersistentType.addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
javaResourcePersistentType.addSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
this.foreignKey.initialize(foreignKeyResource);
firePropertyChanged(FOREIGN_KEY_PROPERTY, null, this.foreignKey);
return this.foreignKey;
@@ -234,7 +502,7 @@
}
ForeignKey oldForeignKey = this.foreignKey;
this.foreignKey = null;
- this.javaResourcePersistentType.removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ this.javaResourcePersistentType.removeSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, null);
}
@@ -245,17 +513,12 @@
}
protected ForeignKeyAnnotation getResourceForeignKey() {
- return (ForeignKeyAnnotation)
this.javaResourcePersistentType.getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ return (ForeignKeyAnnotation)
this.javaResourcePersistentType.getSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
}
public org.eclipse.jpt.db.Table getForeignKeyDbTable() {
return getPrimaryDbTable();
}
-
- @Override
- public HibernateJavaGeneratorContainer getGeneratorContainer() {
- return (HibernateJavaGeneratorContainer)super.getGeneratorContainer();
- }
// ************************* validation ***********************
@Override
@@ -266,8 +529,8 @@
}
protected void validateGenericGenerator(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
- while (getGeneratorContainer().genericGenerators().hasNext()) {
- getGeneratorContainer().genericGenerators().next().validate(messages, reporter,
astRoot);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ genericGenerator.validate(messages, reporter, astRoot);
}
}
@@ -276,7 +539,7 @@
if (!shouldValidateAgainstDatabase() || foreignKey == null || table == null ){
return;
}
- Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.getForeignKeys().iterator();
+ Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.foreignKeys();
while (fks.hasNext()) {
org.eclipse.jpt.db.ForeignKey fk = (org.eclipse.jpt.db.ForeignKey) fks.next();
if (foreignKey.getName().equals(fk.getIdentifier())){
@@ -300,9 +563,8 @@
if (result != null) {
return result;
}
- while (getGeneratorContainer().genericGenerators().hasNext()) {
- result = getGeneratorContainer().genericGenerators().next()
- .javaCompletionProposals(pos, filter, astRoot);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ result = genericGenerator.javaCompletionProposals(pos, filter, astRoot);
if (result != null) {
return result;
}
@@ -325,7 +587,7 @@
}*/
@Override
- protected JavaBaseJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() {
+ protected Owner createPrimaryKeyJoinColumnOwner() {
return new HibernatePrimaryKeyJoinColumnOwner();
}
@@ -336,10 +598,6 @@
public TextRange getValidationTextRange(CompilationUnit astRoot) {
return HibernateJavaEntityImpl.this.getValidationTextRange(astRoot);
}
-
- public String getDefaultTableName() {
- return HibernateJavaEntityImpl.this.getPrimaryTableName();
- }
public TypeMapping getTypeMapping() {
return HibernateJavaEntityImpl.this;
@@ -368,44 +626,24 @@
}
Entity parentEntity = HibernateJavaEntityImpl.this.getParentEntity();
- if (parentEntity != null) {
- HibernateJpaProject hibernateJpaProject =
HibernateJavaEntityImpl.this.getJpaProject();
- NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
- if (hibernateJpaProject.isNamingStrategyEnabled() && ns != null) {
- try {
- String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
- parentEntity.getPrimaryTableName());
- if (parentEntity.getPrimaryDbTable() != null){
- return
parentEntity.getPrimaryDbTable().getDatabase().convertNameToIdentifier(name);
- }
- return name ;
- } catch (Exception e) {
- Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
- HibernateJptPlugin.logException(m.getText(), e);
+ /*HibernateJpaProject hibernateJpaProject =
HibernateJavaEntityImpl.this.getJpaProject();
+ NamingStrategy ns = hibernateJpaProject.getNamingStrategy();
+ if (hibernateJpaProject.isNamingStrategyEnabled() && ns != null) {
+ try {
+ String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
+ parentEntity.getPrimaryTableName());
+ if (parentEntity.getPrimaryDbTable() != null){
+ return
parentEntity.getPrimaryDbTable().getDatabase().convertNameToIdentifier(name);
}
+ return name ;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
}
- return parentEntity.getPrimaryKeyColumnName();
- } else {
- return getPrimaryKeyColumnName();
- }
+ }*/
+ return parentEntity.getPrimaryKeyColumnName();
}
-
- public IMessage buildUnresolvedNameMessage(NamedColumn column, TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
-
- public IMessage buildUnresolvedReferencedColumnNameMessage(BaseJoinColumn column,
TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
-
- public IMessage buildUnspecifiedNameMultipleJoinColumnsMessage(BaseJoinColumn column,
TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
-
- public IMessage
buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(BaseJoinColumn column,
TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
}
@Override
@@ -433,14 +671,6 @@
}
};
}
-
- public JavaCacheable2_0 getCacheable() {
- return cachable;
- }
-
- public boolean calculateDefaultCacheable() {
- return false;
- }
}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainer.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainer.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.ListIterator;
-
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateGeneratorContainer;
-
-/**
- *
- * @author Dmitry Geraskov
- *
- */
-public interface HibernateJavaGeneratorContainer extends
- HibernateGeneratorContainer, JavaGeneratorContainer {
-
- ListIterator<JavaGenericGenerator> genericGenerators();
-
- JavaGenericGenerator addGenericGenerator(int index);
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.jpt.core.context.java.JavaGenerator;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaGeneratorContainer;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
-import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorsAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJavaGeneratorContainerImpl extends
- GenericJavaGeneratorContainer implements
- HibernateJavaGeneratorContainer {
-
- protected final List<JavaGenericGenerator> genericGenerators;
-
- public HibernateJavaGeneratorContainerImpl(JavaJpaContextNode parent) {
- super(parent);
- this.genericGenerators = new ArrayList<JavaGenericGenerator>();
- }
-
- public HibernateJpaFactory getJpaFactory(){
- return (HibernateJpaFactory)super.getJpaFactory();
- }
-
- @Override
- public void initialize(JavaResourcePersistentMember jrpm) {
- super.initialize(jrpm);
- this.initializeGenericGenerators();
- }
-
- @Override
- public void update(JavaResourcePersistentMember jrpm) {
- super.update(jrpm);
- this.updateGenericGenerators();
- }
-
- public JavaGenericGenerator addGenericGenerator(int index) {
- JavaGenericGenerator newGenericGenerator =
getJpaFactory().buildJavaGenericGenerator(this);
- this.genericGenerators.add(index, newGenericGenerator);
- GenericGeneratorAnnotation genericGeneratorAnnotation =
(GenericGeneratorAnnotation)this.javaResourcePersistentMember
- .addAnnotation(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);
- }
-
- 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.javaResourcePersistentMember.moveAnnotation(targetIndex, sourceIndex,
GenericGeneratorsAnnotation.ANNOTATION_NAME);
- fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
- }
-
- public void removeGenericGenerator(int index) {
- JavaGenericGenerator removedGenericGenerator = this.genericGenerators.remove(index);
- this.javaResourcePersistentMember.removeAnnotation(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 (Iterator<NestableAnnotation> stream =
this.javaResourcePersistentMember.annotations(
- 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();
- Iterator<NestableAnnotation> resourceGenericGenerators =
- this.javaResourcePersistentMember.annotations(
- 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()));
- }
- }
-
-
-}
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,15 +12,15 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateIdMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGeneratorHolder;
import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
/**
* @author Dmitry Geraskov
*
*/
-public interface HibernateJavaIdMapping extends JavaIdMapping, IndexHolder,
HibernateIdMapping {
-
- HibernateJavaGeneratorContainer getGeneratorContainer();
+public interface HibernateJavaIdMapping extends HibernateIdMapping,
+ JavaIdMapping, GenericGeneratorHolder, IndexHolder {
}
Modified:
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/java/HibernateJavaIdMappingImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -10,11 +10,25 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-import java.util.Vector;
+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.AbstractJavaIdMapping;
+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.context.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Index;
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.IndexAnnotation;
@@ -23,12 +37,12 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateJavaIdMappingImpl extends AbstractJavaIdMapping
+public class HibernateJavaIdMappingImpl extends GenericJavaIdMapping
implements HibernateJavaIdMapping {
protected JavaGenericGenerator genericGenerator;
- protected JavaIndex index;
+ protected Index index;
/**
* @param parent
@@ -38,17 +52,12 @@
}
@Override
- public HibernateJavaGeneratorContainer getGeneratorContainer() {
- return (HibernateJavaGeneratorContainer)super.getGeneratorContainer();
+ public Iterator<String> supportingAnnotationNames() {
+ return new CompositeIterator<String>(super.supportingAnnotationNames(),
+ Hibernate.INDEX);
}
@Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.INDEX);
- }
-
- @Override
protected HibernateJpaFactory getJpaFactory() {
return (HibernateJpaFactory) super.getJpaFactory();
}
@@ -56,12 +65,14 @@
@Override
protected void initialize() {
super.initialize();
+ this.initializeGenericGenerator();
this.initializeIndex();
}
@Override
public void update() {
super.update();
+ updateGenericGenerator();
this.updateIndex();
}
@@ -83,7 +94,7 @@
}
protected GenericGeneratorAnnotation getResourceGenericGenerator() {
- return (GenericGeneratorAnnotation)
this.getResourcePersistentAttribute().getAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ return (GenericGeneratorAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
}
protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
@@ -92,7 +103,7 @@
return generator;
}
- /*@SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public Iterator<JavaGenerator> generators() {
return new CompositeIterator<JavaGenerator>(super.generators(),
(getGenericGenerator() == null) ? EmptyIterator.instance()
@@ -105,7 +116,7 @@
}
this.genericGenerator =
((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(this);
GenericGeneratorAnnotation genericGeneratorResource =
(GenericGeneratorAnnotation)getResourcePersistentAttribute()
- .addAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ .addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
this.genericGenerator.initialize(genericGeneratorResource);
firePropertyChanged(GENERIC_GENERATORS_LIST, null, this.genericGenerator);
return this.genericGenerator;
@@ -121,7 +132,7 @@
}
JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
this.genericGenerator = null;
- this.getResourcePersistentAttribute().removeAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,null);
}
@@ -200,7 +211,7 @@
if (this.genericGenerator == generator){
removeGenericGenerator();
}
- }*/
+ }
// *** index
@@ -228,23 +239,23 @@
}
}
- public JavaIndex addIndex() {
+ public Index addIndex() {
if (getIndex() != null) {
throw new IllegalStateException("index already exists"); //$NON-NLS-1$
}
this.index = getJpaFactory().buildIndex(this);
- IndexAnnotation indexResource = (IndexAnnotation)
getResourcePersistentAttribute().addAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ IndexAnnotation indexResource = (IndexAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
this.index.initialize(indexResource);
firePropertyChanged(INDEX_PROPERTY, null, this.index);
return this.index;
}
- public JavaIndex getIndex() {
+ public Index getIndex() {
return this.index;
}
- protected void setIndex(JavaIndex newIndex) {
- JavaIndex oldIndex = this.index;
+ protected void setIndex(Index newIndex) {
+ Index oldIndex = this.index;
this.index = newIndex;
firePropertyChanged(INDEX_PROPERTY, oldIndex, newIndex);
}
@@ -253,20 +264,20 @@
if (getIndex() == null) {
throw new IllegalStateException("index does not exist, cannot be removed");
//$NON-NLS-1$
}
- JavaIndex oldIndex = this.index;
+ Index oldIndex = this.index;
this.index = null;
- this.getResourcePersistentAttribute().removeAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
firePropertyChanged(INDEX_PROPERTY, oldIndex, null);
}
- protected JavaIndex buildIndex(IndexAnnotation indexResource) {
- JavaIndex index = getJpaFactory().buildIndex(this);
+ protected Index buildIndex(IndexAnnotation indexResource) {
+ Index index = getJpaFactory().buildIndex(this);
index.initialize(indexResource);
return index;
}
protected IndexAnnotation getResourceIndex() {
- return (IndexAnnotation)
this.getResourcePersistentAttribute().getAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ return (IndexAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,12 +12,17 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.Entity;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.RelationshipMapping;
import org.eclipse.jpt.core.context.java.JavaJoinColumn;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaJoinColumn;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinColumn;
+import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.Column;
import org.eclipse.jpt.db.Table;
import org.eclipse.wst.validation.internal.core.Message;
@@ -25,9 +30,9 @@
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.HibernatePersistenceUnit.LocalMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
@@ -47,10 +52,14 @@
@Override
protected String buildDefaultName() {
- return NamingStrategyMappingTools.buildJoinColumnDefaultName(this, getOwner());
+ return NamingStrategyMappingTools.buildJoinColumnDefaultName(this);
}
public PersistentAttribute getReferencedPersistentAttribute() {
+ RelationshipMapping relationshipMapping = this.getOwner().getRelationshipMapping();
+ if (relationshipMapping == null) {
+ return null;
+ }
if (this.getOwner().joinColumnsSize() != 1) {
return null;
}
@@ -134,7 +143,7 @@
return specifiedReferencedColumnName;
}
- /*protected void validateJoinColumnName(List<IMessage> messages, CompilationUnit
astRoot) {
+ protected void validateName(List<IMessage> messages, CompilationUnit astRoot) {
if ( ! this.isResolved() && getDbTable() != null) {
if (getDBColumnName() != null) {
messages.add(
@@ -148,7 +157,14 @@
);
}
else if (getOwner().joinColumnsSize() > 1) {
- messages.add(this.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(astRoot));
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS,
+ this,
+ this.getNameTextRange(astRoot)
+ )
+ );
}
//If the name is null and there is only one join-column, one of these validation
messages will apply
// 1. target entity does not have a primary key
@@ -185,7 +201,7 @@
// 2. target entity is not specified
// 3. target entity is not an entity
}
- }*/
+ }
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnJoiningStrategy.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnJoiningStrategy.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinColumnJoiningStrategy.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,9 +11,16 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaJoinColumn;
import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference;
import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinColumnJoiningStrategy;
+import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateJoinColumn;
/**
* @author Dmitry Geraskov
@@ -26,13 +33,8 @@
JavaJoinColumnEnabledRelationshipReference parent) {
super(parent);
}
-
- @Override
- protected JavaJoinColumn.Owner buildJoinColumnOwner() {
- return new HibernateJoinColumnOwner();
- }
- /*protected void validateJoinColumnName(JavaJoinColumn joinColumn, List<IMessage>
messages, CompilationUnit astRoot) {
+ protected void validateJoinColumnName(JavaJoinColumn joinColumn, List<IMessage>
messages, CompilationUnit astRoot) {
if ( ! joinColumn.isResolved() && joinColumn.getDbTable() != null) {
if (((HibernateJoinColumn)joinColumn).getDBColumnName() != null) {
messages.add(
@@ -90,14 +92,6 @@
// 2. target entity is not specified
// 3. target entity is not an entity
}
- }*/
-
- protected class HibernateJoinColumnOwner extends JoinColumnOwner {
- protected HibernateJoinColumnOwner() {
- super();
- }
-
- //TODO implement validator messages
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -14,7 +14,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaJoinTable;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinTable;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.Schema;
@@ -24,8 +24,8 @@
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
@@ -73,7 +73,7 @@
return getDefaultName();
}
- protected boolean validateAgainstDatabase(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
+ protected void validateAgainstDatabase(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
if ( ! this.hasResolvedCatalog()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
@@ -84,7 +84,7 @@
this.getCatalogTextRange(astRoot)
)
);
- return false;
+ return;
}
if ( ! this.hasResolvedSchema()) {
@@ -97,7 +97,7 @@
this.getSchemaTextRange(astRoot)
)
);
- return false;
+ return;
}
if ( ! this.isResolved()) {
@@ -111,8 +111,10 @@
this.getNameTextRange(astRoot))
);
}
- return false;
+ return;
}
- return true;
+
+ this.validateJoinColumns(this.joinColumns(), messages, reporter, astRoot);
+ this.validateJoinColumns(this.inverseJoinColumns(), messages, reporter, astRoot);
}
}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableJoiningStrategy.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableJoiningStrategy.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaJoinTableJoiningStrategy.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.java.JavaJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinTableJoiningStrategy;
-import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJavaJoinTableJoiningStrategy extends
- GenericJavaJoinTableJoiningStrategy {
-
- /**
- * @param parent
- */
- public HibernateJavaJoinTableJoiningStrategy(
- JavaJoinTableEnabledRelationshipReference parent) {
- super(parent);
- }
-
- public String getJoinTableDefaultName() {
- return
NamingStrategyMappingTools.buildJoinTableDefaultName(getRelationshipReference());
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,21 +13,21 @@
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaManyToManyMapping;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaManyToManyMapping;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
+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.ForeignKey;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -45,14 +45,13 @@
}
@Override
- protected JavaRelationshipReference buildRelationshipReference() {
- return new HibernateJavaManyToManyRelationshipReference(this);
+ public String getJoinTableDefaultName() {
+ return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
}
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.FOREIGN_KEY);
+ public Iterator<String> supportingAnnotationNames() {
+ return new CompositeIterator<String>(super.supportingAnnotationNames(),
+ Hibernate.FOREIGN_KEY);
}
@Override
@@ -105,7 +104,7 @@
throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
}
this.foreignKey = getJpaFactory().buildForeignKey(this);
- ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
this.foreignKey.initialize(foreignKeyResource);
firePropertyChanged(FOREIGN_KEY_PROPERTY, null, this.foreignKey);
return this.foreignKey;
@@ -127,7 +126,7 @@
}
ForeignKey oldForeignKey = this.foreignKey;
this.foreignKey = null;
- this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, null);
}
@@ -138,7 +137,7 @@
}
protected ForeignKeyAnnotation getResourceForeignKey() {
- return (ForeignKeyAnnotation)
this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ return (ForeignKeyAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
}
public Table getForeignKeyDbTable() {
@@ -157,7 +156,7 @@
if (!shouldValidateAgainstDatabase() || foreignKey == null || table == null ){
return;
}
- Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.getForeignKeys().iterator();
+ Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.foreignKeys();
while (fks.hasNext()) {
org.eclipse.jpt.db.ForeignKey fk = (org.eclipse.jpt.db.ForeignKey) fks.next();
if (foreignKey.getName().equals(fk.getIdentifier())){
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyRelationshipReference.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyRelationshipReference.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyRelationshipReference.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import
org.eclipse.jpt.core.internal.context.java.GenericJavaManyToManyRelationshipReference;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJavaManyToManyRelationshipReference extends
- GenericJavaManyToManyRelationshipReference {
-
- /**
- * @param parent
- */
- public HibernateJavaManyToManyRelationshipReference(
- JavaManyToManyMapping parent) {
- super(parent);
- }
-
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new HibernateJavaJoinTableJoiningStrategy(this);
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToOneMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,20 +13,22 @@
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaManyToOneRelationshipReference;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaManyToOneMapping;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaManyToOneMapping;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
+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.ForeignKey;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
-import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -43,11 +45,20 @@
}
@Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.FOREIGN_KEY);
+ public String getJoinTableDefaultName() {
+ return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
}
+
+ @Override
+ protected JavaManyToOneRelationshipReference buildRelationshipReference() {
+ return new HibernateJavaManyToOneRelationshipReference(this);
+ }
+ public Iterator<String> supportingAnnotationNames() {
+ return new CompositeIterator<String>(super.supportingAnnotationNames(),
+ Hibernate.FOREIGN_KEY);
+ }
+
@Override
protected HibernateJpaFactory getJpaFactory() {
return (HibernateJpaFactory) super.getJpaFactory();
@@ -98,7 +109,7 @@
throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
}
this.foreignKey = getJpaFactory().buildForeignKey(this);
- ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
this.foreignKey.initialize(foreignKeyResource);
firePropertyChanged(FOREIGN_KEY_PROPERTY, null, this.foreignKey);
return this.foreignKey;
@@ -120,7 +131,7 @@
}
ForeignKey oldForeignKey = this.foreignKey;
this.foreignKey = null;
- this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, null);
}
@@ -131,7 +142,7 @@
}
protected ForeignKeyAnnotation getResourceForeignKey() {
- return (ForeignKeyAnnotation)
this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ return (ForeignKeyAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
}
public Table getForeignKeyDbTable() {
@@ -150,7 +161,7 @@
if (!shouldValidateAgainstDatabase() || foreignKey == null || table == null ){
return;
}
- Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.getForeignKeys().iterator();
+ Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.foreignKeys();
while (fks.hasNext()) {
org.eclipse.jpt.db.ForeignKey fk = (org.eclipse.jpt.db.ForeignKey) fks.next();
if (foreignKey.getName().equals(fk.getIdentifier())){
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,8 +12,8 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaOneToManyMapping;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaOneToManyMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
/**
* @author Dmitry Geraskov
@@ -26,8 +26,8 @@
}
@Override
- protected JavaRelationshipReference buildRelationshipReference() {
- return super.buildRelationshipReference();
+ public String getJoinTableDefaultName() {
+ return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
}
}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyRelationshipReference.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyRelationshipReference.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToManyRelationshipReference.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
-import
org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaOneToManyRelationshipReference;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateJavaOneToManyRelationshipReference extends
- GenericJavaOneToManyRelationshipReference {
-
- /**
- * @param parent
- */
- public HibernateJavaOneToManyRelationshipReference(
- JavaOneToManyMapping parent) {
- super(parent);
- }
-
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new HibernateJavaJoinTableJoiningStrategy(this);
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaOneToOneMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,20 +13,22 @@
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaOneToOneMapping;
+import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaOneToOneMapping;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
+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.ForeignKey;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKeyHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
-import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -42,7 +44,7 @@
super(parent);
}
- /*@Override
+ @Override
public String getJoinTableDefaultName() {
return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
}
@@ -50,12 +52,11 @@
@Override
protected JavaRelationshipReference buildRelationshipReference() {
return new HibernateJavaOneToOneRelationshipReference(this);
- }*/
+ }
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(Hibernate.FOREIGN_KEY);
+ public Iterator<String> supportingAnnotationNames() {
+ return new CompositeIterator<String>(super.supportingAnnotationNames(),
+ Hibernate.FOREIGN_KEY);
}
@Override
@@ -108,7 +109,7 @@
throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$
}
this.foreignKey = getJpaFactory().buildForeignKey(this);
- ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
this.foreignKey.initialize(foreignKeyResource);
firePropertyChanged(FOREIGN_KEY_PROPERTY, null, this.foreignKey);
return this.foreignKey;
@@ -130,7 +131,7 @@
}
ForeignKey oldForeignKey = this.foreignKey;
this.foreignKey = null;
- this.getResourcePersistentAttribute().removeAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
firePropertyChanged(FOREIGN_KEY_PROPERTY, oldForeignKey, null);
}
@@ -141,7 +142,7 @@
}
protected ForeignKeyAnnotation getResourceForeignKey() {
- return (ForeignKeyAnnotation)
this.getResourcePersistentAttribute().getAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
+ return (ForeignKeyAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME);
}
public Table getForeignKeyDbTable() {
@@ -160,7 +161,7 @@
if (!shouldValidateAgainstDatabase() || foreignKey == null || table == null ){
return;
}
- Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.getForeignKeys().iterator();
+ Iterator<org.eclipse.jpt.db.ForeignKey> fks = table.foreignKeys();
while (fks.hasNext()) {
org.eclipse.jpt.db.ForeignKey fk = (org.eclipse.jpt.db.ForeignKey) fks.next();
if (foreignKey.getName().equals(fk.getIdentifier())){
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainer.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainer.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.ListIterator;
-
-import org.eclipse.jpt.core.context.java.JavaQueryContainer;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedNativeQuery;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedQuery;
-
-/**
- *
- * @author Dmitry Geraskov
- *
- */
-public interface HibernateJavaQueryContainer extends JavaQueryContainer {
-
- //********** Hibernate Named Queries **************
- ListIterator<HibernateNamedQuery> hibernateNamedQueries();
-
- int hibernateNamedQueriesSize();
-
- HibernateNamedQuery addHibernateNamedQuery(int index);
-
- void removeHibernateNamedQuery(int index);
-
- void removeHibernateNamedQuery(HibernateNamedQuery namedQuery);
-
- void moveHibernateNamedQuery(int targetIndex, int sourceIndex);
-
- String HIBERNATE_NAMED_QUERIES_LIST = "hibernateNamedQueries"; //$NON-NLS-1$
-
- //********** Hibernate Named Native Queries **************;
-
- ListIterator<HibernateNamedNativeQuery> hibernateNamedNativeQueries();
-
- int hibernateNamedNativeQueriesSize();
-
- HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index);
-
- void removeHibernateNamedNativeQuery(int index);
-
- void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery namedQuery);
-
- void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex);
-
- String HIBERNATE_NAMED_NATIVE_QUERIES_LIST = "hibernateNamedQueries";
//$NON-NLS-1$
-
-
- void initialize(JavaResourcePersistentMember jrpm);
-
- /**
- * Update the JavaGeneratorContainer context model object to match the
JavaResourcePersistentMember
- * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
- */
- void update(JavaResourcePersistentMember jrpm);
-
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainerImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainerImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaQueryContainerImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaNamedNativeQuery;
-import org.eclipse.jpt.core.context.java.JavaNamedQuery;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaQueryContainer;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
-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.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 HibernateJavaQueryContainerImpl extends GenericJavaQueryContainer
-implements HibernateJavaQueryContainer{
-
- protected final List<HibernateNamedQuery> hibernateNamedQueries;
-
- protected final List<HibernateNamedNativeQuery> hibernateNamedNativeQueries;
-
- public HibernateJavaQueryContainerImpl(JavaJpaContextNode parent) {
- super(parent);
- this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
- this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
- }
-
- public HibernateJpaFactory getJpaFactory(){
- return (HibernateJpaFactory)super.getJpaFactory();
- }
-
- public void initialize(JavaResourcePersistentMember jrpm) {
- super.initialize(jrpm);
- initializeHibernateNamedQueries();
- initializeHibernateNamedNativeQueries();
- }
-
- public void update(JavaResourcePersistentMember jrpm) {
- super.update(jrpm);
- this.updateHibernateNamedQueries();
- this.updateHibernateNamedNativeQueries();
- }
-
- // *********** Named Queries
-
- protected void initializeHibernateNamedQueries() {
- for (Iterator<NestableAnnotation> stream = this.javaResourcePersistentMember.
- annotations(
- HibernateNamedQueryAnnotation.ANNOTATION_NAME,
- HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- stream.hasNext(); ) {
- this.hibernateNamedQueries.add(buildHibernateNamedQuery((NamedQueryAnnotation)
stream.next()));
- }
- }
-
- protected void updateHibernateNamedQueries() {
- ListIterator<HibernateNamedQuery> queries = hibernateNamedQueries();
- Iterator<NestableAnnotation> resourceNamedQueries =
- this.javaResourcePersistentMember.annotations(
- HibernateNamedQueryAnnotation.ANNOTATION_NAME,
- HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
-
- while (queries.hasNext()) {
- HibernateNamedQuery namedQuery = queries.next();
- if (resourceNamedQueries.hasNext()) {
- namedQuery.update((NamedQueryAnnotation) resourceNamedQueries.next());
- }
- else {
- removeHibernateNamedQuery_(namedQuery);
- }
- }
-
- while (resourceNamedQueries.hasNext()) {
- addHibernateNamedQuery(buildHibernateNamedQuery((NamedQueryAnnotation)
resourceNamedQueries.next()));
- }
- }
-
- public HibernateNamedQuery addHibernateNamedQuery(int index) {
- HibernateNamedQuery namedQuery = getJpaFactory().buildHibernateJavaNamedQuery(this);
- this.hibernateNamedQueries.add(index, namedQuery);
- NamedQueryAnnotation namedQueryAnnotation =
- (NamedQueryAnnotation) this.javaResourcePersistentMember.
- addAnnotation(
- index, HibernateNamedQueryAnnotation.ANNOTATION_NAME,
- HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- namedQuery.initialize(namedQueryAnnotation);
- fireItemAdded(HIBERNATE_NAMED_QUERIES_LIST, index, namedQuery);
- return namedQuery;
- }
-
- public ListIterator<HibernateNamedQuery> hibernateNamedQueries() {
- return new CloneListIterator<HibernateNamedQuery>(this.hibernateNamedQueries);
- }
-
- public int hibernateNamedQueriesSize() {
- return this.hibernateNamedQueries.size();
- }
-
- public void removeHibernateNamedQuery(int index) {
- JavaNamedQuery removedNamedQuery = this.hibernateNamedQueries.remove(index);
- this.javaResourcePersistentMember.removeAnnotation(
- index, HibernateNamedQueryAnnotation.ANNOTATION_NAME,
HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- fireItemRemoved(HIBERNATE_NAMED_QUERIES_LIST, index, removedNamedQuery);
- }
-
- public void removeHibernateNamedQuery(HibernateNamedQuery namedQuery) {
- removeHibernateNamedQuery(this.hibernateNamedQueries.indexOf(namedQuery));
- }
-
- protected void removeHibernateNamedQuery_(HibernateNamedQuery namedQuery) {
- removeItemFromList(namedQuery, this.hibernateNamedQueries,
HIBERNATE_NAMED_QUERIES_LIST);
- }
-
- public void moveHibernateNamedQuery(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.hibernateNamedQueries, targetIndex, sourceIndex);
- this.javaResourcePersistentMember.moveAnnotation(
- targetIndex, sourceIndex, HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
- fireItemMoved(HIBERNATE_NAMED_QUERIES_LIST, targetIndex, sourceIndex);
- }
-
- 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);
- }
-
- protected HibernateNamedQuery buildHibernateNamedQuery(NamedQueryAnnotation
namedQueryResource) {
- HibernateNamedQuery namedQuery = getJpaFactory().buildHibernateJavaNamedQuery(this);
- namedQuery.initialize(namedQueryResource);
- return namedQuery;
- }
-
-
- // *********** Native Queries
-
- protected void initializeHibernateNamedNativeQueries() {
- for (Iterator<NestableAnnotation> stream = this.javaResourcePersistentMember.
- annotations(
- HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
- HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- stream.hasNext(); ) {
- this.hibernateNamedNativeQueries.add(buildHibernateNamedNativeQuery((NamedNativeQueryAnnotation)
stream.next()));
- }
- }
-
- protected void updateHibernateNamedNativeQueries() {
- ListIterator<HibernateNamedNativeQuery> queries = hibernateNamedNativeQueries();
- Iterator<NestableAnnotation> resourceNamedNativeQueries =
- this.javaResourcePersistentMember.annotations(
- HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
- HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
-
- while (queries.hasNext()) {
- HibernateNamedNativeQuery namedQuery = queries.next();
- if (resourceNamedNativeQueries.hasNext()) {
- namedQuery.update((NamedNativeQueryAnnotation) resourceNamedNativeQueries.next());
- }
- else {
- removeHibernateNamedNativeQuery_(namedQuery);
- }
- }
-
- while (resourceNamedNativeQueries.hasNext()) {
- addHibernateNamedNativeQuery(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation)
resourceNamedNativeQueries.next()));
- }
- }
-
- protected HibernateNamedNativeQuery
buildHibernateNamedNativeQuery(NamedNativeQueryAnnotation namedNativeQueryResource) {
- HibernateNamedNativeQuery namedNativeQuery =
getJpaFactory().buildHibernateJavaNamedNativeQuery(this);
- namedNativeQuery.initialize(namedNativeQueryResource);
- return namedNativeQuery;
- }
-
- public HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index) {
- HibernateNamedNativeQuery namedNativeQuery =
getJpaFactory().buildHibernateJavaNamedNativeQuery(this);
- this.hibernateNamedNativeQueries.add(index, namedNativeQuery);
- NamedNativeQueryAnnotation namedNativeQueryAnnotation =
- (NamedNativeQueryAnnotation) this.javaResourcePersistentMember.
- addAnnotation(
- index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
- HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- namedNativeQuery.initialize(namedNativeQueryAnnotation);
- fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, namedNativeQuery);
- return namedNativeQuery;
- }
-
- protected void addHibernateNamedNativeQuery(int index, HibernateNamedNativeQuery
namedNativeQuery) {
- addItemToList(index, namedNativeQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
- }
-
- protected void addHibernateNamedNativeQuery(HibernateNamedNativeQuery namedNativeQuery)
{
- this.addHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size(),
namedNativeQuery);
- }
-
- public ListIterator<HibernateNamedNativeQuery> hibernateNamedNativeQueries() {
- return new
CloneListIterator<HibernateNamedNativeQuery>(this.hibernateNamedNativeQueries);
- }
-
- public int hibernateNamedNativeQueriesSize() {
- return this.hibernateNamedNativeQueries.size();
- }
-
- public void removeHibernateNamedNativeQuery(int index) {
- JavaNamedNativeQuery removedNamedQuery =
this.hibernateNamedNativeQueries.remove(index);
- this.javaResourcePersistentMember.removeAnnotation(
- index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME,
HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, removedNamedQuery);
- }
-
- public void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery namedQuery) {
- removeHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.indexOf(namedQuery));
- }
-
- protected void removeHibernateNamedNativeQuery_(HibernateNamedNativeQuery namedQuery) {
- removeItemFromList(namedQuery, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
- }
-
- public void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex, sourceIndex);
- this.javaResourcePersistentMember.moveAnnotation(
- targetIndex, sourceIndex, HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
- fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaSecondaryTableImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaSecondaryTableImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaSecondaryTableImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -14,7 +14,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaSecondaryTable;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaSecondaryTable;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.Schema;
@@ -74,7 +74,7 @@
return this.getName();
}
- protected boolean validateAgainstDatabase(List<IMessage> messages, CompilationUnit
astRoot) {
+ protected void validateAgainstDatabase(List<IMessage> messages, CompilationUnit
astRoot) {
if ( ! this.hasResolvedCatalog()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
@@ -85,7 +85,7 @@
this.getCatalogTextRange(astRoot)
)
);
- return false;
+ return;
}
if ( ! this.hasResolvedSchema()) {
@@ -98,7 +98,7 @@
this.getSchemaTextRange(astRoot)
)
);
- return false;
+ return;
}
if ( ! this.isResolved()) {
@@ -111,9 +111,8 @@
this.getNameTextRange(astRoot)
)
);
- return false;
+ return;
}
- return true;
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTableImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTableImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTableImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -14,7 +14,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaTable;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaTable;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,7 +11,7 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaNamedNativeQuery;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.CacheModeType;
import org.jboss.tools.hibernate.jpt.core.internal.context.FlushModeType;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedNativeQuery;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,7 +11,7 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaNamedQuery;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.CacheModeType;
import org.jboss.tools.hibernate.jpt.core.internal.context.FlushModeType;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedQuery;
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/IndexImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/IndexImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/IndexImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * 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.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-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.IndexAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class IndexImpl extends AbstractJavaJpaContextNode implements JavaIndex {
-
- private IndexAnnotation indexResource;
-
- private String name;
-
- private String[] columnNames = new String[0];
-
- public IndexImpl(JavaJpaContextNode parent) {
- super(parent);
- }
-
- public void initialize(IndexAnnotation indexResource) {
- this.indexResource = indexResource;
- this.name = indexResource.getName();
- this.columnNames = indexResource.getColumnNames();
- }
-
- public void update(IndexAnnotation indexResource) {
- this.indexResource = indexResource;
- this.setName_(indexResource.getName());
- this.setColumnNames_(indexResource.getColumnNames());
- }
-
- // ***** name
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.getResourceIndex().setName(name);
- this.firePropertyChanged(INDEX_NAME, old, name);
- }
-
- public void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(INDEX_NAME, old, name);
- }
-
- // ***** columnNames
-
- public String[] getColumnNames() {
- return columnNames;
- }
-
- public void setColumnNames(String[] columnNames) {
- if (columnNames == null) columnNames = new String[0];
- String[] old = this.columnNames;
- this.columnNames = columnNames;
- this.getResourceIndex().setColumnNames(columnNames);
- this.firePropertyChanged(INDEX_COLUMN_NAMES, old, columnNames);
- }
-
- public void setColumnNames_(String[] columnNames) {
- String[] old = this.columnNames;
- this.columnNames = columnNames;
- this.firePropertyChanged(INDEX_COLUMN_NAMES, old, columnNames);
- }
-
- private IndexAnnotation getResourceIndex() {
- return indexResource;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.indexResource.getTextRange(astRoot);
- }
-
- public void addColumn(String columnName) {
- String[] old = this.columnNames;
- String[] newColumns = new String[old.length + 1];
- System.arraycopy(old, 0, newColumns, 0, old.length);
- newColumns[newColumns.length - 1] = columnName;
- this.setColumnNames(newColumns);
- }
-
- public void removeColumn(String columnName) {
- String[] old = this.columnNames;
- List<String> newColumns = new ArrayList<String>();
- for (String column : old) {
- if (!column.equals(columnName)) newColumns.add(column);
- }
- this.setColumnNames(newColumns.toArray(new String[newColumns.size()]));
- }
-
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaIndex.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaIndex.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaIndex.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.IndexAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public interface JavaIndex extends JavaJpaContextNode {
-
- String getName();
- void setName(String name);
- String INDEX_NAME = "name"; //$NON-NLS-1$
-
- String[] getColumnNames();
- void addColumn(String columnName);
- void removeColumn(String columnName);
- String INDEX_COLUMN_NAMES = "ColumnNames"; //$NON-NLS-1$
-
-
- public void initialize(IndexAnnotation indexResource);
-
- public void update(IndexAnnotation indexResource);
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,21 +12,21 @@
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.AbstractOrmBasicMapping;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmBasicMapping;
import org.eclipse.jpt.core.resource.orm.XmlBasic;
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateOrmBasicMapping extends AbstractOrmBasicMapping<XmlBasic> {
+public class HibernateOrmBasicMapping extends GenericOrmBasicMapping<XmlBasic> {
public HibernateOrmBasicMapping(OrmPersistentAttribute parent,
XmlBasic resourceMapping) {
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmColumnImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,7 +13,7 @@
import org.eclipse.jpt.core.context.XmlContextNode;
import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmColumn;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmColumn;
import org.eclipse.jpt.db.Column;
import org.eclipse.jpt.db.Table;
import org.eclipse.wst.validation.internal.core.Message;
@@ -21,8 +21,8 @@
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
@@ -70,8 +70,9 @@
return getDefaultName();
}
- public Table getDbTable() {
- return getOwner().getDbTable(this.getDBTableName());
+ @Override
+ protected String getOwningTableName() {
+ return getDBTableName();
}
public String getDBTableName() {
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -16,14 +16,11 @@
import org.eclipse.jpt.core.context.BaseJoinColumn;
import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
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;
import org.eclipse.jpt.core.internal.context.orm.AbstractOrmEntity;
-import org.eclipse.jpt.core.internal.jpa2.context.orm.NullOrmCacheable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0;
import org.eclipse.jpt.core.resource.orm.XmlEntity;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
@@ -34,11 +31,11 @@
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.GenericGenerator;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
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;
/**
* @author Dmitry Geraskov
@@ -46,27 +43,12 @@
*/
public class HibernateOrmEntityImpl extends AbstractOrmEntity
implements HibernateOrmEntity {
-
- protected OrmCacheable2_0 cachable;
public HibernateOrmEntityImpl(OrmPersistentType parent,
XmlEntity resourceMapping) {
super(parent, resourceMapping);
- this.cachable = buildOrmCachable();
}
- protected OrmCacheable2_0 buildOrmCachable() {
- return new NullOrmCacheable2_0(this);
- }
-
- public OrmCacheable2_0 getCacheable() {
- return cachable;
- }
-
- public boolean calculateDefaultCacheable() {
- return false;
- }
-
@Override
public HibernateJpaProject getJpaProject() {
return (HibernateJpaProject) super.getJpaProject();
@@ -144,30 +126,9 @@
return parentEntity.getPrimaryKeyColumnName();
}
- public String getDefaultTableName() {
- //FIXME: use NamingStrategy here
- return HibernateOrmEntityImpl.this.getPrimaryTableName();
- }
-
public TextRange getValidationTextRange() {
return null;
}
-
- public IMessage buildUnresolvedNameMessage(NamedColumn column, TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
-
- public IMessage buildUnresolvedReferencedColumnNameMessage(BaseJoinColumn column,
TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
-
- public IMessage buildUnspecifiedNameMultipleJoinColumnsMessage(BaseJoinColumn column,
TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
-
- public IMessage
buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(BaseJoinColumn column,
TextRange textRange) {
- throw new UnsupportedOperationException("validation not supported yet: bug
148262"); //$NON-NLS-1$
- }
}
@Override
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,7 +12,7 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.orm;
import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateIdMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
/**
* @author Dmitry Geraskov
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -14,7 +14,7 @@
import java.util.List;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.orm.AbstractOrmIdMapping;
+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;
@@ -23,14 +23,14 @@
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateOrmIdMappingImpl extends AbstractOrmIdMapping<XmlId>
+public class HibernateOrmIdMappingImpl extends GenericOrmIdMapping<XmlId>
implements HibernateOrmIdMapping {
public HibernateOrmIdMappingImpl(OrmPersistentAttribute parent,
@@ -76,7 +76,7 @@
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID,
+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_TABLE,
new String[] {pa.getName(), tableName, this.getColumn().getDBColumnName()},
this.column,
this.column.getTableTextRange()
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -15,9 +15,10 @@
import org.eclipse.jpt.core.context.Entity;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.RelationshipMapping;
import org.eclipse.jpt.core.context.XmlContextNode;
import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmJoinColumn;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.db.Column;
import org.eclipse.jpt.db.Table;
@@ -26,9 +27,9 @@
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.HibernatePersistenceUnit.LocalMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
@@ -43,8 +44,8 @@
}
@Override
- protected String buildDefaultName() {
- return NamingStrategyMappingTools.buildJoinColumnDefaultName(this, getOwner());
+ protected String getOwnerDefaultColumnName() {
+ return NamingStrategyMappingTools.buildJoinColumnDefaultName(this);
}
@Override
@@ -114,6 +115,10 @@
}
public PersistentAttribute getReferencedPersistentAttribute() {
+ RelationshipMapping relationshipMapping = this.getOwner().getRelationshipMapping();
+ if (relationshipMapping == null) {
+ return null;
+ }
if (this.getOwner().joinColumnsSize() != 1) {
return null;
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnJoiningStrategy.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnJoiningStrategy.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinColumnJoiningStrategy.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,9 +11,16 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.orm;
+import java.util.List;
+
+import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinColumnJoiningStrategy;
+import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.resource.orm.XmlJoinColumnsMapping;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateJoinColumn;
/**
* @author Dmitry Geraskov
@@ -28,7 +35,7 @@
super(parent, resource);
}
- /*@Override
+ @Override
protected void validateJoinColumnName(OrmJoinColumn joinColumn,
List<IMessage> messages) {
if ( ! joinColumn.isResolved() && joinColumn.getDbTable() != null) {
@@ -136,6 +143,6 @@
}
}
}
- }*/
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinTableImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinTableImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmJoinTableImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,11 +13,12 @@
import java.util.List;
-import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmJoinTable;
+import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinTable;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
+import org.eclipse.jpt.core.resource.orm.XmlJoinTableMapping;
import org.eclipse.jpt.db.Schema;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -25,8 +26,8 @@
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.jboss.tools.hibernate.jpt.core.internal.context.Messages;
/**
* @author Dmitry Geraskov
@@ -37,8 +38,8 @@
public HibernateOrmJoinTableImpl(OrmJoinTableJoiningStrategy parent,
- XmlJoinTable resourceJoinTable) {
- super(parent, resourceJoinTable);
+ XmlJoinTableMapping resourceMapping) {
+ super(parent, resourceMapping);
}
@Override
@@ -77,41 +78,43 @@
}
@Override
- protected boolean validateAgainstDatabase(List<IMessage> messages,
+ protected void validateAgainstDatabase(List<IMessage> messages,
IReporter reporter) {
- PersistentAttribute persistentAttribute = this.getPersistentAttribute();
+ OrmRelationshipMapping mapping = this.getRelationshipMapping();
+
if ( ! this.hasResolvedCatalog()) {
- if (persistentAttribute.isVirtual()) {
+ if (mapping.getPersistentAttribute().isVirtual()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- getVirtualAttributeUnresolvedCatalogMessageId(),
- new String[] {persistentAttribute.getName(), this.getCatalog(),
this.getDBTableName()},
+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG,
+ new String[] {mapping.getName(), this.getCatalog(), this.getDBTableName()},
this,
this.getCatalogTextRange()
)
);
+
} else {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- getUnresolvedCatalogMessageId(),
+ JpaValidationMessages.JOIN_TABLE_UNRESOLVED_CATALOG,
new String[] {this.getCatalog(), this.getDBTableName()},
this,
this.getCatalogTextRange()
)
);
}
- return false;
+ return;
}
-
+
if ( ! this.hasResolvedSchema()) {
- if (persistentAttribute.isVirtual()) {
+ if (mapping.getPersistentAttribute().isVirtual()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- getVirtualAttributeUnresolvedSchemaMessageId(),
- new String[] {persistentAttribute.getName(), this.getSchema(),
this.getDBTableName()},
+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA,
+ new String[] {mapping.getName(), this.getSchema(), this.getDBTableName()},
this,
this.getSchemaTextRange()
)
@@ -120,23 +123,23 @@
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- getUnresolvedSchemaMessageId(),
+ JpaValidationMessages.JOIN_TABLE_UNRESOLVED_SCHEMA,
new String[] {this.getSchema(), this.getDBTableName()},
this,
this.getSchemaTextRange()
)
);
}
- return false;
+ return;
}
if ( ! this.isResolved()) {
- if (getDBTableName() != null) { //if name is null, the validation will be handled
elsewhere, such as the target entity is not defined
- if (persistentAttribute.isVirtual()) {
+ if (getName() != null) { //if name is null, the validation will be handled elsewhere,
such as the target entity is not defined
+ if (mapping.getPersistentAttribute().isVirtual()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- getVirtualAttributeUnresolvedNameMessageId(),
- new String[] {persistentAttribute.getName(), this.getDBTableName()},
+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME,
+ new String[] {mapping.getName(), this.getDBTableName()},
this,
this.getNameTextRange()
)
@@ -146,16 +149,18 @@
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- getUnresolvedNameMessageId(),
- new String[] {this.getDBTableName()},
+ JpaValidationMessages.JOIN_TABLE_UNRESOLVED_NAME,
+ new String[] {this.getName()},
this,
this.getNameTextRange())
- );
+ );
}
}
- return false;
+ return;
}
- return true;
+
+ this.validateJoinColumns(this.joinColumns(), messages, reporter);
+ this.validateJoinColumns(this.inverseJoinColumns(), messages, reporter);
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToManyMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToManyMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToManyMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,7 +12,7 @@
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.AbstractOrmManyToManyMapping;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmManyToManyMapping;
import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
@@ -21,16 +21,16 @@
*
*/
public class HibernateOrmManyToManyMapping<T extends XmlManyToMany> extends
- AbstractOrmManyToManyMapping<T> {
+ GenericOrmManyToManyMapping<T> {
public HibernateOrmManyToManyMapping(OrmPersistentAttribute parent,
T resourceMapping) {
super(parent, resourceMapping);
}
- /*@Override
+ @Override
public String getJoinTableDefaultName() {
return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
- }*/
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToOneMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToOneMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmManyToOneMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,7 +13,7 @@
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.internal.context.orm.AbstractOrmManyToOneMapping;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmManyToOneMapping;
import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
@@ -22,17 +22,17 @@
*
*/
public class HibernateOrmManyToOneMapping<T extends XmlManyToOne>
-extends AbstractOrmManyToOneMapping<T> {
+extends GenericOrmManyToOneMapping<T> {
public HibernateOrmManyToOneMapping(OrmPersistentAttribute parent,
T resourceMapping) {
super(parent, resourceMapping);
}
- /*@Override
+ @Override
public String getJoinTableDefaultName() {
return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
- }*/
+ }
@Override
protected OrmRelationshipReference buildRelationshipReference() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToManyMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToManyMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToManyMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,24 +12,25 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.orm;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmOneToManyMapping;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmOneToManyMapping;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
+import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateOrmOneToManyMapping
- extends GenericOrmOneToManyMapping {
+public class HibernateOrmOneToManyMapping<T extends XmlOneToMany>
+ extends GenericOrmOneToManyMapping<T> {
public HibernateOrmOneToManyMapping(OrmPersistentAttribute parent,
- XmlOneToMany resourceMapping) {
+ T resourceMapping) {
super(parent, resourceMapping);
}
- /*@Override
+ @Override
public String getJoinTableDefaultName() {
return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
- }*/
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToOneMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToOneMapping.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmOneToOneMapping.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -13,7 +13,7 @@
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.internal.context.orm.AbstractOrmOneToOneMapping;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmOneToOneMapping;
import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
import org.jboss.tools.hibernate.jpt.core.internal.context.NamingStrategyMappingTools;
@@ -22,17 +22,17 @@
*
*/
public class HibernateOrmOneToOneMapping<T extends XmlOneToOne> extends
-AbstractOrmOneToOneMapping<T> {
+ GenericOrmOneToOneMapping<T> {
public HibernateOrmOneToOneMapping(OrmPersistentAttribute parent,
T resourceMapping) {
super(parent, resourceMapping);
}
- /*@Override
+ @Override
public String getJoinTableDefaultName() {
return NamingStrategyMappingTools.buildJoinTableDefaultName(this);
- }*/
+ }
@Override
protected OrmRelationshipReference buildRelationshipReference() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -16,7 +16,7 @@
import org.eclipse.jpt.core.context.Table;
import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmTable;
+import org.eclipse.jpt.core.internal.context.orm.GenericOrmTable;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.resource.orm.XmlEntity;
@@ -27,9 +27,9 @@
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.HibernatePersistenceUnit.LocalMessage;
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;
/**
* @author Dmitry Geraskov
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmXmlContextNodeFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmXmlContextNodeFactory.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmXmlContextNodeFactory.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,67 +0,0 @@
-package org.jboss.tools.hibernate.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTable;
-import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTableMapping;
-
-public class HibernateOrmXmlContextNodeFactory extends
- AbstractOrmXmlContextNodeFactory {
-
- @Override
- public OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent,
- XmlBasic resourceMapping) {
- return new HibernateOrmBasicMapping(parent, resourceMapping);
- }
-
- @Override
- public OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent,
- XmlId resourceMapping) {
- return new HibernateOrmIdMappingImpl(parent, resourceMapping);
- }
-
- @Override
- public OrmEntity buildOrmEntity(OrmPersistentType parent,
- XmlEntity resourceMapping) {
- return new HibernateOrmEntityImpl(parent, resourceMapping);
- }
-
- @Override
- public OrmTable buildOrmTable(OrmEntity parent) {
- return new HibernateOrmTableImpl(parent);
- }
-
- @Override
- public OrmJoinTable buildOrmJoinTable(OrmJoinTableJoiningStrategy parent,
- XmlJoinTable resourceJoinTable) {
- return new HibernateOrmJoinTableImpl(parent, resourceJoinTable);
- }
-
- @Override
- public OrmColumn buildOrmColumn(XmlContextNode parent,
- org.eclipse.jpt.core.context.orm.OrmColumn.Owner owner) {
- return new HibernateOrmColumnImpl(parent, owner);
- }
-
- @Override
- public OrmJoinColumn buildOrmJoinColumn(XmlContextNode parent,
- org.eclipse.jpt.core.context.orm.OrmJoinColumn.Owner owner,
- XmlJoinColumn resourceJoinColumn) {
- return new HibernateOrmJoinColumnImpl(parent, owner, resourceJoinColumn);
- }
-
-}
Modified:
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/DiscriminatorFormulaAnnotationImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -49,8 +49,8 @@
this.value = this.buildValue(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncValue(this.buildValue(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setValue(this.buildValue(astRoot));
}
// ***** value
@@ -59,15 +59,12 @@
}
public void setValue(String value) {
- if (this.attributeValueHasChanged(this.value, value)) {
- this.value = value;
- this.valueAdapter.setValue(value);
+ if (this.attributeValueHasNotChanged(this.value, value)) {
+ return;
}
- }
-
- private void syncValue(String value) {
String old = this.value;
this.value = value;
+ this.valueAdapter.setValue(value);
this.firePropertyChanged(VALUE_PROPERTY, old, value);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ForeignKeyAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ForeignKeyAnnotationImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ForeignKeyAnnotationImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -61,62 +61,46 @@
this.inverseName = this.buildInverseName(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncName(this.buildName(astRoot));
- this.syncInverseName(this.buildInverseName(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setInverseName(this.buildInverseName(astRoot));
}
- // ***** name
- public String getName() {
- return this.name;
+ public String getInverseName() {
+ return inverseName;
}
- public void setName(String name) {
- if (this.attributeValueHasChanged(this.name, name)) {
- this.name = name;
- this.nameAdapter.setValue(name);
- }
+ public String getName() {
+ return name;
}
-
- private void syncName(String astName) {
+
+ public void setName(String newName) {
+ if (this.attributeValueHasNotChanged(this.name, newName)) {
+ return;
+ }
String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ this.firePropertyChanged(NAME_PROPERTY, old, newName);
}
-
- private String buildName(CompilationUnit astRoot) {
- return this.nameAdapter.getValue(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(NAME_ADAPTER, astRoot);
- }
-
- // ***** inverse name
- public String getInverseName() {
- return this.inverseName;
- }
-
- public void setInverseName(String inverseName) {
- if (this.attributeValueHasChanged(this.inverseName, inverseName)) {
- this.inverseName = inverseName;
- this.inverseNameAdapter.setValue(inverseName);
+
+ public void setInverseName(String newInverseName) {
+ if (this.attributeValueHasNotChanged(this.inverseName, newInverseName)) {
+ return;
}
- }
-
- private void syncInverseName(String astInverseName) {
String old = this.inverseName;
- this.inverseName = astInverseName;
- this.firePropertyChanged(INVERSE_NAME_PROPERTY, old, astInverseName);
+ this.inverseName = newInverseName;
+ this.inverseNameAdapter.setValue(newInverseName);
+ this.firePropertyChanged(INVERSE_NAME_PROPERTY, old, newInverseName);
}
-
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
private String buildInverseName(CompilationUnit astRoot) {
return this.inverseNameAdapter.getValue(astRoot);
}
-
- public TextRange getInverseNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(INVERSE_NAME_ADAPTER, astRoot);
- }
private static DeclarationAnnotationElementAdapter<String>
buildDeclarationAnnotationAdapter(String property) {
return
ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER,
property, true);
@@ -126,7 +110,14 @@
return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
}
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(NAME_ADAPTER, astRoot);
+ }
+ public TextRange getInverseNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(INVERSE_NAME_ADAPTER, astRoot);
+ }
+
public static class ForeignKeyAnnotationDefinition implements AnnotationDefinition
{
// singleton
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GeneratedAnnotationImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -51,8 +51,8 @@
this.value = this.buildValue(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncValue(this.buildValue(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setValue(this.buildValue(astRoot));
}
// ***** value
@@ -61,15 +61,12 @@
}
public void setValue(GenerationTime value) {
- if (this.attributeValueHasChanged(this.value, value)) {
- this.value = value;
- this.valueAdapter.setValue(GenerationTime.toJavaAnnotationValue(value));
+ if (this.attributeValueHasNotChanged(this.value, value)) {
+ return;
}
- }
-
- private void syncValue(GenerationTime value) {
GenerationTime old = this.value;
this.value = value;
+ this.valueAdapter.setValue(GenerationTime.toJavaAnnotationValue(value));
this.firePropertyChanged(VALUE_PROPERTY, old, value);
}
@@ -130,6 +127,5 @@
}
}
-
-
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -76,15 +76,15 @@
}
public void initialize(CompilationUnit astRoot) {
- this.name = this.buildName(astRoot);
- this.strategy = this.buildStrategy(astRoot);
+ this.name = this.name(astRoot);
+ this.strategy = this.strategy(astRoot);
AnnotationContainerTools.initialize(this.parametersContainer, astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncName(this.buildName(astRoot));
- this.syncStrategy(this.buildStrategy(astRoot));
- AnnotationContainerTools.synchronize(this.parametersContainer, astRoot);
+ public void update(CompilationUnit astRoot) {
+ this.setStrategy(this.strategy(astRoot));
+ this.setName(this.name(astRoot));
+ AnnotationContainerTools.update(this.parametersContainer, astRoot);
}
public String getAnnotationName() {
@@ -96,35 +96,29 @@
}
public void setStrategy(String newStrategy) {
- if (attributeValueHasChanged(this.strategy, newStrategy)) {
- this.strategy = newStrategy;
- this.strategyAdapter.setValue(newStrategy);
+ if (attributeValueHasNotChanged(this.strategy, newStrategy)) {
+ return;
}
+ String oldStrategy = this.strategy;
+ this.strategy = newStrategy;
+ this.strategyAdapter.setValue(newStrategy);
+ firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy);
}
- private void syncStrategy(String strategy) {
- String old = this.strategy;
- this.strategy = strategy;
- this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy);
- }
-
public String getName() {
return this.name;
}
- public void setName(String name) {
- if (this.attributeValueHasChanged(this.name, name)) {
- this.name = name;
- this.nameAdapter.setValue(name);
+ public void setName(String newName) {
+ if (attributeValueHasNotChanged(this.name, newName)) {
+ return;
}
+ String oldName = this.name;
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ firePropertyChanged(NAME_PROPERTY, oldName, newName);
}
- private void syncName(String astName) {
- String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
- }
-
public TextRange getNameTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(nameDeclarationAdapter, astRoot);
}
@@ -158,11 +152,13 @@
}
// ********** java annotations -> persistence model **********
- protected String buildStrategy(CompilationUnit astRoot) {
+ protected String strategy(CompilationUnit astRoot) {
+ //TODO: get Generator instead of String
+ //use buildJavaGenericGenerator method before this will be done
return this.strategyAdapter.getValue(astRoot);
}
- protected String buildName(CompilationUnit astRoot) {
+ protected String name(CompilationUnit astRoot) {
return this.nameAdapter.getValue(astRoot);
}
@@ -173,7 +169,7 @@
return (NestableParameterAnnotation)
AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
}
- NestableParameterAnnotation addParameter_() {
+ NestableParameterAnnotation addParameterInternal() {
NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
this.parameters.add(parameter);
return parameter;
@@ -183,17 +179,15 @@
return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member,
this.daa, index);
}
- Iterable<NestableParameterAnnotation> nestableParameters() {
- return this.parameters;
+ ListIterator<NestableParameterAnnotation> nestableParameters() {
+ return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
}
- void syncAddParameterAnnotation(org.eclipse.jdt.core.dom.Annotation nestedAnnotation) {
- NestableParameterAnnotation parameter = this.addParameter_();
- parameter.initialize((CompilationUnit) nestedAnnotation.getRoot());
- this.fireItemAdded(PARAMETERS_LIST, parametersSize() - 1, parameter);
+ void parameterAdded(int index, NestableParameterAnnotation parameter) {
+ this.fireItemAdded(PARAMETERS_LIST, index, parameter);
}
- NestableParameterAnnotation moveParameter_(int targetIndex, int sourceIndex) {
+ NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
return CollectionTools.move(this.parameters, targetIndex,
sourceIndex).get(targetIndex);
}
@@ -225,12 +219,12 @@
AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
}
- NestableParameterAnnotation removeParameter_(int index) {
+ NestableParameterAnnotation removeParameterInternal(int index) {
return this.parameters.remove(index);
}
- void parameterRemoved(int index) {
- this.removeItemsFromList(index, this.parameters, PARAMETERS_LIST);
+ void parameterRemoved(int index, NestableParameterAnnotation parameter) {
+ this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
}
// ********** NestableAnnotation implementation **********
@@ -283,51 +277,54 @@
return GenericGeneratorAnnotationImpl.this.getAnnotationName();
}
- public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) {
- return GenericGeneratorAnnotationImpl.this.getAstAnnotation(astRoot);
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
+ return GenericGeneratorAnnotationImpl.this.getJdtAnnotation(astRoot);
}
public String getElementName() {
return Hibernate.GENERIC_GENERATOR__PARAMETERS;
}
- public String getNestedAnnotationName() {
+ public String getNestableAnnotationName() {
return ParameterAnnotation.ANNOTATION_NAME;
}
- public Iterable<NestableParameterAnnotation> getNestedAnnotations() {
+ public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
return GenericGeneratorAnnotationImpl.this.nestableParameters();
}
- public int getNestedAnnotationsSize() {
+ public int nestedAnnotationsSize() {
return GenericGeneratorAnnotationImpl.this.parametersSize();
}
- public NestableParameterAnnotation addNestedAnnotation() {
- return GenericGeneratorAnnotationImpl.this.addParameter_();
+ public NestableParameterAnnotation addNestedAnnotationInternal() {
+ return GenericGeneratorAnnotationImpl.this.addParameterInternal();
}
- public void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation
nestedAnnotation) {
- GenericGeneratorAnnotationImpl.this.syncAddParameterAnnotation(nestedAnnotation);
+ public void nestedAnnotationAdded(int index, NestableParameterAnnotation
nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
}
- public NestableParameterAnnotation moveNestedAnnotation(int targetIndex, int
sourceIndex) {
- return GenericGeneratorAnnotationImpl.this.moveParameter_(targetIndex, sourceIndex);
+ public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
+ return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex,
sourceIndex);
}
- public NestableParameterAnnotation removeNestedAnnotation(int index) {
- return GenericGeneratorAnnotationImpl.this.removeParameter_(index);
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
}
- public void syncRemoveNestedAnnotations(int index) {
- GenericGeneratorAnnotationImpl.this.parameterRemoved(index);
+ public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
+ return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
}
+ public void nestedAnnotationRemoved(int index, NestableParameterAnnotation
nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterRemoved(index, nestedAnnotation);
+ }
+
@Override
public String toString() {
return StringTools.buildToStringFor(this);
}
-
}
public static GenericGeneratorAnnotation createNestedGenericGenerator(
@@ -384,5 +381,4 @@
}
}
-
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
-import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -19,7 +19,7 @@
* Corresponds to the Hibernate annotation
* org.hibernate.annotations.NamedQuery
*/
-public interface HibernateNamedQueryAnnotation extends NamedQueryAnnotation,
+public interface HibernateNamedQueryAnnotation extends NestableNamedQueryAnnotation,
HibernateQueryAnnotation {
//replace with Hibernate annotation
String ANNOTATION_NAME = Hibernate.NAMED_QUERY;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -10,9 +10,9 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+import java.util.ListIterator;
import java.util.Vector;
-import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
@@ -21,6 +21,7 @@
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -47,8 +48,8 @@
AnnotationContainerTools.initialize(this, astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- AnnotationContainerTools.synchronize(this, astRoot);
+ public void update(CompilationUnit astRoot) {
+ AnnotationContainerTools.update(this, astRoot);
}
@Override
@@ -57,61 +58,60 @@
}
// ********** AnnotationContainer implementation **********
+
+ public String getContainerAnnotationName() {
+ return this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
+ return this.getJdtAnnotation(astRoot);
+ }
+
public String getElementName() {
return Hibernate.NAMED_NATIVE_QUERIES__VALUE;
}
-
- public String getNestedAnnotationName() {
+
+ public String getNestableAnnotationName() {
return HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME;
- }
+ }
- public String getContainerAnnotationName() {
- return this.getAnnotationName();
+ public ListIterator<HibernateNamedNativeQueryAnnotation> nestedAnnotations() {
+ return new
CloneListIterator<HibernateNamedNativeQueryAnnotation>(this.hibernateNamedNativeQueries);
}
-
- public Iterable<HibernateNamedNativeQueryAnnotation> getNestedAnnotations() {
- return this.hibernateNamedNativeQueries;
- }
-
- public int getNestedAnnotationsSize() {
+
+ public int nestedAnnotationsSize() {
return this.hibernateNamedNativeQueries.size();
}
-
- public HibernateNamedNativeQueryAnnotation addNestedAnnotation() {
- return this.addNestedAnnotation(this.hibernateNamedNativeQueries.size());
+
+ public HibernateNamedNativeQueryAnnotation addNestedAnnotationInternal() {
+ HibernateNamedNativeQueryAnnotation namedQuery =
this.buildHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size());
+ this.hibernateNamedNativeQueries.add(namedQuery);
+ return namedQuery;
}
-
- private HibernateNamedNativeQueryAnnotation addNestedAnnotation(int index) {
- HibernateNamedNativeQueryAnnotation namedNativeQuery =
this.buildHibernateNamedNativeQuery(index);
- this.hibernateNamedNativeQueries.add(namedNativeQuery);
- return namedNativeQuery;
- }
-
- public void syncAddNestedAnnotation(Annotation astAnnotation) {
- int index = this.hibernateNamedNativeQueries.size();
- HibernateNamedNativeQueryAnnotation namedNativeQuery =
this.addNestedAnnotation(index);
- namedNativeQuery.initialize((CompilationUnit) astAnnotation.getRoot());
- this.fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, namedNativeQuery);
- }
-
+
private HibernateNamedNativeQueryAnnotation buildHibernateNamedNativeQuery(int index) {
return
HibernateSourceNamedNativeQueryAnnotation.createNestedHibernateNamedNativeQuery(this,
member, index, this.daa);
}
-
- public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
- return this.getAstAnnotation(astRoot);
+
+ public void nestedAnnotationAdded(int index, HibernateNamedNativeQueryAnnotation
nestedAnnotation) {
+ this.fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation);
}
- public HibernateNamedNativeQueryAnnotation moveNestedAnnotation(int targetIndex, int
sourceIndex) {
+ public HibernateNamedNativeQueryAnnotation moveNestedAnnotationInternal(int targetIndex,
int sourceIndex) {
return CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex,
sourceIndex).get(targetIndex);
}
- public HibernateNamedNativeQueryAnnotation removeNestedAnnotation(int index) {
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
+ }
+
+ public HibernateNamedNativeQueryAnnotation removeNestedAnnotationInternal(int index) {
return this.hibernateNamedNativeQueries.remove(index);
}
- public void syncRemoveNestedAnnotations(int index) {
- this.removeItemsFromList(index, this.hibernateNamedNativeQueries,
HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ public void nestedAnnotationRemoved(int index, HibernateNamedNativeQueryAnnotation
nestedAnnotation) {
+ this.fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation);
}
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -14,9 +14,9 @@
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.ASTTools;
import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
import
org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
@@ -133,10 +133,6 @@
this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa);
this.resultSetMappingAdapter =
this.buildAdapter(this.resultSetMappingDeclarationAdapter);
}
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
public void initialize(CompilationUnit astRoot) {
this.name = this.buildName(astRoot);
@@ -155,25 +151,27 @@
this.resultSetMapping = this.buildResultSetMapping(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncName(this.buildName(astRoot));
- this.syncQuery(this.buildQuery(astRoot));
- this.syncFlushMode(this.buildFlushMode(astRoot));
- this.syncCacheMode(this.buildCacheMode(astRoot));
- this.syncCacheable(this.buildCacheable(astRoot));
- this.syncCacheRegion(this.buildCacheRegion(astRoot));
- this.syncFetchSize(this.buildFetchSize(astRoot));
- this.syncTimeout(this.buildTimeout(astRoot));
- this.syncComment(this.buildComment(astRoot));
- this.syncReadOnly(this.buildReadOnly(astRoot));
- this.syncCallable(this.buildCallable(astRoot));
- this.syncResultClass(this.buildResultClass(astRoot));
- this.syncFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
- this.syncResultSetMapping(this.buildResultSetMapping(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
+ this.setCallable(this.buildCallable(astRoot));
+ this.setResultClass(this.buildResultClass(astRoot));
+ this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
+ this.setResultSetMapping(this.buildResultSetMapping(astRoot));
}
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
-
/**
* convenience method
*/
@@ -189,16 +187,13 @@
}
public void setName(String name) {
- if (this.attributeValueHasChanged(this.name, name)) {
- this.name = name;
- this.nameAdapter.setValue(name);
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
}
- }
-
- private void syncName(String astName) {
String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
}
private String buildName(CompilationUnit astRoot) {
@@ -215,16 +210,13 @@
}
public void setQuery(String query) {
- if (this.attributeValueHasChanged(this.query, query)) {
- this.query = query;
- this.queryAdapter.setValue(query);
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
}
- }
-
- private void syncQuery(String annotationQuery) {
String old = this.query;
- this.query = annotationQuery;
- this.firePropertyChanged(QUERY_PROPERTY, old, annotationQuery);
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
}
private String buildQuery(CompilationUnit astRoot) {
@@ -234,6 +226,10 @@
public TextRange getQueryTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
}
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_NATIVE_QUERY__QUERY;
+ }
// ***** hints
public ListIterator<QueryHintAnnotation> hints() {
@@ -274,17 +270,14 @@
public FlushModeType getFlushMode() {
return flushMode;
}
-
+
public void setFlushMode(FlushModeType flushMode) {
- if (this.attributeValueHasChanged(this.flushMode, flushMode)) {
- this.flushMode = flushMode;
- this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
}
- }
-
- private void syncFlushMode(FlushModeType flushMode) {
FlushModeType old = this.flushMode;
this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
}
@@ -299,19 +292,16 @@
// ***** caheMode
public CacheModeType getCacheMode() {
- return this.cacheMode;
+ return cacheMode;
}
public void setCacheMode(CacheModeType cacheMode) {
- if (this.attributeValueHasChanged(this.cacheMode, cacheMode)) {
- this.cacheMode = cacheMode;
- this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
}
- }
-
- private void syncCacheMode(CacheModeType cacheMode) {
CacheModeType old = this.cacheMode;
this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
}
@@ -329,15 +319,12 @@
}
public void setCacheable(Boolean cacheable){
- if (this.attributeValueHasChanged(this.cacheable, cacheable)) {
- this.cacheable = cacheable;
- this.cacheableAdapter.setValue(cacheable);
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
}
- }
-
- private void syncCacheable(Boolean cacheable) {
Boolean old = this.cacheable;
this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
}
@@ -351,15 +338,12 @@
}
public void setCacheRegion(String cacheRegion){
- if (this.attributeValueHasChanged(this.cacheRegion, cacheRegion)) {
- this.cacheRegion = cacheRegion;
- this.cacheRegionAdapter.setValue(cacheRegion);
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
}
- }
-
- private void syncCacheRegion(String cacheRegion) {
String old = this.cacheRegion;
this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
}
@@ -372,15 +356,12 @@
}
public void setFetchSize(Integer fetchSize){
- if (this.attributeValueHasChanged(this.fetchSize, fetchSize)) {
- this.fetchSize = fetchSize;
- this.fetchSizeAdapter.setValue(fetchSize);
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
}
- }
-
- private void syncFetchSize(Integer fetchSize) {
Integer old = this.fetchSize;
this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
}
@@ -392,15 +373,12 @@
return this.timeout;
}
public void setTimeout(Integer timeout){
- if (this.attributeValueHasChanged(this.timeout, timeout)) {
- this.timeout = timeout;
- this.timeoutAdapter.setValue(timeout);
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
}
- }
-
- private void syncTimeout(Integer timeout) {
Integer old = this.timeout;
this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
}
@@ -413,15 +391,12 @@
}
public void setComment(String comment){
- if (this.attributeValueHasChanged(this.comment, comment)) {
- this.comment = comment;
- this.commentAdapter.setValue(comment);
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
}
- }
-
- private void syncComment(String comment) {
String old = this.comment;
this.comment = comment;
+ this.commentAdapter.setValue(comment);
this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
}
@@ -434,16 +409,13 @@
}
public void setReadOnly(Boolean readOnly){
- if (this.attributeValueHasChanged(this.readOnly, readOnly)) {
- this.readOnly = readOnly;
- this.readOnlyAdapter.setValue(readOnly);
- }
- }
-
- private void syncReadOnly(Boolean readOnly) {
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
Boolean old = this.readOnly;
this.readOnly = readOnly;
- this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
}
private Boolean buildReadOnly(CompilationUnit astRoot) {
@@ -455,16 +427,13 @@
}
public void setCallable(Boolean callable){
- if (this.attributeValueHasChanged(this.callable, callable)) {
- this.callable = callable;
- this.callableAdapter.setValue(callable);
+ if (this.attributeValueHasNotChanged(this.callable, callable)) {
+ return;
}
- }
-
- private void syncCallable(Boolean callable) {
Boolean old = this.callable;
this.callable = callable;
- this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
+ this.callableAdapter.setValue(callable);
+ this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
}
private Boolean buildCallable(CompilationUnit astRoot) {
@@ -476,15 +445,12 @@
}
public void setResultClass(String resultClass) {
- if (this.attributeValueHasChanged(this.resultClass, resultClass)) {
- this.resultClass = resultClass;
- this.resultClassAdapter.setValue(resultClass);
+ if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) {
+ return;
}
- }
-
- private void syncResultClass(String resultClass) {
String old = this.resultClass;
this.resultClass = resultClass;
+ this.resultClassAdapter.setValue(resultClass);
this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass);
}
@@ -501,14 +467,14 @@
return this.fullyQualifiedResultClassName;
}
- private void syncFullyQualifiedResultClassName(String name) {
+ private void setFullyQualifiedResultClassName(String name) {
String old = this.fullyQualifiedResultClassName;
this.fullyQualifiedResultClassName = name;
- this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old,
fullyQualifiedResultClassName);
+ this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name);
}
private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) {
- return (this.resultClass == null) ? null :
ASTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
+ return (this.resultClass == null) ? null :
JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
}
// ***** result set mapping
@@ -517,15 +483,12 @@
}
public void setResultSetMapping(String resultSetMapping) {
- if (this.attributeValueHasChanged(this.resultSetMapping, resultSetMapping)) {
- this.resultSetMapping = resultSetMapping;
- this.resultSetMappingAdapter.setValue(resultSetMapping);
+ if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) {
+ return;
}
- }
-
- private void syncResultSetMapping(String resultSetMapping) {
String old = this.resultSetMapping;
this.resultSetMapping = resultSetMapping;
+ this.resultSetMappingAdapter.setValue(resultSetMapping);
this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -10,9 +10,9 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+import java.util.ListIterator;
import java.util.Vector;
-import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
@@ -21,14 +21,15 @@
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedQueriesAnnotation extends SourceAnnotation<Member>
implements
- HibernateNamedQueriesAnnotation {
+public class HibernateSourceNamedQueriesAnnotation extends SourceAnnotation<Member>
+implements HibernateNamedQueriesAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -47,8 +48,8 @@
AnnotationContainerTools.initialize(this, astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- AnnotationContainerTools.synchronize(this, astRoot);
+ public void update(CompilationUnit astRoot) {
+ AnnotationContainerTools.update(this, astRoot);
}
@Override
@@ -57,61 +58,59 @@
}
// ********** AnnotationContainer implementation **********
+
+ public String getContainerAnnotationName() {
+ return this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
+ return this.getJdtAnnotation(astRoot);
+ }
+
public String getElementName() {
return Hibernate.NAMED_QUERIES__VALUE;
}
-
- public String getNestedAnnotationName() {
+
+ public String getNestableAnnotationName() {
return HibernateNamedQueryAnnotation.ANNOTATION_NAME;
- }
+ }
- public String getContainerAnnotationName() {
- return this.getAnnotationName();
+ public ListIterator<HibernateNamedQueryAnnotation> nestedAnnotations() {
+ return new
CloneListIterator<HibernateNamedQueryAnnotation>(this.hibernateNamedQueries);
}
-
- public Iterable<HibernateNamedQueryAnnotation> getNestedAnnotations() {
- return this.hibernateNamedQueries;
- }
-
- public int getNestedAnnotationsSize() {
+
+ public int nestedAnnotationsSize() {
return this.hibernateNamedQueries.size();
}
-
- public HibernateNamedQueryAnnotation addNestedAnnotation() {
- return this.addNestedAnnotation(this.hibernateNamedQueries.size());
- }
-
- private HibernateNamedQueryAnnotation addNestedAnnotation(int index) {
- HibernateNamedQueryAnnotation namedQuery = this.buildHibernateNamedQuery(index);
+
+ public HibernateNamedQueryAnnotation addNestedAnnotationInternal() {
+ HibernateNamedQueryAnnotation namedQuery =
this.buildHibernateNamedQuery(this.hibernateNamedQueries.size());
this.hibernateNamedQueries.add(namedQuery);
return namedQuery;
}
-
- public void syncAddNestedAnnotation(Annotation astAnnotation) {
- int index = this.hibernateNamedQueries.size();
- HibernateNamedQueryAnnotation namedQuery = this.addNestedAnnotation(index);
- namedQuery.initialize((CompilationUnit) astAnnotation.getRoot());
- this.fireItemAdded(HIBERNATE_NAMED_QUERIES_LIST, index, namedQuery);
- }
-
+
private HibernateNamedQueryAnnotation buildHibernateNamedQuery(int index) {
return HibernateSourceNamedQueryAnnotation.createNestedHibernateNamedQuery(this,
member, index, this.daa);
}
-
- public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
- return this.getAstAnnotation(astRoot);
+
+ public void nestedAnnotationAdded(int index, HibernateNamedQueryAnnotation
nestedAnnotation) {
+ this.fireItemAdded(HIBERNATE_NAMED_QUERIES_LIST, index, nestedAnnotation);
}
- public HibernateNamedQueryAnnotation moveNestedAnnotation(int targetIndex, int
sourceIndex) {
+ public HibernateNamedQueryAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
return CollectionTools.move(this.hibernateNamedQueries, targetIndex,
sourceIndex).get(targetIndex);
}
- public HibernateNamedQueryAnnotation removeNestedAnnotation(int index) {
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(HIBERNATE_NAMED_QUERIES_LIST, targetIndex, sourceIndex);
+ }
+
+ public HibernateNamedQueryAnnotation removeNestedAnnotationInternal(int index) {
return this.hibernateNamedQueries.remove(index);
}
- public void syncRemoveNestedAnnotations(int index) {
- this.removeItemsFromList(index, this.hibernateNamedQueries,
HIBERNATE_NAMED_QUERIES_LIST);
+ public void nestedAnnotationRemoved(int index, HibernateNamedQueryAnnotation
nestedAnnotation) {
+ this.fireItemRemoved(HIBERNATE_NAMED_QUERIES_LIST, index, nestedAnnotation);
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -111,10 +111,6 @@
this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member,
readOnlyDeclarationAdapter);
}
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
public void initialize(CompilationUnit astRoot) {
this.name = this.buildName(astRoot);
this.query = this.buildQuery(astRoot);
@@ -128,19 +124,23 @@
this.readOnly = this.buildReadOnly(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncName(this.buildName(astRoot));
- this.syncQuery(this.buildQuery(astRoot));
- this.syncFlushMode(this.buildFlushMode(astRoot));
- this.syncCacheMode(this.buildCacheMode(astRoot));
- this.syncCacheable(this.buildCacheable(astRoot));
- this.syncCacheRegion(this.buildCacheRegion(astRoot));
- this.syncFetchSize(this.buildFetchSize(astRoot));
- this.syncTimeout(this.buildTimeout(astRoot));
- this.syncComment(this.buildComment(astRoot));
- this.syncReadOnly(this.buildReadOnly(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
}
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
/**
* convenience method
*/
@@ -156,16 +156,13 @@
}
public void setName(String name) {
- if (this.attributeValueHasChanged(this.name, name)) {
- this.name = name;
- this.nameAdapter.setValue(name);
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
}
- }
-
- private void syncName(String astName) {
String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
}
private String buildName(CompilationUnit astRoot) {
@@ -182,16 +179,13 @@
}
public void setQuery(String query) {
- if (this.attributeValueHasChanged(this.query, query)) {
- this.query = query;
- this.queryAdapter.setValue(query);
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
}
- }
-
- private void syncQuery(String annotationQuery) {
String old = this.query;
- this.query = annotationQuery;
- this.firePropertyChanged(QUERY_PROPERTY, old, annotationQuery);
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
}
private String buildQuery(CompilationUnit astRoot) {
@@ -201,6 +195,10 @@
public TextRange getQueryTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
}
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_QUERY__QUERY;
+ }
// ***** hints
public ListIterator<QueryHintAnnotation> hints() {
@@ -241,17 +239,14 @@
public FlushModeType getFlushMode() {
return flushMode;
}
-
+
public void setFlushMode(FlushModeType flushMode) {
- if (this.attributeValueHasChanged(this.flushMode, flushMode)) {
- this.flushMode = flushMode;
- this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
}
- }
-
- private void syncFlushMode(FlushModeType flushMode) {
FlushModeType old = this.flushMode;
this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
}
@@ -266,19 +261,16 @@
// ***** caheMode
public CacheModeType getCacheMode() {
- return this.cacheMode;
+ return cacheMode;
}
public void setCacheMode(CacheModeType cacheMode) {
- if (this.attributeValueHasChanged(this.cacheMode, cacheMode)) {
- this.cacheMode = cacheMode;
- this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
}
- }
-
- private void syncCacheMode(CacheModeType cacheMode) {
CacheModeType old = this.cacheMode;
this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
}
@@ -296,15 +288,12 @@
}
public void setCacheable(Boolean cacheable){
- if (this.attributeValueHasChanged(this.cacheable, cacheable)) {
- this.cacheable = cacheable;
- this.cacheableAdapter.setValue(cacheable);
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
}
- }
-
- private void syncCacheable(Boolean cacheable) {
Boolean old = this.cacheable;
this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
}
@@ -318,15 +307,12 @@
}
public void setCacheRegion(String cacheRegion){
- if (this.attributeValueHasChanged(this.cacheRegion, cacheRegion)) {
- this.cacheRegion = cacheRegion;
- this.cacheRegionAdapter.setValue(cacheRegion);
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
}
- }
-
- private void syncCacheRegion(String cacheRegion) {
String old = this.cacheRegion;
this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
}
@@ -339,15 +325,12 @@
}
public void setFetchSize(Integer fetchSize){
- if (this.attributeValueHasChanged(this.fetchSize, fetchSize)) {
- this.fetchSize = fetchSize;
- this.fetchSizeAdapter.setValue(fetchSize);
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
}
- }
-
- private void syncFetchSize(Integer fetchSize) {
Integer old = this.fetchSize;
this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
}
@@ -359,15 +342,12 @@
return this.timeout;
}
public void setTimeout(Integer timeout){
- if (this.attributeValueHasChanged(this.timeout, timeout)) {
- this.timeout = timeout;
- this.timeoutAdapter.setValue(timeout);
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
}
- }
-
- private void syncTimeout(Integer timeout) {
Integer old = this.timeout;
this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
}
@@ -380,15 +360,12 @@
}
public void setComment(String comment){
- if (this.attributeValueHasChanged(this.comment, comment)) {
- this.comment = comment;
- this.commentAdapter.setValue(comment);
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
}
- }
-
- private void syncComment(String comment) {
String old = this.comment;
this.comment = comment;
+ this.commentAdapter.setValue(comment);
this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
}
@@ -401,16 +378,13 @@
}
public void setReadOnly(Boolean readOnly){
- if (this.attributeValueHasChanged(this.readOnly, readOnly)) {
- this.readOnly = readOnly;
- this.readOnlyAdapter.setValue(readOnly);
- }
- }
-
- private void syncReadOnly(Boolean readOnly) {
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
Boolean old = this.readOnly;
this.readOnly = readOnly;
- this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
}
private Boolean buildReadOnly(CompilationUnit astRoot) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -63,9 +63,9 @@
this.columnNames = this.buildColumnNames(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncName(this.buildName(astRoot));
- this.syncColumnNames(this.buildColumnNames(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setColumnNames(this.buildColumnNames(astRoot));
}
public String[] getColumnNames() {
@@ -77,29 +77,23 @@
}
public void setName(String newName) {
- if (this.attributeValueHasChanged(this.name, newName)) {
- this.name = newName;
- this.nameAdapter.setValue(newName);
+ if (this.attributeValueHasNotChanged(this.name, newName)) {
+ return;
}
- }
-
- private void syncName(String astName) {
String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ this.firePropertyChanged(NAME_PROPERTY, old, newName);
}
public void setColumnNames(String[] newColumnNames) {
- if (this.attributeValueHasChanged(this.columnNames, newColumnNames)) {
- this.columnNames = newColumnNames;
- this.columnNamesAdapter.setValue(newColumnNames);
+ if (this.attributeValueHasNotChanged(this.columnNames, newColumnNames)) {
+ return;
}
- }
-
- private void syncColumnNames(String[] columnNames) {
String[] old = this.columnNames;
- this.columnNames = columnNames;
- this.firePropertyChanged(COLUMN_NAMES_PROPERTY, old, columnNames);
+ this.columnNames = newColumnNames;
+ this.columnNamesAdapter.setValue(newColumnNames);
+ this.firePropertyChanged(COLUMN_NAMES_PROPERTY, old, newColumnNames);
}
private String buildName(CompilationUnit astRoot) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+import java.util.ListIterator;
import java.util.Vector;
import org.eclipse.jdt.core.IAnnotation;
@@ -24,7 +25,7 @@
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -51,8 +52,8 @@
AnnotationContainerTools.initialize(this, astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- AnnotationContainerTools.synchronize(this, astRoot);
+ public void update(CompilationUnit astRoot) {
+ AnnotationContainerTools.update(this, astRoot);
}
@Override
@@ -66,53 +67,54 @@
return this.getAnnotationName();
}
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit
astRoot) {
+ return this.getJdtAnnotation(astRoot);
+ }
+
public String getElementName() {
return Hibernate.GENERIC_GENERATORS__VALUE;
}
- public String getNestedAnnotationName() {
+ public String getNestableAnnotationName() {
return GenericGeneratorAnnotation.ANNOTATION_NAME;
}
- public Iterable<GenericGeneratorAnnotation> getNestedAnnotations() {
- return new
LiveCloneIterable<GenericGeneratorAnnotation>(this.genericGenerators);
+ public ListIterator<GenericGeneratorAnnotation> nestedAnnotations() {
+ return new
CloneListIterator<GenericGeneratorAnnotation>(this.genericGenerators);
}
- public int getNestedAnnotationsSize() {
+ public int nestedAnnotationsSize() {
return this.genericGenerators.size();
}
-
- public GenericGeneratorAnnotation addNestedAnnotation() {
- return this.addNestedAnnotation(this.genericGenerators.size());
- }
-
- private GenericGeneratorAnnotation addNestedAnnotation(int index) {
- GenericGeneratorAnnotation genericGenerator = this.buildGenericGenerator(index);
+
+ public GenericGeneratorAnnotation addNestedAnnotationInternal() {
+ GenericGeneratorAnnotation genericGenerator =
this.buildGenericGenerator(this.genericGenerators.size());
this.genericGenerators.add(genericGenerator);
return genericGenerator;
}
-
- public void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation)
{
- int index = this.genericGenerators.size();
- GenericGeneratorAnnotation genericGenerator = this.addNestedAnnotation(index);
- genericGenerator.initialize((CompilationUnit) astAnnotation.getRoot());
- this.fireItemAdded(GENERIC_GENERATORS_LIST, index, genericGenerator);
- }
private GenericGeneratorAnnotation buildGenericGenerator(int index) {
return GenericGeneratorAnnotationImpl.createNestedGenericGenerator(this, member, index,
this.daa);
}
- public GenericGeneratorAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex)
{
+ public void nestedAnnotationAdded(int index, GenericGeneratorAnnotation
nestedAnnotation) {
+ this.fireItemAdded(GENERIC_GENERATORS_LIST, index, nestedAnnotation);
+ }
+
+ public GenericGeneratorAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
return CollectionTools.move(this.genericGenerators, targetIndex,
sourceIndex).get(targetIndex);
}
- public GenericGeneratorAnnotation removeNestedAnnotation(int index) {
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
+ }
+
+ public GenericGeneratorAnnotation removeNestedAnnotationInternal(int index) {
return this.genericGenerators.remove(index);
}
-
- public void syncRemoveNestedAnnotations(int index) {
- this.removeItemsFromList(index, this.genericGenerators, GENERIC_GENERATORS_LIST);
+
+ public void nestedAnnotationRemoved(int index, GenericGeneratorAnnotation
nestedAnnotation) {
+ this.fireItemRemoved(GENERIC_GENERATORS_LIST, index, nestedAnnotation);
}
public static class GenericGeneratorsAnnotationDefinition implements
AnnotationDefinition {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -72,9 +72,9 @@
this.value = this.buildValue(astRoot);
}
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncName(this.buildName(astRoot));
- this.syncValue(this.buildValue(astRoot));
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setValue(this.buildValue(astRoot));
}
public IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
@@ -95,16 +95,13 @@
}
public void setName(String name) {
- if (this.attributeValueHasChanged(this.name, name)) {
- this.name = name;
- this.nameAdapter.setValue(name);
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
}
- }
-
- private void syncName(String astName) {
String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
}
private String buildName(CompilationUnit astRoot) {
@@ -121,15 +118,12 @@
}
public void setValue(String value) {
- if (this.attributeValueHasChanged(this.value, value)) {
- this.value = value;
- this.valueAdapter.setValue(value);
+ if (this.attributeValueHasNotChanged(this.value, value)) {
+ return;
}
- }
-
- private void syncValue(String value) {
String old = this.value;
this.value = value;
+ this.valueAdapter.setValue(value);
this.firePropertyChanged(VALUE_PROPERTY, old, value);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2010-05-26
13:13:34 UTC (rev 22326)
@@ -16,8 +16,8 @@
org.eclipse.ui.forms,
org.jboss.tools.hibernate.jpt.core,
org.eclipse.ui.ide,
- org.eclipse.jpt.core;bundle-version="[2.3.0,2.3.1)",
- org.eclipse.jpt.ui;bundle-version="[2.3.0,2.3.1)",
+ org.eclipse.jpt.core,
+ org.eclipse.jpt.ui,
org.eclipse.jpt.utility,
org.eclipse.jpt.db;bundle-version="1.2.100",
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.0"
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -10,23 +10,16 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.GeneratorContainer;
-import org.eclipse.jpt.core.context.QueryContainer;
import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.internal.details.AbstractEntityComposite;
-import org.eclipse.jpt.ui.internal.details.EntityNameComposite;
-import org.eclipse.jpt.ui.internal.details.IdClassComposite;
-import org.eclipse.jpt.ui.internal.details.java.JavaInheritanceComposite;
-import org.eclipse.jpt.ui.internal.details.java.JavaSecondaryTablesComposite;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.ui.internal.java.details.JavaSecondaryTablesComposite;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.AbstractEntityComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.EntityNameComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.IdClassComposite;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateGeneratorContainer;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainer;
-import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGenerationComposite2;
+import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGeneratorsComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateQueriesComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateTableComposite;
@@ -46,41 +39,42 @@
super(subjectHolder, parent, widgetFactory);
}
-
@Override
- protected void initializeQueriesSection(Composite container,
PropertyValueModel<QueryContainer> queryContainerHolder) {
- new HibernateQueriesComposite(this, (PropertyValueModel<? extends
HibernateJavaQueryContainer>) queryContainerHolder, container);
+ protected void addSecondaryTablesComposite(Composite container) {
+ new JavaSecondaryTablesComposite(this, container);
}
- private PropertyValueModel<HibernateGeneratorContainer> buildGeneratorContainer()
{
- return new PropertyAspectAdapter<HibernateJavaEntity,
HibernateGeneratorContainer>(getSubjectHolder()) {
- @Override
- protected HibernateGeneratorContainer buildValue_() {
- return this.subject.getGeneratorContainer();
- }
- };
+ @Override
+ protected void initializeQueriesPane(Composite container) {
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.EntityComposite_queries
+ );
+
+ new HibernateQueriesComposite(this, container);
}
@Override
- protected void initializeGeneratorsSection(Composite container,
PropertyValueModel<GeneratorContainer> generatorContainerHolder) {
- new HibernateGenerationComposite2(this, (PropertyValueModel<? extends
HibernateGeneratorContainer>) generatorContainerHolder, addSubPane(container, 10),
true);
+ protected void initializeGeneratorsPane(Composite container) {
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_primaryKeyGenerationSection
+ );
+
+ new HibernateGeneratorsComposite(this, container);
}
-
- protected void initializeEntitySection(Composite container) {
- new HibernateTableComposite(this, container);
- new EntityNameComposite(this, container);
- new IdClassComposite(this, buildIdClassReferenceHolder(), container);
- }
-
@Override
- protected void initializeSecondaryTablesSection(Composite container) {
- new JavaSecondaryTablesComposite(this, container);
+ protected void addInheritanceComposite(Composite container) {
+ new HibernateJavaInheritanceComposite(this, container);
}
+
+ protected void initializeGeneralPane(Composite container) {
+ int groupBoxMargin = getGroupBoxMargin();
- @Override
- protected void initializeInheritanceSection(Composite container) {
- new JavaInheritanceComposite(this, container);
+ new HibernateTableComposite(this, container);
+ new EntityNameComposite(this, addSubPane(container, 0, groupBoxMargin, 0,
groupBoxMargin));
+ new IdClassComposite(this, addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin),
false);
}
}
Modified:
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaInheritanceComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,8 +11,8 @@
package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.ui.internal.details.java.JavaPrimaryKeyJoinColumnsComposite;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+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;
import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateAbstractInheritanceComposite;
@@ -24,9 +24,9 @@
public class HibernateJavaInheritanceComposite extends
HibernateAbstractInheritanceComposite<HibernateJavaEntity> {
@SuppressWarnings("unchecked")
- public HibernateJavaInheritanceComposite(Pane<? extends JavaEntity> parentPane,
+ public HibernateJavaInheritanceComposite(FormPane<? extends JavaEntity>
parentPane,
Composite parent) {
- super((Pane<? extends HibernateJavaEntity>) parentPane, parent);
+ super((FormPane<? extends HibernateJavaEntity>) parentPane, parent);
}
protected void addPrimaryKeyJoinColumnsComposite(Composite container) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GeneratedComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GeneratedComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GeneratedComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -14,7 +14,7 @@
import java.util.Collection;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.hibernate.jpt.core.internal.context.Generated;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenerationTime;
@@ -23,14 +23,14 @@
* @author Dmitry Geraskov
*
*/
-public class GeneratedComposite extends Pane<Generated> {
+public class GeneratedComposite extends FormPane<Generated> {
/**
* Creates a new <code>GeneratedComposite</code>.
*
* @param parentPane The parent container of this one
* @param parent The parent container
*/
- public GeneratedComposite(Pane<? extends Generated> parentPane,
+ public GeneratedComposite(FormPane<? extends Generated> parentPane,
Composite parent) {
super(parentPane, parent);
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * 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.ui.internal.mapping.details;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.ui.internal.mappings.db.SequenceCombo;
+import org.eclipse.jpt.ui.internal.util.ControlEnabler;
+import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringConverter;
+import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+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.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
+import org.jboss.tools.hibernate.jpt.ui.internal.widgets.EnterNameDialog;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ *
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | ----------------------------------------------------- |
+ * | Name: | I | |
+ * | ----------------------------------------------------- |
+ * | ----------------------------------------------------- |
+ * | Sequence : | SequenceCombo | |
+ * | ----------------------------------------------------- |
+ * | - Parameters ----------------------------------------------------------- |
+ * | | --------------------------------------------------------------------- | |
+ * | | | | | |
+ * | | | ParametersComposite | | |
+ * | | | | | |
+ * | | --------------------------------------------------------------------- | |
+ * | ------------------------------------------------------------------------- |
+ *
-----------------------------------------------------------------------------</pre>
+ *
+ * @see HibernateGeneratorsComposite
+ * @see GenericGenerator
+ * @see HibernateGenerationComposite - The parent container
+ * @see SequenceCombo
+ *
+ * @version 2.0
+ * @since 1.0
+ */
+public class GenericGeneratorsComposite extends Pane<GenericGeneratorHolder> {
+
+ private AddRemoveListPane<GenericGeneratorHolder> listPane;
+ private WritablePropertyValueModel<GenericGenerator> generatorHolder;
+
+ public GenericGeneratorsComposite(Pane<? extends GenericGeneratorHolder>
parentPane, Composite parent) {
+ super(parentPane, parent, false);
+ }
+
+ private void addGenericGenerator() {
+ Set<String> generatorNames = new HashSet<String>();
+ for (Iterator<Generator> generators =
this.getSubject().getPersistenceUnit().generators(); generators.hasNext(); ) {
+ generatorNames.add(generators.next().getName());
+ }
+ EnterNameDialog dialog = new EnterNameDialog(getControl().getShell(),
+ HibernateUIMappingMessages.GenericGeneratorsComposite_addGeneratorNameDescription,
+ null,
+ generatorNames);
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ String name = dialog.getName();
+ GenericGenerator generator =
getSubject().addGenericGenerator(getSubject().genericGeneratorsSize());
+ generator.setName(name);
+ }
+
+ private ListValueModel<GenericGenerator> buildDisplayableGeneratorsListHolder() {
+ return new ItemPropertyListValueModelAdapter<GenericGenerator>(
+ buildGeneratorsListHolder(),
+ GenericGenerator.NAME_PROPERTY
+ );
+ }
+
+ private ListValueModel<GenericGenerator> buildGeneratorsListHolder() {
+ return new ListAspectAdapter<GenericGeneratorHolder, GenericGenerator>(
+ getSubjectHolder(),
+ GenericGeneratorHolder.GENERIC_GENERATORS_LIST)
+ {
+ @Override
+ protected ListIterator<GenericGenerator> listIterator_() {
+ return this.subject.genericGenerators();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.genericGeneratorsSize();
+ }
+ };
+ }
+
+ private AddRemoveListPane<GenericGeneratorHolder> addListPane(Composite container)
{
+
+ return new AddRemoveListPane<GenericGeneratorHolder>(
+ this,
+ container,
+ buildGenericGeneratorsAdapter(),
+ buildDisplayableGeneratorsListHolder(),
+ this.generatorHolder,
+ buildGeneratorsListLabelProvider(),
+ null//TODO help
+ );
+ }
+
+ private Adapter buildGenericGeneratorsAdapter() {
+
+ return new AddRemoveListPane.AbstractAdapter() {
+
+ public void addNewItem(ObjectListSelectionModel listSelectionModel) {
+ addGenericGenerator();
+ }
+
+ public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
+ for (Object item : listSelectionModel.selectedValues()) {
+ getSubject().removeGenericGenerator((GenericGenerator) item);
+ }
+ }
+ };
+ }
+
+
+ private ILabelProvider buildGeneratorsListLabelProvider() {
+ return new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ GenericGenerator genericGenerator = (GenericGenerator) element;
+ String name = genericGenerator.getName();
+
+ if (name == null) {
+ int index = CollectionTools.indexOf(getSubject().genericGenerators(),
genericGenerator);
+ name =
NLS.bind(HibernateUIMappingMessages.GenericGeneratorsComposite_generatorNullName, index);
+ }
+
+ return name;
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<GenericGenerator> buildGenericGeneratorHolder()
{
+ return new SimplePropertyValueModel<GenericGenerator>();
+ }
+
+ @Override
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+ this.listPane.enableWidgets(enabled);
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.generatorHolder = buildGenericGeneratorHolder();
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ if (getSubject() instanceof HibernateJavaIdMapping){
+ // Name widgets
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_name,
+ buildGeneratorNameHolder(),
+ null//TODO add help
+ );
+ } else {
+ // List pane
+ this.listPane = addListPane(container);
+ }
+
+ Combo c = addLabeledEditableCombo(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_strategy,
+ new SimpleListValueModel<String>(JavaGenericGeneratorImpl.generatorClasses),
+ buildStrategyHolder(),
+ StringConverter.Default.<String>instance(),
+ null);//TODO add help
+ new ControlEnabler(buildControlEnabler(), c);
+
+ new ParametersComposite(this, container, generatorHolder);
+
+
+ }
+
+ private PropertyValueModel<Boolean> buildControlEnabler() {
+ return new TransformationPropertyValueModel<GenericGenerator,
Boolean>(generatorHolder){
+ public Boolean transform(GenericGenerator generator) {
+ return generator != null;
+ }
+ };
+ }
+
+ protected final WritablePropertyValueModel<String> buildGeneratorNameHolder() {
+ return new PropertyAspectAdapter<GenericGenerator, String>(this.generatorHolder,
GenericGenerator.NAME_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject == null ? null : subject.getName();
+ }
+
+ @Override
+ public void setValue(String value) {
+ if (subject != null) {
+ setValue_(value);
+ return;
+ }
+
+ if ("".equals(value)){ //$NON-NLS-1$
+ return;
+ }
+
+ GenericGenerator generator =
+ (getSubject().genericGeneratorsSize() == 0) ? getSubject().addGenericGenerator(0)
+ : getSubject().genericGenerators().next();
+
+ generator.setName(value);
+ generatorHolder.setValue(generator);
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value)) {//$NON-NLS-1$
+ value = null;
+ }
+ subject.setName(value);
+ }
+ };
+ }
+
+ protected WritablePropertyValueModel<String> buildStrategyHolder() {
+ return new PropertyAspectAdapter<GenericGenerator, String>(this.generatorHolder,
+ GenericGenerator.GENERIC_STRATEGY_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject == null ? null : subject.getStrategy();
+ }
+
+ @Override
+ public void setValue(String value) {
+ if (subject != null) {
+ setValue_(value);
+ return;
+ }
+
+ if ("".equals(value)){ //$NON-NLS-1$
+ return;
+ }
+
+ GenericGenerator generator =
+ (getSubject().genericGeneratorsSize() == 0) ? getSubject().addGenericGenerator(0)
+ : getSubject().genericGenerators().next();
+
+ generator.setStrategy(value);
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value)) {//$NON-NLS-1$
+ value = null;
+ }
+ subject.setStrategy(value);
+ }
+ };
+ }
+
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAbstractInheritanceComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAbstractInheritanceComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAbstractInheritanceComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -15,24 +15,25 @@
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.details.AbstractEntityComposite;
-import org.eclipse.jpt.ui.internal.details.AbstractInheritanceComposite;
-import org.eclipse.jpt.ui.internal.details.DiscriminatorColumnComposite;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
+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.mappings.details.DiscriminatorColumnComposite;
+import org.eclipse.jpt.ui.internal.util.ControlEnabler;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+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.widgets.Combo;
+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;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
-import org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl.ColumnCombo;
/**
* Here the layout of this pane:
@@ -79,7 +80,7 @@
* @since 2.0
*/
@SuppressWarnings("nls")
-public abstract class HibernateAbstractInheritanceComposite<T extends
HibernateEntity> extends Pane<T> {
+public abstract class HibernateAbstractInheritanceComposite<T extends
HibernateEntity> extends FormPane<T> {
/**
* A key used to represent the default value, this is required to convert
@@ -98,7 +99,7 @@
* @param parentPane The parent container of this one
* @param parent The parent container
*/
- public HibernateAbstractInheritanceComposite(Pane<? extends T> parentPane,
+ public HibernateAbstractInheritanceComposite(FormPane<? extends T> parentPane,
Composite parent) {
super(parentPane, parent, false);
@@ -117,13 +118,13 @@
// Strategy widgets
addLabeledComposite(
subPane,
- JptUiDetailsMessages.InheritanceComposite_strategy,
+ JptUiMappingsMessages.InheritanceComposite_strategy,
addStrategyCombo(subPane),
JpaHelpContextIds.ENTITY_INHERITANCE_STRATEGY
);
// Discriminator Value widgets
- Combo discriminatorValueCombo = addEditableCombo(
+ CCombo discriminatorValueCombo = addEditableCCombo(
subPane,
buildDiscriminatorValueListHolder(),
buildDiscriminatorValueHolder(),
@@ -131,7 +132,7 @@
);
Label discriminatorValueLabel = addLabel(
subPane,
- JptUiDetailsMessages.InheritanceComposite_discriminatorValue
+ JptUiMappingsMessages.InheritanceComposite_discriminatorValue
);
addLabeledComposite(
subPane,
@@ -141,11 +142,14 @@
JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_VALUE
);
+ new ControlEnabler(buildDiscriminatorValueEnabledHolder(), discriminatorValueCombo,
discriminatorValueLabel);
+
if (getSubject() instanceof HibernateJavaEntity) {
- new HibernateDiscriminatorColumnComposite((Pane<? extends HibernateJavaEntity>)
this, container);
+ new HibernateDiscriminatorColumnComposite((FormPane<? extends
HibernateJavaEntity>) this, container);
} else {
new DiscriminatorColumnComposite<Entity>(this, container);
- }
+ }
+
// Primary Key Join Columns widgets
addPrimaryKeyJoinColumnsComposite(addSubPane(container, 5));
@@ -212,16 +216,16 @@
if (defaultName.length() > 0) {
value = NLS.bind(
- JptUiDetailsMessages.DefaultWithOneParam,
+ JptUiMappingsMessages.DefaultWithOneParam,
defaultName
);
}
else {
- value = JptUiDetailsMessages.ProviderDefault;
+ value = JptUiMappingsMessages.ProviderDefault;
}
}
if (value.startsWith(NONE_KEY)) {
- value = JptUiDetailsMessages.NoneSelected;
+ value = JptUiMappingsMessages.NoneSelected;
}
return value;
}
@@ -278,7 +282,7 @@
@Override
protected String displayString(InheritanceType value) {
return buildDisplayString(
- JptUiDetailsMessages.class,
+ JptUiMappingsMessages.class,
AbstractInheritanceComposite.class,
value
);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -14,7 +14,7 @@
import java.util.List;
import org.eclipse.jpt.core.context.Query;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.widgets.DialogPane;
import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog;
import org.eclipse.jpt.utility.internal.StringConverter;
@@ -62,17 +62,17 @@
@Override
protected String getTitle() {
- return JptUiDetailsMessages.AddQueryDialog_title;
+ return JptUiMappingsMessages.AddQueryDialog_title;
}
@Override
protected String getDescriptionTitle() {
- return JptUiDetailsMessages.AddQueryDialog_descriptionTitle;
+ return JptUiMappingsMessages.AddQueryDialog_descriptionTitle;
}
@Override
protected String getDescription() {
- return JptUiDetailsMessages.AddQueryDialog_description;
+ return JptUiMappingsMessages.AddQueryDialog_description;
}
@Override
@@ -119,13 +119,13 @@
protected void initializeLayout(Composite container) {
this.nameText = addLabeledText(
container,
- JptUiDetailsMessages.AddQueryDialog_name,
+ JptUiMappingsMessages.AddQueryDialog_name,
buildNameHolder()
);
addLabeledCombo(
container,
- JptUiDetailsMessages.AddQueryDialog_queryType,
+ JptUiMappingsMessages.AddQueryDialog_queryType,
buildQueryTypeListHolder(),
buildQueryTypeHolder(),
buildStringConverter(),
@@ -145,10 +145,10 @@
return new StringConverter<String>() {
public String convertToString(String value) {
if (value == Query.NAMED_QUERY) {
- return JptUiDetailsMessages.AddQueryDialog_namedQuery;
+ return JptUiMappingsMessages.AddQueryDialog_namedQuery;
}
if (value == Query.NAMED_NATIVE_QUERY) {
- return JptUiDetailsMessages.AddQueryDialog_namedNativeQuery;
+ return JptUiMappingsMessages.AddQueryDialog_namedNativeQuery;
}
if (value == HibernateNamedQuery.HIBERNATE_NAMED_QUERY) {
return HibernateUIMappingMessages.HibernateAddQueryDialog_hibernateNamedQuery;
@@ -237,13 +237,13 @@
private void addNameProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.name)) {
- currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_nameMustBeSpecified));
+ currentProblems.add(buildProblem(JptUiMappingsMessages.QueryStateObject_nameMustBeSpecified));
}
}
private void addQueryTypeProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.queryType)) {
- currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_typeMustBeSpecified));
+ currentProblems.add(buildProblem(JptUiMappingsMessages.QueryStateObject_typeMustBeSpecified));
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -11,18 +11,29 @@
package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
import org.eclipse.jpt.core.context.BasicMapping;
+import org.eclipse.jpt.core.context.Converter;
+import org.eclipse.jpt.core.context.ConvertibleMapping;
+import org.eclipse.jpt.core.context.EnumeratedConverter;
+import org.eclipse.jpt.core.context.TemporalConverter;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaComposite;
-import org.eclipse.jpt.ui.internal.details.AbstractBasicMappingComposite;
-import org.eclipse.jpt.ui.internal.details.ColumnComposite;
-import org.eclipse.jpt.ui.internal.details.EnumTypeComposite;
-import org.eclipse.jpt.ui.internal.details.FetchTypeComposite;
-import org.eclipse.jpt.ui.internal.details.OptionalComposite;
-import org.eclipse.jpt.ui.internal.details.TemporalTypeComposite;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.BaseJpaUiFactory;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.ColumnComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.EnumTypeComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.FetchTypeComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.OptionalComposite;
+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;
+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.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Generated;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateColumn;
import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
@@ -74,7 +85,7 @@
* @version 2.0
* @since 1.0
*/
-public class HibernateBasicMappingComposite extends
AbstractBasicMappingComposite<BasicMapping>
+public class HibernateBasicMappingComposite extends FormPane<BasicMapping>
implements JpaComposite
{
/**
@@ -93,30 +104,194 @@
@Override
protected void initializeLayout(Composite container) {
- super.initializeLayout(container);
- this.initializeIndexCollapsibleSection(container);
+ initializeGeneralPane(container);
+ initializeTypePane(container);
+ initializeIndexPane(container);
}
- protected void initializeBasicSection(Composite container) {
- new HibernateColumnComposite(this, (PropertyValueModel<? extends
HibernateColumn>) buildColumnHolder(), container);
+ @SuppressWarnings("unchecked")
+ private void initializeGeneralPane(Composite container) {
+ int groupBoxMargin = getGroupBoxMargin();
+
+ new HibernateColumnComposite(this, buildColumnHolder(), container);
+
+ // Align the widgets under the ColumnComposite
+ container = addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin);
+
+ if (getSubject() instanceof Generated) {
+ new GeneratedComposite((FormPane<? extends Generated>) this, container);
+ }
+
new FetchTypeComposite(this, container);
new OptionalComposite(this, addSubPane(container, 4));
+
}
- protected void initializeIndexCollapsibleSection(Composite container) {
+ private void initializeTypePane(Composite container) {
+
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.TypeSection_type
+ );
+ ((GridLayout) container.getLayout()).numColumns = 2;
+
+ // No converter
+ Button noConverterButton = addRadioButton(
+ container,
+ JptUiMappingsMessages.TypeSection_default,
+ buildNoConverterHolder(),
+ null);
+ ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2;
+
+ // Lob
+ Button lobButton = addRadioButton(
+ container,
+ JptUiMappingsMessages.TypeSection_lob,
+ buildLobConverterHolder(),
+ null);
+ ((GridData) lobButton.getLayoutData()).horizontalSpan = 2;
+
+ PropertyValueModel<Converter> specifiedConverterHolder =
buildSpecifiedConverterHolder();
+ // Temporal
+ addRadioButton(
+ container,
+ JptUiMappingsMessages.TypeSection_temporal,
+ buildTemporalBooleanHolder(),
+ null);
+ registerSubPane(new
TemporalTypeComposite(buildTemporalConverterHolder(specifiedConverterHolder), container,
getWidgetFactory()));
+
+
+ // Enumerated
+ addRadioButton(
+ container,
+ JptUiMappingsMessages.TypeSection_enumerated,
+ buildEnumeratedBooleanHolder(),
+ null);
+ registerSubPane(new
EnumTypeComposite(buildEnumeratedConverterHolder(specifiedConverterHolder), container,
getWidgetFactory()));
+ }
+
+ @SuppressWarnings("unchecked")
+ private void initializeIndexPane(Composite container) {
if (getSubject() instanceof IndexHolder) {
- container = addCollapsibleSection(
+ container = addCollapsableSection(
container,
HibernateUIMappingMessages.Index_section_index
);
((GridLayout) container.getLayout()).numColumns = 2;
- this.initializeIndexSection(container);
+ new IndexHolderComposite((FormPane<? extends IndexHolder>) this, container);
}
+
}
+
+ private PropertyValueModel<HibernateColumn> buildColumnHolder() {
+ return new TransformationPropertyValueModel<BasicMapping,
HibernateColumn>(getSubjectHolder()) {
+ @Override
+ protected HibernateColumn transform_(BasicMapping value) {
+ return (HibernateColumn) value.getColumn();
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildNoConverterHolder() {
+ return new PropertyAspectAdapter<BasicMapping, Boolean>(getSubjectHolder(),
ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.getSpecifiedConverter() == null);
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setSpecifiedConverter(Converter.NO_CONVERTER);
+ }
+ }
+ };
+ }
- private void initializeIndexSection(Composite container) {
- new IndexHolderComposite((Pane<? extends IndexHolder>) this, container);
+ private WritablePropertyValueModel<Boolean> buildLobConverterHolder() {
+ return new PropertyAspectAdapter<BasicMapping, Boolean>(getSubjectHolder(),
ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ Converter converter = this.subject.getSpecifiedConverter();
+ if (converter == null) {
+ return Boolean.FALSE;
+ }
+ return Boolean.valueOf(converter.getType() == Converter.LOB_CONVERTER);
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setSpecifiedConverter(Converter.LOB_CONVERTER);
+ }
+ }
+ };
}
+
+ private PropertyValueModel<Converter> buildSpecifiedConverterHolder() {
+ return new PropertyAspectAdapter<BasicMapping, Converter>(getSubjectHolder(),
ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Converter buildValue_() {
+ return this.subject.getSpecifiedConverter();
+ }
+ };
+ }
+
+ private PropertyValueModel<TemporalConverter>
buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) {
+ return new TransformationPropertyValueModel<Converter,
TemporalConverter>(converterHolder) {
+ @Override
+ protected TemporalConverter transform_(Converter converter) {
+ return (converter != null && converter.getType() ==
Converter.TEMPORAL_CONVERTER) ? (TemporalConverter) converter : null;
+ }
+ };
+ }
+
+ private PropertyValueModel<EnumeratedConverter>
buildEnumeratedConverterHolder(PropertyValueModel<Converter> converterHolder) {
+ return new TransformationPropertyValueModel<Converter,
EnumeratedConverter>(converterHolder) {
+ @Override
+ protected EnumeratedConverter transform_(Converter converter) {
+ return (converter != null && converter.getType() ==
Converter.ENUMERATED_CONVERTER) ? (EnumeratedConverter) converter : null;
+ }
+ };
+ }
+ private WritablePropertyValueModel<Boolean> buildTemporalBooleanHolder() {
+ return new PropertyAspectAdapter<BasicMapping, Boolean>(getSubjectHolder(),
BasicMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ Converter converter = this.subject.getSpecifiedConverter();
+ if (converter == null) {
+ return Boolean.FALSE;
+ }
+ return Boolean.valueOf(converter.getType() == Converter.TEMPORAL_CONVERTER);
+ }
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setSpecifiedConverter(Converter.TEMPORAL_CONVERTER);
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildEnumeratedBooleanHolder() {
+ return new PropertyAspectAdapter<BasicMapping, Boolean>(getSubjectHolder(),
BasicMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ Converter converter = this.subject.getSpecifiedConverter();
+ if (converter == null) {
+ return Boolean.FALSE;
+ }
+ return Boolean.valueOf(converter.getType() == Converter.ENUMERATED_CONVERTER);
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setSpecifiedConverter(Converter.ENUMERATED_CONVERTER);
+ }
+ }
+ };
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateColumnComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateColumnComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateColumnComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -18,13 +18,14 @@
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.details.BasicMappingComposite;
-import org.eclipse.jpt.ui.internal.details.IdMappingComposite;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
-import org.eclipse.jpt.ui.internal.details.VersionMappingComposite;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.BasicMappingComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.EmbeddedAttributeOverridesComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.IdMappingComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.VersionMappingComposite;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
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;
@@ -37,7 +38,6 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateColumn;
import org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl.ColumnCombo;
import org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl.DatabaseObjectCombo;
-import org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl.TableCombo;
/**
* Here the layout of this pane:
@@ -89,7 +89,7 @@
* @version 2.0
* @since 1.0
*/
-public class HibernateColumnComposite extends Pane<HibernateColumn> {
+public class HibernateColumnComposite extends FormPane<HibernateColumn> {
/**
* Creates a new <code>HibernateColumnComposite</code>.
@@ -98,7 +98,7 @@
* @param subjectHolder The holder of the subject <code>IColumn</code>
* @param parent The parent container
*/
- public HibernateColumnComposite(Pane<?> parentPane,
+ public HibernateColumnComposite(FormPane<?> parentPane,
PropertyValueModel<? extends HibernateColumn>
subjectHolder,
Composite parent) {
@@ -115,7 +115,7 @@
* this pane aligned with the widgets of the given parent controller;
* <code>false</code> to not align them
*/
- public HibernateColumnComposite(Pane<?> parentPane,
+ public HibernateColumnComposite(FormPane<?> parentPane,
PropertyValueModel<? extends HibernateColumn>
subjectHolder,
Composite parent,
boolean automaticallyAlignWidgets) {
@@ -133,7 +133,7 @@
* this pane aligned with the widgets of the given parent controller;
* <code>false</code> to not align them
*/
- public HibernateColumnComposite(Pane<?> parentPane,
+ public HibernateColumnComposite(FormPane<?> parentPane,
PropertyValueModel<? extends HibernateColumn>
subjectHolder,
Composite parent,
boolean automaticallyAlignWidgets,
@@ -265,16 +265,16 @@
if ((getSubject() != null) && (value == null)) {
boolean defaultValue = getSubject().isDefaultInsertable();
- String defaultStringValue = defaultValue ? JptUiDetailsMessages.Boolean_True :
- JptUiDetailsMessages.Boolean_False;
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
return NLS.bind(
- JptUiDetailsMessages.ColumnComposite_insertableWithDefault,
+ JptUiMappingsMessages.ColumnComposite_insertableWithDefault,
defaultStringValue
);
}
- return JptUiDetailsMessages.ColumnComposite_insertable;
+ return JptUiMappingsMessages.ColumnComposite_insertable;
}
};
}
@@ -282,46 +282,52 @@
private WritablePropertyValueModel<Boolean> buildNullableHolder() {
return new PropertyAspectAdapter<Column, Boolean>(
- getSubjectHolder(),
- BaseColumn.SPECIFIED_NULLABLE_PROPERTY) {
-
+ getSubjectHolder(),
+ BaseColumn.DEFAULT_NULLABLE_PROPERTY,
+ BaseColumn.SPECIFIED_NULLABLE_PROPERTY)
+ {
@Override
protected Boolean buildValue_() {
return this.subject.getSpecifiedNullable();
}
-
+
@Override
protected void setValue_(Boolean value) {
this.subject.setSpecifiedNullable(value);
}
- };
- }
-
- private PropertyValueModel<String> buildNullableStringHolder() {
- return new TransformationPropertyValueModel<Boolean,
String>(buildDefaultNullableHolder()) {
+
@Override
- protected String transform(Boolean value) {
- if (value != null) {
- String defaultStringValue = value.booleanValue() ? JptUiDetailsMessages.Boolean_True
: JptUiDetailsMessages.Boolean_False;
- return NLS.bind(JptUiDetailsMessages.ColumnComposite_nullableWithDefault,
defaultStringValue);
+ protected 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(Boolean.TRUE, newValue);
}
- return JptUiDetailsMessages.ColumnComposite_nullable;
}
};
}
-
- private PropertyValueModel<Boolean> buildDefaultNullableHolder() {
- return new PropertyAspectAdapter<Column, Boolean>(
- getSubjectHolder(),
- BaseColumn.SPECIFIED_NULLABLE_PROPERTY,
- BaseColumn.DEFAULT_NULLABLE_PROPERTY) {
-
+
+ private PropertyValueModel<String> buildNullableStringHolder() {
+ return new TransformationPropertyValueModel<Boolean,
String>(buildNullableHolder()) {
@Override
- protected Boolean buildValue_() {
- if (this.subject.getSpecifiedNullable() != null) {
- return null;
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultNullable();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ JptUiMappingsMessages.ColumnComposite_nullableWithDefault,
+ defaultStringValue
+ );
}
- return Boolean.valueOf(this.subject.isDefaultNullable());
+
+ return JptUiMappingsMessages.ColumnComposite_nullable;
}
};
}
@@ -385,14 +391,9 @@
}
@Override
- protected Iterable<String> getValues_() {
- return CollectionTools.iterable(this.values());
- }
-
protected Iterator<String> values() {
- return this.getSubject().candidateTableNames();
+ return
this.getSubject().getOwner().getTypeMapping().associatedTableNamesIncludingInherited();
}
-
@Override
public String toString() {
return "ColumnComposite.tableCombo"; //$NON-NLS-1$
@@ -402,97 +403,108 @@
private WritablePropertyValueModel<Boolean> buildUniqueHolder() {
return new PropertyAspectAdapter<Column, Boolean>(
- getSubjectHolder(),
- BaseColumn.SPECIFIED_UNIQUE_PROPERTY) {
-
+ getSubjectHolder(),
+ BaseColumn.DEFAULT_UNIQUE_PROPERTY,
+ BaseColumn.SPECIFIED_UNIQUE_PROPERTY)
+ {
@Override
protected Boolean buildValue_() {
return this.subject.getSpecifiedUnique();
}
-
+
@Override
protected void setValue_(Boolean value) {
this.subject.setSpecifiedUnique(value);
}
- };
- }
- private PropertyValueModel<String> buildUniqueStringHolder() {
-
- return new TransformationPropertyValueModel<Boolean,
String>(buildDefaultUniqueHolder()) {
-
@Override
- protected String transform(Boolean value) {
- if (value != null) {
- String defaultStringValue = value.booleanValue() ? JptUiDetailsMessages.Boolean_True
: JptUiDetailsMessages.Boolean_False;
- return NLS.bind(JptUiDetailsMessages.ColumnComposite_uniqueWithDefault,
defaultStringValue);
+ protected 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(Boolean.TRUE, newValue);
}
- return JptUiDetailsMessages.ColumnComposite_unique;
}
};
}
-
- private PropertyValueModel<Boolean> buildDefaultUniqueHolder() {
- return new PropertyAspectAdapter<Column, Boolean>(
- getSubjectHolder(),
- BaseColumn.SPECIFIED_UNIQUE_PROPERTY,
- BaseColumn.DEFAULT_UNIQUE_PROPERTY) {
-
+
+ private PropertyValueModel<String> buildUniqueStringHolder() {
+
+ return new TransformationPropertyValueModel<Boolean, String>(buildUniqueHolder())
{
+
@Override
- protected Boolean buildValue_() {
- if (this.subject.getSpecifiedUnique() != null) {
- return null;
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultUnique();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ JptUiMappingsMessages.ColumnComposite_uniqueWithDefault,
+ defaultStringValue
+ );
}
- return Boolean.valueOf(this.subject.isDefaultUnique());
+
+ return JptUiMappingsMessages.ColumnComposite_unique;
}
};
}
-
+
private WritablePropertyValueModel<Boolean> buildUpdatableHolder() {
return new PropertyAspectAdapter<Column, Boolean>(
- getSubjectHolder(),
- BaseColumn.DEFAULT_UPDATABLE_PROPERTY,
- BaseColumn.SPECIFIED_UPDATABLE_PROPERTY) {
-
+ getSubjectHolder(),
+ BaseColumn.DEFAULT_UPDATABLE_PROPERTY,
+ BaseColumn.SPECIFIED_UPDATABLE_PROPERTY)
+ {
@Override
protected Boolean buildValue_() {
return this.subject.getSpecifiedUpdatable();
}
-
+
@Override
protected void setValue_(Boolean value) {
this.subject.setSpecifiedUpdatable(value);
}
- };
- }
-
- private PropertyValueModel<String> buildUpdatableStringHolder() {
-
- return new TransformationPropertyValueModel<Boolean,
String>(buildDefaultUpdatableHolder()) {
-
+
@Override
- protected String transform(Boolean value) {
- if (value != null) {
- String defaultStringValue = value.booleanValue() ? JptUiDetailsMessages.Boolean_True
: JptUiDetailsMessages.Boolean_False;
- return NLS.bind(JptUiDetailsMessages.ColumnComposite_updatableWithDefault,
defaultStringValue);
+ protected 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(Boolean.TRUE, newValue);
}
- return JptUiDetailsMessages.ColumnComposite_updatable;
}
};
}
-
- private PropertyValueModel<Boolean> buildDefaultUpdatableHolder() {
- return new PropertyAspectAdapter<Column, Boolean>(
- getSubjectHolder(),
- BaseColumn.SPECIFIED_UPDATABLE_PROPERTY,
- BaseColumn.DEFAULT_UPDATABLE_PROPERTY) {
-
+
+ private PropertyValueModel<String> buildUpdatableStringHolder() {
+
+ return new TransformationPropertyValueModel<Boolean,
String>(buildUpdatableHolder()) {
+
@Override
- protected Boolean buildValue_() {
- if (this.subject.getSpecifiedUpdatable() != null) {
- return null;
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultUpdatable();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ JptUiMappingsMessages.ColumnComposite_updatableWithDefault,
+ defaultStringValue
+ );
}
- return Boolean.valueOf(this.subject.isDefaultUpdatable());
+
+ return JptUiMappingsMessages.ColumnComposite_updatable;
}
};
}
@@ -503,13 +515,13 @@
// Column group pane
container = addTitledGroup(
container,
- JptUiDetailsMessages.ColumnComposite_columnSection
+ JptUiMappingsMessages.ColumnComposite_columnSection
);
// Column widgets
addLabeledComposite(
container,
- JptUiDetailsMessages.ColumnComposite_name,
+ JptUiMappingsMessages.ColumnComposite_name,
addColumnCombo(container),
JpaHelpContextIds.MAPPING_COLUMN
);
@@ -517,24 +529,24 @@
// Table widgets
addLabeledComposite(
container,
- JptUiDetailsMessages.ColumnComposite_table,
+ JptUiMappingsMessages.ColumnComposite_table,
addTableCombo(container),
JpaHelpContextIds.MAPPING_COLUMN_TABLE
);
// Details sub-pane
- container = addCollapsibleSubSection(
+ container = addCollapsableSubSection(
container,
- JptUiDetailsMessages.ColumnComposite_details,
+ JptUiMappingsMessages.ColumnComposite_details,
new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
);
new DetailsComposite(this, getSubjectHolder(), addSubPane(container, 0, 16));
}
- protected class DetailsComposite extends Pane<HibernateColumn> {
+ protected class DetailsComposite extends FormPane<HibernateColumn> {
- public DetailsComposite(Pane<?> parentPane,
+ public DetailsComposite(FormPane<?> parentPane,
PropertyValueModel<? extends HibernateColumn> subjectHolder,
Composite parent) {
@@ -547,7 +559,7 @@
// Insertable tri-state check box
addTriStateCheckBoxWithDefault(
addSubPane(container, 4),
- JptUiDetailsMessages.ColumnComposite_insertable,
+ JptUiMappingsMessages.ColumnComposite_insertable,
buildInsertableHolder(),
buildInsertableStringHolder(),
JpaHelpContextIds.MAPPING_COLUMN_INSERTABLE
@@ -556,7 +568,7 @@
// Updatable tri-state check box
addTriStateCheckBoxWithDefault(
container,
- JptUiDetailsMessages.ColumnComposite_updatable,
+ JptUiMappingsMessages.ColumnComposite_updatable,
buildUpdatableHolder(),
buildUpdatableStringHolder(),
JpaHelpContextIds.MAPPING_COLUMN_UPDATABLE
@@ -565,7 +577,7 @@
// Unique tri-state check box
addTriStateCheckBoxWithDefault(
container,
- JptUiDetailsMessages.ColumnComposite_unique,
+ JptUiMappingsMessages.ColumnComposite_unique,
buildUniqueHolder(),
buildUniqueStringHolder(),
JpaHelpContextIds.MAPPING_COLUMN_UNIQUE
@@ -574,7 +586,7 @@
// Nullable tri-state check box
addTriStateCheckBoxWithDefault(
container,
- JptUiDetailsMessages.ColumnComposite_nullable,
+ JptUiMappingsMessages.ColumnComposite_nullable,
buildNullableHolder(),
buildNullableStringHolder(),
JpaHelpContextIds.MAPPING_COLUMN_NULLABLE
@@ -587,7 +599,7 @@
// Column Definition widgets
addLabeledText(
container,
- JptUiDetailsMessages.ColumnComposite_columnDefinition,
+ JptUiMappingsMessages.ColumnComposite_columnDefinition,
buildColumnDefinitionHolder()
);
}
@@ -597,7 +609,7 @@
@Override
protected String getLabelText() {
- return JptUiDetailsMessages.ColumnComposite_length;
+ return JptUiMappingsMessages.ColumnComposite_length;
}
@Override
@@ -637,7 +649,7 @@
@Override
protected String getLabelText() {
- return JptUiDetailsMessages.ColumnComposite_precision;
+ return JptUiMappingsMessages.ColumnComposite_precision;
}
@Override
@@ -677,7 +689,7 @@
@Override
protected String getLabelText() {
- return JptUiDetailsMessages.ColumnComposite_scale;
+ return JptUiMappingsMessages.ColumnComposite_scale;
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -18,18 +18,25 @@
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.details.AbstractEntityComposite;
-import org.eclipse.jpt.ui.internal.details.DiscriminatorColumnComposite;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+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.IntegerCombo;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+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.DiscriminatorFormula;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl.ColumnCombo;
@@ -67,7 +74,7 @@
* @version 2.0
* @since 2.0
*/
-public class HibernateDiscriminatorColumnComposite extends
Pane<HibernateJavaEntity> {
+public class HibernateDiscriminatorColumnComposite extends
FormPane<HibernateJavaEntity> {
private WritablePropertyValueModel<DiscriminatorFormula>
discriminatorFormulaHolder;
@@ -77,7 +84,7 @@
* @param parentPane The parent container of this one
* @param parent The parent container
*/
- public HibernateDiscriminatorColumnComposite(Pane<? extends HibernateJavaEntity>
parentPane,
+ public HibernateDiscriminatorColumnComposite(FormPane<? extends
HibernateJavaEntity> parentPane,
Composite parent) {
super(parentPane, parent, false);
@@ -91,11 +98,10 @@
@Override
protected void initializeLayout(Composite container) {
-
// Discriminator Column sub-pane
Composite discriminatorColumnContainer = addTitledGroup(
addSubPane(container, 10),
- JptUiDetailsMessages.InheritanceComposite_discriminatorColumnGroupBox
+ JptUiMappingsMessages.InheritanceComposite_discriminatorColumnGroupBox
);
PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder =
@@ -104,7 +110,7 @@
// Name widgets
addLabeledComposite(
discriminatorColumnContainer,
- JptUiDetailsMessages.DiscriminatorColumnComposite_name,
+ JptUiMappingsMessages.DiscriminatorColumnComposite_name,
addDiscriminatorColumnCombo(container, discriminatorColumnHolder),
JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_COLUMN
);
@@ -120,19 +126,19 @@
// Discriminator Type widgets
addLabeledComposite(
discriminatorColumnContainer,
- JptUiDetailsMessages.DiscriminatorColumnComposite_discriminatorType,
+ JptUiMappingsMessages.DiscriminatorColumnComposite_discriminatorType,
addDiscriminatorTypeCombo(container, discriminatorColumnHolder),
JpaHelpContextIds.ENTITY_INHERITANCE_DISCRIMINATOR_TYPE
);
- container = addCollapsibleSubSection(
+ container = addCollapsableSubSection(
discriminatorColumnContainer,
- JptUiDetailsMessages.InheritanceComposite_detailsGroupBox,
+ JptUiMappingsMessages.InheritanceComposite_detailsGroupBox,
new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
);
-
+
new DetailsComposite(this, discriminatorColumnHolder, addSubPane(container, 0, 16));
-
+
new PaneEnabler(buildDiscriminatorColumnEnabledHolder(), this);
}
@@ -175,7 +181,7 @@
@Override
protected String buildNullDefaultValueEntry() {
- return JptUiDetailsMessages.NoneSelected;
+ return JptUiMappingsMessages.NoneSelected;
}
};
}
@@ -252,7 +258,7 @@
@Override
protected String displayString(DiscriminatorType value) {
return buildDisplayString(
- JptUiDetailsMessages.class,
+ JptUiMappingsMessages.class,
DiscriminatorColumnComposite.class,
value
);
@@ -260,7 +266,7 @@
@Override
protected String nullDisplayString() {
- return JptUiDetailsMessages.NoneSelected;
+ return JptUiMappingsMessages.NoneSelected;
}
@Override
@@ -284,8 +290,8 @@
};
}
- protected class DetailsComposite extends Pane<DiscriminatorColumn> {
- public DetailsComposite(Pane<?> parentPane,
+ protected class DetailsComposite extends FormPane<DiscriminatorColumn> {
+ public DetailsComposite(FormPane<?> parentPane,
PropertyValueModel<? extends DiscriminatorColumn> subjectHolder,
Composite parent) {
@@ -295,56 +301,99 @@
@Override
protected void initializeLayout(Composite container) {
// Length widgets
- addLengthCombo(container);
+ 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,
- JptUiDetailsMessages.ColumnComposite_columnDefinition,
+ JptUiMappingsMessages.ColumnComposite_columnDefinition,
buildColumnDefinitionHolder(getSubjectHolder())
);
}
-
- private void addLengthCombo(Composite container) {
- new IntegerCombo<DiscriminatorColumn>(this, container) {
-
+
+ private WritablePropertyValueModel<Integer> buildLengthHolder() {
+
+ return new PropertyAspectAdapter<DiscriminatorColumn,
Integer>(getSubjectHolder(), DiscriminatorColumn.SPECIFIED_LENGTH_PROPERTY) {
@Override
- protected String getLabelText() {
- return JptUiDetailsMessages.ColumnComposite_length;
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedLength();
}
-
+
@Override
- protected String getHelpId() {
- return JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
+ 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 PropertyValueModel<Integer> buildDefaultHolder() {
- return new PropertyAspectAdapter<DiscriminatorColumn,
Integer>(getSubjectHolder(), DiscriminatorColumn.DEFAULT_LENGTH_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultLength());
- }
- };
+ 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 WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<DiscriminatorColumn,
Integer>(getSubjectHolder(), DiscriminatorColumn.SPECIFIED_LENGTH_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedLength();
- }
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultLength());
+ }
- @Override
- protected void setValue_(Integer value) {
- this.subject.setSpecifiedLength(value);
- }
- };
+ @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) {
@@ -362,5 +411,37 @@
}
};
}
+
+ /**
+ * 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
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGenerationComposite.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGenerationComposite.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGenerationComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGenerationComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,295 @@
+/*******************************************************************************
+ * 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.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.context.GeneratedValue;
+import org.eclipse.jpt.core.context.GeneratorHolder;
+import org.eclipse.jpt.core.context.SequenceGenerator;
+import org.eclipse.jpt.core.context.TableGenerator;
+import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.GeneratedValueComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.SequenceGeneratorComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.TableGeneratorComposite;
+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.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateGenerationComposite extends FormPane<HibernateJavaIdMapping>
{
+
+ private WritablePropertyValueModel<Boolean>
sequenceGeneratorExpansionStateHolder;
+ private WritablePropertyValueModel<Boolean> tableGeneratorExpansionStateHolder;
+ private WritablePropertyValueModel<Boolean> genericGeneratorExpansionStateHolder;
+
+ /**
+ * Creates a new <code>GenerationComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public HibernateGenerationComposite(FormPane<? extends HibernateJavaIdMapping>
parentPane,
+ Composite parent)
+ {
+ super(parentPane, parent, false);
+ }
+
+ private WritablePropertyValueModel<Boolean> buildPrimaryKeyGenerationHolder() {
+ return new PropertyAspectAdapter<HibernateJavaIdMapping,
Boolean>(getSubjectHolder(), HibernateJavaIdMapping.GENERATED_VALUE_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getGeneratedValue() != null;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+
+ if (value && (subject.getGeneratedValue() == null)) {
+ subject.addGeneratedValue();
+ }
+ else if (!value && (subject.getGeneratedValue() != null)) {
+ subject.removeGeneratedValue();
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildSequenceGeneratorBooleanHolder()
{
+ return new PropertyAspectAdapter<HibernateJavaIdMapping,
Boolean>(getSubjectHolder(), GeneratorHolder.SEQUENCE_GENERATOR_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getSequenceGenerator() != null;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+
+ if (value && (subject.getSequenceGenerator() == null)) {
+
+ SequenceGenerator sequenceGenerator = subject.addSequenceGenerator();
+ GeneratedValue generatedValue = subject.getGeneratedValue();
+
+ if ((generatedValue != null) &&
+ (generatedValue.getGenerator() != null))
+ {
+ sequenceGenerator.setName(generatedValue.getGenerator());
+ }
+ }
+ else if (!value && (subject.getSequenceGenerator() != null)) {
+ subject.removeSequenceGenerator();
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildTableGeneratorBooleanHolder() {
+ return new PropertyAspectAdapter<HibernateJavaIdMapping,
Boolean>(getSubjectHolder(), GeneratorHolder.TABLE_GENERATOR_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getTableGenerator() != null;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+
+ if (value && (subject.getTableGenerator() == null)) {
+
+ TableGenerator tableGenerator = subject.addTableGenerator();
+ GeneratedValue generatedValue = subject.getGeneratedValue();
+
+ if ((generatedValue != null) &&
+ (generatedValue.getGenerator() != null))
+ {
+ tableGenerator.setName(generatedValue.getGenerator());
+ }
+ }
+ else if (!value && (subject.getTableGenerator() != null)) {
+ subject.removeTableGenerator();
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildGenericGeneratorBooleanHolder()
{
+ return new PropertyAspectAdapter<HibernateJavaIdMapping,
Boolean>(getSubjectHolder(), GenericGeneratorHolder.GENERIC_GENERATORS_LIST) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.genericGeneratorsSize() > 0;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+
+ if (value && (subject.genericGeneratorsSize() > 0)) {
+
+ GenericGenerator genericGenerator = subject.addGenericGenerator(0);
+ GeneratedValue generatedValue = subject.getGeneratedValue();
+
+ if ((generatedValue != null) &&
+ (generatedValue.getGenerator() != null))
+ {
+ genericGenerator.setName(generatedValue.getGenerator());
+ }
+ }
+ else if (!value && (subject.genericGeneratorsSize() > 0)) {
+ subject.removeGenericGenerator(0);
+ }
+ }
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected void doPopulate()
+ {
+ super.doPopulate();
+
+ sequenceGeneratorExpansionStateHolder.setValue(getSubject() != null &&
getSubject().getSequenceGenerator() != null);
+ tableGeneratorExpansionStateHolder .setValue(getSubject() != null &&
getSubject().getTableGenerator() != null);
+ genericGeneratorExpansionStateHolder .setValue(getSubject() != null &&
getSubject().genericGeneratorsSize() > 0);
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected void initialize() {
+ super.initialize();
+
+ sequenceGeneratorExpansionStateHolder = new
SimplePropertyValueModel<Boolean>(false);
+ tableGeneratorExpansionStateHolder = new
SimplePropertyValueModel<Boolean>(false);
+ genericGeneratorExpansionStateHolder = new
SimplePropertyValueModel<Boolean>(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ // Primary Key Generation section
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_primaryKeyGenerationSection,
+ new SimplePropertyValueModel<Boolean>(Boolean.TRUE)
+ );
+
+ // Primary Key Generation check box
+ Button primaryKeyGenerationCheckBox = addCheckBox(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_primaryKeyGenerationCheckBox,
+ buildPrimaryKeyGenerationHolder(),
+ JpaHelpContextIds.MAPPING_PRIMARY_KEY_GENERATION
+ );
+
+ // Generated Value widgets
+ GeneratedValueComposite generatedValueComposite = new GeneratedValueComposite(
+ this,
+ container
+ );
+
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalIndent = primaryKeyGenerationCheckBox.getBorderWidth() +
16;
+
+ generatedValueComposite.getControl().setLayoutData(gridData);
+
+ // Table Generator pane
+ initializeTableGeneratorPane(addSubPane(container, 10));
+
+ // Sequence Generator pane
+ initializeSequenceGeneratorPane(addSubPane(container, 10));
+
+ // Generic Generator pane
+ initializeGenericGeneratorPane(addSubPane(container, 10));
+ }
+
+ private void initializeSequenceGeneratorPane(Composite container) {
+
+ // Sequence Generator sub-section
+ container = addCollapsableSubSection(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_sequenceGeneratorSection,
+ sequenceGeneratorExpansionStateHolder
+ );
+
+ // Sequence Generator check box
+ Button sequenceGeneratorCheckBox = addCheckBox(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_sequenceGeneratorCheckBox,
+ buildSequenceGeneratorBooleanHolder(),
+ JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR
+ );
+
+ // Sequence Generator pane
+ new SequenceGeneratorComposite(
+ this,
+ addSubPane(container, 0, sequenceGeneratorCheckBox.getBorderWidth() + 16)
+ );
+ }
+
+ private void initializeTableGeneratorPane(Composite container) {
+
+ // Table Generator sub-section
+ container = addCollapsableSubSection(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_tableGeneratorSection,
+ tableGeneratorExpansionStateHolder
+ );
+
+ Button tableGeneratorCheckBox = addCheckBox(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_tableGeneratorCheckBox,
+ buildTableGeneratorBooleanHolder(),
+ JpaHelpContextIds.MAPPING_TABLE_GENERATOR
+ );
+
+ new TableGeneratorComposite(
+ this,
+ addSubPane(container, 0, tableGeneratorCheckBox.getBorderWidth() + 16)
+ );
+ }
+
+ private void initializeGenericGeneratorPane(Composite container) {
+
+ // Table Generator sub-section
+ container = addCollapsableSubSection(
+ container,
+ HibernateUIMappingMessages.HibernateIdMappingComposite_genericGeneratorSection,
+ genericGeneratorExpansionStateHolder
+ );
+
+ Button genericGeneratorCheckBox = addCheckBox(
+ container,
+ HibernateUIMappingMessages.HibernateIdMappingComposite_genericGeneratorCheckBox,
+ buildGenericGeneratorBooleanHolder(),
+ null//TODO help
+ );
+
+ new GenericGeneratorsComposite(
+ this,
+ addSubPane(container, 0, genericGeneratorCheckBox.getBorderWidth() + 16)
+ );
+ }
+}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
(from rev 22306,
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java)
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.context.GeneratorHolder;
+import org.eclipse.jpt.ui.internal.mappings.details.GeneratorsComposite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGeneratorHolder;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateGeneratorsComposite extends GeneratorsComposite {
+
+ public HibernateGeneratorsComposite(Pane<? extends GeneratorHolder> parentPane,
Composite parent) {
+ super(parentPane, parent);
+ }
+
+ private WritablePropertyValueModel<Boolean> genericGeneratorExpansionStateHolder;
+
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ genericGeneratorExpansionStateHolder = new
SimplePropertyValueModel<Boolean>(false);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ super.initializeLayout(container);
+ initializeGenericGeneratorPane(container);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void initializeGenericGeneratorPane(Composite container) {
+
+ // Sequence Generator sub-section
+ container = addCollapsableSubSection(
+ addSubPane(container, 10),
+ HibernateUIMappingMessages.HibernateGeneratorsComposite_SectionLabel,
+ genericGeneratorExpansionStateHolder
+ );
+
+ // Sequence Generator check box
+ Button genericGeneratorCheckBox = addCheckBox(
+ addSubPane(container, 5),
+ HibernateUIMappingMessages.HibernateGeneratorsComposite_CheckBoxLabel,
+ buildGenericGeneratorBooleanHolder(),
+ null//TODO add help
+ );
+
+ // Generic Generator pane
+ new GenericGeneratorsComposite(
+ (Pane<? extends GenericGeneratorHolder>) this,
+ addSubPane(container, 0, genericGeneratorCheckBox.getBorderWidth() + 16));
+
+ }
+
+ protected GenericGenerator getGenerator(GeneratorHolder subject) {
+ return (((GenericGeneratorHolder)subject).genericGeneratorsSize() == 0) ? null
+ : ((GenericGeneratorHolder)subject).genericGenerators().next();
+ }
+
+ private WritablePropertyValueModel<Boolean> buildGenericGeneratorBooleanHolder()
{
+ return new PropertyAspectAdapter<GeneratorHolder, Boolean>(getSubjectHolder(),
GenericGeneratorHolder.GENERIC_GENERATORS_LIST) {
+
+ @Override
+ protected Boolean buildValue_() {
+ return getGenerator(subject) != null;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value && (getGenerator(subject) == null)) {
+ ((GenericGeneratorHolder)subject).addGenericGenerator(0);
+ }
+ else if (!value && (getGenerator(subject) != null)) {
+ ((GenericGeneratorHolder)subject).removeGenericGenerator(0);
+ }
+ }
+ };
+ }
+
+
+
+}
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -10,26 +10,34 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
-import org.eclipse.jpt.core.context.Entity;
+import org.eclipse.jpt.core.context.Converter;
+import org.eclipse.jpt.core.context.ConvertibleMapping;
+import org.eclipse.jpt.core.context.IdMapping;
+import org.eclipse.jpt.core.context.TemporalConverter;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaComposite;
-import org.eclipse.jpt.ui.internal.details.AbstractIdMappingComposite;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+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;
+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.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+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.HibernateGeneratorContainer;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
+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
AbstractIdMappingComposite<HibernateIdMapping>
+public class HibernateIdMappingComposite extends FormPane<HibernateIdMapping>
implements JpaComposite{
/**
* Creates a new <code>HibernateIdMappingComposite</code>.
@@ -44,52 +52,123 @@
super(subjectHolder, parent, widgetFactory);
}
-
- @Override
- protected void initializeLayout(Composite container) {
- super.initializeLayout(container);
- this.initializeIndexCollapsibleSection(container);
- }
-
- @Override
- protected void initializeIdSection(Composite container) {
- new HibernateColumnComposite(this, (PropertyValueModel<? extends
HibernateColumn>) buildColumnHolder(), container);
- }
-
- private PropertyValueModel<HibernateGeneratorContainer> buildGeneratorContainer()
{
- return new PropertyAspectAdapter<HibernateIdMapping,
HibernateGeneratorContainer>(getSubjectHolder()) {
+
+ private PropertyValueModel<? extends HibernateColumn> buildColumnHolder() {
+ return new TransformationPropertyValueModel<IdMapping,
HibernateColumn>(getSubjectHolder()) {
@Override
- protected HibernateGeneratorContainer buildValue_() {
- return (HibernateGeneratorContainer) this.subject.getGeneratorContainer();
+ protected HibernateColumn transform_(IdMapping value) {
+ return (HibernateColumn)value.getColumn();
}
};
}
-
+
+ @SuppressWarnings("unchecked")
@Override
- protected void initializeGenerationCollapsibleSection(Composite container) {
+ protected void initializeLayout(Composite container) {
+
+ // Column widgets
+ new HibernateColumnComposite(this, buildColumnHolder(), container);
+
+ initializeTypePane(container);
+
if (getSubject() instanceof HibernateJavaIdMapping) {
// Generic Generator required only for Java.
- new HibernateGenerationComposite2(this, buildGeneratorContainer(),
addSubPane(container, 10), false);
+ new HibernateGenerationComposite((FormPane<? extends HibernateJavaIdMapping>)
this, addSubPane(container, 10));
} else {
- super.initializeGenerationCollapsibleSection(container);
+ new GenerationComposite(this, addSubPane(container, 10));
}
- }
-
- protected void initializeIndexCollapsibleSection(Composite container) {
+
if (getSubject() instanceof IndexHolder) {
- container = addCollapsibleSection(
+ container = addCollapsableSection(
container,
HibernateUIMappingMessages.Index_section_index
);
((GridLayout) container.getLayout()).numColumns = 2;
- this.initializeIndexSection(container);
+ new IndexHolderComposite((FormPane<? extends IndexHolder>) this, container);
}
}
+
+
+ private void initializeTypePane(Composite container) {
- protected void initializeIndexSection(Composite container) {
- new IndexHolderComposite((Pane<? extends IndexHolder>) this, container);
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.TypeSection_type
+ );
+ ((GridLayout) container.getLayout()).numColumns = 2;
+
+ // No converter
+ Button noConverterButton = addRadioButton(
+ container,
+ JptUiMappingsMessages.TypeSection_default,
+ buildNoConverterHolder(),
+ null);
+ ((GridData) noConverterButton.getLayoutData()).horizontalSpan = 2;
+
+ PropertyValueModel<Converter> specifiedConverterHolder =
buildSpecifiedConverterHolder();
+ // Temporal
+ addRadioButton(
+ container,
+ JptUiMappingsMessages.TypeSection_temporal,
+ buildTemporalBooleanHolder(),
+ null);
+ registerSubPane(new
TemporalTypeComposite(buildTemporalConverterHolder(specifiedConverterHolder), container,
getWidgetFactory()));
}
+
+ private WritablePropertyValueModel<Boolean> buildNoConverterHolder() {
+ return new PropertyAspectAdapter<IdMapping, Boolean>(getSubjectHolder(),
ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.getSpecifiedConverter() == null);
+ }
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setSpecifiedConverter(Converter.NO_CONVERTER);
+ }
+ }
+ };
+ }
+
+
+ private WritablePropertyValueModel<Boolean> buildTemporalBooleanHolder() {
+ return new PropertyAspectAdapter<IdMapping, Boolean>(getSubjectHolder(),
ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ Converter converter = this.subject.getSpecifiedConverter();
+ if (converter == null) {
+ return Boolean.FALSE;
+ }
+ return Boolean.valueOf(converter.getType() == Converter.TEMPORAL_CONVERTER);
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ if (value.booleanValue()) {
+ this.subject.setSpecifiedConverter(Converter.TEMPORAL_CONVERTER);
+ }
+ }
+ };
+ }
+
+ private PropertyValueModel<Converter> buildSpecifiedConverterHolder() {
+ return new PropertyAspectAdapter<IdMapping, Converter>(getSubjectHolder(),
ConvertibleMapping.SPECIFIED_CONVERTER_PROPERTY) {
+ @Override
+ protected Converter buildValue_() {
+ return this.subject.getSpecifiedConverter();
+ }
+ };
+ }
+
+ private PropertyValueModel<TemporalConverter>
buildTemporalConverterHolder(PropertyValueModel<Converter> converterHolder) {
+ return new TransformationPropertyValueModel<Converter,
TemporalConverter>(converterHolder) {
+ @Override
+ protected TemporalConverter transform_(Converter converter) {
+ return (converter != null && converter.getType() ==
Converter.TEMPORAL_CONVERTER) ? (TemporalConverter) converter : null;
+ }
+ };
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -11,7 +11,7 @@
package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
@@ -69,7 +69,7 @@
@Override
protected String getLabelText() {
- return JptUiDetailsMessages.NamedNativeQueryPropertyComposite_resultClass;
+ return JptUiMappingsMessages.NamedNativeQueryPropertyComposite_resultClass;
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -22,13 +22,13 @@
import org.eclipse.jpt.core.context.Query;
import org.eclipse.jpt.core.context.QueryContainer;
import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
-import org.eclipse.jpt.ui.internal.details.NamedNativeQueryPropertyComposite;
-import org.eclipse.jpt.ui.internal.details.NamedQueryPropertyComposite;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.details.NamedNativeQueryPropertyComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.NamedQueryPropertyComposite;
import org.eclipse.jpt.ui.internal.util.ControlSwitcher;
import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
-import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.Transformer;
import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
@@ -48,17 +48,17 @@
import org.eclipse.ui.part.PageBook;
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.java.HibernateJavaQueryContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateQueryContainer;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateQueriesComposite extends Pane<HibernateJavaQueryContainer> {
+public class HibernateQueriesComposite extends Pane<HibernateQueryContainer> {
private AddRemoveListPane<QueryContainer> listPane;
private NamedNativeQueryPropertyComposite namedNativeQueryPane;
- private NamedQueryPropertyComposite<? extends NamedQuery> namedQueryPane;
+ private NamedQueryPropertyComposite namedQueryPane;
private HibernateNamedQueryPropertyComposite hibernateNamedQueryPane;
private HibernateNamedNativeQueryPropertyComposite hibernateNamedNativeQueryPane;
private WritablePropertyValueModel<Query> queryHolder;
@@ -69,11 +69,10 @@
* @param parentPane The parent controller of this one
* @param parent The parent container
*/
- public HibernateQueriesComposite(Pane<?> parentPane,
- PropertyValueModel<? extends HibernateJavaQueryContainer> subjectHolder,
- Composite parent) {
+ public HibernateQueriesComposite(Pane<? extends HibernateQueryContainer>
parentPane,
+ Composite parent) {
- super(parentPane, subjectHolder, parent, false);
+ super(parentPane, parent, false);
}
private void addQuery() {
@@ -106,7 +105,7 @@
throw new IllegalArgumentException();
}
query.setName(hibernateAddQueryDialog.getName());
- this.getQueryHolder().setValue(query);//so that it gets selected in the List for the
user to edit
+ this.queryHolder.setValue(query);//so that it gets selected in the List for the user to
edit
}
private ListValueModel<Query> buildDisplayableQueriesListHolder() {
@@ -158,16 +157,16 @@
private ListValueModel<HibernateNamedQuery> buildHibernateNamedQueriesListHolder()
{
return new ListAspectAdapter<QueryContainer, HibernateNamedQuery>(
getSubjectHolder(),
- HibernateJavaQueryContainer.HIBERNATE_NAMED_QUERIES_LIST)
+ HibernateQueryContainer.HIBERNATE_NAMED_QUERIES_LIST)
{
@Override
protected ListIterator<HibernateNamedQuery> listIterator_() {
- return ((HibernateJavaQueryContainer)this.subject).hibernateNamedQueries();
+ return ((HibernateQueryContainer)this.subject).hibernateNamedQueries();
}
@Override
protected int size_() {
- return ((HibernateJavaQueryContainer)this.subject).hibernateNamedQueriesSize();
+ return ((HibernateQueryContainer)this.subject).hibernateNamedQueriesSize();
}
};
}
@@ -175,16 +174,16 @@
private ListValueModel<HibernateNamedNativeQuery>
buildHibernateNamedNativeQueriesListHolder() {
return new ListAspectAdapter<QueryContainer, HibernateNamedNativeQuery>(
getSubjectHolder(),
- HibernateJavaQueryContainer.HIBERNATE_NAMED_NATIVE_QUERIES_LIST)
+ HibernateQueryContainer.HIBERNATE_NAMED_NATIVE_QUERIES_LIST)
{
@Override
protected ListIterator<HibernateNamedNativeQuery> listIterator_() {
- return ((HibernateJavaQueryContainer)this.subject).hibernateNamedNativeQueries();
+ return ((HibernateQueryContainer)this.subject).hibernateNamedNativeQueries();
}
@Override
protected int size_() {
- return
((HibernateJavaQueryContainer)this.subject).hibernateNamedNativeQueriesSize();
+ return ((HibernateQueryContainer)this.subject).hibernateNamedNativeQueriesSize();
}
};
}
@@ -311,7 +310,7 @@
index = CollectionTools.indexOf(getSubject().namedNativeQueries(), query);
}
- name = NLS.bind(JptUiDetailsMessages.QueriesComposite_displayString, index);
+ name = NLS.bind(JptUiMappingsMessages.QueriesComposite_displayString, index);
}
return name;
@@ -379,9 +378,5 @@
private void installPaneSwitcher(PageBook pageBook) {
new ControlSwitcher(this.queryHolder, buildPaneTransformer(), pageBook);
}
-
- protected WritablePropertyValueModel<Query> getQueryHolder() {
- return queryHolder;
- }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -13,7 +13,7 @@
import java.util.Collection;
import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
import org.eclipse.jpt.ui.internal.util.LabeledLabel;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
@@ -51,13 +51,13 @@
addLabeledText(
container,
- JptUiDetailsMessages.NamedQueryComposite_nameTextLabel,
+ JptUiMappingsMessages.NamedQueryComposite_nameTextLabel,
buildNameTextHolder());
// Query text area
addLabeledMultiLineText(
container,
- JptUiDetailsMessages.NamedQueryPropertyComposite_query,
+ JptUiMappingsMessages.NamedQueryPropertyComposite_query,
buildQueryHolder(),
4,
null
@@ -136,7 +136,7 @@
Label label = addLabel(
container,
- JptUiDetailsMessages.DefaultEmpty
+ JptUiMappingsMessages.DefaultEmpty
);
new LabeledControlUpdater(
@@ -158,7 +158,7 @@
HibernateNamedQuery.DEFAULT_FETCH_SIZE;
return NLS.bind(
- JptUiDetailsMessages.DefaultWithOneParam,
+ JptUiMappingsMessages.DefaultWithOneParam,
Integer.valueOf(defaultValue)
);
}
@@ -171,6 +171,18 @@
protected Integer buildValue_() {
return Integer.valueOf(this.subject.getDefaultFetchSize());
}
+
+ @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.MIN_VALUE, newValue);
+ }
+ }
};
}
@@ -221,6 +233,18 @@
protected void setValue_(Boolean value) {
this.subject.setSpecifiedCacheable(value);
}
+
+ @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(Boolean.TRUE, newValue);
+ }
+ }
};
}
@@ -234,8 +258,8 @@
if ((getSubject() != null) && (value == null)) {
boolean defaultValue = getSubject().isDefaultCacheable();
- String defaultStringValue = defaultValue ? JptUiDetailsMessages.Boolean_True :
- JptUiDetailsMessages.Boolean_False;
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
return NLS.bind(
HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheableWithDefault,
@@ -264,6 +288,17 @@
this.subject.setSpecifiedReadOnly(value);
}
+ @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(Boolean.TRUE, newValue);
+ }
+ }
};
}
@@ -277,8 +312,8 @@
if ((getSubject() != null) && (value == null)) {
boolean defaultValue = getSubject().isDefaultReadOnly();
- String defaultStringValue = defaultValue ? JptUiDetailsMessages.Boolean_True :
- JptUiDetailsMessages.Boolean_False;
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
return NLS.bind(
HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnlyWithDefault,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateTableComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateTableComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateTableComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -15,11 +15,11 @@
import org.eclipse.jpt.db.Schema;
import org.eclipse.jpt.db.SchemaContainer;
import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
-import org.eclipse.jpt.ui.internal.details.db.CatalogCombo;
-import org.eclipse.jpt.ui.internal.details.db.SchemaCombo;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.db.CatalogCombo;
+import org.eclipse.jpt.ui.internal.mappings.db.SchemaCombo;
import org.eclipse.jpt.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
@@ -62,7 +62,7 @@
* @version 2.0
* @since 1.0
*/
-public class HibernateTableComposite extends Pane<HibernateEntity>
+public class HibernateTableComposite extends FormPane<HibernateEntity>
{
/**
* Creates a new <code>HibernateTableComposite</code>.
@@ -71,7 +71,7 @@
* @param subjectHolder The holder of the subject
* @param parent The parent container
*/
- public HibernateTableComposite(Pane<? extends HibernateEntity> parentPane,
+ public HibernateTableComposite(FormPane<? extends HibernateEntity> parentPane,
Composite parent) {
super(parentPane, parent, false);
@@ -83,23 +83,24 @@
// Table group pane
Group tableGroupPane = addTitledGroup(
container,
- JptUiDetailsMessages.TableComposite_tableSection
+ JptUiMappingsMessages.TableComposite_tableSection
);
PropertyValueModel<HibernateTable> subjectHolder = buildTableHolder();
+ TableCombo<HibernateTable> tc = addTableCombo(subjectHolder, tableGroupPane);
// Table widgets
addLabeledComposite(
- tableGroupPane,
- JptUiDetailsMessages.TableChooser_label,
- addTableCombo(subjectHolder, tableGroupPane),
- JpaHelpContextIds.ENTITY_TABLE
- );
-
+ tableGroupPane,
+ JptUiMappingsMessages.TableChooser_label,
+ tc,
+ JpaHelpContextIds.ENTITY_TABLE
+ );
+
// Catalog widgets
addLabeledComposite(
tableGroupPane,
- JptUiDetailsMessages.CatalogChooser_label,
+ JptUiMappingsMessages.CatalogChooser_label,
addCatalogCombo(subjectHolder, tableGroupPane),
JpaHelpContextIds.ENTITY_CATALOG
);
@@ -107,7 +108,7 @@
// Schema widgets
addLabeledComposite(
tableGroupPane,
- JptUiDetailsMessages.SchemaChooser_label,
+ JptUiMappingsMessages.SchemaChooser_label,
addSchemaCombo(subjectHolder, tableGroupPane),
JpaHelpContextIds.ENTITY_SCHEMA
);
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Red Hat, Inc.
+ * Copyright (c) 2008-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,
@@ -47,8 +47,6 @@
public static String BasicGeneralSection_generated;
public static String IndexHolderComposite_name;
public static String Index_section_index;
- public static String ParametersComposite_nameColumn;
- public static String ParametersComposite_valueColumn;
private HibernateUIMappingMessages() {}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/IndexHolderComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/IndexHolderComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/IndexHolderComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -11,22 +11,22 @@
package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Index;
import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaIndex;
/**
* @author Dmitry Geraskov
*
*/
-public class IndexHolderComposite extends Pane<IndexHolder> {
+public class IndexHolderComposite extends FormPane<IndexHolder> {
- private WritablePropertyValueModel<JavaIndex> indexHolder;
+ private WritablePropertyValueModel<Index> indexHolder;
- protected IndexHolderComposite(Pane<? extends IndexHolder> parentPane,
+ protected IndexHolderComposite(FormPane<? extends IndexHolder> parentPane,
Composite parent) {
super(parentPane, parent);
}
@@ -50,7 +50,7 @@
protected final WritablePropertyValueModel<String> buildIndexNameHolder() {
- return new PropertyAspectAdapter<JavaIndex, String>(this.indexHolder,
JavaIndex.INDEX_NAME) {
+ return new PropertyAspectAdapter<Index, String>(this.indexHolder,
Index.INDEX_NAME) {
@Override
protected String buildValue_() {
return subject == null ? null : subject.getName();
@@ -67,7 +67,7 @@
return;
}
- JavaIndex index =
+ Index index =
(getSubject().getIndex() == null) ? getSubject().addIndex()
: getSubject().getIndex();
index.setName(value);
@@ -83,10 +83,10 @@
};
}
- private WritablePropertyValueModel<JavaIndex> buildIndexHolder() {
- return new PropertyAspectAdapter<IndexHolder, JavaIndex>(getSubjectHolder(),
IndexHolder.INDEX_PROPERTY) {
+ private WritablePropertyValueModel<Index> buildIndexHolder() {
+ return new PropertyAspectAdapter<IndexHolder, Index>(getSubjectHolder(),
IndexHolder.INDEX_PROPERTY) {
@Override
- protected JavaIndex buildValue_() {
+ protected Index buildValue_() {
return this.subject.getIndex();
}
};
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -19,11 +19,12 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.swt.ColumnAdapter;
import org.eclipse.jpt.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
import org.eclipse.jpt.ui.internal.widgets.AddRemoveTablePane;
import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
@@ -57,7 +58,7 @@
* @param parent The parent container
*/
public ParametersComposite(Pane<?> parentPane,
- Composite container, PropertyValueModel<GenericGenerator> generatorHolder)
{
+ Composite container, WritablePropertyValueModel<GenericGenerator>
generatorHolder) {
super(parentPane, generatorHolder, container, false);
}
@@ -181,11 +182,11 @@
switch (columnIndex) {
case ParameterColumnAdapter.NAME_COLUMN_INDEX: {
- return HibernateUIMappingMessages.ParametersComposite_nameColumn;
+ return JptUiMappingsMessages.QueryHintsComposite_nameColumn;
}
case ParameterColumnAdapter.VALUE_COLUMN_INDEX: {
- return HibernateUIMappingMessages.ParametersComposite_valueColumn;
+ return JptUiMappingsMessages.QueryHintsComposite_valueColumn;
}
default: {
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 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2010-05-26
13:13:34 UTC (rev 22326)
@@ -24,6 +24,4 @@
HibernateDiscriminatorColumnComposite_formula=Formula:
BasicGeneralSection_generated = Generation Time:
IndexHolderComposite_name=Name:
-Index_section_index=Index
-ParametersComposite_nameColumn=Name
-ParametersComposite_valueColumn=Value
\ No newline at end of file
+Index_section_index=Index
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/ColumnCombo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/ColumnCombo.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/ColumnCombo.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -9,11 +9,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl;
+import java.util.Iterator;
import org.eclipse.jpt.core.JpaNode;
import org.eclipse.jpt.db.Table;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -23,45 +24,41 @@
public abstract class ColumnCombo<T extends JpaNode>
extends DatabaseObjectCombo<T>
{
- public ColumnCombo(
- Pane<? extends T> parentPane,
- Composite parent) {
-
+ public ColumnCombo(Pane<? extends T> parentPane, Composite parent) {
super(parentPane, parent);
}
-
+
public ColumnCombo(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
+ Pane<?> parentPane,
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent
+ ) {
super(parentPane, subjectHolder, parent);
}
-
+
public ColumnCombo(
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory
+ ) {
super(subjectHolder, parent, widgetFactory);
}
-
-
+
@Override
- protected Iterable<String> getValues_() {
+ protected Iterator<String> values() {
Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() :
EmptyIterable.<String>instance();
+ return (dbTable == null) ? EmptyIterator.<String>instance() :
dbTable.sortedColumnIdentifiers();
}
-
+
protected Table getDbTable() {
return (this.getSubject() == null) ? null : this.getDbTable_();
}
-
+
/**
* Assume the subject is not null.
*/
protected abstract Table getDbTable_();
-
+
@Override
protected void tableChanged_(Table table) {
super.tableChanged_(table);
@@ -69,4 +66,5 @@
this.doPopulate();
}
}
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/DatabaseObjectCombo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/DatabaseObjectCombo.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/DatabaseObjectCombo.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -11,6 +11,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl;
+import java.util.Iterator;
+
import org.eclipse.jpt.core.JpaDataSource;
import org.eclipse.jpt.core.JpaNode;
import org.eclipse.jpt.core.JpaProject;
@@ -27,12 +29,17 @@
import org.eclipse.jpt.ui.internal.Tracing;
import org.eclipse.jpt.ui.internal.listeners.SWTConnectionListenerWrapper;
import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.ui.internal.widgets.ComboPane;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.util.SWTUtil;
import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
/**
@@ -47,56 +54,61 @@
*/
@SuppressWarnings("nls")
public abstract class DatabaseObjectCombo<T extends JpaNode>
- extends ComboPane<T>
+ extends Pane<T>
{
+
/**
+ * The main (only) widget of this pane.
+ */
+ protected CCombo comboBox;
+
+ /**
* The listener added to the <code>ConnectionProfile</code>.
* It keeps the combo in sync with the database metadata.
*/
private ConnectionListener connectionListener;
-
+
private PropertyChangeListener connectionProfileListener;
-
// ********** constructors **********
-
+
protected DatabaseObjectCombo(
- Pane<? extends T> parentPane,
- Composite parent) {
-
+ Pane<? extends T> parentPane,
+ Composite parent
+ ) {
super(parentPane, parent);
}
-
+
protected DatabaseObjectCombo(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
+ Pane<?> parentPane,
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent
+ ) {
super(parentPane, subjectHolder, parent);
}
-
+
protected DatabaseObjectCombo(
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory
+ ) {
super(subjectHolder, parent, widgetFactory);
}
-
-
+
+
// ********** initialization **********
-
+
@Override
protected void initialize() {
super.initialize();
this.connectionListener = this.buildConnectionListener();
this.connectionProfileListener = this.buildConnectionProfileListener();
}
-
+
protected ConnectionListener buildConnectionListener() {
return new SWTConnectionListenerWrapper(this.buildConnectionListener_());
}
-
+
protected ConnectionListener buildConnectionListener_() {
return new LocalConnectionListener();
}
@@ -104,7 +116,7 @@
protected PropertyChangeListener buildConnectionProfileListener() {
return new SWTPropertyChangeListenerWrapper(this.buildConnectionProfileListener_());
}
-
+
protected PropertyChangeListener buildConnectionProfileListener_() {
return new PropertyChangeListener(){
@@ -113,7 +125,7 @@
}
};
}
-
+
protected void connectionProfileChanged(PropertyChangeEvent event) {
if (event.getOldValue() != null) {
((ConnectionProfile)
event.getOldValue()).removeConnectionListener(this.connectionListener);
@@ -124,9 +136,50 @@
this.repopulateComboBox();
}
-
+ @Override
+ protected void initializeLayout(Composite container) {
+ this.comboBox = this.addEditableCCombo(container);
+ this.comboBox.addModifyListener(this.buildModifyListener());
+ SWTUtil.attachDefaultValueHandler(this.comboBox);
+ }
+
+ protected ModifyListener buildModifyListener() {
+ return new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ DatabaseObjectCombo.this.comboBoxModified();
+ }
+ };
+ }
+
+
+ // ********** abstract methods **********
+
+ /**
+ * Return the possible values to be added to the combo during
+ * population.
+ */
+ protected abstract Iterator<String> values();
+
+ /**
+ * Return the default value, or <code>null</code> if no default is
+ * specified. This method is only called when the subject is non-null.
+ */
+ protected abstract String getDefaultValue();
+
+ /**
+ * Return the current value from the subject.
+ * This method is only called when the subject is non-null.
+ */
+ protected abstract String getValue();
+
+ /**
+ * Set the specified value as the new value on the subject.
+ */
+ protected abstract void setValue(String value);
+
+
// ********** overrides **********
-
+
@Override
protected void engageListeners_(T subject) {
super.engageListeners_(subject);
@@ -137,7 +190,7 @@
cp.addConnectionListener(this.connectionListener);
}
}
-
+
@Override
protected void disengageListeners_(T subject) {
ConnectionProfile cp = subject.getJpaProject().getConnectionProfile();
@@ -148,20 +201,188 @@
super.disengageListeners_(subject);
}
-
+
@Override
- protected final Iterable<String> getValues() {
- return this.connectionProfileIsActive() ? this.getValues_() :
EmptyIterable.<String>instance();
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+
+ if ( ! this.comboBox.isDisposed()) {
+ this.comboBox.setEnabled(enabled);
+ }
}
-
+
+ @Override
+ protected void propertyChanged(String propertyName) {
+ super.propertyChanged(propertyName);
+ this.updateSelectedItem();
+ }
+
+ @Override
+ protected void doPopulate() {
+ super.doPopulate();
+ this.populateComboBox();
+ }
+
+
+ // ********** populating **********
+
/**
- * Called only when connection profile is active
+ * Populate the combo-box list by clearing it, then adding first the default
+ * value, if available, and then the possible choices.
*/
- protected abstract Iterable<String> getValues_();
-
-
+ protected void populateComboBox() {
+ this.comboBox.removeAll();
+
+ this.comboBox.add(this.buildDefaultValueEntry());
+
+ if (this.connectionProfileIsActive()) {
+ for (Iterator<String> stream = this.values(); stream.hasNext(); ) {
+ this.comboBox.add(stream.next());
+ }
+ }
+
+ this.updateSelectedItem_();
+ }
+
+ protected String buildDefaultValueEntry() {
+ if (getSubject() == null) {
+ return JptUiMappingsMessages.NoneSelected;
+ }
+ String defaultValue = this.getDefaultValue();
+ return (defaultValue == null) ? this.buildNullDefaultValueEntry() :
this.buildNonNullDefaultValueEntry(defaultValue);
+ }
+
+ protected String buildNullDefaultValueEntry() {
+ return JptUiMappingsMessages.DefaultEmpty;
+ }
+
+ protected String buildNonNullDefaultValueEntry(String defaultValue) {
+ return NLS.bind(
+ JptUiMappingsMessages.DefaultWithOneParam,
+ defaultValue
+ );
+ }
+
+ protected void updateSelectedItem() {
+ // make sure the default value is up to date (??? ~bjv)
+ String defaultValueEntry = this.buildDefaultValueEntry();
+ if ( ! this.comboBox.getItem(0).equals(defaultValueEntry)) {
+ this.comboBox.remove(0);
+ this.comboBox.add(defaultValueEntry, 0);
+ }
+
+ this.updateSelectedItem_();
+ }
+
+ /**
+ * Updates the selected item by selecting the current value, if not
+ * <code>null</code>, or select the default value if one is available,
+ * otherwise remove the selection.
+ */
+ protected void updateSelectedItem_() {
+ String value = (this.getSubject() == null) ? null : this.getValue();
+ if (value == null) {
+ // select the default value
+ this.comboBox.select(0);
+ } else {
+ // select the new value
+ if ( ! value.equals(this.comboBox.getText())) {
+ // This prevents the cursor from being set back to the beginning of the line (bug
234418).
+ // The reason we are hitting this method at all is because the
+ // context model is updating from the resource model in a way
+ // that causes change notifications to be fired (the annotation
+ // is added to the resource model, change notification occurs
+ // on the update thread, and then the name is set, these 2
+ // threads can get in the wrong order).
+ // The #valueChanged() method sets the populating flag to true,
+ // but in this case it is already set back to false when we
+ // receive notification back from the model because it has
+ // moved to the update thread and then jumps back on the UI thread.
+ this.comboBox.setText(value);
+ }
+ }
+ }
+
+
+ // ********** combo-box listener callback **********
+
+ protected void comboBoxModified() {
+ if ( ! this.isPopulating()) {
+ this.valueChanged(this.comboBox.getText());
+ }
+ }
+
+ /**
+ * The combo-box selection has changed, update the model if necessary.
+ * If the value has changed and the subject is null, we can build a subject
+ * before setting the value.
+ */
+ protected void valueChanged(String newValue) {
+ JpaNode subject = this.getSubject();
+ String oldValue;
+ if (subject == null) {
+ if (this.nullSubjectIsNotAllowed()) {
+ return; // no subject to set the value on
+ }
+ oldValue = null;
+ } else {
+ oldValue = this.getValue();
+ }
+
+ // convert empty string or default to null
+ if (StringTools.stringIsEmpty(newValue) || this.valueIsDefault(newValue)) {
+ newValue = null;
+ }
+
+ // set the new value if it is different from the old value
+ if (this.valuesAreDifferent(oldValue, newValue)) {
+ this.setPopulating(true);
+
+ try {
+ this.setValue(newValue);
+ } finally {
+ this.setPopulating(false);
+ }
+ }
+ }
+
+ /**
+ * Return whether we can set the value when the subject is null
+ * (i.e. #setValue(String) will construct the subject if necessary).
+ */
+ protected boolean nullSubjectIsAllowed() {
+ return false;
+ }
+
+ protected final boolean nullSubjectIsNotAllowed() {
+ return ! this.nullSubjectIsAllowed();
+ }
+
+ /**
+ * pre-condition: value is not null
+ */
+ protected boolean valueIsDefault(String value) {
+ return (this.comboBox.getItemCount() > 0)
+ && value.equals(this.comboBox.getItem(0));
+ }
+
+ protected boolean valuesAreEqual(String value1, String value2) {
+ if ((value1 == null) && (value2 == null)) {
+ return true; // both are null
+ }
+ if ((value1 == null) || (value2 == null)) {
+ return false; // one is null but the other is not
+ }
+ return value1.equals(value2);
+ }
+
+ protected boolean valuesAreDifferent(String value1, String value2) {
+ return ! this.valuesAreEqual(value1, value2);
+ }
+
+
// ********** convenience methods **********
-
+
/**
* Return the subject's JPA project.
* Allow subclasses to override this method, so we can still get the JPA
@@ -171,7 +392,7 @@
T subject = this.getSubject();
return (subject == null) ? null : subject.getJpaProject();
}
-
+
/**
* Return the subject's connection profile.
*/
@@ -179,7 +400,7 @@
JpaProject jpaProject = this.getJpaProject();
return (jpaProject == null) ? null : jpaProject.getConnectionProfile();
}
-
+
/**
* Return whether the subject's connection profile is active.
*/
@@ -187,7 +408,7 @@
ConnectionProfile cp = this.getConnectionProfile();
return (cp != null) && cp.isActive();
}
-
+
/**
* Returns the subject's database.
*/
@@ -195,80 +416,86 @@
ConnectionProfile cp = this.getConnectionProfile();
return (cp == null) ? null : cp.getDatabase();
}
-
-
+
+
// ********** connection listener callbacks **********
-
+
+ protected void repopulateComboBox() {
+ if ( ! this.comboBox.isDisposed()) {
+ this.repopulate();
+ }
+ }
+
protected final void databaseChanged(Database database) {
if ( ! this.comboBox.isDisposed()) {
this.databaseChanged_(database);
}
}
-
- protected void databaseChanged_(@SuppressWarnings("unused") Database database)
{
+
+ protected void databaseChanged_(Database database) {
// do nothing by default
}
-
+
protected final void catalogChanged(Catalog catalog) {
if ( ! this.comboBox.isDisposed()) {
this.catalogChanged_(catalog);
}
}
-
- protected void catalogChanged_(@SuppressWarnings("unused") Catalog catalog) {
+
+ protected void catalogChanged_(Catalog catalog) {
// do nothing by default
}
-
+
protected final void schemaChanged(Schema schema) {
if ( ! this.comboBox.isDisposed()) {
this.schemaChanged_(schema);
}
}
-
- protected void schemaChanged_(@SuppressWarnings("unused") Schema schema) {
+
+ protected void schemaChanged_(Schema schema) {
// do nothing by default
}
-
+
protected final void sequenceChanged(Sequence sequence) {
if ( ! this.comboBox.isDisposed()) {
this.sequenceChanged_(sequence);
}
}
-
- protected void sequenceChanged_(@SuppressWarnings("unused") Sequence sequence)
{
+
+ protected void sequenceChanged_(Sequence sequence) {
// do nothing by default
}
-
+
protected final void tableChanged(Table table) {
if ( ! this.comboBox.isDisposed()) {
this.tableChanged_(table);
}
}
-
- protected void tableChanged_(@SuppressWarnings("unused") Table table) {
+
+ protected void tableChanged_(Table table) {
// do nothing by default
}
-
+
protected final void columnChanged(Column column) {
if ( ! this.comboBox.isDisposed()) {
this.columnChanged_(column);
}
}
-
- protected void columnChanged_(@SuppressWarnings("unused") Column column) {
+
+ protected void columnChanged_(Column column) {
// do nothing by default
}
-
+
protected final void foreignKeyChanged(ForeignKey foreignKey) {
if ( ! this.comboBox.isDisposed()) {
this.foreignKeyChanged_(foreignKey);
}
}
-
- protected void foreignKeyChanged_(@SuppressWarnings("unused") ForeignKey
foreignKey) {
+
+ protected void foreignKeyChanged_(ForeignKey foreignKey) {
// do nothing by default
}
-
+
@Override
protected void log(String flag, String message) {
if (flag.equals(Tracing.UI_DB) && Tracing.booleanDebugOption(Tracing.UI_DB)) {
@@ -278,84 +505,78 @@
}
}
- // broaden accessibility a bit
- @Override
- protected void repopulateComboBox() {
- super.repopulateComboBox();
- }
-
-
+
// ********** connection listener **********
-
- protected class LocalConnectionListener
- implements ConnectionListener
- {
+
+ protected class LocalConnectionListener implements ConnectionListener {
+
protected LocalConnectionListener() {
super();
}
-
+
public void opened(ConnectionProfile profile) {
this.log("opened: " + profile.getName());
DatabaseObjectCombo.this.repopulateComboBox();
}
-
+
public void modified(ConnectionProfile profile) {
this.log("modified: " + profile.getName());
DatabaseObjectCombo.this.repopulateComboBox();
}
-
+
public boolean okToClose(ConnectionProfile profile) {
this.log("OK to close: " + profile.getName());
return true;
}
-
+
public void aboutToClose(ConnectionProfile profile) {
this.log("about to close: " + profile.getName());
}
-
+
public void closed(ConnectionProfile profile) {
this.log("closed: " + profile.getName());
DatabaseObjectCombo.this.repopulateComboBox();
}
-
+
public void databaseChanged(ConnectionProfile profile, Database database) {
this.log("database changed: " + database.getName());
DatabaseObjectCombo.this.databaseChanged(database);
}
-
+
public void catalogChanged(ConnectionProfile profile, Catalog catalog) {
this.log("catalog changed: " + catalog.getName());
DatabaseObjectCombo.this.catalogChanged(catalog);
}
-
+
public void schemaChanged(ConnectionProfile profile, Schema schema) {
this.log("schema changed: " + schema.getName());
DatabaseObjectCombo.this.schemaChanged(schema);
}
-
+
public void sequenceChanged(ConnectionProfile profile, Sequence sequence) {
this.log("sequence changed: " + sequence.getName());
DatabaseObjectCombo.this.sequenceChanged(sequence);
}
-
+
public void tableChanged(ConnectionProfile profile, Table table) {
this.log("table changed: " + table.getName());
DatabaseObjectCombo.this.tableChanged(table);
}
-
+
public void columnChanged(ConnectionProfile profile, Column column) {
this.log("column changed: " + column.getName());
DatabaseObjectCombo.this.columnChanged(column);
}
-
+
public void foreignKeyChanged(ConnectionProfile profile, ForeignKey foreignKey) {
this.log("foreign key changed: " + foreignKey.getName());
DatabaseObjectCombo.this.foreignKeyChanged(foreignKey);
}
-
+
protected void log(String message) {
DatabaseObjectCombo.this.log(Tracing.UI_DB, message);
}
- }
+
+ }
+
}
-
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/TableCombo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/TableCombo.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mappings/db/xpl/TableCombo.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -9,11 +9,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.mappings.db.xpl;
+import java.util.Iterator;
+
import org.eclipse.jpt.core.JpaNode;
import org.eclipse.jpt.db.Schema;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -23,36 +25,32 @@
public abstract class TableCombo<T extends JpaNode>
extends DatabaseObjectCombo<T>
{
- public TableCombo(
- Pane<? extends T> parentPane,
- Composite parent) {
-
+ public TableCombo(Pane<? extends T> parentPane, Composite parent) {
super(parentPane, parent);
}
-
+
public TableCombo(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
+ Pane<?> parentPane,
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent
+ ) {
super(parentPane, subjectHolder, parent);
}
-
+
public TableCombo(
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory
+ ) {
super(subjectHolder, parent, widgetFactory);
}
-
-
+
@Override
- protected Iterable<String> getValues_() {
+ protected Iterator<String> values() {
Schema dbSchema = this.getDbSchema();
- return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() :
EmptyIterable.<String>instance();
+ return (dbSchema == null) ? EmptyIterator.<String>instance() :
dbSchema.sortedTableIdentifiers();
}
-
+
protected Schema getDbSchema() {
return (this.getSubject() == null) ? null : this.getDbSchema_();
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/orm/details/HibernateOrmEntityComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/orm/details/HibernateOrmEntityComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/orm/details/HibernateOrmEntityComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * 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,
@@ -14,14 +14,14 @@
import org.eclipse.jpt.core.context.AccessHolder;
import org.eclipse.jpt.core.context.orm.OrmEntity;
import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.internal.details.AbstractEntityComposite;
import org.eclipse.jpt.ui.internal.details.AccessTypeComposite;
-import org.eclipse.jpt.ui.internal.details.EntityNameComposite;
-import org.eclipse.jpt.ui.internal.details.IdClassComposite;
-import org.eclipse.jpt.ui.internal.details.orm.MetadataCompleteComposite;
-import org.eclipse.jpt.ui.internal.details.orm.OrmInheritanceComposite;
-import org.eclipse.jpt.ui.internal.details.orm.OrmJavaClassChooser;
-import org.eclipse.jpt.ui.internal.details.orm.OrmSecondaryTablesComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.AbstractEntityComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.EntityNameComposite;
+import org.eclipse.jpt.ui.internal.mappings.details.IdClassComposite;
+import org.eclipse.jpt.ui.internal.orm.details.MetadataCompleteComposite;
+import org.eclipse.jpt.ui.internal.orm.details.OrmInheritanceComposite;
+import org.eclipse.jpt.ui.internal.orm.details.OrmJavaClassChooser;
+import org.eclipse.jpt.ui.internal.orm.details.OrmSecondaryTablesComposite;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -45,13 +45,25 @@
}
@Override
- protected void initializeEntitySection(Composite container) {
- new OrmJavaClassChooser(this, getSubjectHolder(), container, false);
+ protected void initializeLayout(Composite container) {
+ initializeGeneralPane(container);
+ initializeQueriesPane(container);
+ initializeInheritancePane(container);
+ initializeAttributeOverridesPane(container);
+ initializeGeneratorsPane(container);
+ initializeSecondaryTablesPane(container);
+ }
+
+ @Override
+ protected void initializeGeneralPane(Composite container) {
+ int groupBoxMargin = getGroupBoxMargin();
+
+ new OrmJavaClassChooser(this, getSubjectHolder(), addSubPane(container, 0,
groupBoxMargin, 0, groupBoxMargin), false);
new HibernateTableComposite(this, container);
- new EntityNameComposite(this, container);
- new AccessTypeComposite(this, buildAccessHolder(), container);
- new IdClassComposite(this, buildIdClassReferenceHolder(), container);
- new MetadataCompleteComposite(this, getSubjectHolder(), container);
+ new EntityNameComposite(this, addSubPane(container, 0, groupBoxMargin, 0,
groupBoxMargin));
+ new AccessTypeComposite(this, buildAccessHolder(), addSubPane(container, 0,
groupBoxMargin, 0, groupBoxMargin));
+ new IdClassComposite(this, addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin),
false);
+ new MetadataCompleteComposite(this, getSubjectHolder(), addSubPane(container, 0,
groupBoxMargin, 0, groupBoxMargin));
}
protected PropertyValueModel<AccessHolder> buildAccessHolder() {
@@ -64,13 +76,14 @@
}
};
}
+
@Override
- protected void initializeSecondaryTablesSection(Composite container) {
+ protected void addSecondaryTablesComposite(Composite container) {
new OrmSecondaryTablesComposite(this, container);
}
-
+
@Override
- protected void initializeInheritanceSection(Composite container) {
+ protected void addInheritanceComposite(Composite container) {
new OrmInheritanceComposite(this, container);
}
}
\ No newline at end of file
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiDefinition.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiDefinition.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.persistence.details;
-
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.ui.ResourceUiDefinition;
-import
org.eclipse.jpt.ui.internal.persistence.details.AbstractPersistenceXmlResourceUiDefinition;
-import org.eclipse.jpt.ui.internal.persistence.details.PersistenceXmlUiFactory;
-import org.eclipse.jpt.ui.internal.structure.PersistenceResourceModelStructureProvider;
-import org.eclipse.jpt.ui.structure.JpaStructureProvider;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernatePersistenceXmlUiDefinition extends
- AbstractPersistenceXmlResourceUiDefinition {
- // singleton
- private static final ResourceUiDefinition INSTANCE = new
HibernatePersistenceXmlUiDefinition();
-
-
- /**
- * Return the singleton
- */
- public static ResourceUiDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private HibernatePersistenceXmlUiDefinition() {
- super();
- }
-
-
- @Override
- protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() {
- return new HibernatePersistenceXmlUiFactory();
- }
-
- public boolean providesUi(JpaResourceType resourceType) {
- return resourceType.equals(JptCorePlugin.PERSISTENCE_XML_1_0_RESOURCE_TYPE);
- }
-
- public JpaStructureProvider getStructureProvider() {
- return PersistenceResourceModelStructureProvider.instance();
- }
-}
Deleted:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiFactory.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePersistenceXmlUiFactory.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.persistence.details;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.ui.WidgetFactory;
-import org.eclipse.jpt.ui.details.JpaPageComposite;
-import
org.eclipse.jpt.ui.internal.persistence.details.GenericPersistenceUnitGeneralComposite;
-import
org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitConnectionComposite;
-import
org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitPropertiesComposite;
-import org.eclipse.jpt.ui.internal.persistence.details.PersistenceXmlUiFactory;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernatePersistenceXmlUiFactory implements
- PersistenceXmlUiFactory {
-
- @Override
- public ListIterator<JpaPageComposite> createPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent, WidgetFactory widgetFactory) {
- List<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(1);
-
- pages.add(new GenericPersistenceUnitGeneralComposite(subjectHolder, parent,
widgetFactory));
- pages.add(new PersistenceUnitConnectionComposite(subjectHolder, parent,
widgetFactory));
- pages.add(new PersistenceUnitPropertiesComposite(subjectHolder, parent,
widgetFactory));
-
- // ************Hibernate pages***************
- PropertyValueModel<BasicHibernateProperties> basicHolder =
this.buildBasicHolder(subjectHolder);
- pages.add(new HibernatePropertiesComposite(basicHolder, parent, widgetFactory));
-
- return pages.listIterator();
- }
-
- private PropertyValueModel<BasicHibernateProperties> buildBasicHolder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit,
BasicHibernateProperties>(subjectHolder) {
- @Override
- protected BasicHibernateProperties transform_(PersistenceUnit value) {
- return ((HibernatePersistenceUnit)value).getHibernatePersistenceUnitProperties();
- }
- };
- }
-
-}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -17,7 +17,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
@@ -25,7 +24,7 @@
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaPageComposite;
import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
+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.SimpleListValueModel;
@@ -53,7 +52,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernatePropertiesComposite extends Pane<BasicHibernateProperties>
implements
+public class HibernatePropertiesComposite extends
FormPane<BasicHibernateProperties> implements
JpaPageComposite {
private Text cfgFile;
@@ -130,7 +129,7 @@
StringConverter.Default.<String>instance(),
null);
- dialectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, new
SWTPropertyChangeListenerWrapper(
+ dialectHolder.addPropertyChangeListener(new SWTPropertyChangeListenerWrapper(
new PropertyChangeListener() {
public void propertyChanged(PropertyChangeEvent event) {
String dialectClass = helper.getDialectClass((String) event.getNewValue());
@@ -144,7 +143,7 @@
)
);
- driverHolder.addPropertyChangeListener( PropertyValueModel.VALUE, new
SWTPropertyChangeListenerWrapper(
+ driverHolder.addPropertyChangeListener( new SWTPropertyChangeListenerWrapper(
new PropertyChangeListener() {
public void propertyChanged(PropertyChangeEvent event) {
String driverClass = (String) event.getNewValue();
@@ -218,6 +217,7 @@
}
private void handleConfigurationFileCreate() {
+ StructuredSelection selection = null;
NewConfigurationWizard wizard = new NewConfigurationWizard();
wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
@@ -386,10 +386,4 @@
public String getPageText() {
return Messages.HibernatePropertiesComposite_hibernate;
}
-
- @Override
- public ImageDescriptor getPageImageDescriptor() {
- // TODO hibernate tab in persistence.xml image
- return null;
- }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUi.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUi.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUi.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -22,8 +22,10 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.ui.JpaPlatformUiProvider;
+import org.eclipse.jpt.ui.JpaUiFactory;
import org.eclipse.jpt.ui.internal.platform.generic.GenericJpaPlatformUi;
import org.eclipse.jpt.ui.navigator.JpaNavigatorProvider;
+import org.eclipse.jpt.ui.structure.JpaStructureProvider;
import org.hibernate.eclipse.launch.HibernateLaunchConstants;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
import org.jboss.tools.hibernate.jpt.ui.HibernateJptUIPlugin;
@@ -42,10 +44,13 @@
public static final String full_exporter_id = HibernateLaunchConstants.ATTR_EXPORTERS +
'.' + "hbmexporter"; //$NON-NLS-1$
public HibernateJpaPlatformUi(
+ JpaUiFactory jpaUiFactory,
JpaNavigatorProvider navigatorProvider,
- JpaPlatformUiProvider platformUiProvider)
+ JpaStructureProvider persistenceStructureProvider,
+ JpaStructureProvider javaStructureProvider,
+ JpaPlatformUiProvider... platformUiProviders)
{
- super(navigatorProvider, platformUiProvider);
+ super(jpaUiFactory, navigatorProvider, persistenceStructureProvider,
javaStructureProvider, platformUiProviders);
}
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUiFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUiFactory.java 2010-05-26
10:57:00 UTC (rev 22325)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaPlatformUiFactory.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -12,8 +12,10 @@
import org.eclipse.jpt.ui.JpaPlatformUi;
import org.eclipse.jpt.ui.JpaPlatformUiFactory;
+import org.eclipse.jpt.ui.internal.GenericJpaPlatformUiProvider;
import org.eclipse.jpt.ui.internal.platform.generic.GenericNavigatorProvider;
-import org.jboss.tools.hibernate.jpt.ui.internal.HibernateJpaPlatformUiProvider;
+import org.eclipse.jpt.ui.internal.structure.JavaResourceModelStructureProvider;
+import org.eclipse.jpt.ui.internal.structure.PersistenceResourceModelStructureProvider;
/**
* @author Dmitry Geraskov
@@ -27,8 +29,11 @@
public JpaPlatformUi buildJpaPlatformUi() {
return new HibernateJpaPlatformUi(
+ new HibernateJpaUiFactory(),
new GenericNavigatorProvider(),
- HibernateJpaPlatformUiProvider.instance()
+ JavaResourceModelStructureProvider.instance(),
+ PersistenceResourceModelStructureProvider.instance(),
+ GenericJpaPlatformUiProvider.instance()
);
}
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
(from rev 22306,
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2010-05-26
13:13:34 UTC (rev 22326)
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2008-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.platform;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+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;
+import org.eclipse.jpt.ui.details.JpaPageComposite;
+import org.eclipse.jpt.ui.internal.BaseJpaUiFactory;
+import
org.eclipse.jpt.ui.internal.persistence.details.GenericPersistenceUnitGeneralComposite;
+import
org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitConnectionComposite;
+import
org.eclipse.jpt.ui.internal.persistence.details.PersistenceUnitPropertiesComposite;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+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;
+import
org.jboss.tools.hibernate.jpt.ui.internal.orm.details.HibernateOrmEntityComposite;
+import
org.jboss.tools.hibernate.jpt.ui.internal.persistence.details.HibernatePropertiesComposite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJpaUiFactory extends BaseJpaUiFactory {
+
+ @SuppressWarnings("unchecked")
+ public ListIterator createPersistenceUnitComposites(
+ PropertyValueModel<PersistenceUnit> subjectHolder, Composite parent,
WidgetFactory widgetFactory) {
+
+ List<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(1);
+
+ pages.add(new GenericPersistenceUnitGeneralComposite(subjectHolder, parent,
widgetFactory));
+ pages.add(new PersistenceUnitConnectionComposite(subjectHolder, parent,
widgetFactory));
+ pages.add(new PersistenceUnitPropertiesComposite(subjectHolder, parent,
widgetFactory));
+
+ // ************Hibernate pages***************
+ PropertyValueModel<HibernatePersistenceUnit> hibernatePersistenceUnitHolder =
this
+ .buildHibernatePersistenceUnitHolder(subjectHolder);
+
+ PropertyValueModel<BasicHibernateProperties> basicHolder =
this.buildBasicHolder(hibernatePersistenceUnitHolder);
+ pages.add(new HibernatePropertiesComposite(basicHolder, parent, widgetFactory));
+
+ return pages.listIterator();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public JpaComposite createJavaIdMappingComposite(
+ PropertyValueModel<JavaIdMapping> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+ 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((PropertyValueModel<? extends
HibernateJavaEntity>) subjectHolder, parent, widgetFactory);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public JpaComposite createOrmEntityComposite(
+ PropertyValueModel<OrmEntity> subjectHolder, Composite parent,
+ WidgetFactory widgetFactory) {
+ return new HibernateOrmEntityComposite((PropertyValueModel<? extends
HibernateOrmEntity>) subjectHolder, parent, widgetFactory);
+ }
+
+ private PropertyValueModel<BasicHibernateProperties> buildBasicHolder(
+ PropertyValueModel<HibernatePersistenceUnit> subjectHolder) {
+ return new TransformationPropertyValueModel<HibernatePersistenceUnit,
BasicHibernateProperties>(subjectHolder) {
+ @Override
+ protected BasicHibernateProperties transform_(HibernatePersistenceUnit value) {
+ return value.getBasicProperties();
+ }
+ };
+ }
+
+ private PropertyValueModel<HibernatePersistenceUnit>
buildHibernatePersistenceUnitHolder(
+ PropertyValueModel<PersistenceUnit> subjectHolder) {
+ return new TransformationPropertyValueModel<PersistenceUnit,
HibernatePersistenceUnit>(subjectHolder) {
+ @Override
+ protected HibernatePersistenceUnit transform_(PersistenceUnit value) {
+ return (HibernatePersistenceUnit) value;
+ }
+ };
+ }
+
+ public JpaComposite createJavaBasicMappingComposite(
+ PropertyValueModel<JavaBasicMapping> subjectHolder,
+ Composite parent,
+ 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