ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [17/22] incubator-ignite git commit: # IGNITE-517 Minor fix for Schema Import to support java 8.
Date Fri, 20 Mar 2015 12:07:52 GMT
# IGNITE-517 Minor fix for Schema Import to support java 8.


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

Branch: refs/heads/ignite-gg-9924
Commit: 1356a20627be5aa0405a8a04823e5ee0af47ba5a
Parents: 49027b7
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Fri Mar 20 16:01:00 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Fri Mar 20 16:01:00 2015 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/schema/ui/Controls.java   | 42 ++++++--------------
 .../ignite/schema/ui/SchemaImportApp.java       | 14 ++++++-
 2 files changed, 25 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1356a206/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
index e270edb..6c4d6bd 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
@@ -31,6 +31,7 @@ import javafx.scene.input.*;
 import javafx.scene.layout.*;
 import javafx.scene.text.*;
 import javafx.util.*;
+import javafx.util.converter.*;
 
 /**
  * Utility class to create controls.
@@ -541,10 +542,6 @@ public class Controls {
         /** */
         private final TextColumnValidator<S> validator;
         /** */
-        private boolean cancelling;
-        /** */
-        private boolean hardCancel;
-        /** */
         private String curTxt = "";
 
         /** Row value. */
@@ -566,6 +563,8 @@ public class Controls {
          * @param validator Input text validator.
          */
         private TextFieldTableCellEx(TextColumnValidator<S> validator) {
+            super(new DefaultStringConverter());
+
             this.validator = validator;
         }
 
@@ -580,15 +579,13 @@ public class Controls {
 
             rowVal = getTableView().getSelectionModel().getSelectedItem();
 
-            curTxt = "";
-
-            hardCancel = false;
-
             Node g = getGraphic();
 
             if (g != null) {
                 final TextField tf = (TextField)g;
 
+                curTxt = tf.getText();
+
                 tf.textProperty().addListener(new ChangeListener<String>() {
                     @Override public void changed(ObservableValue<? extends String>
val, String oldVal, String newVal) {
                         curTxt = newVal;
@@ -597,13 +594,8 @@ public class Controls {
 
                 tf.setOnKeyPressed(new EventHandler<KeyEvent>() {
                     @Override public void handle(KeyEvent evt) {
-                        if (KeyCode.ENTER == evt.getCode())
+                        if (KeyCode.ENTER == evt.getCode() || KeyCode.ESCAPE == evt.getCode())
                             cancelEdit();
-                        else if (KeyCode.ESCAPE == evt.getCode()) {
-                            hardCancel = true;
-
-                            cancelEdit();
-                        }
                     }
                 });
 
@@ -640,22 +632,12 @@ public class Controls {
 
         /** {@inheritDoc} */
         @Override public void cancelEdit() {
-            if (cancelling)
-                super.cancelEdit();
-            else
-                try {
-                    cancelling = true;
-
-                    if (hardCancel || curTxt.trim().isEmpty())
-                        super.cancelEdit();
-                    else if (validator.valid(rowVal, curTxt))
-                        commitEdit(curTxt);
-                    else
-                        super.cancelEdit();
-                }
-                finally {
-                    cancelling = false;
-                }
+            boolean editing = isEditing();
+
+            super.cancelEdit();
+
+            if (editing && validator.valid(rowVal, curTxt))
+                updateItem(curTxt, false);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1356a206/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
index bbd5f3f..22192cd 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -753,6 +753,12 @@ public class SchemaImportApp extends Application {
      * @return {@code true} if class name is valid.
      */
     private boolean checkClassName(PojoDescriptor pojo, String newVal, boolean key) {
+        if (newVal.trim().isEmpty()) {
+            MessageBox.warningDialog(owner, (key ? "Key" : "Value") + " class name must be
non empty!");
+
+            return false;
+        }
+
         if (key) {
             if (newVal.equals(pojo.valueClassName())) {
                 MessageBox.warningDialog(owner, "Key class name must be different from value
class name!");
@@ -800,7 +806,7 @@ public class SchemaImportApp extends Application {
         TableColumn<PojoDescriptor, String> valClsCol = textColumn("Value Class Name",
"valueClassName", "Value class name",
             new TextColumnValidator<PojoDescriptor>() {
                 @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
-                    boolean valid = checkClassName(rowVal, newVal, true);
+                    boolean valid = checkClassName(rowVal, newVal, false);
 
                     if (valid)
                         rowVal.valueClassName(newVal);
@@ -831,6 +837,12 @@ public class SchemaImportApp extends Application {
         TableColumn<PojoField, String> javaNameCol = textColumn("Java Name", "javaName",
"Field name in POJO class",
             new TextColumnValidator<PojoField>() {
                 @Override public boolean valid(PojoField rowVal, String newVal) {
+                    if (newVal.trim().isEmpty()) {
+                        MessageBox.warningDialog(owner, "Java name must be non empty!");
+
+                        return false;
+                    }
+
                     for (PojoField field : curPojo.fields())
                         if (rowVal != field && newVal.equals(field.javaName())) {
                             MessageBox.warningDialog(owner, "Java name must be unique!");


Mime
View raw message