Author: dgeraskov
Date: 2009-10-26 06:38:34 -0400 (Mon, 26 Oct 2009)
New Revision: 18295
Added:
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/IndexHolder.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/java/HibernateJavaBasicMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotation.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.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/IndexHolderComposite.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.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.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/HibernateIdMappingComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
Log:
https://jira.jboss.org/jira/browse/JBIDE-4666
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -22,6 +22,7 @@
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotationImpl.DiscriminatorFormulaAnnotationDefinition;
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.IndexAnnotationImpl.IndexAnnotationDefinition;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceGenericGeneratorsAnnotation.GenericGeneratorsAnnotationDefinition;
/**
@@ -70,5 +71,6 @@
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 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -61,6 +61,8 @@
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.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;
@@ -276,4 +278,8 @@
return new HibernateOrmOneToOneMapping(parent, resourceMapping);
}
+ public Index buildIndex(JavaJpaContextNode parent) {
+ return new IndexImpl(parent);
+ }
+
}
Added:
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 2009-10-26
10:38:34 UTC (rev 18295)
@@ -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);
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Index.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface IndexHolder extends JpaContextNode {
+
+ //******************** index *****************
+
+ String INDEX_PROPERTY = "index"; //$NON-NLS-1$
+
+ Index getIndex();
+
+ Index addIndex();
+
+ void removeIndex();
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexHolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/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 2009-10-26
10:38:34 UTC (rev 18295)
@@ -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()]));
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/IndexImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -15,11 +15,11 @@
*
*/
public interface Hibernate {
-
+
// Hibernate package
String PACKAGE = "org.hibernate.annotations"; //$NON-NLS-1$
String PACKAGE_ = PACKAGE + "."; //$NON-NLS-1$
-
+
// ********** API **********
// Hibernate annotations
@@ -27,14 +27,14 @@
String GENERIC_GENERATOR__NAME = "name"; //$NON-NLS-1$
String GENERIC_GENERATOR__STRATEGY = "strategy"; //$NON-NLS-1$
String GENERIC_GENERATOR__PARAMETERS = "parameters"; //$NON-NLS-1$
-
+
String GENERATOR_PARAMETER = PACKAGE_ + "Parameter"; //$NON-NLS-1$
String GENERATOR_PARAMETER__NAME = "name"; //$NON-NLS-1$
String GENERATOR_PARAMETER__VALUE = "value"; //$NON-NLS-1$
-
+
String GENERIC_GENERATORS = PACKAGE_ + "GenericGenerators"; //$NON-NLS-1$
String GENERIC_GENERATORS__VALUE = "value"; //$NON-NLS-1$
-
+
String NAMED_QUERY = PACKAGE_ + "NamedQuery"; //$NON-NLS-1$
String NAMED_QUERY__NAME = "name"; //$NON-NLS-1$
String NAMED_QUERY__QUERY = "query"; //$NON-NLS-1$
@@ -47,10 +47,10 @@
String NAMED_QUERY__TIMEOUT = "timeout"; //$NON-NLS-1$
String NAMED_QUERY__COMMENT = "comment"; //$NON-NLS-1$
String NAMED_QUERY__READ_ONLY = "readOnly"; //$NON-NLS-1$
-
+
String NAMED_QUERIES = PACKAGE_ + "NamedQueries"; //$NON-NLS-1$
String NAMED_QUERIES__VALUE = "value"; //$NON-NLS-1$
-
+
String NAMED_NATIVE_QUERY = PACKAGE_ + "NamedNativeQuery"; //$NON-NLS-1$
String NAMED_NATIVE_QUERY__NAME = "name"; //$NON-NLS-1$
String NAMED_NATIVE_QUERY__QUERY = "query"; //$NON-NLS-1$
@@ -66,7 +66,7 @@
String NAMED_NATIVE_QUERY__RESULT_CLASS = "resultClass"; //$NON-NLS-1$
String NAMED_NATIVE_QUERY__RESULT_SET_MAPPING = "resultSetMapping";
//$NON-NLS-1$
String NAMED_NATIVE_QUERY__CALLABLE = "callable"; //$NON-NLS-1$
-
+
String NAMED_NATIVE_QUERIES = PACKAGE_ + "NamedNativeQueries"; //$NON-NLS-1$
String NAMED_NATIVE_QUERIES__VALUE = "value"; //$NON-NLS-1$
@@ -77,7 +77,7 @@
String FLUSH_MODE_TYPE__COMMIT = FLUSH_MODE_TYPE_ + "COMMIT"; //$NON-NLS-1$
String FLUSH_MODE_TYPE__NEVER = FLUSH_MODE_TYPE_ + "NEVER"; //$NON-NLS-1$
String FLUSH_MODE_TYPE__MANUAL = FLUSH_MODE_TYPE_ + "MANUAL"; //$NON-NLS-1$
-
+
String CACHE_MODE_TYPE = PACKAGE_ + "CacheModeType"; //$NON-NLS-1$
String CACHE_MODE_TYPE_ = CACHE_MODE_TYPE + '.';
String CACHE_MODE_TYPE__GET = CACHE_MODE_TYPE_ + "GET"; //$NON-NLS-1$
@@ -88,14 +88,18 @@
String DISCRIMINATOR_FORMULA = PACKAGE_ + "DiscriminatorFormula";
//$NON-NLS-1$
String DISCRIMINATOR_FORMULA__VALUE = "value"; //$NON-NLS-1$
-
+
String GENERATED = PACKAGE_ + "Generated"; //$NON-NLS-1$
String GENERATED__VALUE = "value"; //$NON-NLS-1$
-
+
String GENERATION_TIME = PACKAGE_ + "GenerationTime"; //$NON-NLS-1$
String GENERATION_TIME_ = GENERATION_TIME + '.';
String GENERATION_TIME__NEVER = GENERATION_TIME_ + "NEVER"; //$NON-NLS-1$
String GENERATION_TIME__INSERT = GENERATION_TIME_ + "INSERT"; //$NON-NLS-1$
String GENERATION_TIME__ALWAYS = GENERATION_TIME_ + "ALWAYS"; //$NON-NLS-1$
+
+ String INDEX = PACKAGE_ + "Index"; //$NON-NLS-1$
+ String INDEX__NAME = "name"; //$NON-NLS-1$
+ String INDEX__COLUMN_NAMES = "columnNames"; //$NON-NLS-1$
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.JavaBasicMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Generated;
+import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateJavaBasicMapping extends JavaBasicMapping, Generated,
IndexHolder {
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -17,19 +17,24 @@
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;
/**
* @author Dmitry Geraskov
*
*/
public class HibernateJavaBasicMappingImpl extends AbstractJavaBasicMapping
-implements Generated {
+implements HibernateJavaBasicMapping {
protected GenerationTime specifiedGenerationTime;
+
+ protected Index index;
public HibernateJavaBasicMappingImpl(JavaPersistentAttribute parent) {
super(parent);
@@ -41,15 +46,29 @@
JPA.LOB,
JPA.TEMPORAL,
JPA.ENUMERATED,
- Hibernate.GENERATED);
+ Hibernate.GENERATED,
+ Hibernate.INDEX);
}
@Override
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) super.getJpaFactory();
+ }
+
+ @Override
protected void initialize() {
super.initialize();
this.specifiedGenerationTime = this.getResourceGenerationTime();
+ this.initializeIndex();
}
+ @Override
+ protected void update() {
+ super.update();
+ this.setGenerationTime_(this.getResourceGenerationTime());
+ this.updateIndex();
+ }
+
public GeneratedAnnotation getResourceGenerated() {
return (GeneratedAnnotation)
getResourcePersistentAttribute().getSupportingAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
}
@@ -90,11 +109,78 @@
this.specifiedGenerationTime = newGenerationTime;
firePropertyChanged(Generated.GENERATION_TIME_PROPERTY, oldValue, newGenerationTime);
}
+
+
- @Override
- protected void update() {
- super.update();
- this.setGenerationTime_(this.getResourceGenerationTime());
+ public void removeResourceIndex() {
+ getResourcePersistentAttribute().removeSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
}
+ // *** index
+
+ protected void initializeIndex() {
+ IndexAnnotation indexResource = getResourceIndex();
+ if (indexResource != null) {
+ this.index = buildIndex(indexResource);
+ }
+ }
+
+ protected void updateIndex() {
+ IndexAnnotation indexResource = getResourceIndex();
+ if (indexResource == null) {
+ if (getIndex() != null) {
+ setIndex(null);
+ }
+ }
+ else {
+ if (getIndex() == null) {
+ setIndex(buildIndex(indexResource));
+ }
+ else {
+ getIndex().update(indexResource);
+ }
+ }
+ }
+
+ public Index addIndex() {
+ if (getIndex() != null) {
+ throw new IllegalStateException("index already exists"); //$NON-NLS-1$
+ }
+ this.index = getJpaFactory().buildIndex(this);
+ IndexAnnotation indexResource = (IndexAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ this.index.initialize(indexResource);
+ firePropertyChanged(INDEX_PROPERTY, null, this.index);
+ return this.index;
+ }
+
+ public Index getIndex() {
+ return this.index;
+ }
+
+ protected void setIndex(Index newIndex) {
+ Index oldIndex = this.index;
+ this.index = newIndex;
+ firePropertyChanged(INDEX_PROPERTY, oldIndex, newIndex);
+ }
+
+ public void removeIndex() {
+ if (getIndex() == null) {
+ throw new IllegalStateException("index does not exist, cannot be removed");
//$NON-NLS-1$
+ }
+ Index oldIndex = this.index;
+ this.index = null;
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ firePropertyChanged(INDEX_PROPERTY, oldIndex, null);
+ }
+
+ protected Index buildIndex(IndexAnnotation indexResource) {
+ Index index = getJpaFactory().buildIndex(this);
+ index.initialize(indexResource);
+ return index;
+ }
+
+ protected IndexAnnotation getResourceIndex() {
+ 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/HibernateJavaIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -13,6 +13,7 @@
import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.IndexHolder;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
/**
@@ -20,6 +21,6 @@
*
*/
public interface HibernateJavaIdMapping extends HibernateIdMapping,
- JavaIdMapping, GenericGeneratorHolder {
+ 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 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -27,9 +27,11 @@
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.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;
/**
* @author Dmitry Geraskov
@@ -40,20 +42,41 @@
protected JavaGenericGenerator genericGenerator;
+ protected Index index;
+
/**
* @param parent
*/
public HibernateJavaIdMappingImpl(JavaPersistentAttribute parent) {
super(parent);
}
-
+
@Override
+ public Iterator<String> supportingAnnotationNames() {
+ return new CompositeIterator<String>(super.supportingAnnotationNames(),
+ Hibernate.INDEX);
+ }
+
+ @Override
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) super.getJpaFactory();
+ }
+
+ @Override
protected void initialize() {
super.initialize();
this.initializeGenericGenerator();
+ this.initializeIndex();
}
@Override
+ public void update() {
+ super.update();
+ updateGenericGenerator();
+ this.updateIndex();
+ }
+
+ @Override
public HibernateJavaColumn getColumn() {
return (HibernateJavaColumn) column;
}
@@ -119,12 +142,6 @@
firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,
newGenericGenerator);
}
- @Override
- public void update() {
- super.update();
- updateGenericGenerator();
- }
-
protected void updateGenericGenerator() {
GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
if (genericGeneratorResource == null) {
@@ -196,9 +213,71 @@
}
}
- @Override
- public HibernateJpaProject getJpaProject() {
- return (HibernateJpaProject) super.getJpaProject();
+ // *** index
+
+ protected void initializeIndex() {
+ IndexAnnotation indexResource = getResourceIndex();
+ if (indexResource != null) {
+ this.index = buildIndex(indexResource);
+ }
}
+
+ protected void updateIndex() {
+ IndexAnnotation indexResource = getResourceIndex();
+ if (indexResource == null) {
+ if (getIndex() != null) {
+ setIndex(null);
+ }
+ }
+ else {
+ if (getIndex() == null) {
+ setIndex(buildIndex(indexResource));
+ }
+ else {
+ getIndex().update(indexResource);
+ }
+ }
+ }
+
+ public Index addIndex() {
+ if (getIndex() != null) {
+ throw new IllegalStateException("index already exists"); //$NON-NLS-1$
+ }
+ this.index = getJpaFactory().buildIndex(this);
+ IndexAnnotation indexResource = (IndexAnnotation)
getResourcePersistentAttribute().addSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ this.index.initialize(indexResource);
+ firePropertyChanged(INDEX_PROPERTY, null, this.index);
+ return this.index;
+ }
+ public Index getIndex() {
+ return this.index;
+ }
+
+ protected void setIndex(Index newIndex) {
+ Index oldIndex = this.index;
+ this.index = newIndex;
+ firePropertyChanged(INDEX_PROPERTY, oldIndex, newIndex);
+ }
+
+ public void removeIndex() {
+ if (getIndex() == null) {
+ throw new IllegalStateException("index does not exist, cannot be removed");
//$NON-NLS-1$
+ }
+ Index oldIndex = this.index;
+ this.index = null;
+ this.getResourcePersistentAttribute().removeSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ firePropertyChanged(INDEX_PROPERTY, oldIndex, null);
+ }
+
+ protected Index buildIndex(IndexAnnotation indexResource) {
+ Index index = getJpaFactory().buildIndex(this);
+ index.initialize(indexResource);
+ return index;
+ }
+
+ protected IndexAnnotation getResourceIndex() {
+ return (IndexAnnotation)
this.getResourcePersistentAttribute().getSupportingAnnotation(IndexAnnotation.ANNOTATION_NAME);
+ }
+
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotation.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface IndexAnnotation extends Annotation {
+
+ String ANNOTATION_NAME = Hibernate.INDEX;
+
+ String getName();
+ void setName(String name);
+ String NAME_PROPERTY = Hibernate.INDEX__NAME;
+
+ String[] getColumnNames();
+ void setColumnNames(String[] columnNames);
+ String COLUMN_NAMES_PROPERTY = Hibernate.INDEX__COLUMN_NAMES;
+
+ TextRange getNameTextRange(CompilationUnit astRoot);
+ TextRange getColumnNamesTextRange(CompilationUnit astRoot);
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitArrayAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.StringArrayExpressionConverter;
+import org.eclipse.jpt.core.internal.utility.jdt.StringExpressionConverter;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.Attribute;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class IndexAnnotationImpl extends SourceAnnotation<Attribute>
+implements IndexAnnotation{
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER =
buildNameAdapter(DECLARATION_ANNOTATION_ADAPTER);
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private static DeclarationAnnotationElementAdapter<String[]> COLUMN_NAMES_ADAPTER
= buildColumnNamesAdapter(DECLARATION_ANNOTATION_ADAPTER);
+ private AnnotationElementAdapter<String[]> columnNamesAdapter;
+ private String[] columnNames;
+
+ protected IndexAnnotationImpl(JavaResourceNode parent, Attribute member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ this.nameAdapter = this.buildNameAdapter(NAME_ADAPTER);
+ this.columnNamesAdapter = this.buildColumnNamesAdapter(COLUMN_NAMES_ADAPTER);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.columnNames = this.buildColumnNames(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setColumnNames(this.buildColumnNames(astRoot));
+ }
+
+ public String[] getColumnNames() {
+ return columnNames;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String newName) {
+ if (this.attributeValueHasNotChanged(this.name, newName)) {
+ return;
+ }
+ String old = this.name;
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ this.firePropertyChanged(NAME_PROPERTY, old, newName);
+ }
+
+ public void setColumnNames(String[] newColumnNames) {
+ if (this.attributeValueHasNotChanged(this.columnNames, newColumnNames)) {
+ return;
+ }
+ String[] old = this.columnNames;
+ this.columnNames = newColumnNames;
+ this.columnNamesAdapter.setValue(newColumnNames);
+ this.firePropertyChanged(COLUMN_NAMES_PROPERTY, old, newColumnNames);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ private String[] buildColumnNames(CompilationUnit astRoot) {
+ return this.columnNamesAdapter.getValue(astRoot);
+ }
+
+ private static DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter adapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, NAME_PROPERTY,
true);
+ }
+
+ AnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ private static DeclarationAnnotationElementAdapter<String[]>
buildColumnNamesAdapter(DeclarationAnnotationAdapter adapter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String[]>(adapter,
COLUMN_NAMES_PROPERTY, false,
+ new StringArrayExpressionConverter(StringExpressionConverter.instance()));
+ }
+
+ AnnotationElementAdapter<String[]>
buildColumnNamesAdapter(DeclarationAnnotationElementAdapter<String[]> daea) {
+ return new ShortCircuitArrayAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(NAME_ADAPTER, astRoot);
+ }
+
+ public TextRange getColumnNamesTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(COLUMN_NAMES_ADAPTER, astRoot);
+ }
+
+ public static class IndexAnnotationDefinition implements AnnotationDefinition
+ {
+ // singleton
+ private static final IndexAnnotationDefinition INSTANCE = new
IndexAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private IndexAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member
attribute) {
+ return new IndexAnnotationImpl(parent, (Attribute) attribute);
+ }
+
+ public String getAnnotationName() {
+ return IndexAnnotation.ANNOTATION_NAME;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember arg0,
+ IAnnotation arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/IndexAnnotationImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateBasicMappingComposite.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -35,6 +35,7 @@
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;
/**
* Here the layout of this pane:
@@ -105,6 +106,7 @@
protected void initializeLayout(Composite container) {
initializeGeneralPane(container);
initializeTypePane(container);
+ initializeIndexPane(container);
}
@SuppressWarnings("unchecked")
@@ -124,6 +126,7 @@
new OptionalComposite(this, addSubPane(container, 4));
}
+
private void initializeTypePane(Composite container) {
container = addCollapsableSection(
@@ -166,7 +169,20 @@
null);
registerSubPane(new
EnumTypeComposite(buildEnumeratedConverterHolder(specifiedConverterHolder), container,
getWidgetFactory()));
}
+
+ @SuppressWarnings("unchecked")
+ private void initializeIndexPane(Composite container) {
+ if (getSubject() instanceof IndexHolder) {
+ container = addCollapsableSection(
+ container,
+ HibernateUIMappingMessages.Index_section_index
+ );
+ ((GridLayout) container.getLayout()).numColumns = 2;
+ new IndexHolderComposite((FormPane<? extends IndexHolder>) this, container);
+ }
+ }
+
private PropertyValueModel<HibernateColumn> buildColumnHolder() {
return new TransformationPropertyValueModel<BasicMapping,
HibernateColumn>(getSubjectHolder()) {
@Override
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateIdMappingComposite.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -29,6 +29,7 @@
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.IndexHolder;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
@@ -77,6 +78,15 @@
new GenerationComposite(this, addSubPane(container, 10));
}
+ if (getSubject() instanceof IndexHolder) {
+ container = addCollapsableSection(
+ container,
+ HibernateUIMappingMessages.Index_section_index
+ );
+ ((GridLayout) container.getLayout()).numColumns = 2;
+ new IndexHolderComposite((FormPane<? extends IndexHolder>) this, container);
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -45,6 +45,8 @@
public static String HibernateIdMappingComposite_genericGeneratorCheckBox;
public static String HibernateDiscriminatorColumnComposite_formula;
public static String BasicGeneralSection_generated;
+ public static String IndexHolderComposite_name;
+ public static String Index_section_index;
private HibernateUIMappingMessages() {}
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/IndexHolderComposite.java 2009-10-26
10:38:34 UTC (rev 18295)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.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;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class IndexHolderComposite extends FormPane<IndexHolder> {
+
+ private WritablePropertyValueModel<Index> indexHolder;
+
+ protected IndexHolderComposite(FormPane<? extends IndexHolder> parentPane,
+ Composite parent) {
+ super(parentPane, parent);
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.indexHolder = buildIndexHolder();
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ // Name widgets
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.IndexHolderComposite_name,
+ buildIndexNameHolder(),
+ null//TODO add help
+ );
+ }
+
+
+ protected final WritablePropertyValueModel<String> buildIndexNameHolder() {
+ return new PropertyAspectAdapter<Index, String>(this.indexHolder,
Index.INDEX_NAME) {
+ @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;
+ }
+
+ Index index =
+ (getSubject().getIndex() == null) ? getSubject().addIndex()
+ : getSubject().getIndex();
+ index.setName(value);
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value)) {//$NON-NLS-1$
+ value = null;
+ }
+ subject.setName(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Index> buildIndexHolder() {
+ return new PropertyAspectAdapter<IndexHolder, Index>(getSubjectHolder(),
IndexHolder.INDEX_PROPERTY) {
+ @Override
+ protected Index buildValue_() {
+ return this.subject.getIndex();
+ }
+ };
+ }
+}
+
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/IndexHolderComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-10-26
08:39:52 UTC (rev 18294)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-10-26
10:38:34 UTC (rev 18295)
@@ -22,4 +22,6 @@
HibernateIdMappingComposite_genericGeneratorSection=Generic Generator
HibernateIdMappingComposite_genericGeneratorCheckBox=Generic generator
HibernateDiscriminatorColumnComposite_formula=Formula:
-BasicGeneralSection_generated = Generation Time:
\ No newline at end of file
+BasicGeneralSection_generated = Generation Time:
+IndexHolderComposite_name=Name:
+Index_section_index=Index
\ No newline at end of file