You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/01/07 10:56:00 UTC

incubator-ignite git commit: # IGNITE-32 WIP: Implemented loading driver from jar. Minor changes for GUI, POJO and XML generation.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 01d2d5867 -> 232c70d10


# IGNITE-32 WIP: Implemented loading driver from jar. Minor changes for GUI, POJO and XML generation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/232c70d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/232c70d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/232c70d1

Branch: refs/heads/ignite-32
Commit: 232c70d107738f28e7cf9aeec9e80b200941862c
Parents: 01d2d58
Author: AKuznetsov <ak...@gridgain.com>
Authored: Wed Jan 7 16:55:59 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Wed Jan 7 16:55:59 2015 +0700

----------------------------------------------------------------------
 modules/schema-load/pom.xml                     |   1 +
 .../ignite/schema/db/DbMetadataParser.java      |  18 +-
 .../org/apache/ignite/schema/ui/Controls.java   |  54 ++-
 .../org/apache/ignite/schema/ui/GridPaneEx.java |  26 +-
 .../org/apache/ignite/schema/ui/MessageBox.java |  72 +++-
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 411 ++++++++++++++-----
 modules/schema-load/src/test/sql/sample.sql     |  14 +
 7 files changed, 457 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-load/pom.xml b/modules/schema-load/pom.xml
index 8a34b6f..6bee181 100644
--- a/modules/schema-load/pom.xml
+++ b/modules/schema-load/pom.xml
@@ -53,6 +53,7 @@
             <groupId>com.h2database</groupId>
             <artifactId>h2</artifactId>
             <version>1.3.175</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
index 352be7e..e9a0ee2 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
@@ -96,12 +96,11 @@ public class DbMetadataParser {
      * @param catalog Catalog name.
      * @param schema Schema name.
      * @param tbl Table name.
-     * @param include If {@code true} then include key fields into value fields.
      * @return New initialized instance of {@code GridCacheQueryTypeMetadata}.
      * @throws SQLException If parsing failed.
      */
-    private static GridCacheQueryTypeMetadata parse(DatabaseMetaData meta, String catalog, String schema, String tbl,
-        boolean include) throws SQLException {
+    private static GridCacheQueryTypeMetadata parse(DatabaseMetaData meta, String catalog, String schema, String tbl)
+        throws SQLException {
         GridCacheQueryTypeMetadata res = new GridCacheQueryTypeMetadata();
 
         res.setSchema(schema);
@@ -135,12 +134,8 @@ public class DbMetadataParser {
 
                 GridCacheQueryTypeDescriptor desc = new GridCacheQueryTypeDescriptor(javaName, javaType, dbName, dbType);
 
-                if (pkFlds.contains(dbName)) {
+                if (pkFlds.contains(dbName))
                     keyDescs.add(desc);
-
-                    if (include)
-                        valDescs.add(desc);
-                }
                 else
                     valDescs.add(desc);
 
@@ -184,12 +179,11 @@ public class DbMetadataParser {
      * Parse database metadata.
      *
      * @param conn Connection to database.
-     * @param include If {@code true} then include key fields into value fields.
      * @return Map with schemes and tables metadata.
      * @throws SQLException If parsing failed.
      */
-    public static LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>> parse(Connection conn,
-        boolean include) throws SQLException {
+    public static LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>> parse(Connection conn)
+        throws SQLException {
         DatabaseMetaData meta = conn.getMetaData();
 
         LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>> res = new LinkedHashMap<>();
@@ -205,7 +199,7 @@ public class DbMetadataParser {
                     while (tbls.next()) {
                         String tbl = tbls.getString(3);
 
-                        items.put(tbl, parse(meta, catalog, schema, tbl, include));
+                        items.put(tbl, parse(meta, catalog, schema, tbl));
                     }
                 }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
index edec0b8..0de9898 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
@@ -6,6 +6,7 @@ import javafx.event.*;
 import javafx.geometry.*;
 import javafx.scene.*;
 import javafx.scene.control.*;
+import javafx.scene.control.cell.*;
 import javafx.scene.image.*;
 import javafx.scene.layout.*;
 import javafx.scene.text.*;
@@ -30,12 +31,14 @@ public class Controls {
      * Create new {@code HBox} with default padding.
      *
      * @param spacing Amount of horizontal space between each child.
+     * @param dfltPadding If {@code true} than set default padding for pane.
      * @return New {@code HBox} instance.
      */
-    public static HBox hBox(int spacing) {
+    public static HBox hBox(int spacing, boolean dfltPadding) {
         HBox hb = new HBox(spacing);
 
-        hb.setPadding(DFLT_PADDING);
+        if (dfltPadding)
+            hb.setPadding(DFLT_PADDING);
 
         return hb;
     }
@@ -44,11 +47,12 @@ public class Controls {
      * Create new {@code HBox} with default padding and add controls.
      *
      * @param spacing Amount of horizontal space between each child.
+     * @param dfltPadding If {@code true} than set default padding for pane.
      * @param controls Controls to add.
      * @return New {@code HBox} instance.
      */
-    public static HBox hBox(int spacing, Node... controls) {
-        HBox hb = hBox(spacing);
+    public static HBox hBox(int spacing, boolean dfltPadding, Node... controls) {
+        HBox hb = hBox(spacing, dfltPadding);
 
         hb.getChildren().addAll(controls);
 
@@ -134,6 +138,7 @@ public class Controls {
      */
     public static Text text(String text, int wrap) {
         Text t = new Text(text);
+        t.setFont(new Font(14));
 
         t.setWrappingWidth(wrap);
 
@@ -141,6 +146,47 @@ public class Controls {
     }
 
     /**
+     * Create split pane for provided nodes.
+     *
+     * @param node1 First node.
+     * @param node2 Second node.
+     * @param pos Initial divider position.
+     * @return New split pane instance.
+     */
+    public static SplitPane splitPane(Node node1, Node node2, double pos) {
+        SplitPane sp = new SplitPane();
+
+        sp.setOrientation(Orientation.VERTICAL);
+        sp.getItems().addAll(node1, node2);
+        sp.setDividerPosition(0, pos);
+
+        return sp;
+    }
+
+    /**
+     * Create table column.
+     *
+     * @param colName Column name to display.
+     * @param propName Property name column is bound to.
+     * @param minWidth The minimum width column is permitted to be resized to.
+     * @param maxWidth The maximum width column is permitted to be resized to.
+     * @return New table column instance.
+     */
+    public static <S, T> TableColumn<S, T> tableColumn(String colName, String propName, int minWidth, int maxWidth) {
+        TableColumn<S, T> col = new TableColumn<>(colName);
+
+        if (minWidth > 0)
+            col.setMinWidth(minWidth);
+
+        if (maxWidth > 0)
+            col.setMaxWidth(maxWidth);
+
+        col.setCellValueFactory(new PropertyValueFactory<S, T>(propName));
+
+        return col;
+    }
+
+    /**
      * Create image view.
      *
      * @param imgFileName Image filename.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
index 3dfe975..6d847ce 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
@@ -76,6 +76,16 @@ public class GridPaneEx extends GridPane {
     }
 
     /**
+     * Add default rows.
+     *
+     * @param n Number of rows to add.
+     */
+    public void addRows(int n) {
+        for (int i = 0; i < n; i++)
+            addRow();
+    }
+
+    /**
      * Add row with constraints and vertical grow priority for the row.
      *
      * @param min Row minimum size.
@@ -140,11 +150,23 @@ public class GridPaneEx extends GridPane {
      *
      * @param text Label text.
      * @param ctrl Control to add.
+     * @param span How many columns control should take.
      * @return Added control.
      */
-    public <T extends Node> T addLabeled(String text, T ctrl) {
+    public <T extends Node> T addLabeled(String text, T ctrl, int span) {
         add(new Label(text));
 
-        return add(ctrl);
+        return add(ctrl, span);
+    }
+
+    /**
+     * Add control with label.
+     *
+     * @param text Label text.
+     * @param ctrl Control to add.
+     * @return Added control.
+     */
+    public <T extends Node> T addLabeled(String text, T ctrl) {
+        return addLabeled(text, ctrl, 1);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
index 151fe13..dfd48bf 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
@@ -14,6 +14,18 @@ import static org.apache.ignite.schema.ui.Controls.*;
  * Message box functionality.
  */
 public class MessageBox extends Stage {
+    /** Message box type. */
+    private enum MessageType {
+        /** Information. */
+        INFO,
+        /** Warning. */
+        WARN,
+        /** Error. */
+        ERROR,
+        /** Confirm. */
+        CONFIRM
+    }
+
     /** Return value if YES is chosen. */
     public static final int YES_OPTION = 0;
     /** Return value if NO is chosen. */
@@ -28,23 +40,45 @@ public class MessageBox extends Stage {
      * Create message box.
      *
      * @param owner Owner window.
-     * @param title Title text.
+     * @param type Message box type.
      * @param msg Message to show.
-     * @param iconFile Message icon.
-     * @param yesNo If {@code true} show &quot;yes&quot; and &quot;no&quot; buttons
-     *      otherwise show &quot;ok&quot; button.
      */
-    private MessageBox(Stage owner, String title, String msg, String iconFile, boolean yesNo) {
+    private MessageBox(Stage owner, MessageType type, String msg) {
+        String title;
+        String iconFile;
+
+        switch (type) {
+            case WARN:
+                title = "Warning";
+                iconFile = "sign_warning";
+                break;
+
+            case ERROR:
+                title = "Error";
+                iconFile = "error";
+                break;
+
+            case CONFIRM:
+                title = "Confirmation";
+                iconFile = "question";
+                break;
+
+            default:
+                title = "Information";
+                iconFile = "information";
+                break;
+        }
+
         setTitle(title);
         initStyle(StageStyle.UTILITY);
         initModality(Modality.APPLICATION_MODAL);
         initOwner(owner);
         setResizable(false);
 
-        HBox btns = hBox(10);
+        HBox btns = hBox(10, true);
         btns.setAlignment(Pos.CENTER);
 
-        if (yesNo) {
+        if (type == MessageType.CONFIRM) {
             res = NO_OPTION;
 
             btns.getChildren().addAll(button("Yes", new EventHandler<ActionEvent>() {
@@ -68,7 +102,7 @@ public class MessageBox extends Stage {
                 }
             }));
 
-        setScene(new Scene(vBox(10, hBox(10, imageView(iconFile, 48), text(msg, 250)), btns)));
+        setScene(new Scene(vBox(10, hBox(10, true, imageView(iconFile, 48), text(msg, 250)), btns)));
     }
 
     /**
@@ -86,15 +120,12 @@ public class MessageBox extends Stage {
      * Show message in modal dialog.
      *
      * @param owner Owner window.
-     * @param title Title text.
+     * @param type Message box type.
      * @param msg Message to show.
-     * @param iconFile Message icon.
-     * @param yesNo If {@code true} show &quot;yes&quot; and &quot;no&quot; buttons
-     *      otherwise show &quot;ok&quot; button.
      * @return Option selected by the user.
      */
-    private static int showDialog(Stage owner, String title, String msg, String iconFile, boolean yesNo) {
-        MessageBox dlg = new MessageBox(owner, title, msg, iconFile, yesNo);
+    private static int showDialog(Stage owner, MessageType type, String msg) {
+        MessageBox dlg = new MessageBox(owner, type, msg);
 
         dlg.showDialog();
 
@@ -109,7 +140,7 @@ public class MessageBox extends Stage {
      * @return Option selected by the user.
      */
     public static int confirmDialog(Stage owner, String msg) {
-        return showDialog(owner, "Confirmation", msg, "question", true);
+        return showDialog(owner, MessageType.CONFIRM, msg);
     }
 
     /**
@@ -119,7 +150,7 @@ public class MessageBox extends Stage {
      * @param msg Message to show.
      */
     public static void informationDialog(Stage owner, String msg) {
-        showDialog(owner, "Information", msg, "information", false);
+        showDialog(owner, MessageType.INFO, msg);
     }
 
     /**
@@ -129,7 +160,7 @@ public class MessageBox extends Stage {
      * @param msg Message to show.
      */
     public static void warningDialog(Stage owner, String msg) {
-        showDialog(owner, "Warning", msg, "sign_warning", false);
+        showDialog(owner, MessageType.WARN, msg);
     }
 
 
@@ -137,9 +168,10 @@ public class MessageBox extends Stage {
      * Show error dialog.
      *
      * @param owner Owner window.
-     * @param msg Message to show.
+     * @param msg Error message to show.
+     * @param e Optional exception to show.
      */
-    public static void errorDialog(Stage owner, String msg) {
-        showDialog(owner, "Error", msg, "error", false);
+    public static void errorDialog(Stage owner, String msg, Throwable e) {
+        showDialog(owner, MessageType.ERROR, (e != null && e.getMessage() != null) ? msg + "\n" + e.getMessage()  : msg);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
index 4f162bf..148cfb3 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
@@ -3,6 +3,9 @@
 package org.apache.ignite.schema.ui;
 
 import javafx.application.*;
+import javafx.beans.property.*;
+import javafx.beans.value.*;
+import javafx.collections.*;
 import javafx.event.*;
 import javafx.geometry.*;
 import javafx.scene.*;
@@ -10,14 +13,17 @@ import javafx.scene.control.*;
 import javafx.scene.control.cell.*;
 import javafx.scene.image.*;
 import javafx.scene.layout.*;
-import javafx.scene.text.*;
 import javafx.stage.*;
+import javafx.util.*;
 import org.apache.ignite.schema.db.*;
 import org.apache.ignite.schema.pojo.*;
 import org.apache.ignite.schema.xml.*;
 import org.gridgain.grid.cache.query.*;
+import org.gridgain.grid.util.typedef.*;
+import org.gridgain.grid.util.typedef.internal.*;
 
 import java.io.*;
+import java.net.*;
 import java.sql.*;
 import java.util.*;
 
@@ -28,6 +34,102 @@ import static org.apache.ignite.schema.ui.Controls.*;
  * Schema load application.
  */
 public class SchemaLoadApp extends Application {
+    /**
+     * Field descriptor.
+     */
+    @SuppressWarnings("PublicInnerClass")
+    public static class Field {
+        /** If this field belongs to primary key. */
+        private final BooleanProperty key;
+
+        /** Field name for POJO. */
+        private final StringProperty javaName;
+
+        /** Field name in database. */
+        private final StringProperty dbName;
+
+        /** Field type descriptor. */
+        private final GridCacheQueryTypeDescriptor desc;
+
+        /**
+         * @param key {@code true} if this field belongs to primary key.
+         * @param desc Field type descriptor.
+         */
+        private Field(boolean key, GridCacheQueryTypeDescriptor desc) {
+            this.desc = desc;
+            this.key = new SimpleBooleanProperty(key);
+            javaName = new SimpleStringProperty(desc.getJavaName());
+            dbName = new SimpleStringProperty(desc.getDbName());
+        }
+
+        /**
+         * @return {@code true} if this field belongs to primary key.
+         */
+        public boolean isKey() {
+            return key.get();
+        }
+
+        /**
+         * @param pk {@code true} if this field belongs to primary key.
+         */
+        public void setKey(boolean pk) {
+            key.set(pk);
+        }
+
+        /**
+         * @return Field name of corresponding POJO.
+         */
+        public String getJavaName() {
+            return javaName.get();
+        }
+
+        /**
+         * @param name  Field name of corresponding POJO.
+         */
+        public void setJavaName(String name) {
+            desc.setJavaName(name);
+
+            javaName.set(name);
+        }
+
+        /**
+         * @return Field name in database.
+         */
+        public String getDbName() {
+            return dbName.get();
+        }
+
+        /**
+         * @param name Field name in database.
+         */
+        public void setDbName(String name) {
+            desc.setDbName(name);
+
+            dbName.set(name);
+        }
+
+        /**
+         * @return Boolean property support for {@code key} property.
+         */
+        public BooleanProperty keyProperty() {
+            return key;
+        }
+
+        /**
+         * @return String property support for {@code javaName} property.
+         */
+        public StringProperty javaNameProperty() {
+            return javaName;
+        }
+
+        /**
+         * @return String property support for {@code dbName} property.
+         */
+        public StringProperty dbNameProperty() {
+            return dbName;
+        }
+    }
+
     /** TODO: IGNITE 32 remove before release */
     private static final String PATH = "C:/Temp/ignite";
 
@@ -50,6 +152,9 @@ public class SchemaLoadApp extends Application {
     private TextField jdbcTf;
 
     /** */
+    private TextField drvTf;
+
+    /** */
     private TextField urlTf;
 
     /** */
@@ -65,6 +170,9 @@ public class SchemaLoadApp extends Application {
     private CheckBoxTreeItem<String> rootItem;
 
     /** */
+    private TableView<Field> tbl;
+
+    /** */
     private TextField pkgTf;
 
     /** */
@@ -74,7 +182,7 @@ public class SchemaLoadApp extends Application {
     private CheckBox pojoConstructorCh;
 
     /** */
-    private CheckBox pojoSeparateKeyCh;
+    private CheckBox pojoIncludeKeysCh;
 
     /** */
     private CheckBox xmlSingleFileCh;
@@ -82,6 +190,18 @@ public class SchemaLoadApp extends Application {
     /** */
     private GridPaneEx genPnl;
 
+    /** */
+    private LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>> metas;
+
+    /** */
+    private Map<String, Map<String, Collection<Field>>> fields;
+
+    /** */
+    private final ObservableList<Field> noData = FXCollections.emptyObservableList();
+
+    /** */
+    private final Map<String, Driver> drivers = new HashMap<>();
+
     /**
      * Fill tree with database metadata.
      */
@@ -89,41 +209,50 @@ public class SchemaLoadApp extends Application {
         rootItem.getChildren().clear();
 
         try {
-            String driver = jdbcTf.getText();
-
-            try {
-                Class.forName(driver);
+            try (Connection conn = connect()) {
+                metas = DbMetadataParser.parse(conn);
             }
-            catch (Throwable e) {
-                MessageBox.errorDialog(owner, "Failed to load JDBC driver: " + e.getMessage());
 
-                return false;
-            }
+            fields = U.newHashMap(metas.size());
 
-            try (Connection conn = DriverManager.getConnection(urlTf.getText(), userTf.getText(), pwdTf.getText())) {
-                DatabaseMetaData meta = conn.getMetaData();
+            for (Map.Entry<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>> meta : metas.entrySet()) {
+                String schema = meta.getKey();
 
-                try (ResultSet schemas = meta.getSchemas()) {
-                    while(schemas.next()) {
-                        String schema = schemas.getString(1);
-                        String catalog = schemas.getString(2);
+                LinkedHashMap<String, GridCacheQueryTypeMetadata> tbls = meta.getValue();
 
-                        CheckBoxTreeItem<String> schemaItem = new CheckBoxTreeItem<>(schema);
+                Map<String, Collection<Field>> tblsFields = U.newHashMap(tbls.size());
 
-                        rootItem.getChildren().add(schemaItem);
+                fields.put(schema, tblsFields);
 
-                        try (ResultSet tbls = meta.getTables(catalog, schema, "%", null)) {
-                            while(tbls.next())
-                                schemaItem.getChildren().add(new CheckBoxTreeItem<>(tbls.getString(3)));
-                        }
-                    }
+                CheckBoxTreeItem<String> schemaItem = new CheckBoxTreeItem<>(schema);
+
+                rootItem.getChildren().add(schemaItem);
+
+                for(Map.Entry<String, GridCacheQueryTypeMetadata> tbl : tbls.entrySet()) {
+                    GridCacheQueryTypeMetadata type = tbl.getValue();
+
+                    Collection<GridCacheQueryTypeDescriptor> keys = type.getKeyDescriptors();
+
+                    Collection<GridCacheQueryTypeDescriptor> vals = type.getValueDescriptors();
+
+                    Collection<Field> tblFields = new ArrayList<>(keys.size() + vals.size());
+
+                    tblsFields.put(type.getTableName(), tblFields);
+
+                    for (GridCacheQueryTypeDescriptor key : keys)
+                        tblFields.add(new Field(true, key));
+
+                    for (GridCacheQueryTypeDescriptor val : vals)
+                        tblFields.add(new Field(false, val));
+
+                    schemaItem.getChildren().add(new CheckBoxTreeItem<>(tbl.getKey()));
                 }
             }
 
             return true;
         }
         catch (Throwable e) {
-            MessageBox.errorDialog(owner, "Failed to get tables list: " + e.getMessage());
+            MessageBox.errorDialog(owner, "Failed to get tables list from database.", e);
 
             return false;
         }
@@ -139,21 +268,25 @@ public class SchemaLoadApp extends Application {
 
             File destFolder = new File(outFolder);
 
-            List<GridCacheQueryTypeMetadata> all = new ArrayList<>();
-
-            LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>> metas;
+            if (!destFolder.exists() && !destFolder.mkdirs())
+                throw new IOException("Failed to create output folder: " + destFolder);
 
-            try (Connection conn = DriverManager.getConnection(urlTf.getText(), userTf.getText(), pwdTf.getText())) {
-                metas = DbMetadataParser.parse(conn, pojoSeparateKeyCh.isSelected());
-            }
+            List<GridCacheQueryTypeMetadata> all = new ArrayList<>();
 
             boolean constructor = pojoConstructorCh.isSelected();
+            boolean include = pojoIncludeKeysCh.isSelected();
 
             for (TreeItem<String> schemeItem : rootItem.getChildren()) {
                 for (TreeItem<String> tblItem : schemeItem.getChildren()) {
                     if (((CheckBoxTreeItem)tblItem).isSelected()) {
                         GridCacheQueryTypeMetadata meta = metas.get(schemeItem.getValue()).get(tblItem.getValue());
 
+                        if (include) {
+                            meta = new GridCacheQueryTypeMetadata(meta);
+
+                            meta.setValueDescriptors(F.concat(false, meta.getKeyDescriptors(), meta.getValueDescriptors()));
+                        }
+
                         all.add(meta);
 
                         XmlTransformer.transform(pkg, meta, new File(destFolder, meta.getType() + ".xml"));
@@ -173,7 +306,7 @@ public class SchemaLoadApp extends Application {
             }
         }
         catch (Throwable e) {
-            MessageBox.errorDialog(owner, "Generation failed: " + e.getMessage());
+            MessageBox.errorDialog(owner, "Generation failed.", e);
         }
     }
 
@@ -181,7 +314,7 @@ public class SchemaLoadApp extends Application {
      * @return Header pane with title label.
      */
     private Pane createHeaderPane() {
-        HBox hb = hBox(0);
+        HBox hb = hBox(0, true);
 
         titleLb = new Label("");
         titleLb.setId("banner");
@@ -208,9 +341,8 @@ public class SchemaLoadApp extends Application {
             }
         });
 
-        HBox hb = hBox(10);
+        HBox hb = hBox(10, true, prevBtn, nextBtn);
         hb.setAlignment(Pos.BOTTOM_RIGHT);
-        hb.getChildren().addAll(prevBtn, nextBtn);
 
         return hb;
     }
@@ -248,6 +380,57 @@ public class SchemaLoadApp extends Application {
     }
 
     /**
+     * Connect to database.
+     *
+     * @return Connection to database.
+     * @throws SQLException if connection failed.
+     */
+    private Connection connect() throws SQLException {
+        String drvCls = jdbcTf.getText();
+
+        Driver drv = drivers.get(drvCls);
+
+        if (drv == null) {
+            String path = drvTf.getText().trim();
+
+            if (path.isEmpty())
+                throw new IllegalStateException("Driver jar file name is not specified");
+
+            File drvJar = new File(drvTf.getText());
+
+            if (!drvJar.exists())
+                throw new IllegalStateException("Driver jar file is not found");
+
+            try {
+                URL u = new URL("jar:" + drvJar.toURI() + "!/");
+
+                URLClassLoader ucl = URLClassLoader.newInstance(new URL[] { u });
+
+                drv = (Driver)Class.forName(drvCls, true, ucl).newInstance();
+
+                drivers.put(drvCls, drv);
+            }
+            catch (Throwable e) {
+                throw new IllegalStateException(e);
+            }
+        }
+
+        String user = userTf.getText().trim();
+
+        String pwd = pwdTf.getText().trim();
+
+        Properties info = new Properties();
+
+        if (!user.isEmpty())
+            info.put("user", user);
+
+        if (!pwd.isEmpty())
+            info.put("password", pwd);
+
+        return drv.connect(urlTf.getText(), info);
+    }
+
+    /**
      * Create connection pane with controls.
      */
     private void createConnectionPane() {
@@ -255,19 +438,35 @@ public class SchemaLoadApp extends Application {
 
         connPnl.addColumn();
         connPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+        connPnl.addColumn(35, 35, 35, Priority.NEVER);
+
+        drvTf = connPnl.addLabeled("Driver JAR:", textField());
+        drvTf.setText("C:/GridGain/h2/bin/h2-1.3.176.jar");
+
+        connPnl.add(button("...", new EventHandler<ActionEvent>() {
+            /** {@inheritDoc} */
+            @Override public void handle(ActionEvent evt) {
+                FileChooser fc = new FileChooser();
+
+                fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("JDBC Drivers (*.jar)", "*.jar"));
+
+                File drvJar = fc.showOpenDialog(owner);
 
-        jdbcTf = connPnl.addLabeled("JDBC Driver:", textField());
+                if (drvJar != null)
+                    drvTf.setText(drvJar.getAbsolutePath());
+            }
+        }));
+
+        jdbcTf = connPnl.addLabeled("JDBC Driver:", textField(), 2);
         jdbcTf.setText("org.h2.Driver");
 
-        urlTf = connPnl.addLabeled("URL:", textField());
-        urlTf.setText("jdbc:h2:mem:test");
+        urlTf = connPnl.addLabeled("URL:", textField(), 2);
+        urlTf.setText("jdbc:h2:c:/Temp/test");
 
-        userTf = connPnl.addLabeled("User:", textField());
+        userTf = connPnl.addLabeled("User:", textField(), 2);
         userTf.setText("sa");
 
-        pwdTf = connPnl.addLabeled("Password:", new PasswordField());
-
-        connPnl.add(new Text("Put JDBC driver jar file into '/drivers' folder."), 2);
+        pwdTf = connPnl.addLabeled("Password:", new PasswordField(), 2);
     }
 
     /**
@@ -281,32 +480,49 @@ public class SchemaLoadApp extends Application {
         genPnl.addColumn(35, 35, 35, Priority.NEVER);
 
         genPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
-        genPnl.addRow(100, 100, 100, Priority.NEVER);
-        genPnl.addRow();
-        genPnl.addRow();
-        genPnl.addRow();
-        genPnl.addRow();
-        genPnl.addRow();
+        genPnl.addRows(6);
 
         rootItem = new CheckBoxTreeItem<>("Database");
         rootItem.setExpanded(true);
 
         TreeView<String> tree = new TreeView<>(rootItem);
+
         tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
 
-        genPnl.add(tree, 3);
+        tree.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() {
+            /** {@inheritDoc} */
+            @Override public void changed(ObservableValue<? extends TreeItem<String>> val, TreeItem<String> oldItem,
+                TreeItem<String> newItem) {
+                onTreeSelectionChanged(newItem);
+            }
+        });
 
-        TableView<String> tbl = new TableView<>();
+        TableColumn<Field, Boolean> keyCol = tableColumn("Key", "key", 70, 70);
 
-        TableColumn<String, Boolean> keyCol = new TableColumn<>("Key");
-        TableColumn<String, String> dbNameCol = new TableColumn<>("DB Name");
-        TableColumn<String, String> javaNameCol = new TableColumn<>("Ignite Name");
+        keyCol.setCellFactory(new Callback<TableColumn<Field, Boolean>, TableCell<Field, Boolean>>() {
+            /** {@inheritDoc} */
+            @Override public TableCell<Field, Boolean> call(TableColumn<Field, Boolean> col) {
+                CheckBoxTableCell<Field, Boolean> cell = new CheckBoxTableCell<>();
 
-        tbl.getColumns().addAll(keyCol, dbNameCol, javaNameCol);
+                cell.setAlignment(Pos.CENTER);
+
+                return cell;
+            }
+        });
+
+        keyCol.setEditable(true);
+
+        TableColumn<Field, String> dbNameCol = tableColumn("DB Name", "dbName", 0, 0);
+
+        TableColumn<Field, String> javaNameCol = tableColumn("Ignite Name", "javaName", 0, 0);
 
+        tbl = new TableView<>();
+
+        tbl.getColumns().addAll(keyCol, dbNameCol, javaNameCol);
         tbl.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
+        tbl.setEditable(true);
 
-        genPnl.add(tbl, 3);
+        genPnl.add(splitPane(tree, tbl, 0.6), 3);
 
         pkgTf = genPnl.addLabeled("Package:", textField());
         pkgTf.setText("org.apache.ignite");
@@ -317,6 +533,7 @@ public class SchemaLoadApp extends Application {
         outFolderTf.setText(PATH);
 
         genPnl.add(button("...", new EventHandler<ActionEvent>() {
+            /** {@inheritDoc} */
             @Override public void handle(ActionEvent evt) {
                 DirectoryChooser dc = new DirectoryChooser();
 
@@ -327,19 +544,55 @@ public class SchemaLoadApp extends Application {
             }
         }));
 
-        pojoSeparateKeyCh = genPnl.add(checkBox("Include key fields into value POJOs",
+        pojoIncludeKeysCh = genPnl.add(checkBox("Include key fields into value POJOs",
             "If selected then include key fields into value object", true), 3);
 
         pojoConstructorCh = genPnl.add(checkBox("Generate constructors for POJOs",
             "If selected then generate empty and full constructors for POJOs", false), 3);
 
-        xmlSingleFileCh = genPnl.add(checkBox("Write all configurations to a single file", "" +
+        xmlSingleFileCh = genPnl.add(checkBox("Write all configurations to a single file",
             "If selected then all configurations will be saved into the file 'ignite.xml'", true), 3);
+
+        final CheckBox dfltNamingCh = checkBox("Default naming conversions",
+            "If selected then DB names will be converted to default java names", true);
+
+        final Button btnNaming = button("Configure Naming", new EventHandler<ActionEvent>() {
+            /** {@inheritDoc} */
+            @Override public void handle(ActionEvent evt) {
+                MessageBox.informationDialog(owner, "TODO: implement.");
+            }
+        });
+
+        btnNaming.setDisable(true);
+
+        dfltNamingCh.setOnAction(new EventHandler<ActionEvent>() {
+            /** {@inheritDoc} */
+            @Override public void handle(ActionEvent evt) {
+                btnNaming.setDisable(dfltNamingCh.isSelected());
+            }
+        });
+
+        genPnl.add(hBox(10, false, dfltNamingCh, btnNaming), 3);
     }
 
+    /**
+     * Action on tree selection changed.
+     *
+     * @param item Selected tree item.
+     */
+    private void onTreeSelectionChanged(TreeItem<String> item) {
+        if (item != null && item.getParent() != null && item.isLeaf())
+            tbl.setItems(FXCollections.observableArrayList(
+                fields.get(item.getParent().getValue()).get(item.getValue())));
+        else
+            tbl.setItems(noData);
+    }
 
     /** {@inheritDoc} */
     @Override public void start(Stage primaryStage) {
+        System.setProperty("prism.lcdtext", "false");
+        System.setProperty("prism.text", "t2k");
+
         owner = primaryStage;
 
         primaryStage.setTitle("Schema Load");
@@ -384,7 +637,7 @@ public class SchemaLoadApp extends Application {
         primaryStage.setWidth(w);
         primaryStage.setMinWidth(w);
 
-        int h = 540;
+        int h = 600;
         primaryStage.setHeight(h);
         primaryStage.setMinHeight(h);
 
@@ -395,54 +648,10 @@ public class SchemaLoadApp extends Application {
 
     /**
      * Schema load utility launcher.
-     */
-    private static void sampleDb() {
-        // TODO: IGNITE 32 remove before release
-        try {
-            Class.forName("org.h2.Driver");
-
-            try (Connection conn = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "")) {
-                try (Statement stmt = conn.createStatement()) {
-                    stmt.executeUpdate("CREATE TABLE IF NOT EXISTS Organization(" +
-                        "id integer primary key, name varchar(50), city varchar(50))");
-                    stmt.executeUpdate("CREATE TABLE IF NOT EXISTS Person(" +
-                        "id integer primary key, org_id integer, name varchar(50))");
-
-                    stmt.executeUpdate("CREATE INDEX IF NOT EXISTS Org_Name_IDX On Organization (name)");
-                    stmt.executeUpdate("CREATE INDEX IF NOT EXISTS Org_Name_City_IDX On Organization (name, city)");
-                    stmt.executeUpdate("CREATE INDEX IF NOT EXISTS Person_Name_IDX1 On Person (name)");
-                    stmt.executeUpdate("CREATE INDEX IF NOT EXISTS Person_Name_IDX2 On Person (name desc)");
-
-                    conn.commit();
-
-                    try {
-                        stmt.executeUpdate("INSERT INTO Organization(id, name, city) VALUES (1, 'Test1', 'Test2')");
-                        stmt.executeUpdate("INSERT INTO Organization(id, name, city) VALUES (2, 'Test3'), 'Test4'");
-
-                        stmt.executeUpdate("INSERT INTO Person(id, org_id, name) VALUES (1, 1, 'Test5')");
-                        stmt.executeUpdate("INSERT INTO Person(id, org_id, name) VALUES (2, 2, 'Test6')");
-
-                        conn.commit();
-                    }
-                    catch (SQLException ignore) {
-                        // No-op.
-                    }
-                }
-            }
-        }
-        catch (Throwable e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Schema load utility launcher.
      *
      * @param args Command line arguments passed to the application.
      */
     public static void main(String[] args) {
-        sampleDb();
-
         launch(args);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/232c70d1/modules/schema-load/src/test/sql/sample.sql
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/sql/sample.sql b/modules/schema-load/src/test/sql/sample.sql
new file mode 100644
index 0000000..c9f02d7
--- /dev/null
+++ b/modules/schema-load/src/test/sql/sample.sql
@@ -0,0 +1,14 @@
+-- Script to create sample H2 database.
+CREATE TABLE IF NOT EXISTS Organization(id integer primary key, name varchar(50), city varchar(50));
+CREATE TABLE IF NOT EXISTS Person(id integer primary key, org_id integer, name varchar(50));
+
+CREATE INDEX IF NOT EXISTS Org_Name_IDX On Organization (name);
+CREATE INDEX IF NOT EXISTS Org_Name_City_IDX On Organization (name, city);
+CREATE INDEX IF NOT EXISTS Person_Name_IDX1 On Person (name);
+CREATE INDEX IF NOT EXISTS Person_Name_IDX2 On Person (name desc);
+
+INSERT INTO Organization(id, name, city) VALUES (1, 'Test1', 'Test2');
+INSERT INTO Organization(id, name, city) VALUES (2, 'Test3', 'Test4');
+
+INSERT INTO Person(id, org_id, name) VALUES (1, 1, 'Test5');
+INSERT INTO Person(id, org_id, name) VALUES (2, 2, 'Test6');