Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2009-03-13 10:37:29 -0400
committerkmoore2009-03-13 10:37:29 -0400
commit2af93c622a0b9c95ece4a3b911e6b2016385815f (patch)
tree838b2eaa93cebd11da33034a50d3e7e2810c1cf4
parent62ac5b22f8de07d0992ab986e8343e97a142358d (diff)
downloadwebtools.dali-2af93c622a0b9c95ece4a3b911e6b2016385815f.tar.gz
webtools.dali-2af93c622a0b9c95ece4a3b911e6b2016385815f.tar.xz
webtools.dali-2af93c622a0b9c95ece4a3b911e6b2016385815f.zip
251293 - latest contribution for entity generation
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/Association.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/BaseEntityGenCustomizer.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenTable.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/PackageGenerator2.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/column.vm4
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/join.vm12
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/main.java.vm3
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToMany.vm4
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToOne.vm6
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToMany.vm4
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToOne.vm8
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/templates/entities/pk.java.vm3
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties27
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/EntitiesGenerator2.java159
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/AssociationTablesPage.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java266
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/SelectTableDialog.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TableGenPanel.java11
21 files changed, 320 insertions, 282 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/Association.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/Association.java
index aef08c4221..cf4eb38b02 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/Association.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/Association.java
@@ -190,7 +190,8 @@ public class Association implements java.io.Serializable
*/
public List<ORMGenColumn> getReferrerColumns() {
if (mReferrerCols == null) {
- mReferrerCols = getReferrerTable().getColumnsByNames(mReferrerColNames);
+ ORMGenTable referrerTable = getReferrerTable();
+ mReferrerCols = referrerTable.getColumnsByNames(mReferrerColNames);
}
return mReferrerCols;
}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/BaseEntityGenCustomizer.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/BaseEntityGenCustomizer.java
index 8b6191c3ca..15c4a9a899 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/BaseEntityGenCustomizer.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/BaseEntityGenCustomizer.java
@@ -190,7 +190,7 @@ public class BaseEntityGenCustomizer extends ORMGenCustomizer implements java.io
*/
public String genFetch(ORMGenTable table) {
String fetch = table.getDefaultFetch();
- if (fetch == null) {
+ if (fetch == null || ORMGenTable.DEFAULT_FETCH.equals( fetch)) {
return "";
} else if (fetch.equals(ORMGenTable.LAZY_FETCH)) {
return "FetchType.LAZY";
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java
index 24d42111c3..556977f603 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenColumn.java
@@ -9,8 +9,11 @@
******************************************************************************/
package org.eclipse.jpt.gen.internal2;
+import java.util.Collections;
+
import org.eclipse.jpt.db.Column;
import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.gen.internal.EntityGenTools;
import org.eclipse.jpt.gen.internal2.util.DTPUtil;
import org.eclipse.jpt.gen.internal2.util.StringUtil;
@@ -89,7 +92,8 @@ public class ORMGenColumn
public String getPropertyName() {
String name = customized(PROPERTY_NAME);
if (name == null) {
- name = StringUtil.columnNameToVarName(getName());
+ //name = StringUtil.columnNameToVarName(getName());
+ name = EntityGenTools.convertToUniqueJavaStyleAttributeName(getName(), Collections.EMPTY_SET);
}
return name;
}
@@ -117,8 +121,11 @@ public class ORMGenColumn
*/
public boolean isDefaultname(){
String propName = getPropertyName();
- String dbColumnName = getName();
- return propName.equalsIgnoreCase( dbColumnName );
+// String dbColumnName = getName();
+// return propName.equalsIgnoreCase( dbColumnName );
+ String annotationName = this.mCustomizer.getDatabaseAnnotationNameBuilder().
+ buildColumnAnnotationName(propName , this.mDbColumn );
+ return annotationName==null;
}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java
index 32496eb8ac..9ed46bc805 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenCustomizer.java
@@ -52,6 +52,7 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
* indicating that the value applies to any table.
*/
public static final String ANY_TABLE = "__anyTable__";
+ public static final String GENERATE_DDL_ANNOTATION = "generateDDLAnnotations";
/*the string used in the property name in mProps to indicate
* a null table value.*/
private static final String NULL_TABLE = "";
@@ -170,10 +171,7 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
mFile = file;
if (!file.exists()) {
- /*A hack to set the default to eager so thet app does not throw at runtime for new apps
- * (in case a lazy strategy is not developed yet). This is done instead of in ORMGenTable.getDefaultFetch
- * for backward compatibility.*/
- setProperty(ORMGenTable.DEFAULT_FETCH, ORMGenTable.EAGER_FETCH, ORMGenCustomizer.ANY_TABLE, null);
+ setProperty(ORMGenTable.DEFAULT_FETCH, ORMGenTable.DEFAULT_FETCH, ORMGenCustomizer.ANY_TABLE, null);
return;
}
InputStream istream = null;
@@ -276,6 +274,16 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
}
/**
+ * Returns {@link #GENERATE_DDL_ANNOTATION} indicating whether
+ * the optional DDL parameters like length, nullable, unqiue, etc should be generated
+ * in @Column annotation.
+ * defaults to false.
+ */
+ public boolean isGenerateDDLAnnotations() {
+ return "true".equals(getProperty(GENERATE_DDL_ANNOTATION, ANY_TABLE, null)); //defaults to false
+ }
+
+ /**
* Returns a property value.
*/
public String getProperty(String propertyName, String tableName, String colName) {
@@ -322,6 +330,16 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
public List<String> getTableNames() {
return mTableNames != null ? mTableNames : java.util.Collections.EMPTY_LIST;
}
+
+ /**
+ * Returns the fetch type annotation member value, or empty string
+ * if none.
+ * Empty string is returned instead of null because Velocity does not like null
+ * when used in #set.
+ */
+ public String genFetch(ORMGenTable table) {
+ return "";
+ }
/**
* Called when the table user selection is changed in the
* generation wizard.
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenTable.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenTable.java
index 11ab29a29a..e03c7d26a8 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenTable.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/ORMGenTable.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.jpt.db.Column;
import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.gen.internal.EntityGenTools;
import org.eclipse.jpt.gen.internal2.util.DTPUtil;
import org.eclipse.jpt.gen.internal2.util.StringUtil;
import org.eclipse.jpt.utility.JavaType;
@@ -85,9 +86,7 @@ public class ORMGenTable
public String getName() {
if( mDbTable == null )
return ORMGenCustomizer.ANY_TABLE;
- String annotationName = this.mCustomizer.getDatabaseAnnotationNameBuilder().
- buildTableAnnotationName(mDbTable.getName(), mDbTable);
- return annotationName != null ? annotationName : mDbTable.getName();
+ return mDbTable.getName();
}
public String getJoinTableAnnotationName(){
@@ -129,8 +128,9 @@ public class ORMGenTable
public String getClassName() {
String name = customized(CLASS_NAME);
if (name == null) {
- name = StringUtil.tableNameToVarName(getName());
- name = StringUtil.initUpper(name);
+ //name = StringUtil.tableNameToVarName(getName());
+ //name = StringUtil.initUpper(name);
+ name = EntityGenTools.convertToUniqueJavaStyleClassName( getName(), new ArrayList<String>() );
name = StringUtil.singularise(name);
}
return name;
@@ -533,11 +533,11 @@ public class ORMGenTable
* defaults to false.
*/
public boolean isGenerateDDLAnnotations() {
- return "true".equals(customized(GENERATE_DDL_ANNOTATION)); //defaults to false
+ return "true".equals(customized(ORMGenCustomizer.GENERATE_DDL_ANNOTATION)); //defaults to false
}
public void setGenerateDDLAnnotations(boolean generate) {
- setCustomizedBoolean(GENERATE_DDL_ANNOTATION, generate, false);
+ setCustomizedBoolean(ORMGenCustomizer.GENERATE_DDL_ANNOTATION, generate, false);
}
/**
@@ -623,9 +623,11 @@ public class ORMGenTable
* @return true
*/
public boolean isDefaultname(){
- String className = this.getClassName();
- String tableName = this.getDbTable().getName();
- return className.equalsIgnoreCase( tableName) ;
+ String entityName = getClassName();
+ String annotationName = this.mCustomizer.getDatabaseAnnotationNameBuilder().
+ buildTableAnnotationName(entityName, mDbTable);
+
+ return annotationName==null;
}
/**
@@ -790,6 +792,7 @@ public class ORMGenTable
public static final String FIELD_ACCESS = "field";
/*default fech constants. Note that these strings are used in the gen velocity templates.*/
+ public static final String DEFAULT_FETCH = "defaultFetch";
public static final String LAZY_FETCH = "lazy";
public static final String EAGER_FETCH = "eager";
@@ -820,9 +823,7 @@ public class ORMGenTable
private static final String SEQUENCE = "sequence";
private static final String COMPOSITE_KEY_CLASS_NAME = "compositeKeyClassName";
private static final String IMPLEMENT_EQUALS = "implementEquals";
- private static final String GENERATE_DDL_ANNOTATION = "generateDDLAnnotations";
private static final String ACCESS = "access";
- static final String DEFAULT_FETCH = "defaultFetch";
private static final String DEFAULT_COLLECTION_TYPE = "defaultCollectionType";
}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/PackageGenerator2.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/PackageGenerator2.java
index 3b85b09fd0..19692215d8 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/PackageGenerator2.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal2/PackageGenerator2.java
@@ -49,7 +49,11 @@ public class PackageGenerator2 {
private IJavaProject javaProject;
private ORMGenCustomizer customizer ;
+ private static OverwriteConfirmer overwriteConfirmer = null;
+ static public void setOverwriteConfirmer(OverwriteConfirmer confirmer){
+ overwriteConfirmer = confirmer;
+ }
/**
* @param customizer
* @param synchronizePersistenceXml
@@ -99,10 +103,12 @@ public class PackageGenerator2 {
String tableName = (String) iter.next();
ORMGenTable table = (ORMGenTable) customizer.getTable(tableName);
+ String className = table.getQualifiedClassName();
+
generateClass(table, templDir.getAbsolutePath(), progress);
progress.worked(1);
- genClasses.add(table.getQualifiedClassName());
+ genClasses.add( className );
/*
* add the composite key class to persistence.xml because some
* JPA provider(e.g. Kodo) requires it. Hibernate doesn't seem to care).
@@ -162,6 +168,11 @@ public class PackageGenerator2 {
IFolder javaPackageFolder = getJavaPackageFolder(table, monitor);
IFile javaFile = javaPackageFolder.getFile( table.getClassName() + ".java"); //$NON-NLS-1$
+ if( javaFile.exists() ){
+ if( overwriteConfirmer!=null && !overwriteConfirmer.overwrite(javaFile.getName()) )
+ return;
+ }
+
Properties vep = new Properties();
vep.setProperty("file.resource.loader.path", templateDirPath); //$NON-NLS-1$
VelocityEngine ve = new VelocityEngine();
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/column.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/column.vm
index 8bb49108b2..d8e7f32388 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/column.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/column.vm
@@ -18,7 +18,7 @@
@Temporal( TemporalType.$column.temporalType)
#end
#set ($members = "")
-#if ( !$column.default || $table.generateDDLAnnotations )
+#if ( !$column.default || $customizer.generateDDLAnnotations )
#set ($members = "name=$customizer.quote($column.name)")
#if (!$column.insertable)
#set ($members = "$members, insertable=false")
@@ -27,7 +27,7 @@
#set ($members = "$members, updatable=false")
#end
#end
-#if( $table.generateDDLAnnotations )
+#if( $customizer.generateDDLAnnotations )
#if ($column.unique)
#append($members "unique=true")
#end
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/join.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/join.vm
index ece3ff4c3f..32117c664c 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/join.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/join.vm
@@ -7,7 +7,7 @@
#if( !$referencedColumn.primaryKey )
#set ($members = "$members, referencedColumnName=$customizer.quote($referencedColumn.name)")
#end
-#if( $table.generateDDLAnnotations )
+#if( $customizer.generateDDLAnnotations )
#if ($column.unique && !$column.primaryKey)
#set ($members = "$members, unique=true")
#end
@@ -15,7 +15,7 @@
#set ($members = "$members, nullable=false")
#end
#end
-#if (!$role.association.joinTable && !$role.referrerTable.isColumnUpdateInsert($role, $column))
+#if ($customizer.generateDDLAnnotations && !$role.association.joinTable && !$role.referrerTable.isColumnUpdateInsert($role, $column))
#set ($members = "$members, insertable=false, updatable=false")
#end
@JoinColumn($members)#end
@@ -48,8 +48,16 @@
#if ($role.referrerColumns.size() == 1)
#set ($column = $role.referrerColumns.get(0))
#set ($referencedColumn = $role.getReferencedColumn(${column.name}))
+#set ($referencedTableName = $role.getReferencedTable().getName() )
+#set( $referencedTablePkName = $role.getReferencedTable().getPrimaryKeyColumn().name )
+#set( $computedJoinColumnName = "${role.propertyName}_${referencedTablePkName}" )
+#if($column.name.toUpperCase() != $computedJoinColumnName.toUpperCase() )
#joinColumn($column $referencedColumn)
+#elseif( $customizer.generateDDLAnnotations )
+ #joinColumn($column $referencedColumn)
+
+#end
#else
@JoinColumns({
#foreach ($column in $role.referrerColumns)
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/main.java.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/main.java.vm
index 28c861c844..0eb6c4b312 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/main.java.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/main.java.vm
@@ -1,6 +1,7 @@
#if ($table.package != "")
package ${table.package};
#end
+
import java.io.Serializable;
import javax.persistence.*;
@@ -9,7 +10,9 @@ import javax.persistence.*;
*
*/
@Entity
+#if( !${table.defaultname} || $customizer.generateDDLAnnotations)
@Table(name="${table.name}")
+#end
public class ${table.className} ${table.generateExtendsImplements()} {
private static final long serialVersionUID = 1L;
#####
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToMany.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToMany.vm
index fe3bfedd8b..affed63021 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToMany.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToMany.vm
@@ -4,11 +4,15 @@
#if ($role.association.bidirectional && !$role.isReferrerRole())##the owning side (either side for many-to-many)
#set ($members = $customizer.appendAnnotation("", "mappedBy", $role.oppositeRole.propertyName, true))
#set ($members = $customizer.appendAnnotation($members, "cascade", $customizer.genCascades($role), false))
+#if($customizer.genFetch($role.referrerTable)!="" && $customizer.genFetch($role.referrerTable)!="FetchType.LAZY")
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
@ManyToMany($members)
#else
#set ($members = $customizer.appendAnnotation("", "cascade", $customizer.genCascades($role), false))
+#if($customizer.genFetch($role.referrerTable)!="" && $customizer.genFetch($role.referrerTable)!="FetchType.LAZY")
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
@ManyToMany($members)
#parse("join.vm")
#end \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToOne.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToOne.vm
index 8253462972..7d279bbd6b 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToOne.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/manyToOne.vm
@@ -2,6 +2,12 @@
##Assumes that the context has a "role" object representing the generated AssociationRole
##
#set ($members = $customizer.appendAnnotation("", "cascade", $customizer.genCascades($role), false))
+#if( $customizer.genFetch($role.referrerTable)!= "" && $customizer.genFetch($role.referrerTable)!= "FetchType.EAGER")
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
+#if($members!="")
@ManyToOne($members)
+#else
+ @ManyToOne
+#end
#parse("join.vm") \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToMany.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToMany.vm
index bb89d5b885..46f15cbec9 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToMany.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToMany.vm
@@ -4,11 +4,15 @@
#if ($role.association.bidirectional)
#set ($members = $customizer.appendAnnotation("", "mappedBy", $role.oppositeRole.propertyName, true))
#set ($members = $customizer.appendAnnotation($members, "cascade", $customizer.genCascades($role), false))
+#if($customizer.genFetch($role.referrerTable)!="" && $customizer.genFetch($role.referrerTable) !="FetchType.LAZY")
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
@OneToMany($members)
#else
#set ($members = $customizer.appendAnnotation("", "cascade", $customizer.genCascades($role), false))
+#if($customizer.genFetch($role.referrerTable)!="" && $customizer.genFetch($role.referrerTable) !="FetchType.LAZY")
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
@OneToMany($members)
#parse("join.vm")
#end \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToOne.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToOne.vm
index 862c967802..7bd7519a96 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToOne.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/oneToOne.vm
@@ -4,11 +4,19 @@
#if ($role.association.bidirectional && !$role.isReferrerRole())##the owning side (either side for one-to-one)
#set ($members = $customizer.appendAnnotation("", "mappedBy", $role.oppositeRole.propertyName, true))
#set ($members = $customizer.appendAnnotation($members, "cascade", $customizer.genCascades($role), false))
+#if( $customizer.genFetch($role.referrerTable)!="" && $customizer.genFetch($role.referrerTable)!="FetchType.EAGER" )
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
@OneToOne($members)
#else
#set ($members = $customizer.appendAnnotation("", "cascade", $customizer.genCascades($role), false))
+#if( $customizer.genFetch($role.referrerTable)!="" && $customizer.genFetch($role.referrerTable)!="FetchType.EAGER" )
#set ($members = $customizer.appendAnnotation($members, "fetch", $customizer.genFetch($role.referrerTable), false))
+#end
+#if($members!="")
@OneToOne($members)
+#else
+ @OneToOne
+#end
#parse("join.vm")
#end \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/pk.java.vm b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/pk.java.vm
index 780037e8a9..1831098585 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/templates/entities/pk.java.vm
+++ b/jpa/plugins/org.eclipse.jpt.gen/templates/entities/pk.java.vm
@@ -1,6 +1,7 @@
#if ($table.package != "")
package ${table.package};
#end
+
import java.io.Serializable;
import javax.persistence.*;
@@ -8,7 +9,7 @@ import javax.persistence.*;
* The primary key class for the ${table.name} database table.
*
*/
-@Embeddable()
+@Embeddable
public class ${table.compositeKeyClassName} implements Serializable {
//default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties
index 9b8c42a7da..c9eda756e3 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties
@@ -11,14 +11,11 @@
cardinality=Car&dinality:
property=P&roperty:
cascade=&Cascade:
-databaseSettings=Database Settings
connection=&Connection:
schema=&Schema:
schemaInfo=(Note: You must have an active connection to select schema.)
addConnectionLink=Add connections...
-reconnectLink=Reconnect...
connectLink=Connect
-connectingMessage=Connecting...
manyToOne=&Many to one
manyToMany=Man&y to many
oneToMany=&One to many
@@ -29,21 +26,15 @@ manyToManyDesc=Each %s has many %s, and each %s has many %s.
add=&Add
remove=&Remove
-browse=B&rowse...
-
-showInSchemaViewer=Show in Schema Viewer
-showInEntityEditor=Show in Entity Relationship Editor
GenerateEntitiesWizard_generateEntities=Generate Custom Entities
GenerateEntitiesWizard_selectJPAProject=JPA Project Selection
GenerateEntitiesWizard_selectJPAProject_msg=Select a JPA project.
-GenerateEntitiesWizard_selectJPAProject_label=JPA projects in the workspace:
GenerateEntitiesWizard_tableSelectPage_selectTable=Select Tables
GenerateEntitiesWizard_tableSelectPage_chooseEntityTable=Select tables to generate entities from.
GenerateEntitiesWizard_tableSelectPage_synchronizeClasses=Synchronize classes listed in persistence.xml
-GenerateEntitiesWizard_tableSelectPage_copyJdbcDrive = Add JDBC driver to project classpath
GenerateEntitiesWizard_tableSelectPage_tables=&Tables:
GenerateEntitiesWizard_tableSelectPage_tableColumn=Table
@@ -69,19 +60,13 @@ GenerateEntitiesWizard_defaultTablePage_sequence=Sequence &name:
GenerateEntitiesWizard_defaultTablePage_sequenceNote=You can use the patterns %s and/or %s in the sequence name.\n\
These patterns will be replaced by the table name and the primary key \n\
column name when a table mapping is generated.
-GenerateEntitiesWizard_defaultTablePage_package=Java Package *:
-GenerateEntitiesWizard_defaultTablePage_baseClass=Base Class:
-GenerateEntitiesWizard_defaultTablePage_interfaces=Interfaces:
-GenerateEntitiesWizard_defaultTablePage_chooseInterfaces=Choose Class Interfaces
+
GenerateEntitiesWizard_tablesAndColumnsPage_title=Customize Individual Entities
GenerateEntitiesWizard_tablesAndColumnsPage_desc=Customize detail of individual entities by selecting the associated tables or columns and changing values in the editing panel.
GenerateEntitiesWizard_tablesAndColumnsPage_labelTableAndColumns=&Tables and columns
-GenerateEntitiesWizard_tablesAndColumnsPage_tableMapping=Table Mapping
-GenerateEntitiesWizard_tablesAndColumnsPage_columnMapping=Column Mapping
GenerateEntitiesWizard_tablePanel_className=&Class name:
-GenerateEntitiesWizard_tablePanel_implementEq=Implement equals/hashCode
GenerateEntitiesWizard_colPanel_genProp=Generate this property
GenerateEntitiesWizard_colPanel_colMapping=Column mapping
GenerateEntitiesWizard_colPanel_propName=Property &name:
@@ -92,15 +77,11 @@ GenerateEntitiesWizard_colPanel_getterScope=Getter Scope:
GenerateEntitiesWizard_colPanel_setterScope=Setter Scope:
GenerateEntitiesWizard_colPanel_colUpdateable=Column is &updatable
GenerateEntitiesWizard_colPanel_colInsertable=Column is &insertable
-GenerateEntitiesWizard_colPanel_useInToString=Use in toString
-GenerateEntitiesWizard_colPanel_useInEquals=Use in equals/hashCode
GenerateEntitiesWizard_newAssoc_title=Create New Association
-GenerateEntitiesWizard_newAssoc_exists=A similar association between %s and %s already exists.
GenerateEntitiesWizard_newAssoc_tablesPage_title=Association Tables
GenerateEntitiesWizard_newAssoc_tablesPage_desc=Specify the association tables.
-GenerateEntitiesWizard_tablesSelPage_newConn=New...
GenerateEntitiesWizard_newAssoc_tablesPage_assocKind=Association Kind
GenerateEntitiesWizard_newAssoc_tablesPage_assocTables=Association &tables:
GenerateEntitiesWizard_newAssoc_tablesPage_table1=Table &1:
@@ -121,8 +102,8 @@ GenerateEntitiesWizard_assocEditor_setRef=Generate a reference to a collection o
GenerateEntitiesWizard_assocEditor_tableJoin=Table &join:
GenerateEntitiesWizard_assocEditor_joinedWhen=The table rows are joined when:\n%s
GenerateEntitiesWizard_assocEditor_genAssoc=Generate &this association
-GenerateEntitiesWizard_fileWillBeOverwritten = Note that the generated .java files will *overwrite* existing files with the same name.
GenerateEntitiesWizard_doNotShowWarning = Don't show me this warning again
-GenerateEntitiesWizard_inconsistentConn=The selected connection url is different than the connection url specified in the "%s" file .
-
+selectCascadeDlgTitle=Select Cascade
+selectTableDlgTitle=Table Selection
+selectTableDlgDesc=&Select a table
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/EntitiesGenerator2.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/EntitiesGenerator2.java
index 5eb9f0eddd..65c4a08f78 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/EntitiesGenerator2.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/EntitiesGenerator2.java
@@ -73,164 +73,5 @@ public class EntitiesGenerator2 {
return Display.getCurrent().getActiveShell();
}
- // ********** overwrite confirmer **********
-
- static class OverwriteConfirmer implements org.eclipse.jpt.gen.internal2.OverwriteConfirmer {
- private Shell shell;
- private boolean overwriteAll = false;
- private boolean skipAll = false;
-
- OverwriteConfirmer(Shell shell) {
- super();
- this.shell = shell;
- }
-
- public boolean overwrite(final String className) {
- if (this.overwriteAll) {
- return true;
- }
- if (this.skipAll) {
- return false;
- }
- return this.promptUser(className);
- }
-
- private boolean promptUser(String className) {
- final OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.shell, className);
- // get on the UI thread synchronously, need feedback before continuing
- this.shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- if (dialog.getReturnCode() == Window.CANCEL) {
- throw new OperationCanceledException();
- }
- if (dialog.yes()) {
- return true;
- }
- if (dialog.yesToAll()) {
- this.overwriteAll = true;
- return true;
- }
- if (dialog.no()) {
- return false;
- }
- if (dialog.noToAll()) {
- this.skipAll = true;
- return false;
- }
- throw new IllegalStateException();
- }
-
- }
-
-
- // ********** overwrite dialog **********
-
- static class OverwriteConfirmerDialog extends Dialog {
- private final String className;
- private boolean yes = false;
- private boolean yesToAll = false;
- private boolean no = false;
- private boolean noToAll = false;
-
- OverwriteConfirmerDialog(Shell parent, String className) {
- super(parent);
- this.className = className;
- }
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(JptUiMessages.OverwriteConfirmerDialog_title);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- GridLayout gridLayout = (GridLayout) composite.getLayout();
- gridLayout.numColumns = 2;
-
- Label text = new Label(composite, SWT.LEFT);
- text.setText(NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, this.className));
- text.setLayoutData(new GridData());
-
- return composite;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
- this.createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false);
- this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
- this.createButton(parent, IDialogConstants.NO_TO_ALL_ID, IDialogConstants.NO_TO_ALL_LABEL, false);
- this.createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- switch (buttonId) {
- case IDialogConstants.YES_ID :
- this.yesPressed();
- break;
- case IDialogConstants.YES_TO_ALL_ID :
- this.yesToAllPressed();
- break;
- case IDialogConstants.NO_ID :
- this.noPressed();
- break;
- case IDialogConstants.NO_TO_ALL_ID :
- this.noToAllPressed();
- break;
- case IDialogConstants.CANCEL_ID :
- this.cancelPressed();
- break;
- default :
- break;
- }
- }
-
- private void yesPressed() {
- this.yes = true;
- this.setReturnCode(OK);
- this.close();
- }
-
- private void yesToAllPressed() {
- this.yesToAll = true;
- this.setReturnCode(OK);
- this.close();
- }
-
- private void noPressed() {
- this.no = true;
- this.setReturnCode(OK);
- this.close();
- }
-
- private void noToAllPressed() {
- this.noToAll = true;
- this.setReturnCode(OK);
- this.close();
- }
-
- boolean yes() {
- return this.yes;
- }
-
- boolean yesToAll() {
- return this.yesToAll;
- }
-
- boolean no() {
- return this.no;
- }
-
- boolean noToAll() {
- return this.noToAll;
- }
- }
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/AssociationTablesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/AssociationTablesPage.java
index e4d690d27f..b53a27e738 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/AssociationTablesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/AssociationTablesPage.java
@@ -112,7 +112,7 @@ public class AssociationTablesPage extends NewAssociationWizardPage {
}
});
- createLabel(assocTablesGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_assocTables );
+ createLabel(assocTablesGroup, 1, JptUiEntityGenMessages.GenerateEntitiesWizard_newAssoc_tablesPage_intermediateTable );
joinTableTextField = createText(assocTablesGroup, 1);
joinTableTextField.setEnabled(false);
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
index 65713b2337..de65babf0f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
@@ -15,7 +15,6 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
-import org.eclipse.core.internal.runtime.AdapterManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -23,12 +22,15 @@ import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jpt.core.EntityGeneratorDatabaseAnnotationNameBuilder;
@@ -50,25 +52,29 @@ import org.eclipse.jpt.ui.JptUiPlugin;
import org.eclipse.jpt.ui.internal.JptUiIcons;
import org.eclipse.jpt.ui.internal.JptUiMessages;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
-@SuppressWarnings("restriction")
public class GenerateEntitiesFromSchemaWizard extends Wizard
implements INewWizard {
public static final String HELP_CONTEXT_ID = JptUiPlugin.PLUGIN_ID + ".GenerateEntitiesFromSchemaWizard"; //$NON-NLS-1$
+ private static final String DONT_SHOW_OVERWRITE_WARNING_DIALOG = "DONT_SHOW_OVERWRITE_WARNING_DIALOG";
+
private JpaProject jpaProject;
private IStructuredSelection selection;
@@ -160,8 +166,8 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard
*/
public ORMGenCustomizer createORMGenCustomizer(Schema schema){
JpaPlatform jpaPlatform = this.jpaProject.getJpaPlatform();
- Object obj = AdapterManager.getDefault().getAdapter( jpaPlatform, ORMGenCustomizer.class );
- if( obj != null ){
+ Object obj = Platform.getAdapterManager().getAdapter( jpaPlatform, ORMGenCustomizer.class );
+ if( obj != null && obj instanceof ORMGenCustomizer){
customizer = (ORMGenCustomizer) obj ;
customizer.init(getCustomizationFile(), schema );
}else{
@@ -205,10 +211,8 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard
this.synchronizePersistenceXml = this.tablesSelectorPage.synchronizePersistenceXml();
- if( WarnOverwriteDialog.shouldShowDialog() ){
- if( !this.openConfirmDialog() )
- return false;
- }
+ if(shouldShowOverwriteWarning())
+ PackageGenerator2.setOverwriteConfirmer( new OverwriteConfirmer());
WorkspaceJob genEntitiesJob = new GenerateEntitiesJob( this.jpaProject, getCustomizer() );
@@ -244,11 +248,199 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- PackageGenerator2.generate(jpaProject.getJavaProject(),this.customizer, monitor);
+ try{
+ PackageGenerator2.generate(jpaProject.getJavaProject(),this.customizer, monitor);
+ }catch(OperationCanceledException e){
+ //user canceled generation
+ }
return Status.OK_STATUS;
}
}
+ public static boolean shouldShowOverwriteWarning(){
+ IEclipsePreferences pref = new InstanceScope().getNode( JptUiPlugin.PLUGIN_ID);
+ boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ;
+ return( ret );
+ }
+
+ // ********** overwrite confirmer **********
+
+ static class OverwriteConfirmer implements org.eclipse.jpt.gen.internal2.OverwriteConfirmer {
+ private boolean overwriteAll = false;
+ private boolean skipAll = false;
+
+ OverwriteConfirmer() {
+ }
+
+ public boolean overwrite(final String className) {
+ if (this.overwriteAll) {
+ return true;
+ }
+ if (this.skipAll) {
+ return false;
+ }
+ return this.promptUser(className);
+ }
+
+ private boolean promptUser(final String className) {
+ // get on the UI thread synchronously, need feedback before continuing
+ final boolean ret[]=new boolean[1];
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ final OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(Display.getCurrent().getActiveShell(), className);
+ dialog.open();
+ if (dialog.getReturnCode() == Window.CANCEL) {
+ //throw new OperationCanceledException();
+ skipAll = true;
+ ret[0] = false;
+ return;
+ }
+ if (dialog.yes()) {
+ ret[0] = true;
+ }
+ if (dialog.yesToAll()) {
+ overwriteAll = true;
+ ret[0] = true;
+ }
+ if (dialog.no()) {
+ ret[0] = false;
+ }
+ if (dialog.noToAll()) {
+ skipAll = true;
+ ret[0] = false;
+ }
+ }
+ });
+ return ret[0];
+ }
+
+ }
+
+
+ // ********** overwrite dialog **********
+
+ static class OverwriteConfirmerDialog extends Dialog {
+ private final String className;
+ private boolean yes = false;
+ private boolean yesToAll = false;
+ private boolean no = false;
+ private boolean noToAll = false;
+
+ OverwriteConfirmerDialog(Shell parent, String className) {
+ super(parent);
+ this.className = className;
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(JptUiMessages.OverwriteConfirmerDialog_title);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridLayout gridLayout = (GridLayout) composite.getLayout();
+ gridLayout.numColumns = 1;
+
+ Label text = new Label(composite, SWT.LEFT);
+ text.setText(NLS.bind(JptUiMessages.OverwriteConfirmerDialog_text, this.className));
+ text.setLayoutData(new GridData());
+
+ createDontShowControl(composite);
+
+ return composite;
+ }
+
+ protected Control createDontShowControl(Composite composite) {
+ final Button checkbox = new Button( composite, SWT.CHECK );
+ checkbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_doNotShowWarning );
+ checkbox.setSelection(false);
+ final IEclipsePreferences pref = new InstanceScope().getNode( JptUiPlugin.PLUGIN_ID);
+ checkbox.setLayoutData( new GridData(GridData.FILL_BOTH) );
+ checkbox.addSelectionListener(new SelectionListener (){
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetSelected(SelectionEvent e) {
+ boolean b = checkbox.getSelection();
+ pref.putBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, b);
+ }
+ });
+ return checkbox;
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
+ this.createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false);
+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
+ this.createButton(parent, IDialogConstants.NO_TO_ALL_ID, IDialogConstants.NO_TO_ALL_LABEL, false);
+ this.createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId) {
+ switch (buttonId) {
+ case IDialogConstants.YES_ID :
+ this.yesPressed();
+ break;
+ case IDialogConstants.YES_TO_ALL_ID :
+ this.yesToAllPressed();
+ break;
+ case IDialogConstants.NO_ID :
+ this.noPressed();
+ break;
+ case IDialogConstants.NO_TO_ALL_ID :
+ this.noToAllPressed();
+ break;
+ case IDialogConstants.CANCEL_ID :
+ this.cancelPressed();
+ break;
+ default :
+ break;
+ }
+ }
+
+ private void yesPressed() {
+ this.yes = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ private void yesToAllPressed() {
+ this.yesToAll = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ private void noPressed() {
+ this.no = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ private void noToAllPressed() {
+ this.noToAll = true;
+ this.setReturnCode(OK);
+ this.close();
+ }
+
+ boolean yes() {
+ return this.yes;
+ }
+
+ boolean yesToAll() {
+ return this.yesToAll;
+ }
+
+ boolean no() {
+ return this.no;
+ }
+
+ boolean noToAll() {
+ return this.noToAll;
+ }
+ }
+
private DatabaseAnnotationNameBuilder buildDatabaseAnnotationNameBuilder() {
return new LocalDatabaseAnnotationNameBuilder(this.jpaProject.getJpaPlatform().getEntityGeneratorDatabaseAnnotationNameBuilder());
@@ -358,59 +550,5 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard
this.setWindowTitle( JptUiEntityGenMessages.GenerateEntitiesWizard_generateEntities);
}
-
- public boolean openConfirmDialog() {
- Shell parent = Display.getDefault().getActiveShell();
- String title = JptUiEntityGenMessages.WarningDialogTitle;
- String message = JptUiEntityGenMessages.GenerateEntitiesWizard_fileWillBeOverwritten;
- WarnOverwriteDialog dialog = new WarnOverwriteDialog(parent, title, null, // accept
- // the
- // default
- // window
- // icon
- message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL }, 0); // OK is the
- // default
- return dialog.open() == 0;
- }
-
-}
-/**
- * A simple dialog displaying warning message that existing files would be overwritten
- */
-class WarnOverwriteDialog extends MessageDialog {
- static final String DONT_SHOW_OVERWRITE_WARNING = "DONT_SHOW_OVERWRITE_WARNING"; //$NON-NLS-1$
-
- public WarnOverwriteDialog (Shell parentShell, String dialogTitle,
- Image dialogTitleImage, String dialogMessage, int dialogImageType,
- String[] dialogButtonLabels, int defaultIndex) {
- super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType,
- dialogButtonLabels, defaultIndex);
- }
-
- @Override
- protected Control createCustomArea(Composite composite) {
- final Button checkbox = new Button( composite, SWT.CHECK );
- checkbox.setText( JptUiEntityGenMessages.GenerateEntitiesWizard_doNotShowWarning );
- checkbox.setSelection(false);
- final IEclipsePreferences pref = new InstanceScope().getNode( JptUiPlugin.PLUGIN_ID);
- checkbox.setLayoutData( new GridData(GridData.FILL_BOTH) );
- checkbox.addSelectionListener(new SelectionListener (){
- public void widgetDefaultSelected(SelectionEvent e) {}
- public void widgetSelected(SelectionEvent e) {
- boolean b = checkbox.getSelection();
- if( b ){
- pref.putBoolean( DONT_SHOW_OVERWRITE_WARNING, true);
- }
- }
- });
- return checkbox;
- }
-
- public static boolean shouldShowDialog(){
- IEclipsePreferences pref = new InstanceScope().getNode( JptUiPlugin.PLUGIN_ID);
- boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING, true) ;
- return( ret );
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java
index 4a90b55e22..fe7f2756e9 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java
@@ -12,8 +12,6 @@ public class JptUiEntityGenMessages {
private static final String BUNDLE_NAME = "jpt_ui_entity_gen"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptUiEntityGenMessages.class;
public static String GenerateEntitiesWizard_generateEntities;
- public static String GenerateEntitiesWizard_fileWillBeOverwritten;
- public static String WarningDialogTitle;
public static String GenerateEntitiesWizard_doNotShowWarning;
public static String GenerateEntitiesWizard_selectJPAProject;
public static String GenerateEntitiesWizard_selectJPAProject_msg;
@@ -73,6 +71,7 @@ public class JptUiEntityGenMessages {
public static String GenerateEntitiesWizard_newAssoc_tablesPage_assocTables;
public static String GenerateEntitiesWizard_newAssoc_tablesPage_table1;
public static String GenerateEntitiesWizard_newAssoc_tablesPage_table2;
+ public static String GenerateEntitiesWizard_newAssoc_tablesPage_intermediateTable;
public static String GenerateEntitiesWizard_newAssoc_colsPage_title;
public static String GenerateEntitiesWizard_newAssoc_colsPage_desc;
public static String GenerateEntitiesWizard_newAssoc_colsPage_label;
@@ -85,8 +84,8 @@ public class JptUiEntityGenMessages {
public static String oneToOne;
public static String manyToMany;
//select table dialog
- public static String AnnotateJavaClassWizard_classMappingPage_selectTableDlgTitle;
- public static String AnnotateJavaClassWizard_classMappingPage_selectTableDlgDesc;
+ public static String selectTableDlgTitle;
+ public static String selectTableDlgDesc;
//individual table and column gen properties
public static String GenerateEntitiesWizard_tablesAndColumnsPage_title;
public static String GenerateEntitiesWizard_tablesAndColumnsPage_desc;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/SelectTableDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/SelectTableDialog.java
index 66311e56f4..0e071b3c90 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/SelectTableDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/SelectTableDialog.java
@@ -47,8 +47,8 @@ public class SelectTableDialog extends ElementListSelectionDialog {
public void removeListener(ILabelProviderListener listener) {}
});
- this.setTitle( JptUiEntityGenMessages.AnnotateJavaClassWizard_classMappingPage_selectTableDlgTitle );//
- this.setMessage( JptUiEntityGenMessages.AnnotateJavaClassWizard_classMappingPage_selectTableDlgDesc);//
+ this.setTitle( JptUiEntityGenMessages.selectTableDlgTitle );//
+ this.setMessage( JptUiEntityGenMessages.selectTableDlgDesc);//
}
public SelectTableDialog(Shell shell, Schema schema){
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TableGenPanel.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TableGenPanel.java
index c0c4293cc7..9b3d487dac 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TableGenPanel.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TableGenPanel.java
@@ -49,6 +49,7 @@ class TableGenPanel
private Button entityAccessField;
private Button entityAccessProperty;
+ private Button associationFetchDefault;
private Button associationFetchEager;
private Button associationFetchLazy;
@@ -161,7 +162,10 @@ class TableGenPanel
Composite parent = new Composite( composite, SWT.NONE);
parent.setLayout(new RowLayout());
SWTUtil.fillColumns( parent , 3);
-
+ associationFetchDefault = new Button( parent, SWT.RADIO );
+ associationFetchDefault.setText( "Default");
+ associationFetchDefault.setData( ORMGenTable.DEFAULT_FETCH );
+
associationFetchEager = new Button( parent, SWT.RADIO );
associationFetchEager.setText( "&Eager");
associationFetchEager.setData( ORMGenTable.EAGER_FETCH );
@@ -171,6 +175,7 @@ class TableGenPanel
associationFetchLazy.setData( ORMGenTable.LAZY_FETCH );
AssociationFetchListener associationFetchListener = new AssociationFetchListener();
+ associationFetchDefault.addSelectionListener( associationFetchListener );
associationFetchLazy.addSelectionListener( associationFetchListener );
associationFetchEager.addSelectionListener( associationFetchListener );
@@ -243,7 +248,9 @@ class TableGenPanel
if(associationFetchLazy!=null && associationFetchEager != null ){
String defaultFetch = mTable.getDefaultFetch();
- if( ORMGenTable.EAGER_FETCH.equals( defaultFetch ) )
+ if( ORMGenTable.DEFAULT_FETCH.equals( defaultFetch ) )
+ associationFetchDefault.setSelection(true);
+ else if( ORMGenTable.EAGER_FETCH.equals( defaultFetch ) )
associationFetchEager.setSelection(true);
else
associationFetchLazy.setSelection(true);

Back to the top