ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # ignite-32 WIP: Working on UI.
Date Tue, 23 Dec 2014 14:26:34 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 b935c61b9 -> 3357b9624


# ignite-32 WIP: Working on UI.


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

Branch: refs/heads/ignite-32
Commit: 3357b9624fb0d69f029b1c0d59cb40795187baab
Parents: b935c61
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Dec 23 21:26:34 2014 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Dec 23 21:26:34 2014 +0700

----------------------------------------------------------------------
 .../query/GridCacheQueryTypeDescriptor.java     |  18 +--
 .../org/apache/ignite/schema/ui/GridPaneEx.java |  11 ++
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 121 ++++++++++++++-----
 .../ignite/schema/xml/XmlTransformer.java       |  68 +++++++----
 4 files changed, 156 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3357b962/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
index 1aefe66..fb1e6de 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
@@ -20,17 +20,17 @@ public class GridCacheQueryTypeDescriptor {
     private int colJdbcType;
 
     /** Corresponding java type. */
-    private Class<?> type;
+    private Class<?> javaType;
 
     /**
      * @param colName Column name in database.
      * @param colJdbcType Column JDBC type in database.
-     * @param type Corresponding java type.
+     * @param javaType Corresponding java type.
      */
-    public GridCacheQueryTypeDescriptor(String colName, int colJdbcType, Class<?> type)
{
+    public GridCacheQueryTypeDescriptor(String colName, int colJdbcType, Class<?> javaType)
{
         this.colName = colName;
         this.colJdbcType = colJdbcType;
-        this.type = type;
+        this.javaType = javaType;
     }
 
     /**
@@ -64,14 +64,14 @@ public class GridCacheQueryTypeDescriptor {
     /**
      * @return Corresponding java type.
      */
-    public Class<?> getType() {
-        return type;
+    public Class<?> getJavaType() {
+        return javaType;
     }
 
     /**
-     * @param type Corresponding java type.
+     * @param javaType Corresponding java type.
      */
-    public void setType(Class<?> type) {
-        this.type = type;
+    public void setJavaType(Class<?> javaType) {
+        this.javaType = javaType;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3357b962/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 127c53c..7b0da41 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
@@ -9,6 +9,7 @@
 
 package org.apache.ignite.schema.ui;
 
+import javafx.geometry.*;
 import javafx.scene.*;
 import javafx.scene.control.*;
 import javafx.scene.layout.*;
@@ -18,6 +19,16 @@ import javafx.scene.layout.*;
  */
 public class GridPaneEx extends GridPane {
     /**
+     * @param padding Pane padding.
+     */
+    public GridPaneEx(Insets padding) {
+        setAlignment(Pos.CENTER);
+        setPadding(padding);
+        setHgap(10);
+        setVgap(10);
+    }
+
+    /**
      * Add percent columns.
      *
      * @param cols Array of column percentages.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3357b962/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 e7e061d..e53bd56 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
@@ -15,12 +15,14 @@ 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.*;
 import javafx.stage.*;
 import org.apache.ignite.schema.db.*;
 
+import java.io.*;
 import java.util.*;
 
 /**
@@ -67,13 +69,19 @@ public class SchemaLoadApp extends Application {
     private abstract static class WizardPage {
         /** */
         protected Pane contentPane;
+
+        /** */
+        protected final Stage owner;
+
         /** */
         protected final String title;
 
         /**
+         * @param owner Owner window.
          * @param title Page title.
          */
-        protected WizardPage(String title) {
+        protected WizardPage(Stage owner, String title) {
+            this.owner = owner;
             this.title = title;
         }
 
@@ -103,21 +111,16 @@ public class SchemaLoadApp extends Application {
         /**
          * Create page.
          */
-        private DbChooserPage() {
-            super("Choose Database");
+        private DbChooserPage(Stage owner) {
+            super(owner, "Choose Database");
         }
 
         /** {@inheritDoc} */
         @Override protected Pane createContent() {
-            GridPaneEx gp = new GridPaneEx();
+            GridPaneEx gp = new GridPaneEx(DFLT_PADDING);
 
             gp.addPercentColumns(30, 70);
 
-            gp.setAlignment(Pos.CENTER);
-            gp.setHgap(10);
-            gp.setVgap(10);
-            gp.setPadding(DFLT_PADDING);
-
             gp.addLabel("Alias:", 0, 0);
 
             ObservableList<String> options = FXCollections.observableArrayList("My
Settings");
@@ -140,39 +143,101 @@ public class SchemaLoadApp extends Application {
         }
     }
 
+    /**
+     * Wizard page for selecting tables to import.
+     */
     private static class SelectTablesPage extends WizardPage {
-        private SelectTablesPage() {
-            super("Select tables");
+        /**
+         * Create page.
+         */
+        private SelectTablesPage(Stage owner) {
+            super(owner, "Select tables");
         }
 
         /** {@inheritDoc} */
         @Override protected Pane createContent() {
-            return new HBox();
+            GridPaneEx gp = new GridPaneEx(DFLT_PADDING);
+
+            CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>("Scheme1");
+            rootItem.setExpanded(true);
+
+            TreeView<String> tree = new TreeView<>(rootItem);
+
+            tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
+            for (int i = 0; i < 100; i++) {
+                final CheckBoxTreeItem<String> checkBoxTreeItem =
+                    new CheckBoxTreeItem<>("Table" + (i+1));
+                rootItem.getChildren().add(checkBoxTreeItem);
+            }
+
+            gp.add(tree, 0, 0);
+
+            return gp;
         }
     }
 
+    /**
+     * Wizard page for configure generation settings.
+     */
     private static class ImportDbSchemaPage extends WizardPage {
-        private ImportDbSchemaPage() {
-            super("Import Database Schema");
+        /**
+         * Create page.
+         */
+        private ImportDbSchemaPage(Stage owner) {
+            super(owner, "Import Database Schema");
         }
 
         /** {@inheritDoc} */
         @Override protected Pane createContent() {
-            return new HBox();
+            GridPaneEx gp = new GridPaneEx(DFLT_PADDING);
+
+            gp.addPercentColumns(30, 70);
+
+            gp.addTextField("Package:", 0, 0);
+
+            return gp;
         }
     }
 
+    /**
+     * Final wizard page with selecting output folder.
+     */
     private static class GeneratePage extends WizardPage {
-        private GeneratePage() {
-            super("Generate");
+        /**
+         * Create page.
+         */
+        private GeneratePage(Stage owner) {
+            super(owner, "Generate");
         }
 
         /** {@inheritDoc} */
         @Override protected Pane createContent() {
-            HBox hb = new HBox();
+            GridPaneEx gp = new GridPaneEx(DFLT_PADDING);
 
-            Button btn = new Button("Generate");
-            btn.setOnAction(new EventHandler<ActionEvent>() {
+            final TextField outFolderTf = gp.addTextField("Output folder:", 0, 0);
+
+            Button btnFolder = new Button("...");
+            btnFolder.setOnAction(new EventHandler<ActionEvent>() {
+                @Override public void handle(ActionEvent evt) {
+                    DirectoryChooser dc = new DirectoryChooser();
+
+                    File folder = dc.showDialog(owner);
+
+                    if (folder != null)
+                        try {
+                            outFolderTf.setText(folder.getCanonicalPath());
+                        }
+                        catch (IOException ignore) {
+                            // No-op.
+                        }
+
+                }
+            });
+
+            gp.add(btnFolder, 2, 0);
+
+            Button btnGenerate = new Button("Generate");
+            btnGenerate.setOnAction(new EventHandler<ActionEvent>() {
                 @Override public void handle(ActionEvent evt) {
                     DbConnection.main(null);
 
@@ -180,9 +245,9 @@ public class SchemaLoadApp extends Application {
                 }
             });
 
-            hb.getChildren().addAll(btn);
+            gp.add(btnGenerate, 0, 1);
 
-            return hb;
+            return gp;
         }
     }
 
@@ -272,10 +337,10 @@ public class SchemaLoadApp extends Application {
 
         pages = new ArrayList<>();
 
-        pages.add(new DbChooserPage());
-        pages.add(new SelectTablesPage());
-        pages.add(new ImportDbSchemaPage());
-        pages.add(new GeneratePage());
+        pages.add(new DbChooserPage(primaryStage));
+        pages.add(new SelectTablesPage(primaryStage));
+        pages.add(new ImportDbSchemaPage(primaryStage));
+        pages.add(new GeneratePage(primaryStage));
 
         primaryStage.setTitle("Schema Load");
 
@@ -289,12 +354,12 @@ public class SchemaLoadApp extends Application {
         layerPnl.setBottom(createButtonsPane());
 
         primaryStage.setMinWidth(300);
-        primaryStage.setMinHeight(250);
+        primaryStage.setMinHeight(310);
 
         primaryStage.setMaxWidth(600);
         primaryStage.setMaxHeight(500);
 
-        primaryStage.setScene(new Scene(layerPnl, 300, 250));
+        primaryStage.setScene(new Scene(layerPnl, 300, 310));
         primaryStage.show();
 
         go(false);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3357b962/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
index 6a51604..08655d3 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
@@ -67,7 +67,10 @@ public class XmlTransformer {
             throw new IllegalStateException(e);
         }
     }
+
     /**
+     * Add bean to XML document.
+     *
      * @param parent Parent XML node.
      * @param clazz Bean class.
      */
@@ -81,8 +84,9 @@ public class XmlTransformer {
         return elem;
     }
 
-
     /**
+     * Add element to XML document.
+     *
      * @param parent Parent XML node.
      * @param tagName XML tag name.
      * @param name Value for &quot;name&quot; attribute.
@@ -103,6 +107,8 @@ public class XmlTransformer {
     }
 
     /**
+     * Add element to XML document.
+     *
      * @param parent Parent XML node.
      * @param tagName XML tag name.
      */
@@ -111,10 +117,7 @@ public class XmlTransformer {
     }
 
     /**
-     * Add to xml document:
-     * <pre name="code" class="xml">
-     *     &lt;property name=&quot;name&quot; value=&quot;value&quot;/&gt;
-     * </pre>
+     * Add property to xml document.
      *
      * @param parent Parent element.
      * @param name Property name.
@@ -125,10 +128,7 @@ public class XmlTransformer {
     }
 
     /**
-     * Add to xml document:
-     * <pre name="code" class="xml">
-     *     &lt;property name=&quot;name&quot;/&gt;
-     * </pre>
+     * Add property to xml document.
      *
      * @param parent Parent XML node.
      * @param name Property name.
@@ -138,14 +138,7 @@ public class XmlTransformer {
     }
 
     /**
-     * Add fields to xml document:
-     * <pre name="code" class="xml">
-     *     &lt;property name=&quot;name&quot;&gt;
-     *         &lt;map&gt;
-     *             &lt;property entry=&quot;name&quot; value=&quot;value&quot;/&gt;
-     *         &lt;/map&gt;
-     *     &lt;/property&gt;
-     * </pre>
+     * Add fields to xml document.
      *
      * @param parent Parent XML node.
      * @param name Property name.
@@ -163,14 +156,33 @@ public class XmlTransformer {
     }
 
     /**
-     * Add text fields to xml document:
-     * <pre name="code" class="xml">
-     *     &lt;property name=&quot;textFields&quot;&gt;
-     *         &lt;list&gt;
-     *             &lt;value&gt;field&lt;/value&gt;
-     *         &lt;/list&gt;
-     *     &lt;/property&gt;
-     * </pre>
+     * Add type descriptors to XML document.
+     *
+     * @param parent Parent XML node.
+     * @param typeDescs Map with type descriptors.
+     */
+    private void addTypeDescriptors(Node parent, Map<String, GridCacheQueryTypeDescriptor>
typeDescs) {
+        if (!typeDescs.isEmpty()) {
+            Element prop = addProperty(parent, "typeDescriptors");
+
+            Element map = addElement(prop, "map");
+
+            for (Map.Entry<String, GridCacheQueryTypeDescriptor> typeDesc : typeDescs.entrySet())
{
+                Element entry = addElement(map, "entry", typeDesc.getKey(), null);
+
+                Element val = addBean(entry, GridCacheQueryTypeDescriptor.class);
+
+                GridCacheQueryTypeDescriptor desc = typeDesc.getValue();
+
+                addProperty(val, "columnName", desc.getColumnName());
+                addProperty(val, "columnJdbcType", String.valueOf(desc.getColumnJdbcType()));
+                addProperty(val, "javaType", desc.getJavaType().getName());
+            }
+        }
+    }
+
+    /**
+     * Add text fields to xml document.
      *
      * @param textFields Collection with text fields.
      */
@@ -230,8 +242,14 @@ public class XmlTransformer {
 
         addProperty(bean, "type", meta.getType());
 
+        addProperty(bean, "schema", meta.getSchema());
+
+        addProperty(bean, "tableName", meta.getTableName());
+
         addFields(bean, "queryFields", meta.getQueryFields());
 
+        addTypeDescriptors(bean, meta.getTypeDescriptors());
+
         addFields(bean, "ascendingFields", meta.getAscendingFields());
 
         addFields(bean, "descendingFields", meta.getDescendingFields());


Mime
View raw message