ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/2] incubator-ignite git commit: # ignite-32 WIP: Working on UI.
Date Wed, 24 Dec 2014 09:19:13 GMT
# 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/55370e2e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/55370e2e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/55370e2e

Branch: refs/heads/ignite-32
Commit: 55370e2e1b546e4970bf55d154b49659d49ab5fc
Parents: 7619eed
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Wed Dec 24 16:19:09 2014 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Wed Dec 24 16:19:09 2014 +0700

----------------------------------------------------------------------
 .../src/main/java/media/branch_128x128.png      | Bin 0 -> 3766 bytes
 .../src/main/java/media/branch_16x16.png        | Bin 0 -> 411 bytes
 .../src/main/java/media/branch_32x32.png        | Bin 0 -> 775 bytes
 .../src/main/java/media/branch_48x48.png        | Bin 0 -> 1139 bytes
 .../src/main/java/media/error_48x48.png         | Bin 0 -> 4349 bytes
 .../src/main/java/media/information_48x48.png   | Bin 0 -> 4102 bytes
 .../src/main/java/media/question_48x48.png      | Bin 0 -> 3857 bytes
 .../apache/ignite/schema/db/DbConnection.java   |   4 +-
 .../org/apache/ignite/schema/ui/MessageBox.java | 128 ++++++++++++++++++
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 129 ++++++++++++-------
 .../ignite/schema/ui/media/branch_128x128.png   | Bin 3766 -> 0 bytes
 .../ignite/schema/ui/media/branch_16x16.png     | Bin 411 -> 0 bytes
 .../ignite/schema/ui/media/branch_32x32.png     | Bin 775 -> 0 bytes
 .../ignite/schema/ui/media/branch_48x48.png     | Bin 1139 -> 0 bytes
 .../apache/ignite/schema/util/SchemaUtils.java  |  46 +++++++
 15 files changed, 256 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/branch_128x128.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/branch_128x128.png b/modules/schema-load/src/main/java/media/branch_128x128.png
new file mode 100644
index 0000000..dacee19
Binary files /dev/null and b/modules/schema-load/src/main/java/media/branch_128x128.png differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/branch_16x16.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/branch_16x16.png b/modules/schema-load/src/main/java/media/branch_16x16.png
new file mode 100644
index 0000000..9764668
Binary files /dev/null and b/modules/schema-load/src/main/java/media/branch_16x16.png differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/branch_32x32.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/branch_32x32.png b/modules/schema-load/src/main/java/media/branch_32x32.png
new file mode 100644
index 0000000..8f39620
Binary files /dev/null and b/modules/schema-load/src/main/java/media/branch_32x32.png differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/branch_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/branch_48x48.png b/modules/schema-load/src/main/java/media/branch_48x48.png
new file mode 100644
index 0000000..a956f2c
Binary files /dev/null and b/modules/schema-load/src/main/java/media/branch_48x48.png differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/error_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/error_48x48.png b/modules/schema-load/src/main/java/media/error_48x48.png
new file mode 100644
index 0000000..e341b8a
Binary files /dev/null and b/modules/schema-load/src/main/java/media/error_48x48.png differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/information_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/information_48x48.png b/modules/schema-load/src/main/java/media/information_48x48.png
new file mode 100644
index 0000000..8712a1b
Binary files /dev/null and b/modules/schema-load/src/main/java/media/information_48x48.png
differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/media/question_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/question_48x48.png b/modules/schema-load/src/main/java/media/question_48x48.png
new file mode 100644
index 0000000..84683f9
Binary files /dev/null and b/modules/schema-load/src/main/java/media/question_48x48.png differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbConnection.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbConnection.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbConnection.java
index 86c7f2d..d62f98d 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbConnection.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbConnection.java
@@ -35,8 +35,8 @@ public class DbConnection {
 
             Statement stmt = conn.createStatement();
 
-            stmt.executeUpdate("CREATE TABLE Organization (id integer, name varchar(50),
city varchar(50))");
-            stmt.executeUpdate("CREATE TABLE Person (id integer, org_id integer, name varchar(50))");
+            stmt.executeUpdate("CREATE TABLE Organization (id integer PRIMARY KEY, name varchar(50),
city varchar(50))");
+            stmt.executeUpdate("CREATE TABLE Person (id integer PRIMARY KEY, org_id integer,
name varchar(50))");
 
             stmt.executeUpdate("CREATE INDEX Org_Name_IDX On Organization (name)");
             stmt.executeUpdate("CREATE INDEX Org_Name_City_IDX On Organization (name, city)");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/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
new file mode 100644
index 0000000..5d58e22
--- /dev/null
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
@@ -0,0 +1,128 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.schema.ui;
+
+import javafx.event.*;
+import javafx.geometry.*;
+import javafx.scene.*;
+import javafx.scene.control.*;
+import javafx.scene.image.*;
+import javafx.scene.layout.*;
+import javafx.scene.text.*;
+import javafx.stage.*;
+
+import static org.apache.ignite.schema.util.SchemaUtils.*;
+
+/**
+ * TODO: Add class description.
+ */
+public class MessageBox {
+
+    public enum Option {NO, YES, CANCEL}
+
+    private static Option result = Option.CANCEL;
+
+    private static ImageView icon = new ImageView();
+
+    static class Dialog extends Stage {
+        public Dialog(String title, Stage owner, Scene scene, String iconFile) {
+            setTitle(title);
+            initStyle(StageStyle.UTILITY);
+            initModality(Modality.APPLICATION_MODAL);
+            initOwner(owner);
+            setResizable(false);
+            setScene(scene);
+            icon.setImage(image(iconFile, 48));
+        }
+
+        public void showDialog() {
+            sizeToScene();
+            centerOnScreen();
+            showAndWait();
+        }
+    }
+
+    static class Message extends Text {
+        public Message(String msg) {
+            super(msg);
+            setWrappingWidth(250);
+        }
+    }
+
+    public static Option showConfirmDialog(Stage owner, String message, String title) {
+        VBox vb = newVBox(10);
+
+        Scene scene = new Scene(vb);
+
+        final Dialog dial = new Dialog(title, owner, scene, "question");
+
+        Button yesButton = new Button("Yes");
+        yesButton.setOnAction(new EventHandler<ActionEvent>() {
+            @Override public void handle(ActionEvent e) {
+                dial.close();
+                result = Option.YES;
+            }
+        });
+
+        Button noButton = new Button("No");
+        noButton.setOnAction(new EventHandler<ActionEvent>() {
+            @Override public void handle(ActionEvent e) {
+                dial.close();
+                result = Option.NO;
+            }
+        });
+
+        BorderPane bp = new BorderPane();
+        HBox buttons = new HBox();
+        buttons.setAlignment(Pos.CENTER);
+        buttons.setSpacing(10);
+        buttons.getChildren().addAll(yesButton, noButton);
+        bp.setCenter(buttons);
+        HBox msg = new HBox();
+        msg.setSpacing(5);
+        msg.getChildren().addAll(icon, new Message(message));
+        vb.getChildren().addAll(msg, bp);
+        dial.showDialog();
+
+        return result;
+    }
+
+    private static void showDialog(Stage owner, String title, String message, String iconFile)
{
+        VBox vb = newVBox(10);
+        Scene scene = new Scene(vb);
+
+        final Dialog dial = new Dialog(title, owner, scene, iconFile);
+
+        Button okButton = new Button("OK");
+        okButton.setAlignment(Pos.CENTER);
+        okButton.setOnAction(new EventHandler<ActionEvent>() {
+            @Override public void handle(ActionEvent e) {
+                dial.close();
+            }
+        });
+
+        BorderPane bp = new BorderPane();
+        bp.setCenter(okButton);
+        HBox msg = new HBox();
+        msg.setSpacing(5);
+        msg.getChildren().addAll(icon, new Message(message));
+        vb.getChildren().addAll(msg, bp);
+
+        dial.showDialog();
+    }
+
+    public static void showInformationDialog(Stage owner, String title, String message) {
+        showDialog(owner, title, message, "information");
+    }
+
+    public static void showErrorDialog(Stage owner, String title, String message) {
+        showDialog(owner, title, message, "error");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/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 e53bd56..7d429e8 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
@@ -10,29 +10,27 @@
 package org.apache.ignite.schema.ui;
 
 import javafx.application.*;
-import javafx.collections.*;
 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.sql.*;
 import java.util.*;
 
+import static org.apache.ignite.schema.util.SchemaUtils.*;
+
 /**
  * Schema load application.
  */
 public class SchemaLoadApp extends Application {
     /** */
-    private static final Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
-
-    /** */
     private int step;
 
     /** */
@@ -51,19 +49,6 @@ public class SchemaLoadApp extends Application {
     private List<WizardPage> pages;
 
     /**
-     * Create new {@code HBox} with default padding.
-     * @param spacing Amount of horizontal space between each child.
-     * @return New {@code HBox} instance.
-     */
-    private static HBox newHBox(int spacing) {
-        HBox hb = new HBox(spacing);
-
-        hb.setPadding(DFLT_PADDING);
-
-        return hb;
-    }
-
-    /**
      * Base class for wizard pages.
      */
     private abstract static class WizardPage {
@@ -102,12 +87,26 @@ public class SchemaLoadApp extends Application {
             return contentPane;
         }
 
+        /**
+         * @return {@code true} if wizard page complete.
+         */
+        public boolean complete() {
+            return true;
+        }
     }
 
     /**
      * Wizard page for selecting DB settings.
      */
     private static class DbChooserPage extends WizardPage {
+        private TextField jdbcTf;
+
+        private TextField urlTf;
+
+        private TextField userTf;
+
+        private PasswordField pwdTf;
+
         /**
          * Create page.
          */
@@ -121,23 +120,26 @@ public class SchemaLoadApp extends Application {
 
             gp.addPercentColumns(30, 70);
 
-            gp.addLabel("Alias:", 0, 0);
-
-            ObservableList<String> options = FXCollections.observableArrayList("My
Settings");
-            ComboBox<String> aliasCb = new ComboBox<>(options);
-            aliasCb.setPromptText("Schema load settings");
-            aliasCb.setEditable(true);
-            aliasCb.setMaxWidth(Double.MAX_VALUE);
-
-            gp.add(aliasCb, 1, 0);
+//            gp.addLabel("Alias:", 0, 0);
+//
+//            ObservableList<String> options = FXCollections.observableArrayList("My
Settings");
+//            ComboBox<String> aliasCb = new ComboBox<>(options);
+//            aliasCb.setPromptText("Schema load settings");
+//            aliasCb.setEditable(true);
+//            aliasCb.setMaxWidth(Double.MAX_VALUE);
+//
+//            gp.add(aliasCb, 1, 0);
 
-            TextField jdbcTf = gp.addTextField("JDBC Driver:", 0, 2);
+            jdbcTf = gp.addTextField("JDBC Driver:", 0, 2);
+            jdbcTf.setText("org.h2.Driver");
 
-            TextField urlTf = gp.addTextField("URL:", 0, 3);
+            urlTf = gp.addTextField("URL:", 0, 3);
+            urlTf.setText("jdbc:h2:mem:test");
 
-            TextField userTf = gp.addTextField("User:", 0, 4);
+            userTf = gp.addTextField("User:", 0, 4);
+            userTf.setText("sa");
 
-            PasswordField pwdTf = gp.addLabeled("Password:", new PasswordField(), 0, 5);
+            pwdTf = gp.addLabeled("Password:", new PasswordField(), 0, 5);
 
             return gp;
         }
@@ -252,15 +254,6 @@ public class SchemaLoadApp extends Application {
     }
 
     /**
-     * Schema load utility launcher.
-     *
-     * @param args Command line arguments passed to the application.
-     */
-    public static void main(String[] args) {
-        launch(args);
-    }
-
-    /**
      * @return Header pane with title label.
      */
     private Pane createHeaderPane() {
@@ -321,15 +314,6 @@ public class SchemaLoadApp extends Application {
         nextBtn.setDisable(step == pages.size() - 1);
     }
 
-    /**
-     * Gets image by its filename.
-     *
-     * @param fname Image filename.
-     */
-    private Image image(String fname, int sz) {
-        return new Image(getClass().getResourceAsStream(String.format("media/%1$s_%2$dx%2$d.png",
fname, sz)));
-    }
-
     /** {@inheritDoc} */
     @Override public void start(Stage primaryStage) {
         primaryStage.getIcons()
@@ -364,4 +348,51 @@ public class SchemaLoadApp extends Application {
 
         go(false);
     }
+
+    /**
+     * Schema load utility launcher.
+     */
+    private static void sampleDb() {
+        try {
+            Class.forName("org.h2.Driver");
+            Connection conn = DriverManager.getConnection("jdbc:h2:mem:test", "sa", "");
+
+            Statement stmt = conn.createStatement();
+
+            stmt.executeUpdate("CREATE TABLE Organization (id integer, name varchar(50),
city varchar(50))");
+            stmt.executeUpdate("CREATE TABLE Person (id integer, org_id integer, name varchar(50))");
+
+            stmt.executeUpdate("CREATE INDEX Org_Name_IDX On Organization (name)");
+            stmt.executeUpdate("CREATE INDEX Org_Name_City_IDX On Organization (name, city)");
+            stmt.executeUpdate("CREATE INDEX Person_Name_IDX1 On Person (name)");
+            stmt.executeUpdate("CREATE INDEX Person_Name_IDX2 On Person (name desc)");
+
+            conn.commit();
+
+            stmt.executeUpdate("INSERT INTO Organization(id, name) VALUES (1, 'GridGain')");
+            stmt.executeUpdate("INSERT INTO Organization(id, name) VALUES (2, 'Apache')");
+
+            stmt.executeUpdate("INSERT INTO Person(id, org_id, name) VALUES (1, 1, 'Kuznetsov')");
+            stmt.executeUpdate("INSERT INTO Person(id, org_id, name) VALUES (2, 2, 'Boudnik')");
+
+            conn.commit();
+
+            conn.close();
+        }
+        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/55370e2e/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_128x128.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_128x128.png
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_128x128.png
deleted file mode 100644
index dacee19..0000000
Binary files a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_128x128.png
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_16x16.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_16x16.png
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_16x16.png
deleted file mode 100644
index 9764668..0000000
Binary files a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_16x16.png
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_32x32.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_32x32.png
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_32x32.png
deleted file mode 100644
index 8f39620..0000000
Binary files a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_32x32.png
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_48x48.png
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_48x48.png
deleted file mode 100644
index a956f2c..0000000
Binary files a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/media/branch_48x48.png
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55370e2e/modules/schema-load/src/main/java/org/apache/ignite/schema/util/SchemaUtils.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/util/SchemaUtils.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/util/SchemaUtils.java
index 6e0e9f1..3f30158 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/util/SchemaUtils.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/util/SchemaUtils.java
@@ -9,10 +9,17 @@
 
 package org.apache.ignite.schema.util;
 
+import javafx.geometry.*;
+import javafx.scene.image.*;
+import javafx.scene.layout.*;
+
 /**
  * TODO: Add class description.
  */
 public class SchemaUtils {
+    /** */
+    public static final Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
+
     /**
      * @param str Source string.
      * @return String with each word first letters capitalized.
@@ -64,4 +71,43 @@ public class SchemaUtils {
     public static String toJavaFieldName(String name) {
         return uncapitalize(toJavaClassName(name));
     }
+
+    /**
+     * Gets image by its filename.
+     *
+     * @param fname Image filename.
+     */
+    public static Image image(String fname, int sz) {
+        return new Image(SchemaUtils.class.getClassLoader()
+            .getResourceAsStream(String.format("media/%1$s_%2$dx%2$d.png", fname, sz)));
+    }
+
+    /**
+     * Create new {@code HBox} with default padding.
+     *
+     * @param spacing Amount of horizontal space between each child.
+     * @return New {@code HBox} instance.
+     */
+    public static HBox newHBox(int spacing) {
+        HBox hb = new HBox(spacing);
+
+        hb.setPadding(DFLT_PADDING);
+
+        return hb;
+    }
+
+    /**
+     * Create new {@code VBox} with default padding.
+     *
+     * @param spacing Amount of horizontal space between each child.
+     * @return New {@code VBox} instance.
+     */
+    public static VBox newVBox(int spacing) {
+        VBox vb = new VBox(spacing);
+
+        vb.setPadding(DFLT_PADDING);
+
+        return vb;
+    }
 }
+


Mime
View raw message