You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2015/08/06 13:26:19 UTC
[1/3] empire-db git commit: prepare release 2.4.4
Repository: empire-db
Updated Branches:
refs/heads/master 46d3e32e2 -> 83302f083
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/logo.png
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/logo.png b/empire-db-eclipse-codegen/src/main/resources/icons/logo.png
new file mode 100644
index 0000000..5be2395
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/logo.png differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/save.png
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/save.png b/empire-db-eclipse-codegen/src/main/resources/icons/save.png
new file mode 100644
index 0000000..3f7664f
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/save.png differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/testConnection.gif
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/testConnection.gif b/empire-db-eclipse-codegen/src/main/resources/icons/testConnection.gif
new file mode 100644
index 0000000..864034f
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/testConnection.gif differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/uncheck_all.gif
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/uncheck_all.gif b/empire-db-eclipse-codegen/src/main/resources/icons/uncheck_all.gif
new file mode 100644
index 0000000..f6b9f8a
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/uncheck_all.gif differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/lang/messages_en.properties
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/lang/messages_en.properties b/empire-db-eclipse-codegen/src/main/resources/lang/messages_en.properties
new file mode 100644
index 0000000..b4ffc89
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/lang/messages_en.properties
@@ -0,0 +1,141 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+dialog.title=Empire db tool
+dialog.ok=Create entities
+dialog.next=Next
+dialog.back=Back
+dialog.close=Close
+dialog.errorFieldRequired=Field required
+dialog.errorFieldRequired.msg=Field {0} is required. Please fill it out.
+dialog.delete=Delete configuration
+dialog.delete.msg=Do you really want to delete this configuration?
+dialog.save=Save configuration
+dialog.save.msg=Do you want to save the current configuration?
+dialog.passwordMismatch=Password mismatch
+dialog.passwordMismatch.msg=The password does not match!
+dialog.tables.title=Table selection
+dialog.tables.discription=Select the tables to create
+dialog.tables.connect=Connect database
+dialog.tables.finish=OK
+
+existingConfigs=Existing configurations
+configTitle=Config title
+dbConnection=Database connection:
+dbConnectionType=Connection Type
+testConnection=Test connection
+dbServer=Database server
+dbPort=Database port
+dbSid=Database name
+jdbcUser=Database username
+jdbcPassword=Database password
+jdbcPasswordConfirm=Confirm password
+connectionFailed=Connection failed!
+connectionSuccess=Connection success!
+dbTablePattern=Table pattern
+targetFolder=Target folder
+packageName=Package name
+tablePackageName=Table package name
+viewPackageName=View package name
+recordPackageName=Record package name
+dbClassName=Database class name
+tableBaseName=Table base name
+viewBaseName=View base name
+recordBaseName=Record base name
+tableNamePrefix=Table prefix
+requiredParams=Package parameter:
+targetFolder=Target folder
+packageName=Package name
+tablePackageName=Table package name
+viewPackageName=View package name
+recordPackageName=Record package name
+
+# class name config
+classParameter=Class name configuration:
+dbClassName=Database class name
+tableBaseName=Table base name
+viewBaseName=View base name
+recordBaseName=Record base name
+tableNamePrefix=Table name prefix
+tableClassPrefix=Table class prefix
+tableClassSuffix=Table class suffix
+viewNamePrefix=View name prefix
+viewClassPrefix=View class prefix
+viewClassSuffix=View class suffix
+columnNamePrefix=Column name prefix
+
+# schema options
+schemaOptions=Schema options:
+dbCatalog=Catalog name
+dbSchema=Schema
+timestampColumn=Timestamp Column name
+flagGroup=Misc
+nestTables=Nest tables
+nestViews=Nest views
+createRecordProperties=Create Record Properties
+preserverCharCase=Preserver char case
+preserveRelationNames=Preserve relation names
+##############################################
+# tool tips
+##############################################
+tooltip.testConnection=Test your current connection configuration
+tooltip.dbConnectionType=
+tooltip.dbServer=
+tooltip.dbPort=
+tooltip.dbSid=
+tooltip.jdbcUser=
+tooltip.jdbcPassword=
+tooltip.jdbcPasswordConfirm=
+tooltip.dbTablePattern=
+tooltip.targetFolder=
+tooltip.packageName=
+tooltip.tablePackageName=
+tooltip.viewPackageName=
+tooltip.recordPackageName=
+tooltip.dbClassName=
+tooltip.tableBaseName=
+tooltip.viewBaseName=
+tooltip.recordBaseName=
+tooltip.tableNamePrefix=
+tooltip.targetFolder=
+tooltip.packageName=
+tooltip.tablePackageName=
+tooltip.viewPackageName=
+tooltip.recordPackageName=
+
+# class name config
+tooltip.dbClassName=Name of the generated database class. This class extends DBDatabase.
+tooltip.tableBaseName=Target name of the generated table class. This class extends DBTable and is the base class for all generated individual table classes.
+tooltip.viewBaseName=Target name of the generated view class. This class extends DBView and is the base class for all generated individual view classes.
+tooltip.recordBaseName=
+tooltip.tableNamePrefix=
+tooltip.tableClassPrefix=
+tooltip.tableClassSuffix=
+tooltip.viewNamePrefix=
+tooltip.viewClassPrefix=
+tooltip.viewClassSuffix=
+tooltip.columnNamePrefix=
+
+# schema options
+tooltip.dbCatalog=name of the database catalog.
+tooltip.dbSchema=name of the database schema.
+tooltip.timestampColumn=name of the table pattern.
+tooltip.nestTables=if TRUE table classes should be declared as inner classes of DBDatabase.\r\n if FALSE table classes should be declared as top level classes.
+tooltip.nestViews=if TRUE view classes should be declared as inner classes of DBDatabase.<br/>if FALSE view classes should be declared as top level classes.
+tooltip.createRecordProperties=if TRUE record classes should have a getter and setter for each field.<br/>Otherwise getters / setters are omitted.
+tooltip.preserverCharCase=
+tooltip.preserveRelationNames=
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/BaseRecord.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/BaseRecord.vm b/empire-db-eclipse-codegen/src/main/resources/templates/BaseRecord.vm
new file mode 100644
index 0000000..06b0563
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/BaseRecord.vm
@@ -0,0 +1,41 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+package ${recordPackageName};
+
+import org.apache.empire.db.DBRecord;
+import ${tablePackageName}.${baseTableClassName};
+
+
+public abstract class ${baseRecordClassName}<T extends ${baseTableClassName}> extends DBRecord {
+
+ private static final long serialVersionUID = 1L;
+
+ public ${baseRecordClassName}(T table) {
+ super(table);
+ }
+
+ /**
+ * Returns the table this record is based upon.
+ * @return The table this record is based upon.
+ */
+ @SuppressWarnings("unchecked")
+ public T getTable() {
+ return (T)super.getRowSet();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/BaseTable.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/BaseTable.vm b/empire-db-eclipse-codegen/src/main/resources/templates/BaseTable.vm
new file mode 100644
index 0000000..83e090c
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/BaseTable.vm
@@ -0,0 +1,31 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+package $tablePackageName;
+
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTable;
+
+public class ${baseTableClassName} extends DBTable {
+
+ private static final long serialVersionUID = 1L;
+
+ public ${baseTableClassName}(String name, DBDatabase db) {
+ super(name, db);
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/BaseView.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/BaseView.vm b/empire-db-eclipse-codegen/src/main/resources/templates/BaseView.vm
new file mode 100644
index 0000000..c6c934f
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/BaseView.vm
@@ -0,0 +1,31 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+package $viewPackageName;
+
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBView;
+
+public abstract class ${baseViewClassName} extends DBView {
+
+ private static final long serialVersionUID = 1L;
+
+ public ${baseViewClassName}(String name, DBDatabase db) {
+ super(name, db);
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/Database.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/Database.vm b/empire-db-eclipse-codegen/src/main/resources/templates/Database.vm
new file mode 100644
index 0000000..69590a3
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/Database.vm
@@ -0,0 +1,136 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+package $basePackageName;
+
+#if($nestTables == true || $nestViews == true)
+import org.apache.empire.data.DataType;
+#end
+#if($nestViews == true)
+import org.apache.empire.db.DBCommandExpr;
+#end
+import org.apache.empire.db.DBDatabase;
+#if($preserveRelationNames == true)
+import org.apache.empire.db.DBRelation;
+#end
+#if($nestTables == true)
+import org.apache.empire.db.DBTableColumn;
+#end
+#if($nestViews == true)
+import org.apache.empire.exceptions.NotImplementedException;
+#end
+
+#if($nestTables==false || !($tablePackageName.equalsIgnoreCase($basePackageName)))
+import $tablePackageName.*;
+// $tablePackageName vs $basePackageName
+#end
+#if($nestViews==false || ($viewPackageName!=$basePackageName))
+import $viewPackageName.*;
+#end
+
+public class $dbClassName extends DBDatabase {
+
+ private static $dbClassName instance;
+ private static final long serialVersionUID = 1L;
+
+#foreach($table in $database.tables)
+ #set($tblClass=$parser.getTableClassName($table.name))
+ public final $tblClass $parser.getTableName($table) = new $tblClass(this);
+#end
+
+#foreach($view in $database.views)
+ #set($viewClass=$parser.getViewClassName($view.name))
+ public final $viewClass $parser.getViewName($view) = new $viewClass(this);
+#end
+
+ /**
+ * Returns the instance of the database.
+ * @return
+ */
+ public static $dbClassName get() {
+ if (instance == null) {
+ instance = new ${dbClassName}();
+ }
+ return instance;
+ }
+
+ /**
+ * Default constructor for the $dbClassName.
+ */
+ private ${dbClassName}() {
+
+ #if($preserveRelationNames == true)
+ // Define foreign key relations
+#foreach ($relation in $database.relations)
+ addRelation("$relation.name", new DBRelation.DBReference[] {
+#foreach ($reference in $relation.references)
+#if($foreach.isLast())
+ ${parser.getRowsetName($reference.sourceColumn.rowSet)}.${parser.getColumnName($reference.sourceColumn)}.referenceOn(${parser.getRowsetName($reference.targetColumn.rowSet)}.${parser.getColumnName($reference.targetColumn)}) });
+#else
+ ${parser.getRowsetName($reference.sourceColumn.rowSet)}.${parser.getColumnName($reference.sourceColumn)}.referenceOn(${parser.getRowsetName($reference.targetColumn.rowSet)}.${parser.getColumnName($reference.targetColumn)}),
+#end
+#end
+#end
+ // foreign key relations done
+ }
+ #else
+ // Define foreign key relations
+#foreach ($relation in $database.relations)
+#if($relation.references.size()==1)
+#foreach ($reference in $relation.references)
+ addRelation( ${parser.getRowsetName($reference.sourceColumn.rowSet)}.${parser.getColumnName($reference.sourceColumn)}.referenceOn(${parser.getRowsetName($reference.targetColumn.rowSet)}.${parser.getColumnName($reference.targetColumn)}));
+#end
+#else
+#foreach ($reference in $relation.references)
+#if($foreach.isFirst())
+ addRelation( ${parser.getRowsetName($reference.sourceColumn.rowSet)}.${parser.getColumnName($reference.sourceColumn)}.referenceOn(${parser.getRowsetName($reference.targetColumn.rowSet)}.$parser.getColumnName($reference.targetColumn)),
+#else
+#if($foreach.isLast())
+ ${parser.getRowsetName($reference.sourceColumn.rowSet)}.${parser.getColumnName($reference.sourceColumn)}.referenceOn(${parser.getRowsetName($reference.targetColumn.rowSet)}.$parser.getColumnName($reference.targetColumn)));
+#else
+ ${parser.getRowsetName($reference.sourceColumn.rowSet)}.${parser.getColumnName($reference.sourceColumn)}.referenceOn(${parser.getRowsetName($reference.targetColumn.rowSet)}.$parser.getColumnName($reference.targetColumn)),
+#end
+#end
+#end
+#end
+#end
+ // foreign key relations done
+ }
+#end
+
+ #if($nestTables == true)
+ #foreach ($table in $database.tables)
+ #if ($templateFolder)
+ #parse( "$templateFolder/Table.vm" )
+ #else
+ #parse( "Table.vm" )
+ #end
+ #end
+ #end
+
+ #if($nestViews == true)
+ #foreach ($view in $database.views)
+ #if ($templateFolder)
+ #parse( "$templateFolder/View.vm" )
+ #else
+ #parse( "View.vm" )
+ #end
+ #end
+ #end
+
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/Record.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/Record.vm b/empire-db-eclipse-codegen/src/main/resources/templates/Record.vm
new file mode 100644
index 0000000..a559404
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/Record.vm
@@ -0,0 +1,66 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+package ${recordPackageName};
+
+#if ($parser.hasBigDecimalField($table))
+import java.math.BigDecimal;
+#end
+
+#if ($parser.hasDateField($table))
+import java.util.Date;
+#end
+
+import ${basePackageName}.${dbClassName};
+import ${recordPackageName}.${baseRecordClassName};
+import ${tablePackageName}.$parser.getTableClassName($table.name);
+
+/**
+ * Auto-generated class that represents one record (or row) of data from a
+ * database table. One of these is generated for each table or view in the
+ * database. The interface defines getters for auto-generated data (e.g.
+ * primary key, time stamp field for optimistic locking). It generates both
+ * getter and setter method for all other columns in the table, with the
+ * exception of foreign key references.
+ *
+ * This class provides protected method that subclasses should use to provide
+ * access to related records.
+ */
+public class $parser.getRecordClassName($table.name) extends ${baseRecordClassName}<$parser.getTableClassName($table.name)> {
+
+ private static final long serialVersionUID = 1L;
+
+ public $parser.getRecordClassName($table.name)() {
+ super(${dbClassName}.get().$parser.getTableName($table));
+ }
+
+#if($createRecordProperties == true)
+ // Access methods for all columns
+#foreach($col in $table.columns)
+
+ public $parser.getJavaType($col).getCanonicalName() $parser.getAccessorName($col)() {
+ return ($parser.getJavaType($col).getCanonicalName())super.getValue(getTable().${parser.getColumnName($col)});
+ }
+ public void $parser.getMutatorName($col)($parser.getJavaType($col).getCanonicalName() val) {
+ super.setValue(getTable().${parser.getColumnName($col)}, val);
+ }
+#end
+#end
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/Table.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/Table.vm b/empire-db-eclipse-codegen/src/main/resources/templates/Table.vm
new file mode 100644
index 0000000..1193fe8
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/Table.vm
@@ -0,0 +1,76 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+#if($nestTables == false)
+package $tablePackageName;
+
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBTableColumn;
+import $basePackageName.${dbClassName};
+#end
+
+#if($nestTables == true)
+ public static class $parser.getTableClassName($table.name) extends ${baseTableClassName} {
+#else
+public class $parser.getTableClassName($table.name) extends ${baseTableClassName} {
+#end
+
+ private static final long serialVersionUID = 1L;
+
+ // define columns
+#foreach ($col in $table.columns)
+ public final DBTableColumn ${parser.getColumnName($col)};
+#end
+
+ public $parser.getTableClassName($table.name)(${dbClassName} db) {
+ super("$table.name", db);
+
+ // create columns
+#foreach ($col in $table.columns)
+ ${parser.getColumnName($col)} = addColumn("${col.name}", DataType.${parser.getDataType($col)}, ${col.size}, ${col.isRequired()}, ${parser.getDefaultValue($col)});
+#end
+
+ // configure key columns (primary key)
+#if($table.keyColumns.size()>0)
+#if($table.keyColumns.size()==1)
+ setPrimaryKey(${parser.getColumnName($table.keyColumns[0])});
+#else
+ DBTableColumn[] keyColumns = new DBTableColumn[] {
+#foreach ($col in $table.keyColumns)
+#if($foreach.isLast()==false)
+ ${parser.getColumnName($col)},
+#else
+ ${parser.getColumnName($col)} };
+ setPrimaryKey(keyColumns);
+#end
+#end
+#end
+
+ // Optimistic locking column
+#if($parser.hasLockingColumn($table) == true)
+ setTimestampColumn(${parser.getColumnName($table.getTimestampColumn())});
+#else
+ /*no locking column specified*/
+#end
+#end
+ }
+#if($nestTables == true)
+ }
+#else
+}
+#end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/templates/View.vm
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/templates/View.vm b/empire-db-eclipse-codegen/src/main/resources/templates/View.vm
new file mode 100644
index 0000000..0c875b9
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/templates/View.vm
@@ -0,0 +1,68 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+
+#if($nestViews == false)
+package $viewPackageName;
+
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBCommandExpr;
+import org.apache.empire.exceptions.NotImplementedException;
+
+import $basePackageName.${dbClassName};
+
+#end
+
+#if($nestViews == true)
+ public static class $parser.getViewClassName($view.name) extends ${baseViewClassName} {
+#else
+public class $parser.getViewClassName($view.name) extends ${baseViewClassName} {
+#end
+
+ private static final long serialVersionUID = 1L;
+
+ // define columns
+#foreach ($col in $view.columns)
+ public final DBViewColumn ${parser.getColumnName($col)};
+#end
+
+ public $parser.getViewClassName($view.name)(${dbClassName} db) {
+ super("$view.name", db);
+
+ // create all columns
+#foreach ($col in $view.columns)
+ ${parser.getColumnName($col)} = super.addColumn("${col.name}", DataType.${col.getDataType()});
+#end
+ }
+
+ @Override
+ public DBCommandExpr createCommand()
+ {
+ /*
+ Supply a command for the creation of this view here
+ or return null to skip view creation
+ */
+ throw new NotImplementedException(this, "createCommand");
+ }
+
+#if($nestViews == true)
+ }
+#else
+}
+#end
+
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-examples/empire-db-example-basic/.gitignore
----------------------------------------------------------------------
diff --git a/empire-db-examples/empire-db-example-basic/.gitignore b/empire-db-examples/empire-db-example-basic/.gitignore
index c35a751..86a41ba 100644
--- a/empire-db-examples/empire-db-example-basic/.gitignore
+++ b/empire-db-examples/empire-db-example-basic/.gitignore
@@ -3,3 +3,4 @@
/.classpath
/.project
/hsqldb/
+/bin/
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-examples/empire-db-example-basic/pom.xml
----------------------------------------------------------------------
diff --git a/empire-db-examples/empire-db-example-basic/pom.xml b/empire-db-examples/empire-db-example-basic/pom.xml
index 9bc61b2..50d840e 100644
--- a/empire-db-examples/empire-db-example-basic/pom.xml
+++ b/empire-db-examples/empire-db-example-basic/pom.xml
@@ -34,6 +34,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
+
<!-- This dependency should be declared as runtime but the exec plugin is broken atm... -->
<dependency>
<groupId>hsqldb</groupId>
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-examples/empire-db-example-jsf2/.gitignore
----------------------------------------------------------------------
diff --git a/empire-db-examples/empire-db-example-jsf2/.gitignore b/empire-db-examples/empire-db-example-jsf2/.gitignore
index 8bd3a05..f0b1fcf 100644
--- a/empire-db-examples/empire-db-example-jsf2/.gitignore
+++ b/empire-db-examples/empire-db-example-jsf2/.gitignore
@@ -2,3 +2,4 @@
/.settings/
/.classpath
/.project
+/.tomcatplugin
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-examples/empire-db-example-struts2-cxf/.gitignore
----------------------------------------------------------------------
diff --git a/empire-db-examples/empire-db-example-struts2-cxf/.gitignore b/empire-db-examples/empire-db-example-struts2-cxf/.gitignore
index 8bd3a05..f0b1fcf 100644
--- a/empire-db-examples/empire-db-example-struts2-cxf/.gitignore
+++ b/empire-db-examples/empire-db-example-struts2-cxf/.gitignore
@@ -2,3 +2,4 @@
/.settings/
/.classpath
/.project
+/.tomcatplugin
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-examples/empire-db-example-struts2/.gitignore
----------------------------------------------------------------------
diff --git a/empire-db-examples/empire-db-example-struts2/.gitignore b/empire-db-examples/empire-db-example-struts2/.gitignore
index 8bd3a05..f0b1fcf 100644
--- a/empire-db-examples/empire-db-example-struts2/.gitignore
+++ b/empire-db-examples/empire-db-example-struts2/.gitignore
@@ -2,3 +2,4 @@
/.settings/
/.classpath
/.project
+/.tomcatplugin
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-examples/pom.xml
----------------------------------------------------------------------
diff --git a/empire-db-examples/pom.xml b/empire-db-examples/pom.xml
index bd6274c..8f17974 100644
--- a/empire-db-examples/pom.xml
+++ b/empire-db-examples/pom.xml
@@ -27,16 +27,6 @@
<name>Apache Empire-db Examples</name>
<dependencies>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- </dependency>
- <dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/empire-db-maven-plugin/pom.xml b/empire-db-maven-plugin/pom.xml
index 9bb60f5..135a943 100644
--- a/empire-db-maven-plugin/pom.xml
+++ b/empire-db-maven-plugin/pom.xml
@@ -59,12 +59,12 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.14</version>
+ <version>1.2.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c4a701a..6ba163f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,8 +44,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <maven.compile.source>1.5</maven.compile.source>
- <maven.compile.target>1.5</maven.compile.target>
+ <maven.compile.source>1.6</maven.compile.source>
+ <maven.compile.target>1.6</maven.compile.target>
<disclaimer.dir>{project.basedir}</disclaimer.dir>
</properties>
@@ -54,8 +54,9 @@
</prerequisites>
<profiles>
+
+ <!-- Hudson profile -->
<profile>
- <!-- Hudson profile -->
<id>CI</id>
<build>
<plugins>
@@ -108,6 +109,8 @@
</plugins>
</build>
</profile>
+
+ <!-- empire-db-dist -->
<profile>
<!-- Part of the release profile, merged with release profile defined in apache parent pom -->
<id>apache-release</id>
@@ -145,6 +148,15 @@
</plugins>
</build>
</profile>
+
+ <!-- eclipse-plugin -->
+ <profile>
+ <id>eclipse-plugin</id>
+ <modules>
+ <module>empire-db-eclipse-codegen</module>
+ </modules>
+ </profile>
+
</profiles>
@@ -574,6 +586,7 @@
<excludeDefaults>true</excludeDefaults>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<plugins>
+ <!-- maven-project-info-reports-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
@@ -591,14 +604,17 @@
</reportSet>
</reportSets>
</plugin>
+ <!-- apache-rat-plugin -->
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>
+ <!-- maven-site-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
</plugin>
+ <!-- maven-pmd-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
@@ -607,6 +623,7 @@
<targetJdk>1.5</targetJdk>
</configuration>
</plugin>
+ <!-- findbugs-maven-plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
@@ -617,11 +634,13 @@
<omitVisitors>SerializableIdiom</omitVisitors>
</configuration>
</plugin>
+ <!-- jdepend-maven-plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
+ <!-- cobertura-maven-plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
@@ -633,15 +652,18 @@
</formats>
</configuration>
</plugin>
+ <!-- maven-jxr-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.4</version>
</plugin>
+ <!-- maven-javadoc-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
+ <!-- maven-changelog-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
[3/3] empire-db git commit: prepare release 2.4.4
Posted by do...@apache.org.
prepare release 2.4.4
Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/83302f08
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/83302f08
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/83302f08
Branch: refs/heads/master
Commit: 83302f0838c04027f034ca99d960d156a1cb16d0
Parents: 46d3e32
Author: Rainer Döbele <do...@apache.org>
Authored: Thu Aug 6 13:26:12 2015 +0200
Committer: Rainer Döbele <do...@apache.org>
Committed: Thu Aug 6 13:26:12 2015 +0200
----------------------------------------------------------------------
CHANGELOG.txt | 19 +
empire-db-eclipse-codegen/.gitignore | 3 +
empire-db-eclipse-codegen/META-INF/MANIFEST.MF | 30 +
empire-db-eclipse-codegen/build.properties | 30 +
empire-db-eclipse-codegen/lib/.gitignore | 8 +
empire-db-eclipse-codegen/lib/readme.txt | 24 +
empire-db-eclipse-codegen/plugin.xml | 76 +++
empire-db-eclipse-codegen/pom.xml | 86 +++
.../apache/empire/db/eclipse/CodeGenConfig.java | 574 +++++++++++++++++++
.../org/apache/empire/db/eclipse/Plugin.java | 190 ++++++
.../apache/empire/db/eclipse/PluginConsts.java | 47 ++
.../db/eclipse/handler/ConfigDialogHandler.java | 48 ++
.../empire/db/eclipse/model/ConfigFile.java | 64 +++
.../db/eclipse/model/JdbcDriverClass.java | 39 ++
.../db/eclipse/service/ConfigFileService.java | 38 ++
.../eclipse/service/ConfigFileServiceImpl.java | 234 ++++++++
.../db/eclipse/service/MessageService.java | 26 +
.../db/eclipse/service/MessageServiceImpl.java | 52 ++
.../db/eclipse/ui/ClassParameterPage.java | 272 +++++++++
.../db/eclipse/ui/ConfigurationDialog.java | 293 ++++++++++
.../empire/db/eclipse/ui/DBTablesDialog.java | 350 +++++++++++
.../apache/empire/db/eclipse/ui/INavigator.java | 46 ++
.../org/apache/empire/db/eclipse/ui/IPage.java | 30 +
.../apache/empire/db/eclipse/ui/MainPage.java | 305 ++++++++++
.../apache/empire/db/eclipse/ui/Navigator.java | 145 +++++
.../org/apache/empire/db/eclipse/ui/Page.java | 51 ++
.../empire/db/eclipse/ui/SchemaOptionsPage.java | 241 ++++++++
.../db/eclipse/util/SWTResourceManager.java | 455 +++++++++++++++
.../src/main/resources/defaultConfig.xml | 84 +++
.../src/main/resources/icons/addButton.png | Bin 0 -> 366 bytes
.../src/main/resources/icons/check_all.gif | Bin 0 -> 344 bytes
.../src/main/resources/icons/db_element.gif | Bin 0 -> 959 bytes
.../src/main/resources/icons/deleteButton.png | Bin 0 -> 582 bytes
.../src/main/resources/icons/empire-db-logo.gif | Bin 0 -> 12167 bytes
.../src/main/resources/icons/empire_db_icon.png | Bin 0 -> 581 bytes
.../src/main/resources/icons/folder.gif | Bin 0 -> 219 bytes
.../src/main/resources/icons/logo.png | Bin 0 -> 5482 bytes
.../src/main/resources/icons/save.png | Bin 0 -> 550 bytes
.../src/main/resources/icons/testConnection.gif | Bin 0 -> 920 bytes
.../src/main/resources/icons/uncheck_all.gif | Bin 0 -> 148 bytes
.../main/resources/lang/messages_en.properties | 141 +++++
.../src/main/resources/templates/BaseRecord.vm | 41 ++
.../src/main/resources/templates/BaseTable.vm | 31 +
.../src/main/resources/templates/BaseView.vm | 31 +
.../src/main/resources/templates/Database.vm | 136 +++++
.../src/main/resources/templates/Record.vm | 66 +++
.../src/main/resources/templates/Table.vm | 76 +++
.../src/main/resources/templates/View.vm | 68 +++
.../empire-db-example-basic/.gitignore | 1 +
.../empire-db-example-basic/pom.xml | 1 +
.../empire-db-example-jsf2/.gitignore | 1 +
.../empire-db-example-struts2-cxf/.gitignore | 1 +
.../empire-db-example-struts2/.gitignore | 1 +
empire-db-examples/pom.xml | 10 -
empire-db-maven-plugin/pom.xml | 4 +-
pom.xml | 28 +-
56 files changed, 4482 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/CHANGELOG.txt
----------------------------------------------------------------------
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 811bb52..9d53398 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -5,6 +5,25 @@ For more Information about a particular issue please visit
https://issues.apache.org/jira/browse/EMPIREDB
--------------
+Release 2.4.4:
+--------------
+** Improvement
+ EMPIREDB-221 Allow batch execution through JDBC executeBatch
+ EMPIREDB-220 Allow override of fraction digits on JSF input tag
+ EMPIREDB-219 Added source code for Eclipse-Code-Generation-Plugin
+ EMPIREDB-217 Consistency check for data model defintion vs deployed data model
+
+** Bugfix
+ EMPIREDB-218 Missing reserved keywords in DBDatabaseDriverMySQL
+ EMPIREDB-216 Reserved words as colum names not correctly escaped/quoted for derby
+ EMPIREDB-215 Sequence generation and use for HSql to not agree in using toUpperCase
+ EMPIREDB-214 SQLServer - wrong 'alterColumnPhrase'
+ EMPIREDB-212 MySQL Nested Union bad syntax
+ EMPIREDB-210 Wrong Java Type in Records for BLOB Columns
+ EMPIREDB-209 Using a reserved word as a column alias in a select statement.
+ EMPIREDB-208 Decimal fields don't support scales above 9
+
+--------------
Release 2.4.3:
--------------
** Improvement
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/.gitignore
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/.gitignore b/empire-db-eclipse-codegen/.gitignore
new file mode 100644
index 0000000..ddd6d6d
--- /dev/null
+++ b/empire-db-eclipse-codegen/.gitignore
@@ -0,0 +1,3 @@
+/.settings/
+/.classpath
+/.project
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/META-INF/MANIFEST.MF b/empire-db-eclipse-codegen/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..328a0a3
--- /dev/null
+++ b/empire-db-eclipse-codegen/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Empire-db eclipse code generator
+Bundle-SymbolicName: org.apache.empire.db.eclipse;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-ClassPath: .,
+ lib/commons-beanutils-1.8.3.jar,
+ lib/commons-logging-1.1.1.jar,
+ lib/commons-io-1.4.jar,
+ lib/empire-db-2.4.3.jar,
+ lib/empire-db-codegen-2.4.3.jar,
+ lib/slf4j-api-1.6.1.jar,
+ lib/slf4j-log4j12-1.6.1.jar,
+ lib/log4j-1.2.16.jar
+Bundle-Activator: org.apache.empire.db.eclipse.Plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.workbench,
+ org.eclipse.swt,
+ org.eclipse.core.resources,
+ org.apache.empire.db.eclipse
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: icons,
+ lang,
+ org.apache.empire.db.eclipse,
+ org.apache.empire.db.eclipse.handler,
+ org.apache.empire.db.eclipse.service,
+ org.apache.empire.db.eclipse.ui,
+ org.apache.empire.db.eclipse.util
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/build.properties
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/build.properties b/empire-db-eclipse-codegen/build.properties
new file mode 100644
index 0000000..75ab60b
--- /dev/null
+++ b/empire-db-eclipse-codegen/build.properties
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version
+# 2.0 (the "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+# applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, either express or implied. See the License for
+# the specific language governing permissions and limitations under the
+# License.
+bin.includes = META-INF/,\
+ plugin.xml,\
+ .,\
+ lib/commons-beanutils-1.8.3.jar,\
+ lib/commons-logging-1.1.1.jar,\
+ lib/commons-io-1.4.jar,\
+ lib/empire-db-2.4.3.jar,\
+ lib/empire-db-codegen-2.4.3.jar,\
+ lib/slf4j-api-1.6.1.jar,\
+ lib/slf4j-log4j12-1.6.1.jar,\
+ lib/log4j-1.2.16.jar,\
+ src/main/resources/
+jre.compilation.profile = J2SE-1.6
+src.includes = lib/,\
+ src/main/
+source.. = src/main/java/,\
+ src/main/resources/
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/lib/.gitignore
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/lib/.gitignore b/empire-db-eclipse-codegen/lib/.gitignore
new file mode 100644
index 0000000..156fd81
--- /dev/null
+++ b/empire-db-eclipse-codegen/lib/.gitignore
@@ -0,0 +1,8 @@
+/commons-beanutils-1.8.3.jar
+/commons-io-1.4.jar
+/commons-logging-1.1.1.jar
+/empire-db-2.4.3.jar
+/empire-db-codegen-2.4.3.jar
+/log4j-1.2.16.jar
+/slf4j-api-1.6.1.jar
+/slf4j-log4j12-1.6.1.jar
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/lib/readme.txt
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/lib/readme.txt b/empire-db-eclipse-codegen/lib/readme.txt
new file mode 100644
index 0000000..558439b
--- /dev/null
+++ b/empire-db-eclipse-codegen/lib/readme.txt
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version
+# 2.0 (the "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+# applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, either express or implied. See the License for
+# the specific language governing permissions and limitations under the
+# License.
+
+In order to compile in Eclipse please copy the following files into this folder:
+
+ commons-beanutils-1.8.3.jar,
+ commons-logging-1.1.1.jar,
+ commons-io-1.4.jar,
+ empire-db-2.4.3.jar,
+ empire-db-codegen-2.4.3.jar,
+ slf4j-api-1.6.1.jar,
+ slf4j-log4j12-1.6.1.jar,
+ log4j-1.2.16.jar
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/plugin.xml
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/plugin.xml b/empire-db-eclipse-codegen/plugin.xml
new file mode 100644
index 0000000..9af512a
--- /dev/null
+++ b/empire-db-eclipse-codegen/plugin.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
+<?eclipse version="3.4"?>
+<plugin id="empire-db-eclipse-plugin" version="1.0.0" name="Empire-db Eclipse Plugin">
+<extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.apache.empire.db.eclipse.handler.ConfigDialogHandler"
+ commandId="codegen.commands.configDialogHandler">
+ </handler>
+</extension>
+
+<extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
+ <command
+ commandId="codegen.commands.configDialogHandler"
+ icon="src/main/resources/icons/empire_db_icon.png"
+ id="org.empire.codegen.menus.packageExplorer.configCommand"
+ label="EmpireDB Tool"
+ tooltip="">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu">
+ <command
+ commandId="codegen.commands.configDialogHandler"
+ icon="src/main/resources/icons/empire_db_icon.png"
+ id="org.empire.codegen.menus.projectExplorer.configCommand"
+ label="EmpireDB Tool"
+ tooltip="">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+</extension>
+</plugin>
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/pom.xml
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/pom.xml b/empire-db-eclipse-codegen/pom.xml
new file mode 100644
index 0000000..58cc2e3
--- /dev/null
+++ b/empire-db-eclipse-codegen/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>empire-db-parent</artifactId>
+ <groupId>org.apache.empire-db</groupId>
+ <version>2.4.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>empire-db-eclipse-codegen</artifactId>
+ <name>Empire db eclipse codegen</name>
+ <packaging>eclipse-plugin</packaging>
+
+ <properties>
+ <tycho-version>0.16.0</tycho-version>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>luna</id>
+ <url>http://download.eclipse.org/releases/luna</url>
+ <layout>p2</layout>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.empire-db</groupId>
+ <artifactId>empire-db</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.empire-db</groupId>
+ <artifactId>empire-db-codegen</artifactId>
+ </dependency>
+ <!-- use log4j for logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <!-- commons -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Eclipse -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <pde>true</pde>
+ </configuration>
+ </plugin>
+ <!-- enable tycho build extension -->
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/CodeGenConfig.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/CodeGenConfig.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/CodeGenConfig.java
new file mode 100644
index 0000000..e57a6c0
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/CodeGenConfig.java
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.empire.exceptions.ItemNotFoundException;
+import org.apache.empire.exceptions.ObjectNotValidException;
+import org.apache.empire.xml.XMLConfiguration;
+import org.apache.empire.xml.XMLUtil;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.slf4j.Logger;
+import org.w3c.dom.Element;
+
+@XmlRootElement
+public class CodeGenConfig extends XMLConfiguration {
+ private static final Logger log = org.slf4j.LoggerFactory.getLogger(CodeGenConfig.class);
+
+ // the logging configuration root node name
+ private final String loggingNodeName = "log4j:configuration";
+
+ private String configTitle;
+
+ private String jdbcType;
+
+ private String jdbcClass;
+
+ private String jdbcURL;
+
+ private String jdbcServer;
+
+ private String jdbcPort;
+
+ private String jdbcSID;
+
+ private String jdbcUser;
+
+ private String jdbcPwd;
+
+ // generation options
+ /**
+ * name of the database catalog (may be null)
+ */
+ private String dbCatalog = null;
+
+ /**
+ * name of the database schema (may be null)
+ */
+ private String dbSchema = null;
+
+ /**
+ * name of the table pattern (may be null)
+ */
+ private String dbTablePattern = null;
+ /**
+ * Name of the timestamp column used for optimistic locking (may be null)
+ * e.g. "UPDATE_TIMESTAMP";
+ */
+ private String timestampColumn = null;
+
+ /**
+ * name of the target folder
+ */
+ private String targetFolder;
+
+ /**
+ * name of the template folder
+ */
+ private String templateFolder = "configuration\\org.apache.empire\\templates\\";
+
+ /**
+ * name of the target package
+ */
+ private String packageName;
+
+ /**
+ * name of the table target package
+ */
+ private String tablePackageName;
+
+ /**
+ * name of the record target package
+ */
+ private String recordPackageName;
+
+ /**
+ * name of the view target package
+ */
+ private String viewPackageName;
+
+ /**
+ * Target name of the generated database class. This class extends
+ * DBDatabase.
+ */
+ private String dbClassName;
+
+ /**
+ * Target name of the generated table class. This class extends DBTable and
+ * is the base class for all generated individual table classes.
+ */
+ private String tableBaseName;
+
+ /**
+ * Target name of the generated view class. This class extends DBView and is
+ * the base class for all generated individual view classes.
+ */
+ private String viewBaseName;
+
+ /**
+ * Target name of the generated record class. This is a template class that
+ * extends DBRecord as follows:<br/>
+ *
+ * <pre>
+ * XXRecord<T extends XXTable> extends DBRecord
+ * </pre>
+ *
+ * <br/>
+ */
+ private String recordBaseName;
+
+ /**
+ * Prefix used for table member declarations
+ */
+ private String tableNamePrefix = "";
+
+ /**
+ * Prefix used for view member declarations
+ */
+ private String viewNamePrefix = "";
+
+ /**
+ * Prefix used for column member declarations
+ */
+ private String columnNamePrefix = "";
+
+ /**
+ * Prefix used for generating table class names.<br/>
+ * The Table name is appended after the prefix starting with captial letter
+ * followed by lower case letters.<br/>
+ * Occurrence an of underscore indicates a new word which will again start
+ * with a capital letter.<br/>
+ * e.g.<br/>
+ * <ul>
+ * <li>Table "names" -> Class "XXNames"</li>
+ * <li>Table "flight_bookings" -> Class "XXFlightBookings"</li>
+ * </ul>
+ * Where XX is the prefix.
+ */
+ private String tableClassPrefix = "";
+
+ /**
+ * Suffix used for generating table class names.<br/>
+ * The Table name is appended before the suffix starting with captial letter
+ * followed by lower case letters.<br/>
+ * Occurrence an of underscore indicates a new word which will again start
+ * with a capital letter.<br/>
+ * e.g.<br/>
+ * <ul>
+ * <li>Table "names" -> Class "NamesTable"</li>
+ * <li>Table "flight_bookings" -> Class "FlightBookingsTable"</li>
+ * </ul>
+ * Where "Table" is the suffix.
+ */
+ private String tableClassSuffix = "";
+
+ /**
+ * Prefix used for generating view class names.<br/>
+ * The Table name is appended after the prefix starting with captial letter
+ * followed by lower case letters.<br/>
+ * Occurrence an of underscore indicates a new word which will again start
+ * with a capital letter.<br/>
+ * See naming of table classes above.
+ */
+ private String viewClassPrefix = "";
+
+ /**
+ * Suffix used for generating view class names.<br/>
+ * The View name is appended before the suffix starting with captial letter
+ * followed by lower case letters.<br/>
+ * Occurrence an of underscore indicates a new word which will again start
+ * with a capital letter.<br/>
+ * e.g.<br/>
+ * <ul>
+ * <li>View "names" -> Class "NamesView"</li>
+ * <li>View "flight_bookings" -> Class "FlightBookingsView"</li>
+ * </ul>
+ * Where "View" is the suffix.
+ */
+ private String viewClassSuffix = "";
+
+ /**
+ * if TRUE table classes should be declared as inner classes of DBDatabase.
+ * <br/>
+ * if FALSE table classes should be declared as top level classes.
+ */
+ private boolean nestTables = false;
+
+ /**
+ * if TRUE view classes should be declared as inner classes of DBDatabase.
+ * <br/>
+ * if FALSE view classes should be declared as top level classes.
+ */
+ private boolean nestViews = false;
+
+ /**
+ * if TRUE record classes should have a getter and setter for each field.
+ * <br/>
+ * Otherwise getters / setters are omitted.
+ */
+ private boolean createRecordProperties;
+
+ /**
+ * true if names of tables and views should not be camel-cased
+ */
+ private boolean preserverCharacterCase = false;
+
+ /**
+ * true if names of foreign-key-relations should be preserved
+ */
+ private boolean preserveRelationNames = false;
+
+ /**
+ * Initialize the configuration.
+ *
+ * @param filename
+ * the file to read
+ */
+ public void init(String filename) {
+ // Read the properties file
+ super.init(filename, false);
+
+ // Init Logging
+ initLogging();
+
+ // Reader Provider Properties
+ readProperties(this, "properties");
+ }
+
+ /**
+ * Init logging using Log4J's DOMConfigurator
+ *
+ * @return
+ */
+ private void initLogging() {
+ // Get configuration root node
+ Element rootNode = getRootNode();
+ if (rootNode == null) {
+ throw new ObjectNotValidException(getClass().getName());
+ }
+ // Find log configuration node
+ Element loggingNode = XMLUtil.findFirstChild(rootNode, this.loggingNodeName);
+ if (loggingNode == null) { // log configuration node not found
+ CodeGenConfig.log.error("Log configuration node {} has not been found. Logging has not been configured.",
+ this.loggingNodeName);
+ throw new ItemNotFoundException(this.loggingNodeName);
+ }
+ // Init Log4J
+ DOMConfigurator.configure(loggingNode);
+ // done
+ CodeGenConfig.log.info("Logging sucessfully configured from node {}.", this.loggingNodeName);
+ }
+
+ public String getJdbcClass() {
+ return this.jdbcClass;
+ }
+
+ public void setJdbcClass(String jdbcClass) {
+ this.jdbcClass = jdbcClass;
+ }
+
+ public String getJdbcURL() {
+ return this.jdbcURL;
+ }
+
+ public void setJdbcURL(String jdbcURL) {
+ this.jdbcURL = jdbcURL;
+ }
+
+ public String getJdbcUser() {
+ return this.jdbcUser;
+ }
+
+ public void setJdbcUser(String jdbcUser) {
+ this.jdbcUser = jdbcUser;
+ }
+
+ public String getJdbcPwd() {
+ return this.jdbcPwd;
+ }
+
+ public void setJdbcPwd(String jdbcPwd) {
+ this.jdbcPwd = jdbcPwd;
+ }
+
+ // ------- generation options -------
+
+ public String getDbCatalog() {
+ if(this.dbCatalog == "") {
+ this.dbCatalog = null;
+ }
+ return this.dbCatalog;
+ }
+
+ public void setDbCatalog(String dbCatalog) {
+ this.dbCatalog = dbCatalog;
+ }
+
+ public String getDbSchema() {
+ if(this.dbSchema == "") {
+ this.dbSchema = null;
+ }
+ return this.dbSchema;
+ }
+
+ public void setDbSchema(String dbSchema) {
+ this.dbSchema = dbSchema;
+ }
+
+ public String getDbTablePattern() {
+ return this.dbTablePattern;
+ }
+
+ public void setDbTablePattern(String dbTablePattern) {
+ this.dbTablePattern = dbTablePattern;
+ }
+
+ public String getTimestampColumn() {
+ return this.timestampColumn;
+ }
+
+ public void setTimestampColumn(String timestampColumn) {
+ this.timestampColumn = timestampColumn;
+ }
+
+ public String getTargetFolder() {
+ return this.targetFolder;
+ }
+
+ public void setTargetFolder(String targetFolder) {
+ this.targetFolder = targetFolder;
+ }
+
+ public String getTemplateFolder() {
+ return this.templateFolder;
+ }
+
+ public void setTemplateFolder(String templateFolder) {
+ this.templateFolder = templateFolder;
+ }
+
+ public String getPackageName() {
+ return this.packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getTablePackageName() {
+ return fallback(this.tablePackageName, "tables");
+ }
+
+ public void setTablePackageName(String tablePackageName) {
+ this.tablePackageName = tablePackageName;
+ }
+
+ public String getRecordPackageName() {
+ return fallback(this.recordPackageName, "records");
+ }
+
+ public void setRecordPackageName(String recordPackageName) {
+ this.recordPackageName = recordPackageName;
+ }
+
+ public String getViewPackageName() {
+ return fallback(this.viewPackageName, "views");
+ }
+
+ public void setViewPackageName(String viewPackageName) {
+ this.viewPackageName = viewPackageName;
+ }
+
+ public String getDbClassName() {
+ return this.dbClassName;
+ }
+
+ public void setDbClassName(String dbClassName) {
+ this.dbClassName = dbClassName;
+ }
+
+ public String getTableBaseName() {
+ return this.tableBaseName;
+ }
+
+ public void setTableBaseName(String tableBaseName) {
+ this.tableBaseName = tableBaseName;
+ }
+
+ public String getViewBaseName() {
+ return this.viewBaseName;
+ }
+
+ public void setViewBaseName(String viewBaseName) {
+ this.viewBaseName = viewBaseName;
+ }
+
+ public String getRecordBaseName() {
+ return this.recordBaseName;
+ }
+
+ public void setRecordBaseName(String recordBaseName) {
+ this.recordBaseName = recordBaseName;
+ }
+
+ public String getTableNamePrefix() {
+ return this.tableNamePrefix;
+ }
+
+ public void setTableNamePrefix(String tableNamePrefix) {
+ this.tableNamePrefix = tableNamePrefix;
+ }
+
+ public String getTableClassPrefix() {
+ return this.tableClassPrefix;
+ }
+
+ public void setTableClassPrefix(String tableClassPrefix) {
+ this.tableClassPrefix = tableClassPrefix;
+ }
+
+ public String getTableClassSuffix() {
+ return this.tableClassSuffix;
+ }
+
+ public void setTableClassSuffix(String tableClassSuffix) {
+ this.tableClassSuffix = tableClassSuffix;
+ }
+
+ public String getViewNamePrefix() {
+ return this.viewNamePrefix;
+ }
+
+ public void setViewNamePrefix(String viewNamePrefix) {
+ this.viewNamePrefix = viewNamePrefix;
+ }
+
+ public String getViewClassPrefix() {
+ return this.viewClassPrefix;
+ }
+
+ public void setViewClassPrefix(String viewClassPrefix) {
+ this.viewClassPrefix = viewClassPrefix;
+ }
+
+ public String getViewClassSuffix() {
+ return this.viewClassSuffix;
+ }
+
+ public void setViewClassSuffix(String viewClassSuffix) {
+ this.viewClassSuffix = viewClassSuffix;
+ }
+
+ public String getColumnNamePrefix() {
+ return this.columnNamePrefix;
+ }
+
+ public void setColumnNamePrefix(String columnNamePrefix) {
+ this.columnNamePrefix = columnNamePrefix;
+ }
+
+ public boolean isNestTables() {
+ return this.nestTables;
+ }
+
+ public void setNestTables(boolean nestTables) {
+ this.nestTables = nestTables;
+ }
+
+ public boolean isNestViews() {
+ return this.nestViews;
+ }
+
+ public void setNestViews(boolean nestViews) {
+ this.nestViews = nestViews;
+ }
+
+ public boolean isCreateRecordProperties() {
+ return this.createRecordProperties;
+ }
+
+ public void setCreateRecordProperties(boolean createRecordProperties) {
+ this.createRecordProperties = createRecordProperties;
+ }
+
+ public boolean isPreserverCharacterCase() {
+ return this.preserverCharacterCase;
+ }
+
+ public void setPreserverCharacterCase(boolean preserverCharacterCase) {
+ this.preserverCharacterCase = preserverCharacterCase;
+ }
+
+ public boolean isPreserveRelationNames() {
+ return this.preserveRelationNames;
+ }
+
+ public void setPreserveRelationNames(boolean preserveRelationNames) {
+ this.preserveRelationNames = preserveRelationNames;
+ }
+
+ private String fallback(String packageName, String defaultSubpackage) {
+ String pkg = packageName;
+ if (pkg == null && this.packageName != null) {
+ pkg = this.packageName + "." + defaultSubpackage;
+ }
+ return pkg;
+ }
+
+ public String getConfigTitle() {
+ return this.configTitle;
+ }
+
+ public void setConfigTitle(String configTitle) {
+ this.configTitle = configTitle;
+ }
+
+ public String getJdbcType() {
+ return this.jdbcType;
+ }
+
+ public void setJdbcType(String jdbcType) {
+ this.jdbcType = jdbcType;
+ }
+
+ public String getJdbcServer() {
+ return this.jdbcServer;
+ }
+
+ public void setJdbcServer(String jdbcServer) {
+ this.jdbcServer = jdbcServer;
+ }
+
+ public String getJdbcPort() {
+ return this.jdbcPort;
+ }
+
+ public void setJdbcPort(String jdbcPort) {
+ this.jdbcPort = jdbcPort;
+ }
+
+ public String getJdbcSID() {
+ return this.jdbcSID;
+ }
+
+ public void setJdbcSID(String jdbcSID) {
+ this.jdbcSID = jdbcSID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/Plugin.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/Plugin.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/Plugin.java
new file mode 100644
index 0000000..905cfef
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/Plugin.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.empire.db.eclipse.model.JdbcDriverClass;
+import org.apache.empire.db.eclipse.service.ConfigFileService;
+import org.apache.empire.db.eclipse.service.ConfigFileServiceImpl;
+import org.apache.empire.db.eclipse.service.MessageService;
+import org.apache.empire.db.eclipse.service.MessageServiceImpl;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Plugin extends AbstractUIPlugin
+{
+ private static final Logger log = LoggerFactory.getLogger(Plugin.class);
+ // The shared instance
+ private static Plugin plugin;
+
+ private final MessageService messageService;
+
+ private final ConfigFileService configFileService;
+
+ private final Map<String, JdbcDriverClass> driverClasses;
+
+ /**
+ * The constructor
+ */
+ public Plugin()
+ {
+ this.messageService = new MessageServiceImpl(Locale.ENGLISH);
+ // check config dir
+ File checkConfigDir = new File(PluginConsts.CONFIG_DIR_PATH, PluginConsts.CONFIG_DIR);
+ if (!checkConfigDir.exists())
+ {
+ checkConfigDir.mkdirs();
+ }
+ // check default config file
+ checkConfigFile(PluginConsts.DEFAULT_CONFIG_FILE);
+ // check database generation templates
+ checkConfigFile(PluginConsts.TEMPLATE_BASE_RECORD);
+ checkConfigFile(PluginConsts.TEMPLATE_BASE_TABLE);
+ checkConfigFile(PluginConsts.TEMPLATE_BASE_VIEW);
+ checkConfigFile(PluginConsts.TEMPLATE_DATABASE);
+ checkConfigFile(PluginConsts.TEMPLATE_RECORD);
+ checkConfigFile(PluginConsts.TEMPLATE_TABLE);
+ checkConfigFile(PluginConsts.TEMPLATE_VIEW);
+
+ this.configFileService = new ConfigFileServiceImpl(checkConfigDir);
+ this.driverClasses = new HashMap<String, JdbcDriverClass>();
+ this.driverClasses.put("Oracle", new JdbcDriverClass("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@%s:%s:%s"));
+ this.driverClasses.put("Microsoft SQL Server", new JdbcDriverClass("com.microsoft.sqlserver.jdbc.SQLServerDriver",
+ "jdbc:sqlserver://%s:%s;databaseName=%s"));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context)
+ throws Exception
+ {
+ Plugin.log.debug("Start empire-db-codegen plugin");
+ super.start(context);
+ Plugin.plugin = this;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context)
+ throws Exception
+ {
+ Plugin.log.debug("Stop empire-db-codegen plugin");
+ Plugin.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Plugin getInstance()
+ {
+ return Plugin.plugin;
+ }
+
+ public MessageService getMessageService()
+ {
+ return this.messageService;
+ }
+
+ public ConfigFileService getConfigFileService()
+ {
+ return this.configFileService;
+ }
+
+ public Map<String, JdbcDriverClass> getDriverClasses()
+ {
+ return this.driverClasses;
+ }
+
+ public String[] getDriverClassNames()
+ {
+ String[] driverClassNames = new String[this.driverClasses.size() + 1];
+ driverClassNames[0] = " ";
+ int i = 1;
+ for (String key : this.driverClasses.keySet())
+ {
+ driverClassNames[i] = key;
+ i++;
+ }
+ return driverClassNames;
+ }
+
+ public Connection getJDBCConnection(String connectionType, String jdbcServer, String jdbcPort, String jdbcDatabase, String jdbcUser,
+ String jdbcPwd)
+ throws SQLException
+ {
+ JdbcDriverClass jdbcDriverClass = this.driverClasses.get(connectionType);
+ String jdbcClass = jdbcDriverClass.getJdbcClass();
+ String jdbcURL = String.format(jdbcDriverClass.getJdbcUrl(), jdbcServer, jdbcPort, jdbcDatabase);
+ Plugin.log.info("Connecting to Database'" + jdbcURL + "' / User=" + jdbcUser);
+ Connection conn = null;
+ try
+ {
+ Class.forName(jdbcClass).newInstance();
+ }
+ catch (Exception ex)
+ {
+ throw new SQLException("Could not load database driver: " + jdbcClass);
+ }
+ conn = DriverManager.getConnection(jdbcURL, jdbcUser, jdbcPwd);
+ Plugin.log.info("Connected successfully");
+ return conn;
+ }
+
+ private void checkConfigFile(String filename)
+ {
+ File configFile = new File(PluginConsts.CONFIG_DIR_PATH, filename);
+ if (!configFile.exists())
+ {
+ URL inputUrl = Plugin.class.getClassLoader().getResource(filename);
+ try
+ {
+ FileUtils.copyURLToFile(inputUrl, configFile);
+ }
+ catch (IOException e)
+ {
+ Plugin.log.error("Could not copy resoucres file in configuration directory! %s", e.getMessage());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/PluginConsts.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/PluginConsts.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/PluginConsts.java
new file mode 100644
index 0000000..479cbc5
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/PluginConsts.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse;
+
+public class PluginConsts
+{
+ // The plug-in ID
+ public static final String PLUGIN_ID = "empire-db-eclipse-codegen";
+
+ public static int BUTTON_NEXT_ID = 2;
+
+ public static int BUTTON_PREVIOUS_ID = 3;
+
+ public static int BUTTON_OK = 4;
+
+ public static int BUTTON_CANCEL = 5;
+
+ public static final String CONFIG_DIR_PATH = "configuration/org.apache.empire";
+
+ public static final String CONFIG_DIR = "config";
+
+ public static final String DEFAULT_CONFIG_FILE = "defaultConfig.xml";
+
+ public static final String TEMPLATE_BASE_RECORD = "templates/BaseRecord.vm";
+ public static final String TEMPLATE_BASE_TABLE = "templates/BaseTable.vm";
+ public static final String TEMPLATE_BASE_VIEW = "templates/BaseView.vm";
+ public static final String TEMPLATE_DATABASE = "templates/Database.vm";
+ public static final String TEMPLATE_RECORD = "templates/Record.vm";
+ public static final String TEMPLATE_TABLE = "templates/Table.vm";
+ public static final String TEMPLATE_VIEW = "templates/View.vm";
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/handler/ConfigDialogHandler.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/handler/ConfigDialogHandler.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/handler/ConfigDialogHandler.java
new file mode 100644
index 0000000..da36e1d
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/handler/ConfigDialogHandler.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.handler;
+
+import org.apache.empire.db.codegen.CodeGenerator;
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.ui.ConfigurationDialog;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class ConfigDialogHandler extends AbstractHandler
+{
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException
+ {
+ // loads the configurations
+ Plugin.getInstance().getConfigFileService().refreshConfigList();
+ // create new window
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ ConfigurationDialog dialog = new ConfigurationDialog(window.getShell());
+ if (dialog.open() == Window.OK)
+ {
+ // start the class cration
+ CodeGenerator.main(new String[] { dialog.getConfigFileAbsolutPath() });
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/ConfigFile.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/ConfigFile.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/ConfigFile.java
new file mode 100644
index 0000000..a810733
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/ConfigFile.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.model;
+
+import org.apache.empire.db.eclipse.CodeGenConfig;
+
+public class ConfigFile {
+
+ private String uuid;
+
+ private String filename;
+
+ private CodeGenConfig codeGenConfig;
+
+ public ConfigFile(CodeGenConfig codeGenConfig) {
+ this.codeGenConfig = codeGenConfig;
+ }
+
+ public ConfigFile(String filename, String uuid, CodeGenConfig pluginCodeGenConfig) {
+ this.filename = filename;
+ this.uuid = uuid;
+ this.codeGenConfig = pluginCodeGenConfig;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+ public CodeGenConfig getCodeGenConfig() {
+ return codeGenConfig;
+ }
+
+ public void setCodeGenConfig(CodeGenConfig codeGenConfig) {
+ this.codeGenConfig = codeGenConfig;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/JdbcDriverClass.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/JdbcDriverClass.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/JdbcDriverClass.java
new file mode 100644
index 0000000..52451a0
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/model/JdbcDriverClass.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.model;
+
+public class JdbcDriverClass {
+
+ private final String jdbcClass;
+
+ private final String jdbcUrl;
+
+ public JdbcDriverClass(String jdbcClass, String jdbcUrl) {
+ this.jdbcClass = jdbcClass;
+ this.jdbcUrl = jdbcUrl;
+ }
+
+ public String getJdbcClass() {
+ return jdbcClass;
+ }
+
+ public String getJdbcUrl() {
+ return jdbcUrl;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileService.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileService.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileService.java
new file mode 100644
index 0000000..11ccea4
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.service;
+
+import org.apache.empire.db.eclipse.model.ConfigFile;
+
+public interface ConfigFileService
+{
+ public boolean saveConfig(ConfigFile config);
+
+ public ConfigFile getConfig(String configTitle);
+
+ public boolean deleteConfig(String uuid);
+
+ public void refreshConfigList();
+
+ public String[] getConfigTitles();
+
+ public ConfigFile getDefaultConfig();
+
+ public String getConfigFilePath(String uuid);
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileServiceImpl.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileServiceImpl.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileServiceImpl.java
new file mode 100644
index 0000000..bbc8b7f
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/ConfigFileServiceImpl.java
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.service;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.db.eclipse.CodeGenConfig;
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.PluginConsts;
+import org.apache.empire.db.eclipse.model.ConfigFile;
+import org.apache.empire.db.eclipse.model.JdbcDriverClass;
+import org.apache.empire.xml.XMLWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class ConfigFileServiceImpl implements ConfigFileService
+{
+ private Map<String, ConfigFile> configurationgs;
+
+ private final File directory;
+
+ public ConfigFileServiceImpl(File configDir)
+ {
+ this.directory = configDir;
+ }
+
+ public boolean saveConfig(ConfigFile config)
+ {
+ ConfigFile configFile = this.configurationgs.get(config.getUuid());
+ if (configFile == null)
+ {
+ configFile = config;
+ configFile.setFilename(config.getCodeGenConfig().getConfigTitle() + "_" + Calendar.getInstance().getTimeInMillis()
+ + ".xml");
+ configFile.setUuid(UUID.randomUUID().toString());
+ this.configurationgs.put(configFile.getUuid(), configFile);
+ }
+ else
+ {
+ configFile.setCodeGenConfig(config.getCodeGenConfig());
+ }
+ try
+ {
+ File file = new File(this.directory, configFile.getFilename());
+ if (!file.exists())
+ {
+ file.createNewFile();
+ }
+ // build url string
+ CodeGenConfig pluginConfig = configFile.getCodeGenConfig();
+ if (!StringUtils.isEmpty(pluginConfig.getJdbcType()))
+ {
+ JdbcDriverClass driver = Plugin.getInstance().getDriverClasses().get(pluginConfig.getJdbcType());
+ pluginConfig.setJdbcURL(String.format(driver.getJdbcUrl(), pluginConfig.getJdbcServer(), pluginConfig.getJdbcPort(),
+ pluginConfig.getJdbcSID()));
+ pluginConfig.setJdbcClass(driver.getJdbcClass());
+ }
+ else
+ {
+ pluginConfig.setJdbcURL("");
+ }
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document document = db.newDocument();
+ Element configElement = document.createElement("config");
+ document.appendChild(configElement);
+ // Marshal the Object to a Document
+ JAXBContext jc = JAXBContext.newInstance(CodeGenConfig.class);
+ Marshaller marshaller = jc.createMarshaller();
+ marshaller.marshal(pluginConfig, configElement);
+ document.renameNode(configElement.getFirstChild(), configElement.getFirstChild().getNamespaceURI(), "properties");
+ configElement.appendChild(createLogginNode(document));
+ XMLWriter writer = new XMLWriter(new FileOutputStream(file));
+ writer.print(document);
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private Element createLogginNode(Document document)
+ {
+ Element log4j = document.createElement("log4j:configuration");
+ log4j.setAttribute("xmlns:log4j", "http://jakarta.apache.org/log4j/");
+ Element appender = document.createElement("appender");
+ appender.setAttribute("name", "default");
+ appender.setAttribute("class", "org.apache.log4j.ConsoleAppender");
+ Element layout = document.createElement("layout");
+ layout.setAttribute("class", "org.apache.log4j.PatternLayout");
+ Element param = document.createElement("param");
+ param.setAttribute("name", "ConversionPattern");
+ param.setAttribute("value", "%-5p [%d{yyyy/MM/dd HH:mm}]: %m at %l %n");
+ layout.appendChild(param);
+ appender.appendChild(layout);
+ log4j.appendChild(appender);
+
+ Element logger = document.createElement("logger");
+ logger.setAttribute("name", "org.apache.empire.commons");
+ logger.setAttribute("additivity", "false");
+ Element level = document.createElement("level");
+ level.setAttribute("value", "warn");
+ Element loggerAppender = document.createElement("appender-ref");
+ loggerAppender.setAttribute("ref", "default");
+ logger.appendChild(level);
+ logger.appendChild(loggerAppender);
+ log4j.appendChild(logger);
+
+ Element root = document.createElement("root");
+ Element priority = document.createElement("priority");
+ priority.setAttribute("value", "info");
+ Element rootAppender = document.createElement("appender-ref");
+ rootAppender.setAttribute("ref", "default");
+ root.appendChild(priority);
+ root.appendChild(rootAppender);
+ log4j.appendChild(root);
+
+ return log4j;
+ }
+
+ public ConfigFile getConfig(String configTitle)
+ {
+ for (ConfigFile configFile : this.configurationgs.values())
+ {
+ if (configFile.getCodeGenConfig().getConfigTitle().equals(configTitle))
+ {
+ return configFile;
+ }
+ }
+ return null;
+ }
+
+ public boolean deleteConfig(String uuid)
+ {
+ ConfigFile configFile = this.configurationgs.get(uuid);
+ if (configFile == null)
+ {
+ return false;
+ }
+ File file = new File(this.directory, configFile.getFilename());
+ boolean deleted = file.delete();
+ if (deleted)
+ {
+ this.configurationgs.remove(configFile);
+ }
+ return deleted;
+ }
+
+ public void refreshConfigList()
+ {
+ File[] files = this.directory.listFiles();
+ this.configurationgs = new HashMap<String, ConfigFile>();
+ if (files != null)
+ {
+ for (File file : files)
+ {
+ if (file.isFile())
+ {
+ CodeGenConfig config = new CodeGenConfig();
+ try
+ {
+ config.init(file.getAbsolutePath());
+ }
+ catch (Exception e)
+ {
+ continue;
+ }
+ String uuid = UUID.randomUUID().toString();
+ this.configurationgs.put(uuid, new ConfigFile(file.getName(), uuid, config));
+ }
+ }
+ }
+ }
+
+ public String[] getConfigTitles()
+ {
+ List<String> configTitles = new ArrayList<String>();
+ for (ConfigFile configFile : this.configurationgs.values())
+ {
+ configTitles.add(configFile.getCodeGenConfig().getConfigTitle());
+ }
+ Collections.sort(configTitles);
+ return configTitles.toArray(new String[configTitles.size()]);
+ }
+
+ public ConfigFile getDefaultConfig()
+ {
+ CodeGenConfig defaultConfig = new CodeGenConfig();
+ File file = new File(PluginConsts.CONFIG_DIR_PATH, PluginConsts.DEFAULT_CONFIG_FILE);
+ defaultConfig.init(file.getAbsolutePath());
+ return new ConfigFile(defaultConfig);
+ }
+
+ public String getConfigFilePath(String uuid)
+ {
+ ConfigFile config = this.configurationgs.get(uuid);
+ if (config == null)
+ {
+ return null;
+ }
+ return new File(new File(PluginConsts.CONFIG_DIR_PATH, PluginConsts.CONFIG_DIR), config.getFilename()).getAbsolutePath();
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageService.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageService.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageService.java
new file mode 100644
index 0000000..b76fb2f
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.service;
+
+public interface MessageService
+{
+ String resolveMessageKey(String key);
+
+ String resolveMessageKey(String key, Object... params);
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageServiceImpl.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageServiceImpl.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageServiceImpl.java
new file mode 100644
index 0000000..1cc4dc8
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/service/MessageServiceImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.service;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class MessageServiceImpl implements MessageService
+{
+ private final Locale locale;
+
+ public static List<Locale> supportedLocales = new ArrayList<Locale>();
+
+ static
+ {
+ MessageServiceImpl.supportedLocales.add(Locale.ENGLISH);
+ }
+
+ public MessageServiceImpl(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ public String resolveMessageKey(String key)
+ {
+ return ResourceBundle.getBundle("lang.messages", this.locale).getString(key);
+ }
+
+ public String resolveMessageKey(String key, Object... params)
+ {
+ return MessageFormat.format(resolveMessageKey(key), params);
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ClassParameterPage.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ClassParameterPage.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ClassParameterPage.java
new file mode 100644
index 0000000..1660b62
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ClassParameterPage.java
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import org.apache.empire.db.eclipse.CodeGenConfig;
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.util.SWTResourceManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class ClassParameterPage extends Page
+{
+ private final Text ctlDbClassName;
+ private final Text ctlTableBaseName;
+ private final Text ctlViewBaseName;
+ private final Text ctlRecordBaseName;
+ private final Text ctlTableNamePrefix;
+ private final Text ctlTableClassPrefix;
+ private final Text ctlTableClassSuffix;
+ private final Text ctlViewNamePrefix;
+ private final Text ctlViewClassPrefix;
+ private final Text ctlViewClassSuffix;
+ private final Text ctlColumnNamePrefix;
+ private final Label lblClassParameter;
+ private final Label lblTableBaseName;
+ private final Label lblViewBaseName;
+ private final Label lblRecordBaseName;
+ private final Label lblDbClassName;
+
+ private final Button ctlNestTables;
+ private final Button ctlNestViews;
+ private final Button ctlCreateRecordProperties;
+ private final Button ctlPreserverCharCase;
+ private final Button ctlPreserveRelationNames;
+
+ public ClassParameterPage(Composite parent, int style)
+ {
+ super(parent, style);
+
+ this.lblDbClassName = new Label(this, SWT.NONE);
+ this.lblDbClassName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbClassName"));
+ this.lblDbClassName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbClassName"));
+ this.lblDbClassName.setBounds(15, 50, 145, 17);
+
+ this.ctlDbClassName = new Text(this, SWT.BORDER);
+ this.ctlDbClassName.setBounds(185, 47, 250, 21);
+ this.ctlDbClassName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbClassName"));
+
+ this.lblClassParameter = new Label(this, SWT.NONE);
+ this.lblClassParameter.setAlignment(SWT.CENTER);
+ this.lblClassParameter.setText(Plugin.getInstance().getMessageService().resolveMessageKey("classParameter"));
+ this.lblClassParameter.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD));
+ this.lblClassParameter.setBounds(0, 10, 418, 21);
+
+ this.lblTableBaseName = new Label(this, SWT.NONE);
+ this.lblTableBaseName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("tableBaseName"));
+ this.lblTableBaseName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableBaseName"));
+ this.lblTableBaseName.setBounds(15, 76, 145, 17);
+
+ this.ctlTableBaseName = new Text(this, SWT.BORDER);
+ this.ctlTableBaseName.setBounds(185, 73, 250, 21);
+ this.ctlTableBaseName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableBaseName"));
+
+ this.lblViewBaseName = new Label(this, SWT.NONE);
+ this.lblViewBaseName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("viewBaseName"));
+ this.lblViewBaseName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewBaseName"));
+ this.lblViewBaseName.setBounds(15, 102, 145, 17);
+
+ this.ctlViewBaseName = new Text(this, SWT.BORDER);
+ this.ctlViewBaseName.setBounds(185, 99, 250, 21);
+ this.ctlViewBaseName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewBaseName"));
+
+ this.lblRecordBaseName = new Label(this, SWT.NONE);
+ this.lblRecordBaseName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("recordBaseName"));
+ this.lblRecordBaseName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.recordBaseName"));
+ this.lblRecordBaseName.setBounds(15, 128, 145, 17);
+
+ this.ctlRecordBaseName = new Text(this, SWT.BORDER);
+ this.ctlRecordBaseName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.recordBaseName"));
+ this.ctlRecordBaseName.setBounds(185, 125, 250, 21);
+
+ Label lblTableNamePrefix = new Label(this, SWT.NONE);
+ lblTableNamePrefix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("tableNamePrefix"));
+ lblTableNamePrefix.setBounds(15, 154, 145, 17);
+ lblTableNamePrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableNamePrefix"));
+
+ this.ctlTableNamePrefix = new Text(this, SWT.BORDER);
+ this.ctlTableNamePrefix.setBounds(185, 151, 250, 21);
+ this.ctlTableNamePrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableNamePrefix"));
+
+ Label lblTableClassPrefix = new Label(this, SWT.NONE);
+ lblTableClassPrefix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("tableClassPrefix"));
+ lblTableClassPrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableClassPrefix"));
+ lblTableClassPrefix.setBounds(15, 180, 145, 17);
+
+ this.ctlTableClassPrefix = new Text(this, SWT.BORDER);
+ this.ctlTableClassPrefix.setBounds(185, 177, 250, 21);
+ this.ctlTableClassPrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableClassPrefix"));
+
+ Label lblTableClassSuffix = new Label(this, SWT.NONE);
+ lblTableClassSuffix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("tableClassSuffix"));
+ lblTableClassSuffix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableClassSuffix"));
+ lblTableClassSuffix.setBounds(15, 206, 145, 17);
+
+ this.ctlTableClassSuffix = new Text(this, SWT.BORDER);
+ this.ctlTableClassSuffix.setBounds(185, 203, 250, 21);
+ this.ctlTableClassSuffix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tableClassSuffix"));
+
+ Label lblViewNamePrefix = new Label(this, SWT.NONE);
+ lblViewNamePrefix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("viewNamePrefix"));
+ lblViewNamePrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewNamePrefix"));
+ lblViewNamePrefix.setBounds(15, 232, 145, 17);
+
+ this.ctlViewNamePrefix = new Text(this, SWT.BORDER);
+ this.ctlViewNamePrefix.setBounds(185, 229, 250, 21);
+ this.ctlViewNamePrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewNamePrefix"));
+
+ Label lblViewClassPrefix = new Label(this, SWT.NONE);
+ lblViewClassPrefix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("viewClassPrefix"));
+ lblViewClassPrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewClassPrefix"));
+ lblViewClassPrefix.setBounds(15, 258, 145, 17);
+
+ this.ctlViewClassPrefix = new Text(this, SWT.BORDER);
+ this.ctlViewClassPrefix.setBounds(185, 255, 250, 21);
+ this.ctlViewClassPrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewClassPrefix"));
+
+ Label lblViewClassSuffix = new Label(this, SWT.NONE);
+ lblViewClassSuffix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("viewClassSuffix"));
+ lblViewClassSuffix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewClassSuffix"));
+ lblViewClassSuffix.setBounds(15, 285, 145, 17);
+
+ this.ctlViewClassSuffix = new Text(this, SWT.BORDER);
+ this.ctlViewClassSuffix.setBounds(185, 282, 250, 21);
+ this.ctlViewClassSuffix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewClassSuffix"));
+
+ Label lblColumnNamePrefix = new Label(this, SWT.NONE);
+ lblColumnNamePrefix.setText(Plugin.getInstance().getMessageService().resolveMessageKey("columnNamePrefix"));
+ lblColumnNamePrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.columnNamePrefix"));
+ lblColumnNamePrefix.setBounds(15, 312, 145, 17);
+
+ this.ctlColumnNamePrefix = new Text(this, SWT.BORDER);
+ this.ctlColumnNamePrefix.setBounds(185, 309, 250, 21);
+ this.ctlColumnNamePrefix.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.columnNamePrefix"));
+
+ Group grpFlag = new Group(this, SWT.NONE);
+ grpFlag.setFont(SWTResourceManager.getFont("Segoe UI", 10, SWT.BOLD));
+ grpFlag.setText(Plugin.getInstance().getMessageService().resolveMessageKey("flagGroup"));
+ grpFlag.setBounds(5, 335, 440, 144);
+
+ this.ctlNestTables = new Button(grpFlag, SWT.CHECK);
+ this.ctlNestTables.setBounds(180, 22, 93, 16);
+
+ Label lblNestTables = new Label(grpFlag, SWT.NONE);
+ lblNestTables.setBounds(10, 23, 156, 15);
+ lblNestTables.setText(Plugin.getInstance().getMessageService().resolveMessageKey("nestTables"));
+
+ Label lblNestViews = new Label(grpFlag, SWT.NONE);
+ lblNestViews.setText(Plugin.getInstance().getMessageService().resolveMessageKey("nestViews"));
+ lblNestViews.setBounds(10, 45, 156, 15);
+
+ this.ctlNestViews = new Button(grpFlag, SWT.CHECK);
+ this.ctlNestViews.setBounds(180, 44, 93, 16);
+
+ Label lblCreateRecordProperties = new Label(grpFlag, SWT.NONE);
+ lblCreateRecordProperties.setText(Plugin.getInstance().getMessageService().resolveMessageKey("createRecordProperties"));
+ lblCreateRecordProperties.setBounds(10, 67, 156, 15);
+
+ this.ctlCreateRecordProperties = new Button(grpFlag, SWT.CHECK);
+ this.ctlCreateRecordProperties.setBounds(180, 66, 93, 16);
+
+ Label lblPreserverCharCase = new Label(grpFlag, SWT.NONE);
+ lblPreserverCharCase.setText(Plugin.getInstance().getMessageService().resolveMessageKey("preserverCharCase"));
+ lblPreserverCharCase.setBounds(10, 89, 156, 15);
+
+ this.ctlPreserverCharCase = new Button(grpFlag, SWT.CHECK);
+ this.ctlPreserverCharCase.setBounds(180, 88, 93, 16);
+
+ Label lblPreserveRelationNames = new Label(grpFlag, SWT.NONE);
+ lblPreserveRelationNames.setText(Plugin.getInstance().getMessageService().resolveMessageKey("preserveRelationNames"));
+ lblPreserveRelationNames.setBounds(10, 111, 156, 15);
+
+ this.ctlPreserveRelationNames = new Button(grpFlag, SWT.CHECK);
+ this.ctlPreserveRelationNames.setBounds(180, 110, 93, 16);
+ }
+
+ public void save(CodeGenConfig config)
+ {
+ config.setDbClassName(this.ctlDbClassName.getText());
+ config.setTableBaseName(this.ctlTableBaseName.getText());
+ config.setViewBaseName(this.ctlViewBaseName.getText());
+ config.setRecordBaseName(this.ctlRecordBaseName.getText());
+ config.setTableNamePrefix(this.ctlTableNamePrefix.getText());
+ config.setTableClassPrefix(this.ctlTableClassPrefix.getText());
+ config.setTableClassSuffix(this.ctlTableClassSuffix.getText());
+ config.setViewClassPrefix(this.ctlViewClassPrefix.getText());
+ config.setViewClassSuffix(this.ctlViewClassSuffix.getText());
+ config.setColumnNamePrefix(this.ctlColumnNamePrefix.getText());
+ config.setNestTables(this.ctlNestTables.getSelection());
+ config.setNestViews(this.ctlNestViews.getSelection());
+ config.setCreateRecordProperties(this.ctlCreateRecordProperties.getSelection());
+ config.setPreserverCharacterCase(this.ctlPreserverCharCase.getSelection());
+ config.setPreserveRelationNames(this.ctlPreserveRelationNames.getSelection());
+ }
+
+ public void load(CodeGenConfig config)
+ {
+ setControlText(this.ctlDbClassName, config.getDbClassName());
+ setControlText(this.ctlTableBaseName, config.getTableBaseName());
+ setControlText(this.ctlViewBaseName, config.getViewBaseName());
+ setControlText(this.ctlRecordBaseName, config.getRecordBaseName());
+ setControlText(this.ctlTableNamePrefix, config.getTableNamePrefix());
+ setControlText(this.ctlTableClassPrefix, config.getTableClassPrefix());
+ setControlText(this.ctlTableClassSuffix, config.getTableClassSuffix());
+ setControlText(this.ctlViewClassPrefix, config.getViewClassPrefix());
+ setControlText(this.ctlViewClassSuffix, config.getViewClassSuffix());
+ setControlText(this.ctlColumnNamePrefix, config.getColumnNamePrefix());
+ this.ctlNestTables.setSelection(config.isNestTables());
+ this.ctlNestViews.setSelection(config.isNestViews());
+ this.ctlCreateRecordProperties.setSelection(config.isCreateRecordProperties());
+ this.ctlPreserverCharCase.setSelection(config.isPreserverCharacterCase());
+ this.ctlPreserveRelationNames.setSelection(config.isPreserveRelationNames());
+ }
+
+ @Override
+ public void setEnabled(boolean enabled)
+ {
+ this.ctlDbClassName.setEnabled(enabled);
+ this.ctlTableBaseName.setEnabled(enabled);
+ this.ctlViewBaseName.setEnabled(enabled);
+ this.ctlRecordBaseName.setEnabled(enabled);
+ this.ctlTableNamePrefix.setEnabled(enabled);
+ this.ctlTableClassPrefix.setEnabled(enabled);
+ this.ctlTableClassSuffix.setEnabled(enabled);
+ this.ctlViewNamePrefix.setEnabled(enabled);
+ this.ctlViewClassPrefix.setEnabled(enabled);
+ this.ctlViewClassSuffix.setEnabled(enabled);
+ this.ctlColumnNamePrefix.setEnabled(enabled);
+ this.ctlNestTables.setEnabled(enabled);
+ this.ctlNestViews.setEnabled(enabled);
+ this.ctlCreateRecordProperties.setEnabled(enabled);
+ this.ctlPreserverCharCase.setEnabled(enabled);
+ this.ctlPreserveRelationNames.setEnabled(enabled);
+ }
+
+ public boolean checkRequiredFields()
+ {
+ return checkControlFilled(this.ctlDbClassName, this.lblDbClassName.getText())
+ && checkControlFilled(this.ctlTableBaseName, this.lblTableBaseName.getText())
+ && checkControlFilled(this.ctlViewBaseName, this.lblViewBaseName.getText())
+ && this.checkControlFilled(this.ctlRecordBaseName, this.lblRecordBaseName.getText());
+ }
+}
[2/3] empire-db git commit: prepare release 2.4.4
Posted by do...@apache.org.
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ConfigurationDialog.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ConfigurationDialog.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ConfigurationDialog.java
new file mode 100644
index 0000000..8670e51
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/ConfigurationDialog.java
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.PluginConsts;
+import org.apache.empire.db.eclipse.model.ConfigFile;
+import org.apache.empire.db.eclipse.util.SWTResourceManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class ConfigurationDialog extends TitleAreaDialog
+{
+ private Navigator navigator;
+
+ private Page visiblePage;
+
+ private Button btnNextPage;
+
+ private Button btnPreviousPage;
+
+ private Button btnOk;
+
+ private Button btnCancel;
+
+ public ConfigurationDialog(Shell shell)
+ {
+ super(shell);
+ }
+
+ @Override
+ public void create()
+ {
+ super.create();
+ UpdateControls();
+ }
+
+ // overriding this methods allows you to set the
+ // title of the custom dialog
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dialog.title"));
+ }
+
+ @Override
+ protected Point getInitialSize()
+ {
+ return new Point(470, 685);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ this.btnPreviousPage = createButton(parent, PluginConsts.BUTTON_PREVIOUS_ID, Plugin.getInstance().getMessageService()
+ .resolveMessageKey("dialog.back"), true);
+ this.btnPreviousPage.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ ConfigurationDialog.this.navigator.showPreviousPage();
+ UpdateControls();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ }
+ });
+ this.btnNextPage = createButton(parent, PluginConsts.BUTTON_NEXT_ID,
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.next"), true);
+ this.btnNextPage.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ ConfigurationDialog.this.navigator.showNextPage();
+ UpdateControls();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ }
+ });
+
+ this.btnOk = createButton(parent, PluginConsts.BUTTON_OK, Plugin.getInstance().getMessageService().resolveMessageKey("dialog.ok"),
+ false);
+ this.btnOk.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ if (checkRequiredFields())
+ {
+ saveAction();
+ setReturnCode(Window.OK);
+ close();
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ this.btnCancel = createButton(parent, PluginConsts.BUTTON_CANCEL,
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.close"), false);
+ this.btnCancel.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ save();
+ setReturnCode(Window.CANCEL);
+ close();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ setTitleImage(SWTResourceManager.getImage(ConfigurationDialog.class, "/icons/empire-db-logo.gif"));
+ Composite area = (Composite) super.createDialogArea(parent);
+ area.setLayout(null);
+ final MainPage mainPage = new MainPage(area, SWT.NONE);
+ mainPage.addExistingConfigsListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ if (event.widget instanceof Combo)
+ {
+ Combo combo = (Combo) event.widget;
+ save();
+ load(Plugin.getInstance().getConfigFileService().getConfig(combo.getText()));
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+
+ mainPage.addBtnAddListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ save();
+ load(Plugin.getInstance().getConfigFileService().getDefaultConfig());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+
+ }
+ });
+ mainPage.addBtnSaveListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ saveAction();
+ mainPage.setConfigTitleList(Plugin.getInstance().getConfigFileService().getConfigTitles());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ mainPage.addBtnDeleteListener(new SelectionListener()
+ {
+
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ if (MessageDialog.openConfirm(getShell(), Plugin.getInstance().getMessageService().resolveMessageKey("dialog.delete"),
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.delete.msg")))
+ {
+ deleteConfig();
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ this.visiblePage = mainPage;
+ this.navigator = new Navigator();
+ this.navigator.addPage(this.visiblePage);
+ final SchemaOptionsPage schemaOptions = new SchemaOptionsPage(area, SWT.NONE);
+ schemaOptions.addBtnTableDialogListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ ConfigurationDialog.this.navigator.save();
+ DBTablesDialog dbTablesDialog = new DBTablesDialog(getShell(), ConfigurationDialog.this.navigator.getCurrentConfig()
+ .getCodeGenConfig());
+ if (dbTablesDialog.open() == Window.OK)
+ {
+ schemaOptions.getCtlDbTablePattern().setText(dbTablesDialog.getSelectedTables());
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ this.navigator.addPage(schemaOptions);
+ ClassParameterPage classParameterPage = new ClassParameterPage(area, SWT.NONE);
+ this.navigator.addPage(classParameterPage);
+ this.navigator.setPagesEnabled(false);
+
+ setHelpAvailable(false);
+ return area;
+ }
+
+ private void UpdateControls()
+ {
+ this.btnPreviousPage.setVisible(this.navigator.hasPreviousPage());
+ this.btnNextPage.setVisible(this.navigator.hasNextPage());
+ }
+
+ public void save()
+ {
+ if (ConfigurationDialog.this.navigator.getCurrentConfig() != null
+ && MessageDialog.openQuestion(getShell(), Plugin.getInstance().getMessageService().resolveMessageKey("dialog.save"),
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.save.msg")))
+ {
+ saveAction();
+ }
+ }
+
+ public void saveAction()
+ {
+ ConfigFile configFile = this.navigator.save();
+ if (configFile != null)
+ {
+ Plugin.getInstance().getConfigFileService().saveConfig(configFile);
+ }
+ }
+
+ public void load(ConfigFile config)
+ {
+ this.navigator.load(config);
+ }
+
+ public void deleteConfig()
+ {
+ Plugin.getInstance().getConfigFileService().deleteConfig(this.navigator.getCurrentConfig().getUuid());
+ this.navigator.load(null);
+ }
+
+ public boolean hasConfig()
+ {
+ return this.navigator.getCurrentConfig() != null;
+ }
+
+ public String getConfigFileAbsolutPath()
+ {
+ return Plugin.getInstance().getConfigFileService().getConfigFilePath(this.navigator.getCurrentConfig().getUuid());
+ }
+
+ private boolean checkRequiredFields()
+ {
+ return this.navigator.checkRequiredFields();
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/DBTablesDialog.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/DBTablesDialog.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/DBTablesDialog.java
new file mode 100644
index 0000000..585f1d9
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/DBTablesDialog.java
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.apache.empire.db.codegen.util.DBUtil;
+import org.apache.empire.db.eclipse.CodeGenConfig;
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.PluginConsts;
+import org.apache.empire.db.eclipse.util.SWTResourceManager;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DBTablesDialog extends TitleAreaDialog
+{
+ private CheckboxTableViewer checkboxTableViewer;
+ private Button btnConnect;
+
+ private final CodeGenConfig config;
+ private Label lblConnection;
+ private Button btnOk;
+ private Button btnSpaceholder;
+
+ private String selectedTables;
+
+ public DBTablesDialog(Shell parentShell, CodeGenConfig config)
+ {
+ super(parentShell);
+ this.config = config;
+ }
+
+ @Override
+ public void create()
+ {
+ super.create();
+ setTitle(Plugin.getInstance().getMessageService().resolveMessageKey("dialog.tables.discription"));
+ }
+
+ @Override
+ protected Point getInitialSize()
+ {
+ return new Point(343, 473);
+ }
+
+ // overriding this methods allows you to set the
+ // title of the custom dialog
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dialog.tables.title"));
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ parent.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, true, true));
+
+ this.btnSpaceholder = createButton(parent, PluginConsts.BUTTON_PREVIOUS_ID, " ", true);
+ this.btnSpaceholder.setText("################");
+ this.btnSpaceholder.setVisible(false);
+
+ // Update layout of the parent composite to count the spacer
+ GridLayout layout = (GridLayout) parent.getLayout();
+ layout.makeColumnsEqualWidth = false;
+
+ this.btnOk = createButton(parent, PluginConsts.BUTTON_OK,
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.tables.finish"), false);
+ this.btnOk.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ StringBuilder sb = new StringBuilder();
+ Object[] tables = DBTablesDialog.this.checkboxTableViewer.getCheckedElements();
+ for (Object table : tables)
+ {
+ sb.append(table).append(",");
+ }
+ DBTablesDialog.this.selectedTables = sb.toString().substring(0, sb.length() - 1);
+ setReturnCode(Window.OK);
+ close();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ createButton(parent, Window.CANCEL, Plugin.getInstance().getMessageService().resolveMessageKey("dialog.close"), false);
+
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ setTitleImage(SWTResourceManager.getImage(ConfigurationDialog.class, "/icons/logo.png"));
+ Composite composite = (Composite) super.createDialogArea(parent);
+ composite.setLayout(null);
+
+ this.btnConnect = new Button(composite, SWT.NONE);
+ this.btnConnect.setBounds(5, 5, 145, 25);
+ this.btnConnect.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dialog.tables.connect"));
+ this.btnConnect.setImage(SWTResourceManager.getImage(ConfigurationDialog.class, "/icons/testConnection.gif"));
+ this.btnConnect.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ try
+ {
+ Connection con = Plugin.getInstance().getJDBCConnection(DBTablesDialog.this.config.getJdbcType(),
+ DBTablesDialog.this.config.getJdbcServer(),
+ DBTablesDialog.this.config.getJdbcPort(),
+ DBTablesDialog.this.config.getJdbcSID(),
+ DBTablesDialog.this.config.getJdbcUser(),
+ DBTablesDialog.this.config.getJdbcPwd());
+ if (con != null)
+ {
+ DBTablesDialog.this.lblConnection.setText(Plugin.getInstance().getMessageService()
+ .resolveMessageKey("connectionSuccess"));
+ DBTablesDialog.this.lblConnection.setForeground(new Color(getShell().getDisplay(), 0, 255, 0));
+ DBTablesDialog.this.checkboxTableViewer.setInput(con);
+ if (DBTablesDialog.this.config.getDbTablePattern() != null)
+ {
+ String[] tablePatterns = DBTablesDialog.this.config.getDbTablePattern().split(",");
+ for (String pattern : tablePatterns)
+ {
+ DBTablesDialog.this.checkboxTableViewer.setChecked(pattern, true);
+ }
+ }
+ }
+ con.close();
+ }
+ catch (Exception e)
+ {
+ DBTablesDialog.this.lblConnection.setText(Plugin.getInstance().getMessageService()
+ .resolveMessageKey("connectionFailed"));
+ DBTablesDialog.this.lblConnection.setForeground(new Color(getShell().getDisplay(), 255, 0, 0));
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+
+ this.checkboxTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
+ final Table table = this.checkboxTableViewer.getTable();
+ table.setBounds(5, 35, 290, 231);
+ table.setLinesVisible(true);
+
+ final Button btnCheckAll = new Button(composite, SWT.NONE);
+ btnCheckAll.setBounds(301, 35, 26, 26);
+ btnCheckAll.setImage(SWTResourceManager.getImage(ConfigurationDialog.class, "/icons/check_all.gif"));
+ btnCheckAll.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ Table table = DBTablesDialog.this.checkboxTableViewer.getTable();
+ for (int i = 0; i < table.getItemCount(); i++)
+ {
+ table.getItem(i).setChecked(true);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+
+ final Button btnUncheckAll = new Button(composite, SWT.NONE);
+ btnUncheckAll.setBounds(301, 67, 26, 26);
+ btnUncheckAll.setImage(SWTResourceManager.getImage(ConfigurationDialog.class, "/icons/uncheck_all.gif"));
+ btnUncheckAll.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ Table table = DBTablesDialog.this.checkboxTableViewer.getTable();
+ for (int i = 0; i < table.getItemCount(); i++)
+ {
+ table.getItem(i).setChecked(false);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+
+ this.lblConnection = new Label(composite, SWT.NONE);
+ this.lblConnection.setBounds(156, 10, 139, 15);
+ this.checkboxTableViewer.setContentProvider(new DBTablesContentProvider(this.config));
+ this.checkboxTableViewer.setLabelProvider(new DBTablesLabelProvider());
+
+ setHelpAvailable(false);
+ return composite;
+ }
+
+ public String getSelectedTables()
+ {
+ return this.selectedTables;
+ }
+
+ public void setSelectedTables(String selectedTables)
+ {
+ this.selectedTables = selectedTables;
+ }
+}
+
+class DBTablesContentProvider implements IStructuredContentProvider
+{
+ private static final Logger log = LoggerFactory.getLogger(DBTablesContentProvider.class);
+
+ private static final Object[] EMPTY = new Object[] {};
+
+ private final CodeGenConfig config;
+
+ public DBTablesContentProvider(CodeGenConfig config)
+ {
+ this.config = config;
+ }
+
+ public Object[] getElements(Object arg0)
+ {
+ Connection con = (Connection) arg0;
+ ResultSet tables = null;
+ ArrayList<String> tableNames = new ArrayList<String>();
+ try
+ {
+ DatabaseMetaData dbMeta = con.getMetaData();
+ // Get table metadata
+ tables = dbMeta.getTables(this.config.getDbCatalog(), this.config.getDbSchema(), "%", new String[] { "TABLE", "VIEW" });
+ // Add all tables and views
+ while (tables.next())
+ {
+ String tableName = tables.getString("TABLE_NAME");
+ String tableType = tables.getString("TABLE_TYPE");
+ // Ignore system tables containing a '$' symbol (required for
+ // Oracle!)
+ if (tableName.indexOf('$') >= 0)
+ {
+ DBTablesContentProvider.log.info("Ignoring system table " + tableName);
+ continue;
+ }
+ DBTablesContentProvider.log.info(tableType + ": " + tableName);
+ tableNames.add(tableName);
+ }
+ return tableNames.toArray();
+ }
+ catch (SQLException e)
+ {
+ DBTablesContentProvider.log.info("Error loading meta data: " + e.getMessage());
+ }
+ finally
+ {
+ DBUtil.close(tables, DBTablesContentProvider.log);
+ }
+ return DBTablesContentProvider.EMPTY;
+ }
+
+ public void dispose()
+ {
+ // Nothing to dispose
+ }
+
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2)
+ {
+ // Nothing to do
+ }
+}
+
+class DBTablesLabelProvider implements ILabelProvider
+{
+ public Image getImage(Object arg0)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the name of the file
+ *
+ * @param arg0
+ * the name of the file
+ * @return String
+ */
+ public String getText(Object arg0)
+ {
+ return (String) arg0;
+ }
+
+ public void addListener(ILabelProviderListener arg0)
+ {
+ // Throw it away
+ }
+
+ public void dispose()
+ {
+ // Nothing to dispose
+ }
+
+ public boolean isLabelProperty(Object arg0, String arg1)
+ {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener arg0)
+ {
+ // Ignore
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/INavigator.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/INavigator.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/INavigator.java
new file mode 100644
index 0000000..ca366a2
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/INavigator.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import org.apache.empire.db.eclipse.model.ConfigFile;
+
+public interface INavigator
+{
+ public void addPage(Page page);
+
+ public boolean removePage(Page page);
+
+ public boolean showNextPage();
+
+ public boolean showPreviousPage();
+
+ public boolean hasNextPage();
+
+ public boolean hasPreviousPage();
+
+ public ConfigFile save();
+
+ public void load(ConfigFile config);
+
+ public ConfigFile getCurrentConfig();
+
+ public void setPagesEnabled(boolean enabled);
+
+ public boolean checkRequiredFields();
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/IPage.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/IPage.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/IPage.java
new file mode 100644
index 0000000..550d675
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/IPage.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import org.apache.empire.db.eclipse.CodeGenConfig;
+
+public interface IPage
+{
+ public void save(CodeGenConfig config);
+
+ public void load(CodeGenConfig config);
+
+ public boolean checkRequiredFields();
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/MainPage.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/MainPage.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/MainPage.java
new file mode 100644
index 0000000..7edeefb
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/MainPage.java
@@ -0,0 +1,305 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import java.sql.Connection;
+
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.db.eclipse.CodeGenConfig;
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.util.SWTResourceManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class MainPage extends Page
+{
+ private final Text ctlConfigTitle;
+ private final Text ctlServerUrl;
+ private final Text ctlServerPort;
+ private final Text ctlUser;
+ private final Text ctlPassword;
+ private final Text ctlPasswordConfirm;
+ private final Text ctlSID;
+
+ private final Combo ctlExistingConfigs;
+ private final Combo ctlDatabaseType;
+
+ private final Group groupJdbc;
+
+ private final Button btnAdd;
+ private final Button btnSave;
+ private final Button btnDelete;
+ private final Label lblDatabaseType;
+ private final Label lblServerAddress;
+ private final Label lblServerPort;
+ private final Label lblUser;
+ private final Label lblPassword;
+ private final Label lblPasswordConfirm;
+ private final Label lblSid;
+ private final Label lblConfigurationTitle;
+ private final Button btnTestConnection;
+ private final Label lblTestConResult;
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ */
+ public MainPage(Composite parent, int style)
+ {
+ super(parent, style);
+ setLayout(null);
+
+ Label lblExistingConfigurations = new Label(this, SWT.NONE);
+ lblExistingConfigurations.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
+ lblExistingConfigurations.setBounds(6, 31, 154, 15);
+ lblExistingConfigurations.setText(Plugin.getInstance().getMessageService().resolveMessageKey("existingConfigs"));
+
+ this.ctlExistingConfigs = new Combo(this, SWT.READ_ONLY);
+ this.ctlExistingConfigs.setItems(Plugin.getInstance().getConfigFileService().getConfigTitles());
+ this.ctlExistingConfigs.setBounds(165, 27, 248, 23);
+ this.btnAdd = new Button(this, SWT.NONE);
+ this.btnAdd.setBounds(419, 25, 26, 26);
+ this.btnAdd.setImage(SWTResourceManager.getImage(MainPage.class, "/icons/addButton.png"));
+
+ this.lblConfigurationTitle = new Label(this, SWT.NONE);
+ this.lblConfigurationTitle.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
+ this.lblConfigurationTitle.setBounds(6, 62, 154, 15);
+ this.lblConfigurationTitle.setText(Plugin.getInstance().getMessageService().resolveMessageKey("configTitle"));
+
+ this.ctlConfigTitle = new Text(this, SWT.BORDER);
+ this.ctlConfigTitle.setBounds(165, 59, 216, 21);
+
+ this.btnSave = new Button(this, SWT.NONE);
+ this.btnSave.setImage(SWTResourceManager.getImage(MainPage.class, "/icons/save.png"));
+ this.btnSave.setBounds(387, 56, 26, 26);
+
+ this.btnDelete = new Button(this, SWT.NONE);
+ this.btnDelete.setBounds(419, 56, 26, 26);
+ this.btnDelete.setImage(SWTResourceManager.getImage(MainPage.class, "/icons/deleteButton.png"));
+
+ this.groupJdbc = new Group(this, SWT.NONE);
+ this.groupJdbc.setFont(SWTResourceManager.getFont("Segoe UI", 10, SWT.BOLD));
+ this.groupJdbc.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbConnection"));
+ this.groupJdbc.setBounds(5, 110, 440, 243);
+
+ this.lblDatabaseType = new Label(this.groupJdbc, SWT.NONE);
+ this.lblDatabaseType.setBounds(10, 21, 154, 15);
+ this.lblDatabaseType.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbConnectionType"));
+
+ this.ctlDatabaseType = new Combo(this.groupJdbc, SWT.READ_ONLY);
+ this.ctlDatabaseType.setBounds(180, 18, 250, 23);
+ this.ctlDatabaseType.setItems(Plugin.getInstance().getDriverClassNames());
+
+ this.lblServerAddress = new Label(this.groupJdbc, SWT.NONE);
+ this.lblServerAddress.setBounds(10, 49, 154, 17);
+ this.lblServerAddress.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbServer"));
+
+ this.ctlServerUrl = new Text(this.groupJdbc, SWT.BORDER);
+ this.ctlServerUrl.setBounds(180, 46, 250, 21);
+
+ this.lblServerPort = new Label(this.groupJdbc, SWT.NONE);
+ this.lblServerPort.setBounds(10, 75, 154, 15);
+ this.lblServerPort.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbPort"));
+
+ this.ctlServerPort = new Text(this.groupJdbc, SWT.BORDER);
+ this.ctlServerPort.setBounds(180, 72, 78, 21);
+
+ this.ctlSID = new Text(this.groupJdbc, SWT.BORDER);
+ this.ctlSID.setBounds(180, 99, 250, 21);
+
+ this.lblSid = new Label(this.groupJdbc, SWT.NONE);
+ this.lblSid.setBounds(10, 102, 154, 15);
+ this.lblSid.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbSid"));
+
+ this.lblUser = new Label(this.groupJdbc, SWT.NONE);
+ this.lblUser.setBounds(10, 129, 154, 15);
+ this.lblUser.setText(Plugin.getInstance().getMessageService().resolveMessageKey("jdbcUser"));
+
+ this.ctlUser = new Text(this.groupJdbc, SWT.BORDER);
+ this.ctlUser.setBounds(180, 126, 250, 21);
+
+ this.lblPassword = new Label(this.groupJdbc, SWT.NONE);
+ this.lblPassword.setBounds(10, 156, 154, 15);
+ this.lblPassword.setText(Plugin.getInstance().getMessageService().resolveMessageKey("jdbcPassword"));
+
+ this.ctlPassword = new Text(this.groupJdbc, SWT.BORDER | SWT.PASSWORD);
+ this.ctlPassword.setBounds(180, 153, 250, 21);
+
+ this.lblPasswordConfirm = new Label(this.groupJdbc, SWT.NONE);
+ this.lblPasswordConfirm.setBounds(10, 183, 154, 15);
+ this.lblPasswordConfirm.setText(Plugin.getInstance().getMessageService().resolveMessageKey("jdbcPasswordConfirm"));
+
+ this.ctlPasswordConfirm = new Text(this.groupJdbc, SWT.BORDER | SWT.PASSWORD);
+ this.ctlPasswordConfirm.setBounds(180, 180, 250, 21);
+
+ this.btnTestConnection = new Button(this.groupJdbc, SWT.NONE);
+ this.btnTestConnection.setImage(SWTResourceManager.getImage(MainPage.class, "/icons/testConnection.gif"));
+ this.btnTestConnection.setText(Plugin.getInstance().getMessageService().resolveMessageKey("testConnection"));
+ this.btnTestConnection.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.testConnection"));
+ this.btnTestConnection.setBounds(10, 207, 166, 26);
+
+ this.lblTestConResult = new Label(this.groupJdbc, SWT.NONE);
+ this.lblTestConResult.setBounds(180, 213, 250, 15);
+ this.btnTestConnection.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ try
+ {
+ if (!MainPage.this.ctlPassword.getText().equals(MainPage.this.ctlPasswordConfirm.getText()))
+ {
+ MessageDialog.openError(getShell(),
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.passwordMismatch"),
+ Plugin.getInstance().getMessageService()
+ .resolveMessageKey("dialog.passwordMismatch.msg"));
+ return;
+ }
+ Connection con = Plugin.getInstance().getJDBCConnection(MainPage.this.ctlDatabaseType.getText(),
+ MainPage.this.ctlServerUrl.getText(),
+ MainPage.this.ctlServerPort.getText(),
+ MainPage.this.ctlSID.getText(),
+ MainPage.this.ctlUser.getText(),
+ MainPage.this.ctlPassword.getText());
+ if (con != null && !con.isClosed())
+ {
+ MainPage.this.lblTestConResult.setText(Plugin.getInstance().getMessageService()
+ .resolveMessageKey("connectionSuccess"));
+ MainPage.this.lblTestConResult.setForeground(new Color(getDisplay(), 0, 255, 0));
+ }
+ else
+ {
+ MainPage.this.lblTestConResult.setText(Plugin.getInstance().getMessageService()
+ .resolveMessageKey("connectionFailed"));
+ MainPage.this.lblTestConResult.setForeground(new Color(getDisplay(), 255, 0, 0));
+ }
+ if (con != null)
+ {
+ con.close();
+ }
+ }
+ catch (Exception e)
+ {
+ MainPage.this.lblTestConResult.setText(Plugin.getInstance().getMessageService()
+ .resolveMessageKey("connectionFailed"));
+ MainPage.this.lblTestConResult.setForeground(new Color(getDisplay(), 255, 0, 0));
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+ }
+
+ public void save(CodeGenConfig config)
+ {
+ config.setConfigTitle(this.ctlConfigTitle.getText());
+ config.setJdbcServer(this.ctlServerUrl.getText());
+ config.setJdbcPort(this.ctlServerPort.getText());
+ config.setJdbcSID(this.ctlSID.getText());
+ config.setJdbcUser(this.ctlUser.getText());
+ config.setJdbcPwd(this.ctlPassword.getText());
+ config.setJdbcType(this.ctlDatabaseType.getText());
+ }
+
+ public void load(CodeGenConfig config)
+ {
+ setControlText(this.ctlConfigTitle, config.getConfigTitle());
+ setControlText(this.ctlServerUrl, config.getJdbcServer());
+ setControlText(this.ctlServerPort, config.getJdbcPort());
+ setControlText(this.ctlSID, config.getJdbcSID());
+ setControlText(this.ctlUser, config.getJdbcUser());
+ setControlText(this.ctlPassword, config.getJdbcPwd());
+ this.ctlDatabaseType.setText(!StringUtils.isEmpty(config.getJdbcType()) ? config.getJdbcType() : " ");
+ this.lblTestConResult.setText(" ");
+ }
+
+ @Override
+ public void setEnabled(boolean enabled)
+ {
+ this.ctlConfigTitle.setEnabled(enabled);
+ this.ctlServerUrl.setEnabled(enabled);
+ this.ctlServerPort.setEnabled(enabled);
+ this.ctlUser.setEnabled(enabled);
+ this.ctlPassword.setEnabled(enabled);
+ this.ctlPasswordConfirm.setEnabled(enabled);
+ this.ctlSID.setEnabled(enabled);
+ this.ctlDatabaseType.setEnabled(enabled);
+ this.btnTestConnection.setEnabled(enabled);
+ }
+
+ public boolean checkRequiredFields()
+ {
+ if (!this.ctlPassword.getText().equals(this.ctlPasswordConfirm.getText()))
+ {
+ MessageDialog.openError(getShell(), Plugin.getInstance().getMessageService().resolveMessageKey("dialog.passwordMismatch"),
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.passwordMismatch.msg"));
+ return false;
+ }
+ return checkControlFilled(this.ctlConfigTitle, this.lblConfigurationTitle.getText())
+ && checkControlFilled(this.ctlServerUrl, this.lblServerAddress.getText())
+ && checkControlFilled(this.ctlServerPort, this.lblServerPort.getText())
+ && checkControlFilled(this.ctlUser, this.lblUser.getText())
+ && checkControlFilled(this.ctlPassword, this.lblPassword.getText())
+ && checkControlFilled(this.ctlPasswordConfirm, this.lblPasswordConfirm.getText())
+ && checkControlFilled(this.ctlSID, this.lblSid.getText());
+ }
+
+ public void addExistingConfigsListener(SelectionListener listener)
+ {
+ this.ctlExistingConfigs.addSelectionListener(listener);
+ }
+
+ public void addBtnAddListener(SelectionListener listener)
+ {
+ this.btnAdd.addSelectionListener(listener);
+ }
+
+ public void addBtnSaveListener(SelectionListener listener)
+ {
+ this.btnSave.addSelectionListener(listener);
+ }
+
+ public void addBtnDeleteListener(SelectionListener listener)
+ {
+ this.btnDelete.addSelectionListener(listener);
+ }
+
+ public void setConfigTitleList(String[] configTitleList)
+ {
+ this.ctlExistingConfigs.setItems(configTitleList);
+ }
+
+ @Override
+ protected void checkSubclass()
+ {
+ // Disable the check that prevents subclassing of SWT components
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Navigator.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Navigator.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Navigator.java
new file mode 100644
index 0000000..28534d7
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Navigator.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.empire.db.eclipse.CodeGenConfig;
+import org.apache.empire.db.eclipse.model.ConfigFile;
+
+public class Navigator implements INavigator
+{
+ private final List<Page> pages;
+
+ private int currentPage;
+
+ private ConfigFile currentConfig;
+
+ public Navigator()
+ {
+ this.pages = new ArrayList<Page>();
+ this.currentPage = 0;
+ }
+
+ public void addPage(Page page)
+ {
+ if (this.pages.size() > 0)
+ {
+ page.setVisible(false);
+ }
+ this.pages.add(page);
+ }
+
+ public boolean removePage(Page page)
+ {
+ if (!this.pages.contains(page))
+ {
+ return false;
+ }
+ return this.pages.remove(page);
+ }
+
+ public boolean showNextPage()
+ {
+ if (!hasNextPage())
+ {
+ return false;
+ }
+ this.pages.get(this.currentPage).setVisible(false);
+ this.currentPage++;
+ this.pages.get(this.currentPage).setVisible(true);
+ return true;
+ }
+
+ public boolean showPreviousPage()
+ {
+ if (!hasPreviousPage())
+ {
+ return false;
+ }
+ this.pages.get(this.currentPage).setVisible(false);
+ this.currentPage--;
+ this.pages.get(this.currentPage).setVisible(true);
+ return true;
+ }
+
+ public boolean hasNextPage()
+ {
+ return this.currentPage < this.pages.size() - 1;
+ }
+
+ public boolean hasPreviousPage()
+ {
+ return this.currentPage > 0;
+ }
+
+ public ConfigFile save()
+ {
+ if (this.currentConfig == null)
+ {
+ return null;
+ }
+ for (Page page : this.pages)
+ {
+ page.save(this.currentConfig.getCodeGenConfig());
+ }
+ return this.currentConfig;
+ }
+
+ public void load(ConfigFile config)
+ {
+ setCurrentConfig(config);
+ for (Page page : this.pages)
+ {
+ page.load(config != null ? config.getCodeGenConfig() : new CodeGenConfig());
+ }
+ }
+
+ public ConfigFile getCurrentConfig()
+ {
+ return this.currentConfig;
+ }
+
+ private void setCurrentConfig(ConfigFile currentConfig)
+ {
+ setPagesEnabled(currentConfig != null);
+ this.currentConfig = currentConfig;
+ }
+
+ public void setPagesEnabled(boolean enabled)
+ {
+ for (Page page : this.pages)
+ {
+ page.setEnabled(enabled);
+ }
+ }
+
+ public boolean checkRequiredFields()
+ {
+ for (Page page : this.pages)
+ {
+ if (!page.checkRequiredFields())
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Page.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Page.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Page.java
new file mode 100644
index 0000000..badca1a
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/Page.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.db.eclipse.Plugin;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public abstract class Page extends Composite implements IPage
+{
+ public Page(Composite parent, int style)
+ {
+ super(parent, style);
+ this.setSize(450, 500);
+ this.setBounds(10, 0, 450, 500);
+ }
+
+ protected void setControlText(Text ctlText, String value)
+ {
+ ctlText.setText(value != null ? value : "");
+ }
+
+ protected boolean checkControlFilled(Text ctlText, String field)
+ {
+ if (StringUtils.isNotEmpty(ctlText.getText()))
+ {
+ return true;
+ }
+ MessageDialog.openError(getShell(), Plugin.getInstance().getMessageService().resolveMessageKey("dialog.errorFieldRequired"),
+ Plugin.getInstance().getMessageService().resolveMessageKey("dialog.errorFieldRequired.msg", field));
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/SchemaOptionsPage.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/SchemaOptionsPage.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/SchemaOptionsPage.java
new file mode 100644
index 0000000..69ce3c3
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/ui/SchemaOptionsPage.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.ui;
+
+import org.apache.empire.db.eclipse.CodeGenConfig;
+import org.apache.empire.db.eclipse.Plugin;
+import org.apache.empire.db.eclipse.util.SWTResourceManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class SchemaOptionsPage extends Page
+{
+ private final Text ctlDbCatalog;
+ private final Text ctlDbSchema;
+ private final Text ctlTimestampCol;
+ private final Text ctlDbTablePattern;
+
+ private final Text ctlTargetFolder;
+ private final Text ctlPackageName;
+ private final Text ctlTablePackageName;
+ private final Text ctlViewPackageName;
+ private final Text ctlRecordPackageName;
+
+ private final Group groupRequired;
+
+ private final Label lblTargetFolder;
+ private final Label lblPackageName;
+ private final Label lblTablePackageName;
+ private final Label lblViewPackageName;
+ private final Label lblRecordPackageName;
+ private final Button btnDirectoryDialog;
+ private final Button btnOpenTableDialog;
+
+ public SchemaOptionsPage(Composite parent, int style)
+ {
+ super(parent, style);
+ setLayout(null);
+
+ Group grpSchemaOptions = new Group(this, SWT.NONE);
+ grpSchemaOptions.setFont(SWTResourceManager.getFont("Segoe UI", 10, SWT.BOLD));
+ grpSchemaOptions.setText(Plugin.getInstance().getMessageService().resolveMessageKey("schemaOptions"));
+ grpSchemaOptions.setBounds(5, 30, 440, 128);
+
+ Label lblDbCatalog = new Label(grpSchemaOptions, SWT.NONE);
+ lblDbCatalog.setBounds(10, 23, 154, 17);
+ lblDbCatalog.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbCatalog"));
+ lblDbCatalog.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbCatalog"));
+
+ this.ctlDbCatalog = new Text(grpSchemaOptions, SWT.BORDER);
+ this.ctlDbCatalog.setBounds(180, 20, 250, 21);
+ this.ctlDbCatalog.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbCatalog"));
+
+ Label lblDbSchema = new Label(grpSchemaOptions, SWT.NONE);
+ lblDbSchema.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbSchema"));
+ lblDbSchema.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbSchema"));
+ lblDbSchema.setBounds(10, 49, 154, 17);
+
+ this.ctlDbSchema = new Text(grpSchemaOptions, SWT.BORDER);
+ this.ctlDbSchema.setBounds(180, 46, 250, 21);
+ this.ctlDbSchema.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbSchema"));
+
+ Label lblDbTablePattern = new Label(grpSchemaOptions, SWT.NONE);
+ lblDbTablePattern.setText(Plugin.getInstance().getMessageService().resolveMessageKey("dbTablePattern"));
+ lblDbTablePattern.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbTablePattern"));
+ lblDbTablePattern.setBounds(10, 75, 154, 17);
+
+ this.ctlDbTablePattern = new Text(grpSchemaOptions, SWT.BORDER);
+ this.ctlDbTablePattern.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.dbTablePattern"));
+ this.getCtlDbTablePattern().setBounds(180, 72, 218, 21);
+
+ Label lblTimestampCol = new Label(grpSchemaOptions, SWT.NONE);
+ lblTimestampCol.setText(Plugin.getInstance().getMessageService().resolveMessageKey("timestampColumn"));
+ lblTimestampCol.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.timestampColumn"));
+ lblTimestampCol.setBounds(10, 98, 154, 17);
+
+ this.ctlTimestampCol = new Text(grpSchemaOptions, SWT.BORDER);
+ this.ctlTimestampCol.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.timestampColumn"));
+ this.ctlTimestampCol.setBounds(180, 98, 250, 21);
+
+ this.btnOpenTableDialog = new Button(grpSchemaOptions, SWT.NONE);
+ this.btnOpenTableDialog.setBounds(404, 69, 26, 26);
+ this.btnOpenTableDialog.setImage(SWTResourceManager.getImage(SchemaOptionsPage.class, "/icons/db_element.gif"));
+
+ this.groupRequired = new Group(this, SWT.NONE);
+ this.groupRequired.setText(Plugin.getInstance().getMessageService().resolveMessageKey("requiredParams"));
+ this.groupRequired.setFont(SWTResourceManager.getFont("Segoe UI", 10, SWT.BOLD));
+ this.groupRequired.setBounds(5, 180, 440, 149);
+
+ this.lblTargetFolder = new Label(this.groupRequired, SWT.NONE);
+ this.lblTargetFolder.setBounds(10, 18, 154, 15);
+ this.lblTargetFolder.setText(Plugin.getInstance().getMessageService().resolveMessageKey("targetFolder"));
+ this.lblTargetFolder.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.targetFolder"));
+
+ this.ctlTargetFolder = new Text(this.groupRequired, SWT.BORDER);
+ this.ctlTargetFolder.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.targetFolder"));
+ this.ctlTargetFolder.setBounds(180, 15, 218, 21);
+
+
+ this.btnDirectoryDialog = new Button(this.groupRequired, SWT.NONE);
+ this.btnDirectoryDialog.setImage(SWTResourceManager.getImage(SchemaOptionsPage.class, "/icons/folder.gif"));
+ this.btnDirectoryDialog.setBounds(404, 12, 26, 26);
+ this.btnDirectoryDialog.addSelectionListener(new SelectionListener()
+ {
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
+ directoryDialog.setFilterPath(SchemaOptionsPage.this.ctlTargetFolder.getText());
+ String path = directoryDialog.open();
+ if (path != null)
+ {
+ SchemaOptionsPage.this.ctlTargetFolder.setText(path);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0)
+ {
+ }
+ });
+
+ this.lblPackageName = new Label(this.groupRequired, SWT.NONE);
+ this.lblPackageName.setBounds(10, 45, 154, 15);
+ this.lblPackageName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("packageName"));
+ this.lblPackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.packageName"));
+
+ this.ctlPackageName = new Text(this.groupRequired, SWT.BORDER);
+ this.ctlPackageName.setBounds(180, 42, 250, 21);
+ this.ctlPackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.packageName"));
+
+ this.lblTablePackageName = new Label(this.groupRequired, SWT.NONE);
+ this.lblTablePackageName.setBounds(10, 72, 154, 15);
+ this.lblTablePackageName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("tablePackageName"));
+ this.lblTablePackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tablePackageName"));
+
+ this.ctlTablePackageName = new Text(this.groupRequired, SWT.BORDER);
+ this.ctlTablePackageName.setBounds(180, 69, 250, 21);
+ this.ctlTablePackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.tablePackageName"));
+
+ this.lblViewPackageName = new Label(this.groupRequired, SWT.NONE);
+ this.lblViewPackageName.setBounds(10, 99, 154, 15);
+ this.lblViewPackageName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("viewPackageName"));
+ this.lblViewPackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewPackageName"));
+
+ this.ctlViewPackageName = new Text(this.groupRequired, SWT.BORDER);
+ this.ctlViewPackageName.setBounds(180, 96, 250, 21);
+ this.ctlViewPackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.viewPackageName"));
+
+ this.lblRecordPackageName = new Label(this.groupRequired, SWT.NONE);
+ this.lblRecordPackageName.setBounds(10, 126, 154, 15);
+ this.lblRecordPackageName.setText(Plugin.getInstance().getMessageService().resolveMessageKey("recordPackageName"));
+ this.lblRecordPackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.recordPackageName"));
+
+ this.ctlRecordPackageName = new Text(this.groupRequired, SWT.BORDER);
+ this.ctlRecordPackageName.setBounds(180, 123, 250, 21);
+ this.ctlRecordPackageName.setToolTipText(Plugin.getInstance().getMessageService().resolveMessageKey("tooltip.recordPackageName"));
+ }
+
+ public void save(CodeGenConfig config)
+ {
+ config.setDbCatalog(this.ctlDbCatalog.getText());
+ config.setDbSchema(this.ctlDbSchema.getText());
+ config.setTimestampColumn(this.ctlTimestampCol.getText());
+ config.setDbTablePattern(this.getCtlDbTablePattern().getText());
+ config.setTargetFolder(this.ctlTargetFolder.getText());
+ config.setPackageName(this.ctlPackageName.getText());
+ config.setTablePackageName(this.ctlTablePackageName.getText());
+ config.setViewPackageName(this.ctlViewPackageName.getText());
+ config.setRecordPackageName(this.ctlRecordPackageName.getText());
+ }
+
+ public void load(CodeGenConfig config)
+ {
+ setControlText(this.ctlDbCatalog, config.getDbCatalog());
+ setControlText(this.ctlDbSchema, config.getDbSchema());
+ setControlText(this.ctlTimestampCol, config.getTimestampColumn());
+ setControlText(this.getCtlDbTablePattern(), config.getDbTablePattern());
+ setControlText(this.ctlTargetFolder, config.getTargetFolder());
+ setControlText(this.ctlPackageName, config.getPackageName());
+ setControlText(this.ctlTablePackageName, config.getTablePackageName());
+ setControlText(this.ctlViewPackageName, config.getViewPackageName());
+ setControlText(this.ctlRecordPackageName, config.getRecordPackageName());
+
+ }
+
+ @Override
+ public void setEnabled(boolean enabled)
+ {
+ this.ctlDbCatalog.setEnabled(enabled);
+ this.ctlDbSchema.setEnabled(enabled);
+ this.ctlTimestampCol.setEnabled(enabled);
+ this.getCtlDbTablePattern().setEnabled(enabled);
+ this.ctlTargetFolder.setEnabled(enabled);
+ this.ctlPackageName.setEnabled(enabled);
+ this.ctlTablePackageName.setEnabled(enabled);
+ this.ctlViewPackageName.setEnabled(enabled);
+ this.ctlRecordPackageName.setEnabled(enabled);
+ this.btnDirectoryDialog.setEnabled(enabled);
+ this.btnOpenTableDialog.setEnabled(enabled);
+ }
+
+ public boolean checkRequiredFields()
+ {
+ return checkControlFilled(this.ctlTargetFolder, this.lblTargetFolder.getText())
+ && checkControlFilled(this.ctlPackageName, this.lblPackageName.getText())
+ && checkControlFilled(this.ctlTablePackageName, this.lblTablePackageName.getText())
+ && checkControlFilled(this.ctlViewPackageName, this.lblViewPackageName.getText())
+ && checkControlFilled(this.ctlRecordPackageName, this.lblRecordPackageName.getText());
+ }
+
+ public void addBtnTableDialogListener(SelectionListener selectionListener)
+ {
+ this.btnOpenTableDialog.addSelectionListener(selectionListener);
+ }
+
+ public Text getCtlDbTablePattern()
+ {
+ return this.ctlDbTablePattern;
+ }
+}
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/util/SWTResourceManager.java
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/util/SWTResourceManager.java b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/util/SWTResourceManager.java
new file mode 100644
index 0000000..8217af2
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/java/org/apache/empire/db/eclipse/util/SWTResourceManager.java
@@ -0,0 +1,455 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.eclipse.util;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc.
+ * <p>
+ * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
+ * operating system resources managed by cached objects when those objects and OS resources are no longer
+ * needed (e.g. on application shutdown)
+ * <p>
+ * This class may be freely distributed as part of any application or plugin.
+ * <p>
+ * @author scheglov_ke
+ * @author Dan Rubel
+ */
+public class SWTResourceManager {
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Color
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>();
+ /**
+ * Returns the system {@link Color} matching the specific ID.
+ *
+ * @param systemColorID
+ * the ID value for the color
+ * @return the system {@link Color} matching the specific ID
+ */
+ public static Color getColor(int systemColorID) {
+ Display display = Display.getCurrent();
+ return display.getSystemColor(systemColorID);
+ }
+ /**
+ * Returns a {@link Color} given its red, green and blue component values.
+ *
+ * @param r
+ * the red component of the color
+ * @param g
+ * the green component of the color
+ * @param b
+ * the blue component of the color
+ * @return the {@link Color} matching the given red, green and blue component values
+ */
+ public static Color getColor(int r, int g, int b) {
+ return getColor(new RGB(r, g, b));
+ }
+ /**
+ * Returns a {@link Color} given its RGB value.
+ *
+ * @param rgb
+ * the {@link RGB} value of the color
+ * @return the {@link Color} matching the RGB value
+ */
+ public static Color getColor(RGB rgb) {
+ Color color = m_colorMap.get(rgb);
+ if (color == null) {
+ Display display = Display.getCurrent();
+ color = new Color(display, rgb);
+ m_colorMap.put(rgb, color);
+ }
+ return color;
+ }
+ /**
+ * Dispose of all the cached {@link Color}'s.
+ */
+ public static void disposeColors() {
+ for (Color color : m_colorMap.values()) {
+ color.dispose();
+ }
+ m_colorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Image
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps image paths to images.
+ */
+ private static Map<String, Image> m_imageMap = new HashMap<String, Image>();
+ /**
+ * Returns an {@link Image} encoded by the specified {@link InputStream}.
+ *
+ * @param stream
+ * the {@link InputStream} encoding the image data
+ * @return the {@link Image} encoded by the specified input stream
+ */
+ protected static Image getImage(InputStream stream) throws IOException {
+ try {
+ Display display = Display.getCurrent();
+ ImageData data = new ImageData(stream);
+ if (data.transparentPixel > 0) {
+ return new Image(display, data, data.getTransparencyMask());
+ }
+ return new Image(display, data);
+ } finally {
+ stream.close();
+ }
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path.
+ *
+ * @param path
+ * the path to the image file
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(String path) {
+ Image image = m_imageMap.get(path);
+ if (image == null) {
+ try {
+ image = getImage(new FileInputStream(path));
+ m_imageMap.put(path, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(path, image);
+ }
+ }
+ return image;
+ }
+ /**
+ * Returns an {@link Image} stored in the file at the specified path relative to the specified class.
+ *
+ * @param clazz
+ * the {@link Class} relative to which to find the image
+ * @param path
+ * the path to the image file, if starts with <code>'/'</code>
+ * @return the {@link Image} stored in the file at the specified path
+ */
+ public static Image getImage(Class<?> clazz, String path) {
+ String key = clazz.getName() + '|' + path;
+ Image image = m_imageMap.get(key);
+ if (image == null) {
+ try {
+ image = getImage(clazz.getResourceAsStream(path));
+ m_imageMap.put(key, image);
+ } catch (Exception e) {
+ image = getMissingImage();
+ m_imageMap.put(key, image);
+ }
+ }
+ return image;
+ }
+ private static final int MISSING_IMAGE_SIZE = 10;
+ /**
+ * @return the small {@link Image} that can be used as placeholder for missing image.
+ */
+ private static Image getMissingImage() {
+ Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ //
+ GC gc = new GC(image);
+ gc.setBackground(getColor(SWT.COLOR_RED));
+ gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
+ gc.dispose();
+ //
+ return image;
+ }
+ /**
+ * Style constant for placing decorator image in top left corner of base image.
+ */
+ public static final int TOP_LEFT = 1;
+ /**
+ * Style constant for placing decorator image in top right corner of base image.
+ */
+ public static final int TOP_RIGHT = 2;
+ /**
+ * Style constant for placing decorator image in bottom left corner of base image.
+ */
+ public static final int BOTTOM_LEFT = 3;
+ /**
+ * Style constant for placing decorator image in bottom right corner of base image.
+ */
+ public static final int BOTTOM_RIGHT = 4;
+ /**
+ * Internal value.
+ */
+ protected static final int LAST_CORNER_KEY = 5;
+ /**
+ * Maps images to decorated images.
+ */
+ @SuppressWarnings("unchecked")
+ private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @return {@link Image} The resulting decorated image
+ */
+ public static Image decorateImage(Image baseImage, Image decorator) {
+ return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
+ }
+ /**
+ * Returns an {@link Image} composed of a base image decorated by another image.
+ *
+ * @param baseImage
+ * the base {@link Image} that should be decorated
+ * @param decorator
+ * the {@link Image} to decorate the base image
+ * @param corner
+ * the corner to place decorator image
+ * @return the resulting decorated {@link Image}
+ */
+ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
+ if (corner <= 0 || corner >= LAST_CORNER_KEY) {
+ throw new IllegalArgumentException("Wrong decorate corner");
+ }
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
+ if (cornerDecoratedImageMap == null) {
+ cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+ m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+ }
+ Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
+ if (decoratedMap == null) {
+ decoratedMap = new HashMap<Image, Image>();
+ cornerDecoratedImageMap.put(baseImage, decoratedMap);
+ }
+ //
+ Image result = decoratedMap.get(decorator);
+ if (result == null) {
+ Rectangle bib = baseImage.getBounds();
+ Rectangle dib = decorator.getBounds();
+ //
+ result = new Image(Display.getCurrent(), bib.width, bib.height);
+ //
+ GC gc = new GC(result);
+ gc.drawImage(baseImage, 0, 0);
+ if (corner == TOP_LEFT) {
+ gc.drawImage(decorator, 0, 0);
+ } else if (corner == TOP_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, 0);
+ } else if (corner == BOTTOM_LEFT) {
+ gc.drawImage(decorator, 0, bib.height - dib.height);
+ } else if (corner == BOTTOM_RIGHT) {
+ gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
+ }
+ gc.dispose();
+ //
+ decoratedMap.put(decorator, result);
+ }
+ return result;
+ }
+ /**
+ * Dispose all of the cached {@link Image}'s.
+ */
+ public static void disposeImages() {
+ // dispose loaded images
+ {
+ for (Image image : m_imageMap.values()) {
+ image.dispose();
+ }
+ m_imageMap.clear();
+ }
+ // dispose decorated images
+ for (int i = 0; i < m_decoratedImageMap.length; i++) {
+ Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
+ if (cornerDecoratedImageMap != null) {
+ for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
+ for (Image image : decoratedMap.values()) {
+ image.dispose();
+ }
+ decoratedMap.clear();
+ }
+ cornerDecoratedImageMap.clear();
+ }
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Font
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps font names to fonts.
+ */
+ private static Map<String, Font> m_fontMap = new HashMap<String, Font>();
+ /**
+ * Maps fonts to their bold versions.
+ */
+ private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>();
+ /**
+ * Returns a {@link Font} based on its name, height and style.
+ *
+ * @param name
+ * the name of the font
+ * @param height
+ * the height of the font
+ * @param style
+ * the style of the font
+ * @return {@link Font} The font matching the name, height and style
+ */
+ public static Font getFont(String name, int height, int style) {
+ return getFont(name, height, style, false, false);
+ }
+ /**
+ * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
+ * flags are also supported.
+ *
+ * @param name
+ * the name of the font
+ * @param size
+ * the size of the font
+ * @param style
+ * the style of the font
+ * @param strikeout
+ * the strikeout flag (warning: Windows only)
+ * @param underline
+ * the underline flag (warning: Windows only)
+ * @return {@link Font} The font matching the name, height, style, strikeout and underline
+ */
+ public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
+ String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
+ Font font = m_fontMap.get(fontName);
+ if (font == null) {
+ FontData fontData = new FontData(name, size, style);
+ if (strikeout || underline) {
+ try {
+ Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$
+ Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$
+ if (logFont != null && logFontClass != null) {
+ if (strikeout) {
+ logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ if (underline) {
+ logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
+ }
+ }
+ } catch (Throwable e) {
+ System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ font = new Font(Display.getCurrent(), fontData);
+ m_fontMap.put(fontName, font);
+ }
+ return font;
+ }
+ /**
+ * Returns a bold version of the given {@link Font}.
+ *
+ * @param baseFont
+ * the {@link Font} for which a bold version is desired
+ * @return the bold version of the given {@link Font}
+ */
+ public static Font getBoldFont(Font baseFont) {
+ Font font = m_fontToBoldFontMap.get(baseFont);
+ if (font == null) {
+ FontData fontDatas[] = baseFont.getFontData();
+ FontData data = fontDatas[0];
+ font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
+ m_fontToBoldFontMap.put(baseFont, font);
+ }
+ return font;
+ }
+ /**
+ * Dispose all of the cached {@link Font}'s.
+ */
+ public static void disposeFonts() {
+ // clear fonts
+ for (Font font : m_fontMap.values()) {
+ font.dispose();
+ }
+ m_fontMap.clear();
+ // clear bold fonts
+ for (Font font : m_fontToBoldFontMap.values()) {
+ font.dispose();
+ }
+ m_fontToBoldFontMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Cursor
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Maps IDs to cursors.
+ */
+ private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>();
+ /**
+ * Returns the system cursor matching the specific ID.
+ *
+ * @param id
+ * int The ID value for the cursor
+ * @return Cursor The system cursor matching the specific ID
+ */
+ public static Cursor getCursor(int id) {
+ Integer key = Integer.valueOf(id);
+ Cursor cursor = m_idToCursorMap.get(key);
+ if (cursor == null) {
+ cursor = new Cursor(Display.getDefault(), id);
+ m_idToCursorMap.put(key, cursor);
+ }
+ return cursor;
+ }
+ /**
+ * Dispose all of the cached cursors.
+ */
+ public static void disposeCursors() {
+ for (Cursor cursor : m_idToCursorMap.values()) {
+ cursor.dispose();
+ }
+ m_idToCursorMap.clear();
+ }
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // General
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Dispose of cached objects and their underlying OS resources. This should only be called when the cached
+ * objects are no longer needed (e.g. on application shutdown).
+ */
+ public static void dispose() {
+ disposeColors();
+ disposeImages();
+ disposeFonts();
+ disposeCursors();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/defaultConfig.xml
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/defaultConfig.xml b/empire-db-eclipse-codegen/src/main/resources/defaultConfig.xml
new file mode 100644
index 0000000..33c77bf
--- /dev/null
+++ b/empire-db-eclipse-codegen/src/main/resources/defaultConfig.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<config>
+ <properties>
+ <!-- provider name must match the property-section containing the connection data -->
+ <jdbcClass></jdbcClass>
+ <jdbcURL></jdbcURL>
+ <jdbcServer></jdbcServer>
+ <jdbcPort></jdbcPort>
+ <jdbcSID></jdbcSID>
+ <jdbcUser></jdbcUser>
+ <jdbcPwd></jdbcPwd>
+
+ <!-- Schema options -->
+ <dbCatalog></dbCatalog>
+ <dbSchema></dbSchema>
+ <dbTablePattern></dbTablePattern>
+ <timestampColumn>CREATIONDATE</timestampColumn>
+
+ <!-- generation options -->
+ <targetFolder></targetFolder>
+ <packageName>org.apache.empire.db</packageName>
+ <tablePackageName>org.apache.empire.db.table</tablePackageName>
+ <viewPackageName>org.apache.empire.db.view</viewPackageName>
+ <recordPackageName>org.apache.empire.db.record</recordPackageName>
+ <dbClassName>EmpireDB</dbClassName>
+ <tableBaseName>BaseTable</tableBaseName>
+ <viewBaseName>BaseView</viewBaseName>
+ <recordBaseName>BaseRecord</recordBaseName>
+ <tableNamePrefix></tableNamePrefix>
+ <tableClassPrefix>T_</tableClassPrefix>
+ <tableClassSuffix></tableClassSuffix>
+ <viewNamePrefix></viewNamePrefix>
+ <viewClassPrefix>V_</viewClassPrefix>
+ <viewClassSuffix></viewClassSuffix>
+ <columnNamePrefix></columnNamePrefix>
+ <nestTables>true</nestTables>
+ <nestViews>false</nestViews>
+ <createRecordProperties>true</createRecordProperties>
+ <preserverCharacterCase>false</preserverCharacterCase>
+ <preserveRelationNames>false</preserveRelationNames>
+ </properties>
+
+ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="default" class="org.apache.log4j.ConsoleAppender">
+ <!-- layout class="org.apache.log4j.TTCCLayout"/ -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- param name="ConversionPattern" value="NSB(%c) %-5p %m at %l%n"/ -->
+ <param name="ConversionPattern" value="%-5p [%d{yyyy/MM/dd HH:mm}]: %m at %l %n"/>
+ </layout>
+ </appender>
+
+ <!-- log detail configuration -->
+ <logger name="org.apache.empire.commons" additivity="false">
+ <level value="warn"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <root>
+ <priority value="info"/>
+ <appender-ref ref="default"/>
+ </root>
+
+ </log4j:configuration>
+
+</config>
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/addButton.png
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/addButton.png b/empire-db-eclipse-codegen/src/main/resources/icons/addButton.png
new file mode 100644
index 0000000..c6aeae4
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/addButton.png differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/check_all.gif
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/check_all.gif b/empire-db-eclipse-codegen/src/main/resources/icons/check_all.gif
new file mode 100644
index 0000000..4370bf1
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/check_all.gif differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/db_element.gif
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/db_element.gif b/empire-db-eclipse-codegen/src/main/resources/icons/db_element.gif
new file mode 100644
index 0000000..1d459ce
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/db_element.gif differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/deleteButton.png
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/deleteButton.png b/empire-db-eclipse-codegen/src/main/resources/icons/deleteButton.png
new file mode 100644
index 0000000..5f00385
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/deleteButton.png differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/empire-db-logo.gif
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/empire-db-logo.gif b/empire-db-eclipse-codegen/src/main/resources/icons/empire-db-logo.gif
new file mode 100644
index 0000000..3d60d76
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/empire-db-logo.gif differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/empire_db_icon.png
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/empire_db_icon.png b/empire-db-eclipse-codegen/src/main/resources/icons/empire_db_icon.png
new file mode 100644
index 0000000..30ac6e9
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/empire_db_icon.png differ
http://git-wip-us.apache.org/repos/asf/empire-db/blob/83302f08/empire-db-eclipse-codegen/src/main/resources/icons/folder.gif
----------------------------------------------------------------------
diff --git a/empire-db-eclipse-codegen/src/main/resources/icons/folder.gif b/empire-db-eclipse-codegen/src/main/resources/icons/folder.gif
new file mode 100644
index 0000000..42e027c
Binary files /dev/null and b/empire-db-eclipse-codegen/src/main/resources/icons/folder.gif differ