ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [3/4] incubator-ignite git commit: # IGNITE-32 WIP: Reworked UI.
Date Sun, 28 Dec 2014 04:25:50 GMT
# IGNITE-32 WIP: Reworked 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/d34e6fd8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d34e6fd8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d34e6fd8

Branch: refs/heads/ignite-32
Commit: d34e6fd89c8aa2f50cbc1068751f80be133f3ad6
Parents: 38c721e
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Sun Dec 28 11:18:47 2014 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Sun Dec 28 11:18:47 2014 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/schema/ui/Controls.java   | 55 ++++++++++++
 .../org/apache/ignite/schema/ui/GridPaneEx.java | 93 ++++++++------------
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 64 +++++++-------
 3 files changed, 127 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d34e6fd8/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
new file mode 100644
index 0000000..954bdb1
--- /dev/null
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
@@ -0,0 +1,55 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.schema.ui;
+
+import javafx.event.*;
+import javafx.scene.control.*;
+
+/**
+ * Utility class to create controls.
+ */
+public class Controls {
+    /**
+     * Create button.
+     *
+     * @param text Button text.
+     * @param onAct Button action.
+     * @return New button instance.
+     */
+    public static Button button(String text, EventHandler<ActionEvent> onAct) {
+        Button btn = new Button(text);
+
+        btn.setOnAction(onAct);
+
+        return btn;
+    }
+
+    /**
+     * Create checkbox.
+     *
+     * @param text Checkbox text.
+     * @param sel Checkbox selected state.
+     * @return New checkbox instance.
+     */
+    public static CheckBox checkBox(String text, boolean sel) {
+        CheckBox ch = new CheckBox(text);
+
+        ch.setSelected(sel);
+
+        return ch;
+    }
+
+    /**
+     * @return New text field instance.
+     */
+    public static TextField textField() {
+        return new TextField();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d34e6fd8/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 eb1a8b7..e7e42e8 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,7 +9,6 @@
 
 package org.apache.ignite.schema.ui;
 
-import javafx.collections.*;
 import javafx.geometry.*;
 import javafx.scene.*;
 import javafx.scene.control.*;
@@ -19,6 +18,12 @@ import javafx.scene.layout.*;
  * Utility extention of {@code GridPane}.
  */
 public class GridPaneEx extends GridPane {
+    /** Current column. */
+    private int col;
+
+    /** Current row. */
+    private int row;
+
     /**
      * @param padding Pane padding.
      */
@@ -30,22 +35,6 @@ public class GridPaneEx extends GridPane {
     }
 
     /**
-     * Add percent columns.
-     *
-     * @param cols Columns percentages.
-     */
-    public void addPercentColumns(double... cols) {
-        ObservableList<ColumnConstraints> ccs = getColumnConstraints();
-
-        for (double col : cols) {
-            ColumnConstraints cc = new ColumnConstraints(2);
-            cc.setPercentWidth(col);
-
-            ccs.add(cc);
-        }
-    }
-
-    /**
      * Add fixed width column.
      *
      * @param width Column width.
@@ -65,11 +54,11 @@ public class GridPaneEx extends GridPane {
      * Add column with constraints and horizontal grow priority for the column.
      *
      * @param min Column minimum size.
-     * @param pref Column preffered size.
+     * @param pref Column preferred size.
      * @param max Column max size.
      * @param hgrow Column horizontal grow priority.
      */
-    public void addColumnn(double min, double pref, double max, Priority hgrow) {
+    public void addColumn(double min, double pref, double max, Priority hgrow) {
         ColumnConstraints cc = new ColumnConstraints(min, pref, max);
 
         cc.setHgrow(hgrow);
@@ -94,10 +83,10 @@ public class GridPaneEx extends GridPane {
     }
 
     /**
-     * Add row with constraints and verical grow priority for the row.
+     * Add row with constraints and vertical grow priority for the row.
      *
      * @param min Row minimum size.
-     * @param pref Row preffered size.
+     * @param pref Row preferred size.
      * @param max Row max size.
      * @param vgrow Row vertical grow priority.
      */
@@ -110,46 +99,47 @@ public class GridPaneEx extends GridPane {
     }
 
     /**
-     * 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.
+     * Wrap to next row.
      */
-    public Label addLabel(String text, int colIx, int rowIx) {
-        Label lb = new Label(text);
+    public void wrap() {
+        col = 0;
 
-        add(lb, colIx, rowIx);
+        row++;
+    }
 
-        return lb;
+    /**
+     * Move to next column.
+     */
+    private void nextCol(int span) {
+        col += span;
+
+        if (col >= getColumnConstraints().size())
+            wrap();
     }
 
     /**
-     * Add text field to gridpane.
+     * Add control to grid pane.
      *
-     * @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.
+     * @param ctrl Control to add.
+     * @param span How many columns control should take.
+     * @return Added control.
      */
-    public TextField addTextField(int colIx, int rowIx) {
-        TextField tf = new TextField();
+    public <T extends Node> T add(T ctrl, int span) {
+        add(ctrl, col, row, span, 1);
 
-        add(tf, colIx, rowIx);
+        nextCol(span);
 
-        return tf;
+        return ctrl;
     }
 
     /**
-     * Add label and text field to gridpane.
+     * Add control 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 the label within the grid pane.
-     * @return New text field instance.
+     * @param ctrl Control to add.
+     * @return Added control.
      */
-    public TextField addTextField(String text, int colIx, int rowIx) {
-        return addLabeled(text, new TextField(), colIx, rowIx);
+    public <T extends Node> T add(T ctrl) {
+        return add(ctrl, 1);
     }
 
     /**
@@ -157,16 +147,11 @@ public class GridPaneEx extends GridPane {
      *
      * @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);
+    public <T extends Node> T addLabeled(String text, T ctrl) {
+        add(new Label(text));
 
-        add(lb, colIx, rowIx);
-        add(ctrl, colIx + 1, rowIx);
-
-        return ctrl;
+        return add(ctrl);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d34e6fd8/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 84ac4f4..e3d512e 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
@@ -23,8 +23,6 @@ import org.apache.ignite.schema.pojo.*;
 import org.apache.ignite.schema.xml.*;
 import org.gridgain.grid.cache.query.*;
 
-import javax.xml.transform.*;
-import javax.xml.transform.stream.*;
 import java.io.*;
 import java.sql.*;
 import java.util.*;
@@ -78,6 +76,12 @@ public class SchemaLoadApp extends Application {
     private TextField outFolderTf;
 
     /** */
+    private CheckBox pojoConstructorCh;
+
+    /** */
+    private CheckBox xmlSingleFileCh;
+
+    /** */
     private GridPaneEx genPnl;
 
     /** */
@@ -91,18 +95,18 @@ public class SchemaLoadApp extends Application {
             connPnl = new GridPaneEx(DFLT_PADDING);
 
             connPnl.addColumn();
-            connPnl.addColumnn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+            connPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
 
-            jdbcTf = connPnl.addTextField("JDBC Driver:", 0, 0);
+            jdbcTf = connPnl.addLabeled("JDBC Driver:", Controls.textField());
             jdbcTf.setText("org.h2.Driver");
 
-            urlTf = connPnl.addTextField("URL:", 0, 1);
+            urlTf = connPnl.addLabeled("URL:", Controls.textField());
             urlTf.setText("jdbc:h2:mem:test");
 
-            userTf = connPnl.addTextField("User:", 0, 2);
+            userTf = connPnl.addLabeled("User:", Controls.textField());
             userTf.setText("sa");
 
-            pwdTf = connPnl.addLabeled("Password:", new PasswordField(), 0, 3);
+            pwdTf = connPnl.addLabeled("Password:", new PasswordField());
         }
 
         return connPnl;
@@ -118,12 +122,14 @@ public class SchemaLoadApp extends Application {
             genPnl = new GridPaneEx(DFLT_PADDING);
 
             genPnl.addColumn();
-            genPnl.addColumnn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+            genPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
             genPnl.addColumn(30);
 
             genPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
             genPnl.addRow();
             genPnl.addRow();
+            genPnl.addRow();
+            genPnl.addRow();
 
             rootItem = new CheckBoxTreeItem<>("Database");
             rootItem.setExpanded(true);
@@ -131,16 +137,17 @@ public class SchemaLoadApp extends Application {
             TreeView<String> tree = new TreeView<>(rootItem);
             tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
 
-            genPnl.add(tree, 0, 0, 3, 1);
+            genPnl.add(tree, 3);
 
-            pkgTf = genPnl.addTextField("Package:", 0, 2);
+            pkgTf = genPnl.addLabeled("Package:", Controls.textField());
             pkgTf.setText("org.apache.ignite");
 
-            outFolderTf = genPnl.addTextField("Output folder:", 0, 3);
+            genPnl.wrap();
+
+            outFolderTf = genPnl.addLabeled("Output Folder:", Controls.textField());
             outFolderTf.setText(PATH);
 
-            Button btnFolder = new Button("...");
-            btnFolder.setOnAction(new EventHandler<ActionEvent>() {
+            genPnl.add(Controls.button("...", new EventHandler<ActionEvent>() {
                 @Override public void handle(ActionEvent evt) {
                     DirectoryChooser dc = new DirectoryChooser();
 
@@ -149,9 +156,11 @@ public class SchemaLoadApp extends Application {
                     if (folder != null)
                         outFolderTf.setText(folder.getAbsolutePath());
                 }
-            });
+            }));
 
-            genPnl.add(btnFolder, 2, 3);
+            pojoConstructorCh = genPnl.add(Controls.checkBox("Generate Constructor For POJO",
false), 3);
+
+            xmlSingleFileCh = genPnl.add(Controls.checkBox("Write All Configurations To Single
File", true), 3);
         }
 
         return genPnl;
@@ -196,6 +205,8 @@ public class SchemaLoadApp extends Application {
 
             List<GridCacheQueryTypeMetadata> all = new ArrayList<>();
 
+            boolean constructor = pojoConstructorCh.isSelected();
+
             for (TreeItem<String> schemeItem : rootItem.getChildren()) {
                 for (TreeItem<String> tblItem : schemeItem.getChildren()) {
                     if (((CheckBoxTreeItem)tblItem).isSelected()) {
@@ -204,13 +215,9 @@ public class SchemaLoadApp extends Application {
 
                         all.add(meta);
 
-                        XmlTransformer transformer = new XmlTransformer(4);
-
-                        Result res = new StreamResult(new File(destFolder, meta.getType()
+ ".xml"));
+                        XmlTransformer.transform(pkg, meta, new File(destFolder, meta.getType()
+ ".xml"));
 
-                        transformer.transform(pkg, meta, res);
-
-                        PojoCodeGenerator.generate(meta, outFolder, pkg);
+                        PojoCodeGenerator.generate(meta, outFolder, pkg, constructor);
                     }
                 }
             }
@@ -218,11 +225,8 @@ public class SchemaLoadApp extends Application {
             if (all.isEmpty())
                 MessageBox.showInformationDialog(owner, "Warning", "Nothing selected");
             else {
-                XmlTransformer transformer = new XmlTransformer(4);
-
-                Result res = new StreamResult(new File(outFolder, "all.xml"));
-
-                transformer.transform(pkg, all, res);
+                if (xmlSingleFileCh.isSelected())
+                    XmlTransformer.transform(pkg, all, new File(outFolder, "all.xml"));
 
                 MessageBox.showInformationDialog(owner, "Information", "Generation complete!");
             }
@@ -250,15 +254,13 @@ public class SchemaLoadApp extends Application {
      * @return Panel with control buttons.
      */
     private Pane createButtonsPane() {
-        prevBtn = new Button("Prev");
-        prevBtn.setOnAction(new EventHandler<ActionEvent>() {
+        prevBtn = Controls.button("Prev", new EventHandler<ActionEvent>() {
             @Override public void handle(ActionEvent evt) {
                 prev();
             }
         });
 
-        nextBtn = new Button("Next");
-        nextBtn.setOnAction(new EventHandler<ActionEvent>() {
+        nextBtn = Controls.button("Next", new EventHandler<ActionEvent>() {
             @Override public void handle(ActionEvent evt) {
                 next();
             }
@@ -323,7 +325,7 @@ public class SchemaLoadApp extends Application {
         primaryStage.setMinWidth(w);
         primaryStage.setMaxWidth(2 * w);
 
-        int h = 350;
+        int h = 400;
         primaryStage.setHeight(h);
         primaryStage.setMinHeight(h);
         primaryStage.setMaxHeight(2 * h);


Mime
View raw message