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 Tue, 23 Dec 2014 10:22:30 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/b935c61b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b935c61b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b935c61b

Branch: refs/heads/ignite-32
Commit: b935c61b940b61bcc432a2ec66ec796d705e0688
Parents: 5b63a47
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Dec 23 17:22:28 2014 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Dec 23 17:22:28 2014 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/schema/ui/GridPaneEx.java | 94 ++++++++++++++++++++
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 92 ++++++++++---------
 2 files changed, 144 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b935c61b/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
new file mode 100644
index 0000000..127c53c
--- /dev/null
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
@@ -0,0 +1,94 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.schema.ui;
+
+import javafx.scene.*;
+import javafx.scene.control.*;
+import javafx.scene.layout.*;
+
+/**
+ * Utility extention of {@code GridPane}.
+ */
+public class GridPaneEx extends GridPane {
+    /**
+     * Add percent columns.
+     *
+     * @param cols Array of column percentages.
+     */
+    public void addPercentColumns(double ... cols) {
+        for (double col : cols) {
+            ColumnConstraints cc = new ColumnConstraints();
+            cc.setPercentWidth(col);
+
+            getColumnConstraints().add(cc);
+        }
+    }
+
+    /**
+     * Add label to grid pane.
+     *
+     * @param text Label text.
+     * @param colIx Column index position for the label within the grid pane.
+     * @param rowIx Row index position for the label within the grid pane.
+     * @return Label instance.
+     */
+    public Label addLabel(String text, int colIx, int rowIx) {
+        Label lb = new Label(text);
+
+        add(lb, colIx, rowIx);
+
+        return lb;
+    }
+
+    /**
+     * Add text field to gridpane.
+     *
+     * @param colIx Column index position for the text field within the grid pane.
+     * @param rowIx Row index position for the the text field within the grid pane.
+     * @return new label instance.
+     */
+    public TextField addTextField(int colIx, int rowIx) {
+        TextField tf = new TextField();
+
+        add(tf, colIx, rowIx);
+
+        return tf;
+    }
+
+    /**
+     * Add label and text field to gridpane.
+     *
+     * @param text Label text.
+     * @param colIx Column index position for the label within the grid pane.
+     * @param rowIx Row index position for the the label within the grid pane.
+     * @return New text field instance.
+     */
+    public TextField addTextField(String text, int colIx, int rowIx) {
+        return addLabeled(text, new TextField(), colIx, rowIx);
+    }
+
+    /**
+     * Add control with label.
+     *
+     * @param text Label text.
+     * @param ctrl Control to add.
+     * @param colIx Column index position for the label within the grid pane.
+     * @param rowIx Row index position for the the label within the grid pane.
+     * @return Added control.
+     */
+    public <T extends Node> T addLabeled(String text, T ctrl, int colIx, int rowIx)
{
+        Label lb = new Label(text);
+
+        add(lb, colIx, rowIx);
+        add(ctrl, colIx + 1, rowIx);
+
+        return ctrl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b935c61b/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 b2e1d39..e7e061d 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
@@ -28,10 +28,10 @@ import java.util.*;
  */
 public class SchemaLoadApp extends Application {
     /** */
-    private static Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
+    private static final Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
 
     /** */
-    private int step = 0;
+    private int step;
 
     /** */
     private BorderPane contentPane;
@@ -48,6 +48,11 @@ 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);
 
@@ -56,17 +61,32 @@ public class SchemaLoadApp extends Application {
         return hb;
     }
 
-    private abstract class WizardPage {
+    /**
+     * Base class for wizard pages.
+     */
+    private abstract static class WizardPage {
+        /** */
         protected Pane contentPane;
-
+        /** */
         protected final String title;
 
+        /**
+         * @param title Page title.
+         */
         protected WizardPage(String title) {
             this.title = title;
         }
 
+        /**
+         * Create wizard pane content.
+         *
+         * @return New pane instance with controls.
+         */
         protected abstract Pane createContent();
 
+        /**
+         * @return Wizard page with controls.
+         */
         protected Pane content() {
             if (contentPane == null)
                 contentPane = createContent();
@@ -76,90 +96,78 @@ public class SchemaLoadApp extends Application {
 
     }
 
-    private class DbChooserPage extends WizardPage {
-        public DbChooserPage() {
+    /**
+     * Wizard page for selecting DB settings.
+     */
+    private static class DbChooserPage extends WizardPage {
+        /**
+         * Create page.
+         */
+        private DbChooserPage() {
             super("Choose Database");
         }
 
+        /** {@inheritDoc} */
         @Override protected Pane createContent() {
-            GridPane gp = new GridPane();
-
-            gp.setGridLinesVisible(true);
+            GridPaneEx gp = new GridPaneEx();
 
-            ColumnConstraints col1 = new ColumnConstraints();
-            col1.setPercentWidth(30);
-            ColumnConstraints col2 = new ColumnConstraints();
-            col2.setPercentWidth(70);
-            gp.getColumnConstraints().addAll(col1, col2);
+            gp.addPercentColumns(30, 70);
 
             gp.setAlignment(Pos.CENTER);
             gp.setHgap(10);
             gp.setVgap(10);
             gp.setPadding(DFLT_PADDING);
 
-            Label aliasLb = new Label("Alias:");
-            gp.add(aliasLb, 0, 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);
 
-            Label jdbcLb = new Label("JDBC Driver:");
-            gp.add(jdbcLb, 0, 2);
-
-            TextField jdbcTf = new TextField();
-            gp.add(jdbcTf, 1, 2);
-
-            Label urlLb = new Label("URL:");
-            gp.add(urlLb, 0, 3);
-
-            TextField urlTf = new TextField();
-            gp.add(urlTf, 1, 3);
-
-            Label userLb = new Label("User:");
-            gp.add(userLb, 0, 4);
+            TextField jdbcTf = gp.addTextField("JDBC Driver:", 0, 2);
 
-            TextField userTf = new TextField();
-            gp.add(userTf, 1, 4);
+            TextField urlTf = gp.addTextField("URL:", 0, 3);
 
-            Label pwdLb = new Label("Password:");
-            gp.add(pwdLb, 0, 5);
+            TextField userTf = gp.addTextField("User:", 0, 4);
 
-            PasswordField pwdTf = new PasswordField();
-            gp.add(pwdTf, 1, 5);
+            PasswordField pwdTf = gp.addLabeled("Password:", new PasswordField(), 0, 5);
 
             return gp;
         }
     }
 
-    private class SelectTablesPage extends WizardPage {
-        public SelectTablesPage() {
+    private static class SelectTablesPage extends WizardPage {
+        private SelectTablesPage() {
             super("Select tables");
         }
 
+        /** {@inheritDoc} */
         @Override protected Pane createContent() {
             return new HBox();
         }
     }
 
-    private class ImportDbSchemaPage extends WizardPage {
-        public ImportDbSchemaPage() {
+    private static class ImportDbSchemaPage extends WizardPage {
+        private ImportDbSchemaPage() {
             super("Import Database Schema");
         }
 
+        /** {@inheritDoc} */
         @Override protected Pane createContent() {
             return new HBox();
         }
     }
 
-    private class GeneratePage extends WizardPage {
-        public GeneratePage() {
+    private static class GeneratePage extends WizardPage {
+        private GeneratePage() {
             super("Generate");
         }
 
+        /** {@inheritDoc} */
         @Override protected Pane createContent() {
             HBox hb = new HBox();
 


Mime
View raw message