Author: dgeraskov
Date: 2009-06-30 07:46:40 -0400 (Tue, 30 Jun 2009)
New Revision: 16283
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.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/mapping/details/HibernateUIMappingMessages.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
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.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/platform/HibernateJpaUiFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4527
GenericGenerator parameters and composite
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context;
+
+import org.eclipse.jpt.core.context.JpaContextNode;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface Parameter extends JpaContextNode {
+
+ String getName();
+ void setName(String value);
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ String getValue();
+ void setValue(String value);
+ String VALUE_PROPERTY = "value"; //$NON-NLS-1$
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.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/GenericGenerator.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
import org.eclipse.jpt.core.context.Generator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
/**
* @author Dmitry Geraskov
@@ -22,7 +25,42 @@
String getStrategy();
- void setSpecifiedStrategy(String value);
+ void setStrategy(String value);
String GENERIC_STRATEGY_PROPERTY = "genericStrategyProperty"; //$NON-NLS-1$
-
+
+
+ //************************ parameters ***********************
+
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Return a list iterator of the parameters. This will not be null.
+ */
+ <T extends Parameter> ListIterator<T> parameters();
+
+ /**
+ * Return the number of parameters.
+ */
+ int parametersSize();
+
+ /**
+ * Add a parameter to the generator and return the object representing it.
+ */
+ Parameter addParameter(int index);
+
+ /**
+ * Remove the parameter from the generator.
+ */
+ void removeParameter(int index);
+
+ /**
+ * Remove the parameter at the index from the query.
+ */
+ void removeParameter(Parameter queryParameter);
+
+ /**
+ * Move the parameter from the source index to the target index.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
}
\ 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/java/GenericGeneratorAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -10,10 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
/**
* @author Dmitry Geraskov
@@ -34,9 +37,46 @@
* Set to null to remove the strategy element.
*/
void setStrategy(String strategy);
- String STRATEGY_PROPERTY = "strategyProperty"; //$NON-NLS-1$
+ String STRATEGY_PROPERTY = "strategyProperty"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ * Return an empty iterator if the element does not exist in Java.
+ */
+ ListIterator<ParameterAnnotation> parameters();
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ int parametersSize();
/**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ ParameterAnnotation parameterAt(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ int indexOfParameter(ParameterAnnotation parameter);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ ParameterAnnotation addParameter(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator
annotation.
+ */
+ void removeParameter(int index);
+
+ /**
* Return the {@link TextRange} for the strategy element. If the strategy element
* does not exist return the {@link TextRange} for the GenericGenerator annotation.
*/
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -10,13 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+import java.util.Vector;
+
import org.eclipse.jdt.core.IAnnotation;
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;
import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationContainer;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.TextRange;
@@ -24,7 +29,13 @@
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.NestableParameterAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
+import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceParameterAnnotation;
/**
* @author Dmitry Geraskov
@@ -43,13 +54,17 @@
private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER
= buildStrategyAdapter();
+ final ParametersAnnotationContainer parametersContainer = new
ParametersAnnotationContainer();
+
private String name;
private String strategy;
+ final Vector<NestableParameterAnnotation> parameters = new
Vector<NestableParameterAnnotation>();
+
private Integer initialValue = 1;
- private Integer allocationSize = 1;
+ private Integer allocationSize = 50;
/**
* @param parent
@@ -63,9 +78,16 @@
public void initialize(CompilationUnit astRoot) {
this.name = this.name(astRoot);
- this.strategy = this.strategy(astRoot);
+ this.strategy = this.strategy(astRoot);
+ AnnotationContainerTools.initialize(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() {
return ANNOTATION_NAME;
}
@@ -106,9 +128,6 @@
return this.getElementTextRange(STRATEGY_ADAPTER, astRoot);
}
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSize()
- */
public Integer getAllocationSize() {
return allocationSize;
}
@@ -153,11 +172,6 @@
}
// ********** java annotations -> persistence model **********
- public void updateFromJava(CompilationUnit astRoot) {
- this.setStrategy(this.strategy(astRoot));
- this.setName(this.name(astRoot));
- }
-
protected String strategy(CompilationUnit astRoot) {
//TODO: get Generator instead of String
//use buildJavaGenericGenerator method before thi will be done
@@ -166,12 +180,8 @@
protected String name(CompilationUnit astRoot) {
return this.nameAdapter.getValue(astRoot);
- }
+ }
- public void update(CompilationUnit astRoot) {
- updateFromJava(astRoot);
- }
-
// ********** static methods **********
private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() {
return
ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER,
Hibernate.GENERIC_GENERATOR__NAME, false);
@@ -231,4 +241,130 @@
}
}
+ //************************ parameters ***********************
+
+ public ParameterAnnotation addParameter(int index) {
+ return (NestableParameterAnnotation)
AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation addParameterInternal() {
+ NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
+ this.parameters.add(parameter);
+ return parameter;
+ }
+
+ NestableParameterAnnotation buildParameter(int index) {
+ return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member,
this.daa, index);
+ }
+
+ ListIterator<NestableParameterAnnotation> nestableParameters() {
+ return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
+ }
+
+ void parameterAdded(int index, NestableParameterAnnotation parameter) {
+ this.fireItemAdded(PARAMETERS_LIST, index, parameter);
+ }
+
+ NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.parameters, targetIndex,
sourceIndex).get(targetIndex);
+ }
+
+ void parameterMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(PARAMETERS_LIST, targetIndex, sourceIndex);
+ }
+
+ public int indexOfParameter(ParameterAnnotation parameter) {
+ return this.parameters.indexOf(parameter);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex,
this.parametersContainer);
+ }
+
+ public ParameterAnnotation parameterAt(int index) {
+ return this.parameters.get(index);
+ }
+
+ public ListIterator<ParameterAnnotation> parameters() {
+ return new CloneListIterator<ParameterAnnotation>(this.parameters);
+ }
+
+ public int parametersSize() {
+ return parameters.size();
+ }
+
+ public void removeParameter(int index) {
+ AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation removeParameterInternal(int index) {
+ return this.parameters.remove(index);
+ }
+
+ void hintRemoved(int index, NestableParameterAnnotation parameter) {
+ this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
+ }
+
+ /**
+ * adapt the AnnotationContainer interface to the override's join columns
+ */
+ class ParametersAnnotationContainer
+ implements AnnotationContainer<NestableParameterAnnotation>
+ {
+ public String getContainerAnnotationName() {
+ return GenericGeneratorAnnotationImpl.this.getAnnotationName();
+ }
+
+ 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 getNestableAnnotationName() {
+ return ParameterAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
+ return GenericGeneratorAnnotationImpl.this.nestableParameters();
+ }
+
+ public int nestedAnnotationsSize() {
+ return GenericGeneratorAnnotationImpl.this.parametersSize();
+ }
+
+ public NestableParameterAnnotation addNestedAnnotationInternal() {
+ return GenericGeneratorAnnotationImpl.this.addParameterInternal();
+ }
+
+ public void nestedAnnotationAdded(int index, NestableParameterAnnotation
nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
+ }
+
+ public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int
sourceIndex) {
+ return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex,
sourceIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
+ }
+
+ public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
+ return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, NestableParameterAnnotation
nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.hintRemoved(index, nestedAnnotation);
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+
+
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -10,11 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import org.eclipse.jpt.core.context.GeneratorHolder;
+
/**
* @author Dmitry Geraskov
*
*/
-public interface GenericGeneratorHolder {
+public interface GenericGeneratorHolder extends GeneratorHolder {
String GENERIC_GENERATOR_PROPERTY = "genericGenerator"; //$NON-NLS-1$
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaParameter extends AbstractJavaJpaContextNode implements
JavaParameter {
+
+ protected String name;
+
+ protected String value;
+
+ protected ParameterAnnotation resourceParameter;
+
+ public HibernateJavaParameter(JavaGenericGenerator parent) {
+ super(parent);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String newName) {
+ String oldName = this.name;
+ this.name = newName;
+ this.resourceParameter.setName(newName);
+ firePropertyChanged(Parameter.NAME_PROPERTY, oldName, newName);
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String newValue) {
+ String oldValue = this.value;
+ this.value = newValue;
+ this.resourceParameter.setValue(newValue);
+ firePropertyChanged(Parameter.VALUE_PROPERTY, oldValue, newValue);
+ }
+
+ public void initialize(ParameterAnnotation resourceParameter) {
+ this.resourceParameter = resourceParameter;
+ this.name = resourceParameter.getName();
+ this.value = resourceParameter.getValue();
+ }
+
+ public void update(ParameterAnnotation resourceParameter) {
+ this.resourceParameter = resourceParameter;
+ this.setName(resourceParameter.getName());
+ this.setValue(resourceParameter.getValue());
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.resourceParameter.getTextRange(astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.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/JavaGenericGenerator.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
+import org.eclipse.jpt.core.utility.TextRange;
/**
* @author Dmitry Geraskov
@@ -18,6 +22,15 @@
*/
public interface JavaGenericGenerator extends JavaGenerator, GenericGenerator {
+ @SuppressWarnings("unchecked")
+ ListIterator<JavaParameter> parameters();
+
+ JavaParameter addParameter(int index);
+
+ // **************** validation *********************************************
+
+ TextRange getNameTextRange(CompilationUnit astRoot);
+
void initialize(GenericGeneratorAnnotation generator);
void update(GenericGeneratorAnnotation generator);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -20,12 +21,16 @@
import org.eclipse.jpt.core.context.Generator;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaGenerator;
-import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
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.Messages;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
/**
* @author Dmitry Geraskov
@@ -36,10 +41,12 @@
private String strategy;
- protected GeneratorAnnotation generatorResource;
+ protected final List<JavaParameter> parameters;
- private static List<String> generatorClasses = new ArrayList<String>();
+ protected GenericGeneratorAnnotation generatorResource;
+ public static List<String> generatorClasses = new ArrayList<String>();
+
//see org.hibernate.id.IdentifierGeneratorFactory.GENERATORS
static {
generatorClasses.add( "uuid");
@@ -61,17 +68,14 @@
*/
public JavaGenericGeneratorImpl(JavaJpaContextNode parent) {
super(parent);
+ this.parameters = new ArrayList<JavaParameter>();
}
-
- protected GenericGeneratorAnnotation getGeneratorResource() {
- return (GenericGeneratorAnnotation) generatorResource;
- }
public int getDefaultInitialValue() {
return GenericGenerator.DEFAULT_INITIAL_VALUE;
}
- protected GeneratorAnnotation getResourceGenerator() {
+ protected GenericGeneratorAnnotation getResourceGenerator() {
return this.generatorResource;
}
@@ -81,6 +85,7 @@
this.specifiedInitialValue = generator.getInitialValue();
this.specifiedAllocationSize = generator.getAllocationSize();
this.strategy = generator.getStrategy();
+ this.initializeParameters();
}
public void update(GenericGeneratorAnnotation generator) {
@@ -89,7 +94,8 @@
this.setSpecifiedInitialValue_(generator.getInitialValue());
this.setSpecifiedAllocationSize_(generator.getAllocationSize());
this.setSpecifiedStrategy_(generator.getStrategy());
- this.getPersistenceUnit().addGenerator(this);
+ this.updateParameters();
+ this.getPersistenceUnit().addGenerator(this);
}
public void setName(String name) {
@@ -125,10 +131,10 @@
return strategy;
}
- public void setSpecifiedStrategy(String strategy) {
+ public void setStrategy(String strategy) {
String oldStrategy = this.strategy;
this.strategy = strategy;
- getGeneratorResource().setStrategy(strategy);
+ getResourceGenerator().setStrategy(strategy);
firePropertyChanged(GENERIC_STRATEGY_PROPERTY, oldStrategy, strategy);
}
@@ -146,9 +152,6 @@
return null;
}
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode#validate(java.util.List,
org.eclipse.wst.validation.internal.provisional.core.IReporter,
org.eclipse.jdt.core.dom.CompilationUnit)
- */
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
super.validate(messages, reporter, astRoot);
@@ -213,5 +216,89 @@
message.setLineNo(lineNum);
return message;
}
+
+ @Override
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) super.getJpaFactory();
+ }
+
+ //************************ parameters ***********************
+ public JavaParameter addParameter(int index) {
+ JavaParameter parameter = getJpaFactory().buildJavaParameter(this);
+ this.parameters.add(index, parameter);
+ this.getResourceGenerator().addParameter(index);
+ this.fireItemAdded(GenericGenerator.PARAMETERS_LIST, index, parameter);
+ return parameter;
+ }
+
+ protected void addParameter(int index, JavaParameter parameter) {
+ addItemToList(index, parameter, this.parameters, GenericGenerator.PARAMETERS_LIST);
+ }
+
+ protected void addParameter(JavaParameter parameter) {
+ addParameter(this.parameters.size(), parameter);
+ }
+
+ public void removeParameter(Parameter parameter) {
+ removeParameter(this.parameters.indexOf(parameter));
+ }
+
+ public void removeParameter(int index) {
+ JavaParameter removedParameter = this.parameters.remove(index);
+ this.getResourceGenerator().removeParameter(index);
+ fireItemRemoved(GenericGenerator.PARAMETERS_LIST, index, removedParameter);
+ }
+
+ protected void removeParameter_(JavaParameter parameter) {
+ removeItemFromList(parameter, this.parameters, GenericGenerator.PARAMETERS_LIST);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.parameters, targetIndex, sourceIndex);
+ this.getResourceGenerator().moveParameter(targetIndex, sourceIndex);
+ fireItemMoved(GenericGenerator.PARAMETERS_LIST, targetIndex, sourceIndex);
+ }
+
+ public ListIterator<JavaParameter> parameters() {
+ return new CloneListIterator<JavaParameter>(this.parameters);
+ }
+
+ public int parametersSize() {
+ return parameters.size();
+ }
+
+ protected void initializeParameters() {
+ ListIterator<ParameterAnnotation> resourceParameters =
this.generatorResource.parameters();
+
+ while(resourceParameters.hasNext()) {
+ this.parameters.add(createParameter(resourceParameters.next()));
+ }
+ }
+
+ protected void updateParameters() {
+ ListIterator<JavaParameter> contextParameters = parameters();
+ ListIterator<ParameterAnnotation> resourceParameters =
this.generatorResource.parameters();
+
+ while (contextParameters.hasNext()) {
+ JavaParameter parameter = contextParameters.next();
+ if (resourceParameters.hasNext()) {
+ parameter.update(resourceParameters.next());
+ }
+ else {
+ removeParameter_(parameter);
+ }
+ }
+
+ while (resourceParameters.hasNext()) {
+ addParameter(createParameter(resourceParameters.next()));
+ }
+ }
+
+ protected JavaParameter createParameter(ParameterAnnotation resourceParameter) {
+ JavaParameter parameter = getJpaFactory().buildJavaParameter(this);
+ parameter.initialize(resourceParameter);
+ return parameter;
+ }
+
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaParameter extends Parameter, JavaJpaContextNode {
+
+ void initialize(ParameterAnnotation parameterResource);
+
+ /**
+ * Update the JavaParameter context model object to match the ParameterAnnotation
+ * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
+ */
+ void update(ParameterAnnotation parameterResource);
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.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/NestableParameterAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface NestableParameterAnnotation extends
+ ParameterAnnotation, NestableAnnotation {
+
+ // combine two interfaces
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.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/ParameterAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,55 @@
+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;
+
+/**
+ * Corresponds to the JPA annotation
+ * org.hibernate.annotations.Parameter
+ */
+
+public interface ParameterAnnotation extends Annotation {
+ String ANNOTATION_NAME = Hibernate.GENERATOR_PARAMETER;
+
+ /**
+ * Corresponds to the 'name' element of the ParameterAnnotation annotation.
+ * Return null if the element does not exist in the annotation
+ */
+ String getName();
+ String NAME_PROPERTY = Hibernate.GENERATOR_PARAMETER__NAME;
+
+ /**
+ * Corresponds to the 'name' element of the ParameterAnnotation annotation.
+ * Setting to null will remove the element.
+ */
+ void setName(String name);
+
+ /**
+ * Return the {@link TextRange} for the 'name' element. If the element
+ * does not exist return the {@link TextRange} for the QueryHint annotation.
+ */
+ TextRange getNameTextRange(CompilationUnit astRoot);
+
+
+ /**
+ * Corresponds to the 'value' element of the ParameterAnnotation annotation.
+ * Return null if the element does not exist in the annotation
+ */
+ String getValue();
+ String VALUE_PROPERTY = Hibernate.GENERATOR_PARAMETER__VALUE;
+
+ /**
+ * Corresponds to the 'value' element of the ParameterAnnotation annotation.
+ * Setting to null will remove the element.
+ */
+ void setValue(String value);
+
+ /**
+ * Return the {@link TextRange} for the 'value' element. If the element
+ * does not exist return the {@link TextRange} for the QueryHint annotation.
+ */
+ TextRange getValueTextRange(CompilationUnit astRoot);
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.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/SourceParameterAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import
org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import
org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class SourceParameterAnnotation extends SourceAnnotation<Member> implements
+ NestableParameterAnnotation {
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String>
valueDeclarationAdapter;
+ private final AnnotationElementAdapter<String> valueAdapter;
+ private String value;
+
+
+ public SourceParameterAnnotation(JavaResourceNode parent, Member member,
IndexedDeclarationAnnotationAdapter idaa) {
+ super(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa));
+ this.nameDeclarationAdapter = this.buildNameAdapter(idaa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.valueDeclarationAdapter = this.buildValueAdapter(idaa);
+ this.valueAdapter = this.buildAdapter(this.valueDeclarationAdapter);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ private AnnotationElementAdapter<String>
buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ private DeclarationAnnotationElementAdapter<String>
buildNameAdapter(DeclarationAnnotationAdapter adapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter,
NAME_PROPERTY);
+ }
+
+ private DeclarationAnnotationElementAdapter<String>
buildValueAdapter(DeclarationAnnotationAdapter adapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter,
VALUE_PROPERTY);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.value = this.buildValue(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setValue(this.buildValue(astRoot));
+ }
+
+ public IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+
+ // ********** ParameterAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** value
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ if (this.attributeValueHasNotChanged(this.value, value)) {
+ return;
+ }
+ String old = this.value;
+ this.value = value;
+ this.valueAdapter.setValue(value);
+ this.firePropertyChanged(VALUE_PROPERTY, old, value);
+ }
+
+ private String buildValue(CompilationUnit astRoot) {
+ return this.valueAdapter.getValue(astRoot);
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.valueDeclarationAdapter, astRoot);
+ }
+
+
+ // ********** NestableAnnotation implementation **********
+
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ ParameterAnnotation oldParameter = (ParameterAnnotation) oldAnnotation;
+ this.setName(oldParameter.getName());
+ this.setValue(oldParameter.getValue());
+ }
+
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ // ********** static methods **********
+
+ public static SourceParameterAnnotation createGenericGeneratorParameter(JavaResourceNode
parent, Member member, DeclarationAnnotationAdapter genericGeneratorAdapter, int index)
{
+ return new SourceParameterAnnotation(parent, member,
buildGenericGeneratorParameterAnnotationAdapter(genericGeneratorAdapter, index));
+ }
+
+ private static IndexedDeclarationAnnotationAdapter
buildGenericGeneratorParameterAnnotationAdapter(DeclarationAnnotationAdapter
genericGeneratorAdapter, int index) {
+ return new NestedIndexedDeclarationAnnotationAdapter(genericGeneratorAdapter,
Hibernate.GENERIC_GENERATOR__PARAMETERS, index, Hibernate.GENERATOR_PARAMETER);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.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/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2009-06-30
11:46:40 UTC (rev 16283)
@@ -18,7 +18,8 @@
org.eclipse.ui.ide,
org.eclipse.jpt.core,
org.eclipse.jpt.ui,
- org.eclipse.jpt.utility
+ org.eclipse.jpt.utility,
+ org.eclipse.jpt.db;bundle-version="1.2.100"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor.0
Added:
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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.java.details;
+
+import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.eclipse.jpt.ui.WidgetFactory;
+import org.eclipse.jpt.ui.internal.java.details.JavaEntityComposite;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import
org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGeneratorsComposite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaEntityComposite<HibernateJavaEntity> extends
JavaEntityComposite {
+
+ /**
+ * @param subjectHolder
+ * @param parent
+ * @param widgetFactory
+ */
+ public HibernateJavaEntityComposite(PropertyValueModel<? extends JavaEntity>
subjectHolder,
+ Composite parent, WidgetFactory widgetFactory) {
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeGeneratorsPane(Composite container) {
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_primaryKeyGenerationSection
+ );
+
+ new HibernateGeneratorsComposite(this, container);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.context.GeneratorHolder;
+import org.eclipse.jpt.ui.internal.mappings.details.GeneratorComposite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+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;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenericGeneratorComposite extends GeneratorComposite<GenericGenerator>
{
+
+ public GenericGeneratorComposite(Pane<? extends GeneratorHolder> parentPane,
Composite parent) {
+ super(parentPane, parent);
+ }
+
+ @Override
+ protected GenericGenerator buildGenerator(GeneratorHolder subject) {
+ return ((GenericGeneratorHolder)subject).addGenericGenerator();
+ }
+
+ protected GenericGenerator buildGenerator() {
+ return this.buildGenerator(this.getSubject());
+ }
+
+ @Override
+ protected GenericGenerator getGenerator(GeneratorHolder subject) {
+ return ((GenericGeneratorHolder)subject).getGenericGenerator();
+ }
+
+ @Override
+ protected String getPropertyName() {
+ return GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY;
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ // Name widgets
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_name,
+ buildGeneratorNameHolder(),
+ null//TODO add help
+ );
+
+ addLabeledEditableCombo(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_strategy,
+ new SimpleListValueModel<String>(JavaGenericGeneratorImpl.generatorClasses),
+ buildStrategyHolder(),
+ StringConverter.Default.<String>instance(),
+ null);//TODO add help
+
+ new ParametersComposite(this, container);
+ }
+
+ protected WritablePropertyValueModel<String> buildStrategyHolder() {
+ return new PropertyAspectAdapter<GeneratorHolder, String>(getSubjectHolder(),
+ GenericGenerator.GENERIC_STRATEGY_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return ((GenericGeneratorHolder)subject).getGenericGenerator() == null ?
+ null : ((GenericGeneratorHolder)subject).getGenericGenerator().getStrategy();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value))value = null; //$NON-NLS-1$
+ GenericGenerator generator =
((GenericGeneratorHolder)subject).getGenericGenerator();
+ if (generator == null){
+ generator = ((GenericGeneratorHolder)subject).addGenericGenerator();
+ }
+ generator.setStrategy(value);
+ }
+ };
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/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 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.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.java.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);
+ }
+
+ protected void initializeGenericGeneratorPane(Composite container) {
+
+ // Sequence Generator sub-section
+ container = addCollapsableSubSection(
+ addSubPane(container, 10),
+ "Generic Generator",
+ genericGeneratorExpansionStateHolder
+ );
+
+ // Sequence Generator check box
+ Button genericGeneratorCheckBox = addCheckBox(
+ addSubPane(container, 5),
+ "Generic generator",
+ buildGenericGeneratorBooleanHolder(),
+ null//TODO add help
+ );
+
+ // Sequence Generator pane
+ new GenericGeneratorComposite(
+ this,
+ addSubPane(container, 0, genericGeneratorCheckBox.getBorderWidth() + 16)
+ );
+
+ }
+
+ private WritablePropertyValueModel<Boolean> buildGenericGeneratorBooleanHolder()
{
+ return new PropertyAspectAdapter<GeneratorHolder, Boolean>(getSubjectHolder(),
GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return ((GenericGeneratorHolder)subject).getGenericGenerator() != null;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+
+ if (value && (((GenericGeneratorHolder)subject).getGenericGenerator() ==
null)) {
+ ((GenericGeneratorHolder)subject).addGenericGenerator();
+ }
+ else if (!value && (((GenericGeneratorHolder)subject).getGenericGenerator()
!= null)) {
+ ((GenericGeneratorHolder)subject).removeGenericGenerator();
+ }
+ }
+ };
+ }
+
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateUIMappingMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.messages";
//$NON-NLS-1$
+
+ public static String GenericGeneratorComposite_name;
+ public static String GenericGeneratorComposite_strategy;
+
+ private HibernateUIMappingMessages() {}
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, HibernateUIMappingMessages.class);
+ }
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,351 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import java.util.ListIterator;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.core.context.GeneratorHolder;
+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.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;
+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.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ParametersComposite extends Pane<GeneratorHolder> {
+
+ private PropertyValueModel<Generator> generatorHolder;
+
+ private WritablePropertyValueModel<Parameter> parameterHolder;
+
+ /**
+ * Creates a new <code>ParametersComposite</code>.
+ *
+ * @param parentPane The parent pane of this one
+ * @param parent The parent container
+ */
+ public ParametersComposite(Pane<? extends GeneratorHolder> parentPane,
+ Composite container) {
+
+ super(parentPane,container);
+ }
+
+ protected GenericGenerator getGenericGenerator(){
+ return ((GenericGeneratorHolder) getSubject()).getGenericGenerator();
+ }
+
+ private PropertyValueModel<Boolean> buildPaneEnableHolder() {
+ return new TransformationPropertyValueModel<GeneratorHolder,
Boolean>(getSubjectHolder()) {
+ @Override
+ protected Boolean transform(GeneratorHolder generator) {
+ return (generator != null);
+ }
+ };
+ }
+
+ private Adapter buildParameterAdapter() {
+ return new AddRemoveTablePane.AbstractAdapter() {
+ public void addNewItem(ObjectListSelectionModel listSelectionModel) {
+ Parameter parameter =
getGenericGenerator().addParameter(getGenericGenerator().parametersSize());
+ parameterHolder.setValue(parameter);
+ }
+
+ public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
+ for (Object item : listSelectionModel.selectedValues()) {
+ getGenericGenerator().removeParameter((Parameter) item);
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Parameter> buildParameterHolder() {
+ return new SimplePropertyValueModel<Parameter>();
+ };
+
+ private ITableLabelProvider buildParameterLabelProvider() {
+ return new TableLabelProvider();
+ }
+
+ private ListValueModel<Parameter> buildParameterListHolder() {
+ return new ListAspectAdapter<Generator, Parameter>(
+ generatorHolder,
+ GenericGenerator.PARAMETERS_LIST) {
+ @Override
+ protected ListIterator<Parameter> listIterator_() {
+ GenericGenerator generator = (GenericGenerator) subject;
+ if (generator == null ){
+ return EmptyListIterator.instance();
+ } else {
+ return generator.parameters();
+ }
+ }
+
+ @Override
+ protected int size_() {
+ GenericGenerator generator = (GenericGenerator) subject;
+ return generator == null ? 0 : generator.parametersSize();
+ }
+ };
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.generatorHolder = buildGeneratorHolder();
+ parameterHolder = buildParameterHolder();
+ }
+
+ private PropertyValueModel<Generator> buildGeneratorHolder() {
+ return new PropertyAspectAdapter<GeneratorHolder, Generator>(getSubjectHolder(),
+ GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY) {
+ @Override
+ protected Generator buildValue_() {
+ return ParametersComposite.this.getGenericGenerator();
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ TablePane tablePane = new TablePane(container);
+ installPaneEnabler(tablePane);
+ }
+
+ private PaneEnabler installPaneEnabler(TablePane tablePane) {
+ return new PaneEnabler(buildPaneEnableHolder(), tablePane);
+ }
+
+ private static class ParameterColumnAdapter implements ColumnAdapter<Parameter> {
+
+ static final int COLUMN_COUNT = 2;
+ static final int NAME_COLUMN_INDEX = 0;
+ static final int VALUE_COLUMN_INDEX = 1;
+
+ private WritablePropertyValueModel<String> buildNameHolder(Parameter subject) {
+ return new PropertyAspectAdapter<Parameter, String>(Parameter.NAME_PROPERTY,
subject) {
+ @Override
+ protected String buildValue_() {
+ return subject.getName();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setName(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<?> buildValueHolder(Parameter subject) {
+ return new PropertyAspectAdapter<Parameter, String>(Parameter.VALUE_PROPERTY,
subject) {
+ @Override
+ protected String buildValue_() {
+ return subject.getValue();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setValue(value);
+ }
+ };
+ }
+
+ public WritablePropertyValueModel<?>[] cellModels(Parameter subject) {
+ WritablePropertyValueModel<?>[] models = new
WritablePropertyValueModel<?>[COLUMN_COUNT];
+ models[NAME_COLUMN_INDEX] = buildNameHolder(subject);
+ models[VALUE_COLUMN_INDEX] = buildValueHolder(subject);
+ return models;
+ }
+
+ public int columnCount() {
+ return COLUMN_COUNT;
+ }
+
+ public String columnName(int columnIndex) {
+
+ switch (columnIndex) {
+ case ParameterColumnAdapter.NAME_COLUMN_INDEX: {
+ return JptUiMappingsMessages.QueryHintsComposite_nameColumn;
+ }
+
+ case ParameterColumnAdapter.VALUE_COLUMN_INDEX: {
+ return JptUiMappingsMessages.QueryHintsComposite_valueColumn;
+ }
+
+ default: {
+ return null;
+ }
+ }
+ }
+ }
+
+ private class TableLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+
+ Parameter parameter = (Parameter) element;
+ String value = "";
+
+ switch (columnIndex) {
+ case ParameterColumnAdapter.NAME_COLUMN_INDEX: {
+ value = parameter.getName();
+ break;
+ }
+
+ case ParameterColumnAdapter.VALUE_COLUMN_INDEX: {
+ value = parameter.getValue();
+ break;
+ }
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+ }
+
+ private class TablePane extends AddRemoveTablePane<GeneratorHolder> {
+
+ private TablePane(Composite parent) {
+ super(ParametersComposite.this,
+ parent,
+ buildParameterAdapter(),
+ buildParameterListHolder(),
+ parameterHolder,
+ buildParameterLabelProvider());
+ }
+
+ private CellEditor[] buildCellEditors(Table table) {
+ return new CellEditor[] {
+ new TextCellEditor(table),
+ new TextCellEditor(table)
+ };
+ }
+
+ private ICellModifier buildCellModifier() {
+ return new ICellModifier() {
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ Parameter parameter = (Parameter) element;
+ String value = "";
+
+ if (property == Parameter.NAME_PROPERTY) {
+ value = parameter.getName();
+ }
+ else if (property == Parameter.VALUE_PROPERTY) {
+ value = parameter.getValue();
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ Parameter parameter;
+
+ if (element instanceof TableItem) {
+ TableItem tableItem = (TableItem) element;
+ parameter = (Parameter) tableItem.getData();
+ }
+ else {
+ parameter = (Parameter) element;
+ }
+
+ if (property == Parameter.NAME_PROPERTY) {
+ parameter.setName(value.toString());
+ }
+ else if (property == Parameter.VALUE_PROPERTY) {
+ parameter.setValue(value.toString());
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ColumnAdapter<?> buildColumnAdapter() {
+ return new ParameterColumnAdapter();
+ }
+
+ private String[] buildColumnProperties() {
+ return new String[] {
+ Parameter.NAME_PROPERTY,
+ Parameter.VALUE_PROPERTY
+ };
+ }
+
+ @Override
+ protected void initializeMainComposite(Composite container,
+ Adapter adapter,
+ ListValueModel<?> listHolder,
+ WritablePropertyValueModel<?>
selectedItemHolder,
+ IBaseLabelProvider labelProvider,
+ String helpId) {
+
+ super.initializeMainComposite(
+ container,
+ adapter,
+ listHolder,
+ selectedItemHolder,
+ labelProvider,
+ helpId
+ );
+
+ Table table = getMainControl();
+
+ TableViewer tableViewer = new TableViewer(table);
+ tableViewer.setCellEditors(buildCellEditors(table));
+ tableViewer.setCellModifier(buildCellModifier());
+ tableViewer.setColumnProperties(buildColumnProperties());
+ }
+ }
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/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
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-06-30
11:46:40 UTC (rev 16283)
@@ -0,0 +1,2 @@
+GenericGeneratorComposite_strategy=Strategy:
+GenericGeneratorComposite_name=Name:
\ No newline at end of file
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-06-30
11:44:20 UTC (rev 16282)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-06-30
11:46:40 UTC (rev 16283)
@@ -14,8 +14,10 @@
import java.util.List;
import java.util.ListIterator;
+import org.eclipse.jpt.core.context.java.JavaEntity;
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.GenericJpaUiFactory;
import
org.eclipse.jpt.ui.internal.persistence.details.GenericPersistenceUnitGeneralComposite;
@@ -26,6 +28,8 @@
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.ui.internal.java.details.HibernateJavaEntityComposite;
import
org.jboss.tools.hibernate.jpt.ui.internal.persistence.details.HibernatePropertiesComposite;
/**
@@ -53,6 +57,12 @@
return pages.listIterator();
}
+
+ @Override
+ public JpaComposite createJavaEntityComposite(PropertyValueModel<JavaEntity>
subjectHolder,
+ Composite parent, WidgetFactory widgetFactory) {
+ return new HibernateJavaEntityComposite<HibernateJavaEntity>(subjectHolder,
parent, widgetFactory);
+ }
private PropertyValueModel<BasicHibernateProperties> buildBasicHolder(
PropertyValueModel<HibernatePersistenceUnit> subjectHolder) {