ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: # IGNITE-32: Implemented renaming.
Date Thu, 29 Jan 2015 06:29:41 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 b170fcd55 -> dae3e16ed


# IGNITE-32: Implemented renaming.


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

Branch: refs/heads/ignite-32
Commit: dae3e16ed67feb8b4e823fea0aaf152a5bca4e6c
Parents: b170fcd
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Jan 29 13:29:42 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Jan 29 13:29:42 2015 +0700

----------------------------------------------------------------------
 .../schema-load/src/main/java/media/style.css   |  16 +++
 .../ignite/schema/model/PojoDescriptor.java     |  28 ++++
 .../org/apache/ignite/schema/ui/Controls.java   |  15 +++
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 131 ++++++++++++++++---
 4 files changed, 169 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dae3e16e/modules/schema-load/src/main/java/media/style.css
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/media/style.css b/modules/schema-load/src/main/java/media/style.css
index 89959f1..90e1667 100644
--- a/modules/schema-load/src/main/java/media/style.css
+++ b/modules/schema-load/src/main/java/media/style.css
@@ -67,6 +67,22 @@
     -fx-background-color: -fx-box-border, eeeeee;
 }
 
+.titled-pane {
+    -fx-font-size: 14;
+}
+
+.titled-pane:focused {
+    -fx-text-fill: -fx-text-base-color;
+}
+
+.titled-pane:focused > .title {
+    -fx-color: eeeeee;
+}
+
+.titled-pane:focused > .title > .arrow-button .arrow {
+    -fx-background-color: black;
+}
+
 #banner {
    -fx-font-size: 20px;
    -fx-font-weight: bold;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dae3e16e/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
index e215dcb..7bcb14a 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
@@ -176,6 +176,13 @@ public class PojoDescriptor {
     }
 
     /**
+     * @param name New key class name.
+     */
+    public void keyClassName(String name) {
+        keyClsName.set(name);
+    }
+
+    /**
      * @return Value class name.
      */
     public String valueClassName() {
@@ -183,6 +190,13 @@ public class PojoDescriptor {
     }
 
     /**
+     * @param name New value class name.
+     */
+    public void valueClassName(String name) {
+        valClsName.set(name);
+    }
+
+    /**
      * @return Collection of key fields.
      */
     public Collection<PojoField> keyFields() {
@@ -264,6 +278,20 @@ public class PojoDescriptor {
     }
 
     /**
+     * Revert changes to key class name made by user.
+     */
+    public void revertKeyClassName() {
+       keyClsName.set(keyClsNamePrev);
+    }
+
+    /**
+     * Revert changes to value class name made by user.
+     */
+    public void revertValueClassName() {
+        valClsName.set(valClsNamePrev);
+    }
+
+    /**
      * Revert changes to java names made by user.
      */
     public void revertJavaNames() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dae3e16e/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 5ec47a3..e4f1ef7 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
@@ -345,6 +345,21 @@ public class Controls {
     }
 
     /**
+     * Create titled pane.
+     *
+     * @param title Title.
+     * @param node Node.
+     * @return New {@code TitledPane} instance.
+     */
+    public static TitledPane titledPane(String title, Node node) {
+        TitledPane tp = new TitledPane(title, node);
+
+        tp.setExpanded(false);
+
+        return tp;
+    }
+
+    /**
      * Create table column.
      *
      * @param colName Column name to display.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dae3e16e/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 9d53a06..07467e6 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
@@ -87,10 +87,22 @@ public class SchemaLoadApp extends Application {
     /** */
     private BorderPane rootPane;
 
+    /** Header pane. */
+    private BorderPane hdrPane;
+
+    /** */
+    private HBox dbIcon;
+
+    /** */
+    private HBox genIcon;
+
     /** */
     private Label titleLb;
 
     /** */
+    private Label subTitleLb;
+
+    /** */
     private Button prevBtn;
 
     /** */
@@ -273,8 +285,10 @@ public class SchemaLoadApp extends Application {
 
                 unlockUI(connLayerPnl, connPnl, nextBtn);
 
+                hdrPane.setLeft(genIcon);
+
                 titleLb.setText("Generate XML And POJOs");
-                titleLb.setGraphic(imageView("text_tree", 48));
+                subTitleLb.setText(jdbcUrlTf.getText());
 
                 rootPane.setCenter(genLayerPnl);
 
@@ -422,11 +436,16 @@ public class SchemaLoadApp extends Application {
     /**
      * @return Header pane with title label.
      */
-    private Pane createHeaderPane() {
+    private BorderPane createHeaderPane() {
+        dbIcon = hBox(0, true, imageView("data_connection", 48));
+        genIcon = hBox(0, true, imageView("text_tree", 48));
+
         titleLb = label("");
         titleLb.setId("banner");
 
-        BorderPane bp = borderPane(null, hBox(10, true, titleLb), null, null, hBox(0, true,
imageView("ignite", 48)));
+        subTitleLb = label("");
+
+        BorderPane bp = borderPane(null, vBox(5, titleLb, subTitleLb), null, dbIcon, hBox(0,
true, imageView("ignite", 48)));
         bp.setId("banner");
 
         return bp;
@@ -470,8 +489,10 @@ public class SchemaLoadApp extends Application {
             "This will discard all your changes."))
             return;
 
+        hdrPane.setLeft(dbIcon);
+
         titleLb.setText("Connect To Database");
-        titleLb.setGraphic(imageView("data_connection", 48));
+        subTitleLb.setText("Specify database connection properties...");
 
         rootPane.setCenter(connLayerPnl);
 
@@ -581,7 +602,8 @@ public class SchemaLoadApp extends Application {
 
         connPnl.wrap();
 
-        ComboBox<String> rdbmsCb = connPnl.addLabeled("DB Server type:", comboBox("tt",
RDBMS_NAMES), 2);
+        ComboBox<String> rdbmsCb = connPnl.addLabeled("DB Server preset:",
+            comboBox("Select database server to get predefined settings", RDBMS_NAMES), 2);
 
         jdbcDrvJarTf = connPnl.addLabeled("Driver JAR:", textField("Path to driver jar"));
 
@@ -776,16 +798,12 @@ public class SchemaLoadApp extends Application {
         openFolderCh = genPnl.add(checkBox("Reveal output folder",
             "Open output folder in system file manager after generation complete", true),
3);
 
-        genPnl.add(new Separator(), 3);
-
-        GridPaneEx regexPnl = paneEx(0, 0, 0, 0);
+        GridPaneEx regexPnl = paneEx(5, 5, 5, 5);
         regexPnl.addColumn();
         regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         regexPnl.addColumn();
         regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
 
-        regexPnl.add(label("Replace \"Key class name\", \"Value class name\" or  \"Java name\"
for selected tables:"), 4);
-
         regexTf = regexPnl.addLabeled("  Regexp:", textField("Regular expression. For example:
(\\w+)"));
 
         replaceTf = regexPnl.addLabeled("  Replace with:", textField("Replace text. For example:
$1_SomeText"));
@@ -826,11 +844,15 @@ public class SchemaLoadApp extends Application {
                         String replace = replaceTf.getText();
 
                         try {
-//                            fieldsTbl.getSelectionModel().getSelectedItems()
+                            switch (replaceCb.getSelectionModel().getSelectedIndex()) {
+                                case 0: renameKeyClassNames(regex, replace);
+                                    break;
+
+                                case 1: renameValueClassNames(regex, replace);
+                                    break;
 
-                            for (PojoDescriptor pojo : selItems)
-                                for (PojoField field : pojo.fields())
-                                    field.javaName(field.javaName().replaceAll(regex, replace));
+                                default: renameJavaNames(regex, replace);
+                            }
                         }
                         catch (Exception e) {
                             MessageBox.errorDialog(owner, "Failed to rename " + target +
"!", e);
@@ -859,8 +881,15 @@ public class SchemaLoadApp extends Application {
                         "Are you sure you want to revert " + target + " for all selected
" + src + "?"))
                         return;
 
-                    for (PojoDescriptor pojo : selItems)
-                        pojo.revertJavaNames();
+                    switch (replaceCb.getSelectionModel().getSelectedIndex()) {
+                        case 0: revertKeyClassNames();
+                            break;
+
+                        case 1: revertValueClassNames();
+                            break;
+
+                        default: revertJavaNames();
+                    }
                 }
             })
         ), 2).setPadding(new Insets(0, 0, 0, 10));
@@ -872,7 +901,7 @@ public class SchemaLoadApp extends Application {
                     curPojo = newItem;
 
                     fieldsTbl.setItems(curPojo.fields());
-                    fieldsTbl.getSelectionModel().clearAndSelect(0);
+                    fieldsTbl.getSelectionModel().clearSelection();
 
                     keyValPnl.setDisable(false);
                 }
@@ -885,12 +914,71 @@ public class SchemaLoadApp extends Application {
             }
         });
 
-        genPnl.add(regexPnl, 3);
+        genPnl.add(titledPane("Rename \"Key class name\", \"Value class name\" or  \"Java
name\" for selected tables",
+            regexPnl), 3);
 
         genLayerPnl = stackPane(genPnl);
     }
 
     /**
+     * Rename key class name for selected tables.
+     *
+     * @param regex Regex to search.
+     * @param replace Text for replacement.
+     */
+    private void renameKeyClassNames(String regex, String replace) {
+        for (PojoDescriptor pojo : pojosTbl.getSelectionModel().getSelectedItems())
+            pojo.keyClassName(pojo.keyClassName().replaceAll(regex, replace));
+    }
+
+    /**
+     * Rename value class name for selected tables.
+     *
+     * @param regex Regex to search.
+     * @param replace Text for replacement.
+     */
+    private void renameValueClassNames(String regex, String replace) {
+        for (PojoDescriptor pojo : pojosTbl.getSelectionModel().getSelectedItems())
+            pojo.valueClassName(pojo.valueClassName().replaceAll(regex, replace));
+    }
+
+    /**
+     * Rename fields java name for current or selected tables.
+     *
+     * @param regex Regex to search.
+     * @param replace Text for replacement.
+     */
+    private void renameJavaNames(String regex, String replace) {
+        for (PojoDescriptor pojo : pojosTbl.getSelectionModel().getSelectedItems())
+            for (PojoField field : pojo.fields())
+                field.javaName(field.javaName().replaceAll(regex, replace));
+    }
+
+    /**
+     * Revert key class name for selected tables to initial value.
+     */
+    private void revertKeyClassNames() {
+        for (PojoDescriptor pojo : pojosTbl.getSelectionModel().getSelectedItems())
+            pojo.revertKeyClassName();
+    }
+
+    /**
+     * Revert value class name for selected tables to initial value.
+     */
+    private void revertValueClassNames() {
+        for (PojoDescriptor pojo : pojosTbl.getSelectionModel().getSelectedItems())
+            pojo.revertValueClassName();
+    }
+
+    /**
+     * Revert fields java name for selected or current table to initial value.
+     */
+    private void revertJavaNames() {
+        for (PojoDescriptor pojo : pojosTbl.getSelectionModel().getSelectedItems())
+            pojo.revertJavaNames();
+    }
+
+    /**
      * @return Selected tree view items.
      */
     private Collection<PojoDescriptor> selectedItems() {
@@ -921,7 +1009,8 @@ public class SchemaLoadApp extends Application {
 
         createGeneratePane();
 
-        rootPane = borderPane(createHeaderPane(), createConnectionPane(), createButtonsPane(),
null, null);
+        hdrPane = createHeaderPane();
+        rootPane = borderPane(hdrPane, createConnectionPane(), createButtonsPane(), null,
null);
 
         primaryStage.setScene(scene(rootPane));
 
@@ -975,8 +1064,8 @@ public class SchemaLoadApp extends Application {
 
         xmlSingleFileCh.setSelected(userPrefs.getBoolean("xml.single", true));
 
-        regexTf.setText(userPrefs.get("naming.pattern", ""));
-        replaceTf.setText(userPrefs.get("naming.replace", ""));
+        regexTf.setText(userPrefs.get("naming.pattern", "(\\w+)"));
+        replaceTf.setText(userPrefs.get("naming.replace", "$1_SomeText"));
 
         primaryStage.show();
     }


Mime
View raw message