ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # IGNITE-32 WIP: Fixed UI after QA.
Date Mon, 19 Jan 2015 03:39:20 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 79f3a5f79 -> 4f5523b11


# IGNITE-32 WIP: Fixed UI after QA.


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

Branch: refs/heads/ignite-32
Commit: 4f5523b1170910d5e0a31c3149f50cc6fb122569
Parents: 79f3a5f
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Jan 19 10:39:50 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Jan 19 10:39:50 2015 +0700

----------------------------------------------------------------------
 .../ignite/schema/pojo/PojoCodeGenerator.java   | 12 ++++-
 .../ignite/schema/ui/ConfirmCallable.java       | 21 ++++----
 .../org/apache/ignite/schema/ui/MessageBox.java | 21 ++++++--
 .../apache/ignite/schema/ui/PojoDescriptor.java |  5 +-
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 50 ++++++++++++++++++--
 .../ignite/schema/xml/XmlTransformer.java       | 13 ++++-
 .../auto/AbstractAutoCacheStoreSelfTest.java    |  2 +-
 .../gridgain/grid/cache/store/auto/package.html |  4 +-
 8 files changed, 99 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/modules/schema-load/src/main/java/org/apache/ignite/schema/pojo/PojoCodeGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/pojo/PojoCodeGenerator.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/pojo/PojoCodeGenerator.java
index 0a2754a..7908406 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/pojo/PojoCodeGenerator.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/pojo/PojoCodeGenerator.java
@@ -23,6 +23,7 @@ import org.gridgain.grid.cache.query.*;
 import java.io.*;
 import java.util.*;
 
+import static org.apache.ignite.schema.ui.MessageBox.Result.*;
 import static org.apache.ignite.schema.util.SchemaUtils.*;
 
 /**
@@ -90,8 +91,15 @@ public class PojoCodeGenerator {
         File pkgFolder, boolean constructor, ConfirmCallable askOverwrite) throws IOException
{
         File out = new File(pkgFolder, type + ".java");
 
-        if (out.exists() && !askOverwrite.confirm(out.getName()))
-            return;
+        if (out.exists()) {
+            MessageBox.Result choice = askOverwrite.confirm(out.getName());
+
+            if (CANCEL == choice)
+                throw new IllegalStateException("POJO generation was canceled!");
+
+            if (NO == choice || NO_TO_ALL == choice)
+                return;
+        }
 
         Collection<String> src = new ArrayList<>(256);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
index d00ac3f..3990496 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
@@ -27,7 +27,7 @@ import static org.apache.ignite.schema.ui.MessageBox.Result.*;
 /**
  * Callable to ask user for confirmation from non EDT thread.
  */
-public class ConfirmCallable implements Callable<Boolean> {
+public class ConfirmCallable implements Callable<MessageBox.Result> {
     /** Owner window. */
     private final Stage owner;
 
@@ -50,27 +50,24 @@ public class ConfirmCallable implements Callable<Boolean> {
     }
 
     /** {@inheritDoc} */
-    @Override public Boolean call() throws Exception {
+    @Override public MessageBox.Result call() throws Exception {
         choice = MessageBox.confirmRememberChoiceDialog(owner, String.format(template, msg));
 
-        return choice == YES || choice == YES_TO_ALL;
+        return choice;
     }
 
     /**
      * Execute confirmation in EDT thread.
      *
-     * @return {@code true} If user confirm.
+     * @return Confirm result.
      */
-    public boolean confirm(String msg) {
+    public MessageBox.Result confirm(String msg) {
         this.msg = msg;
 
-        if (choice == YES_TO_ALL)
-            return true;
+        if (choice == YES_TO_ALL || choice == NO_TO_ALL)
+            return choice;
 
-        if (choice == NO_TO_ALL)
-            return false;
-
-        FutureTask<Boolean> fut = new FutureTask<>(this);
+        FutureTask<MessageBox.Result> fut = new FutureTask<>(this);
 
         Platform.runLater(fut);
 
@@ -78,7 +75,7 @@ public class ConfirmCallable implements Callable<Boolean> {
             return fut.get();
         }
         catch (Exception ignored) {
-            return false;
+            return NO;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/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
index 337d72f..902bd91 100644
--- 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
@@ -38,7 +38,9 @@ public class MessageBox extends ModalDialog {
         /** Error. */
         ERROR,
         /** Confirm. */
-        CONFIRM
+        CONFIRM,
+        /** Confirm with cancel option. */
+        CANCELLABLE_CONFIRM
     }
 
     /** Message box type. */
@@ -84,6 +86,7 @@ public class MessageBox extends ModalDialog {
                 break;
 
             case CONFIRM:
+            case CANCELLABLE_CONFIRM:
                 title = "Confirmation";
                 iconFile = "question";
                 break;
@@ -118,7 +121,7 @@ public class MessageBox extends ModalDialog {
         HBox btns = hBox(10, true);
         btns.setAlignment(Pos.CENTER);
 
-        if (type == MessageType.CONFIRM) {
+        if (MessageType.CONFIRM == type || MessageType.CANCELLABLE_CONFIRM == type) {
             res = Result.NO;
 
             btns.getChildren().addAll(
@@ -142,6 +145,16 @@ public class MessageBox extends ModalDialog {
                             close();
                     }
                 }));
+
+            if (MessageType.CANCELLABLE_CONFIRM == type)
+                btns.getChildren().addAll(
+                    button("Cancel", "Cancel the request", new EventHandler<ActionEvent>()
{
+                        @Override public void handle(ActionEvent e) {
+                            res = Result.CANCEL;
+
+                            close();
+                        }
+                    }));
         }
         else
             btns.getChildren().add(button("OK", "Close dialog", new EventHandler<ActionEvent>()
{
@@ -177,7 +190,7 @@ public class MessageBox extends ModalDialog {
      * @return {@code true} If user confirm.
      */
     public static boolean confirmDialog(Stage owner, String msg) {
-        return showDialog(owner, MessageType.CONFIRM, msg, true) == Result.YES;
+        return showDialog(owner, MessageType.CONFIRM, msg, false) == Result.YES;
     }
 
     /**
@@ -188,7 +201,7 @@ public class MessageBox extends ModalDialog {
      * @return User confirmation result.
      */
     public static Result confirmRememberChoiceDialog(Stage owner, String msg) {
-        return showDialog(owner, MessageType.CONFIRM, msg, true);
+        return showDialog(owner, MessageType.CANCELLABLE_CONFIRM, msg, true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/PojoDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/PojoDescriptor.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/PojoDescriptor.java
index c8c9c7f..76c29d4 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/PojoDescriptor.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/PojoDescriptor.java
@@ -130,7 +130,7 @@ public class PojoDescriptor {
      * @param name Name for value class.
      */
     public void valueClassName(String name) {
-        meta.setKeyType(name);
+        meta.setType(name);
     }
 
     /**
@@ -140,6 +140,9 @@ public class PojoDescriptor {
         return fields;
     }
 
+    /**
+     * @return Type metadata.
+     */
     public GridCacheQueryTypeMetadata metadata() {
         return meta;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/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 9f1848a..997afea 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
@@ -286,6 +286,14 @@ public class SchemaLoadApp extends Application {
      * Generate XML and POJOs.
      */
     private void generate() {
+        Collection<PojoDescriptor> selItems = selectedItems();
+
+        if (selItems.isEmpty()) {
+            MessageBox.warningDialog(owner, "Please select tables to generate POJOs and XML
files!");
+
+            return;
+        }
+
         lockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
 
         final String outFolder = outFolderTf.getText();
@@ -896,14 +904,23 @@ public class SchemaLoadApp extends Application {
 
         regexPnl.add(buttonsPane(Pos.BOTTOM_RIGHT, false,
             renBtn,
-            button("Rename All", "Replace Ignite names by provided regular expression for
all tables",
+            button("Rename All", "Replace Ignite names by provided regular expression for
all selected tables",
                 new EventHandler<ActionEvent>() {
                     /** {@inheritDoc} */
                     @Override public void handle(ActionEvent evt) {
                         if (checkInput(regexTf, false, "Regular expression should not be
empty!"))
                             return;
 
-                        if (!MessageBox.confirmDialog(owner, "Are you sure you want to rename
Ignite names in all tables?"))
+                        Collection<PojoDescriptor> selItems = selectedItems();
+
+                        if (selItems.isEmpty()) {
+                            MessageBox.warningDialog(owner, "Please select tables to rename
Ignite names!");
+
+                            return;
+                        }
+
+                        if (!MessageBox.confirmDialog(owner,
+                            "Are you sure you want to rename Ignite names in all selected
tables?"))
                             return;
 
                         String regex = regexTf.getText();
@@ -911,7 +928,7 @@ public class SchemaLoadApp extends Application {
                         String replace = replaceTf.getText();
 
                         try {
-                            for (PojoDescriptor pojo : pojos)
+                            for (PojoDescriptor pojo : selItems)
                                 for (PojoField field : pojo.fields())
                                     field.javaName(field.javaName().replaceAll(regex, replace));
                         }
@@ -924,10 +941,19 @@ public class SchemaLoadApp extends Application {
             button("Revert All", "Revert changes to Ignite names for all tables", new EventHandler<ActionEvent>()
{
                 /** {@inheritDoc} */
                 @Override public void handle(ActionEvent evt) {
-                    if (!MessageBox.confirmDialog(owner, "Are you sure you want to revert
Ignite names for all tables?"))
+                    Collection<PojoDescriptor> selItems = selectedItems();
+
+                    if (selItems.isEmpty()) {
+                        MessageBox.warningDialog(owner, "Please select tables to revert Ignite
names!");
+
                         return;
+                    }
 
-                    for (PojoDescriptor pojo : pojos)
+                    if (!MessageBox.confirmDialog(owner,
+                        "Are you sure you want to revert Ignite names for all selected tables?"))
+                        return;
+
+                    for (PojoDescriptor pojo : selItems)
                         pojo.revertJavaNames();
                 }
             })
@@ -973,6 +999,20 @@ public class SchemaLoadApp extends Application {
         genLayerPnl = stackPane(genPnl);
     }
 
+    /**
+     * @return Selected tree view items.
+     */
+    private Collection<PojoDescriptor> selectedItems() {
+        Collection<PojoDescriptor> res = new ArrayList<>();
+
+        for (TreeItem<String> schemeItem : rootItem.getChildren())
+            for (TreeItem<String> tblItem : schemeItem.getChildren())
+                if (((CheckBoxTreeItem)tblItem).isSelected())
+                    res.add(schemas.get(schemeItem.getValue()).get(tblItem.getValue()));
+
+        return res;
+    }
+
     /** {@inheritDoc} */
     @Override public void start(Stage primaryStage) {
         owner = primaryStage;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
index 3171521..ea40150 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/xml/XmlTransformer.java
@@ -30,6 +30,8 @@ import javax.xml.transform.stream.*;
 import java.io.*;
 import java.util.*;
 
+import static org.apache.ignite.schema.ui.MessageBox.Result.*;
+
 /**
  * Transformer that will take cache query metadata and transform it to XML and write to file.
  */
@@ -272,8 +274,15 @@ public class XmlTransformer {
     public static void transform(String pkg, Collection<GridCacheQueryTypeMetadata>
meta, File out,
         ConfirmCallable askOverwrite) {
         try {
-            if (out.exists() && !askOverwrite.confirm(out.getName()))
-                return;
+            if (out.exists()) {
+                MessageBox.Result choice = askOverwrite.confirm(out.getName());
+
+                if (CANCEL == choice)
+                    throw new IllegalStateException("XML generation was canceled!");
+
+                if (NO == choice || NO_TO_ALL == choice)
+                    return;
+            }
 
             DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java
b/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java
index 842659f..8fcb67f 100644
--- a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java
+++ b/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/AbstractAutoCacheStoreSelfTest.java
@@ -71,7 +71,7 @@ abstract class AbstractAutoCacheStoreSelfTest extends GridCommonAbstractTest
{
     public void testLoadCache() throws Exception {
         final T2<Integer, Integer> keys = new T2<>(0, 0);
 
-        IgniteBiInClosure<Object,Object> c = new CI2<Object, Object>() {
+        IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() {
             @Override public void apply(Object k, Object v) {
                 if (k instanceof OrganizationKey && v instanceof Organization)
                     keys.set1(keys.get1() + 1);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f5523b1/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/package.html
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/package.html
b/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/package.html
index 6556981..d7a7863 100644
--- a/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/package.html
+++ b/modules/schema-load/src/test/java/org/gridgain/grid/cache/store/auto/package.html
@@ -18,7 +18,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <body>
-    <!-- Package description. -->
-    Contains internal tests or test related classes and interfaces.
+<!-- Package description. -->
+Contains internal tests or test related classes and interfaces.
 </body>
 </html>


Mime
View raw message