ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/3] incubator-ignite git commit: # IGNITE-32 WIP: Implemented table fields reordering. Added option to reveal output folder in system file manager. Minor UI tweaks.
Date Thu, 08 Jan 2015 16:31:41 GMT
# IGNITE-32 WIP: Implemented table fields reordering. Added option to reveal output folder
in system file manager. Minor UI tweaks.


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

Branch: refs/heads/ignite-32
Commit: 8103d876170027cd5fa38e5ff6a241580f9e1465
Parents: d4ba030
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Jan 8 23:29:20 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Jan 8 23:29:20 2015 +0700

----------------------------------------------------------------------
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 94 +++++++++++++-------
 1 file changed, 61 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8103d876/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 5ae7e8e..52ac1cb 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
@@ -9,9 +9,12 @@ import javafx.concurrent.*;
 import javafx.event.*;
 import javafx.geometry.*;
 import javafx.scene.*;
+import javafx.scene.control.Button;
 import javafx.scene.control.*;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
 import javafx.scene.control.cell.*;
-import javafx.scene.image.*;
+import javafx.scene.image.Image;
 import javafx.scene.layout.*;
 import javafx.stage.*;
 import javafx.util.*;
@@ -21,11 +24,12 @@ import org.apache.ignite.schema.xml.*;
 import org.gridgain.grid.cache.query.*;
 import org.gridgain.grid.util.typedef.internal.*;
 
-import java.awt.Toolkit;
+import java.awt.*;
 import java.io.*;
 import java.net.*;
 import java.sql.*;
 import java.util.*;
+import java.util.List;
 import java.util.concurrent.*;
 import java.util.prefs.*;
 
@@ -97,6 +101,9 @@ public class SchemaLoadApp extends Application {
     private CheckBox dfltNamingCh;
 
     /** */
+    private CheckBox openFolderCh;
+
+    /** */
     private Button btnNaming;
 
     /** */
@@ -112,7 +119,10 @@ public class SchemaLoadApp extends Application {
     private LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
metas;
 
     /** Map with fields descriptors. */
-    private Map<String, Map<String, Collection<Field>>> fields;
+    private Map<String, Map<String, List<Field>>> fields;
+
+    /** Fields collection of currently selected table. */
+    private List<Field> curFields;
 
     /** */
     private final ObservableList<Field> noData = FXCollections.emptyObservableList();
@@ -197,7 +207,7 @@ public class SchemaLoadApp extends Application {
 
                     LinkedHashMap<String, GridCacheQueryTypeMetadata> tbls = meta.getValue();
 
-                    Map<String, Collection<Field>> tblsFields = U.newHashMap(tbls.size());
+                    Map<String, List<Field>> tblsFields = U.newHashMap(tbls.size());
 
                     fields.put(schema, tblsFields);
 
@@ -208,7 +218,7 @@ public class SchemaLoadApp extends Application {
 
                         Collection<GridCacheQueryTypeDescriptor> vals = type.getValueDescriptors();
 
-                        Collection<Field> tblFields = new ArrayList<>(keys.size()
+ vals.size());
+                        List<Field> tblFields = new ArrayList<>(keys.size() +
vals.size());
 
                         tblsFields.put(type.getTableName(), tblFields);
 
@@ -231,7 +241,7 @@ public class SchemaLoadApp extends Application {
 
                 rootItem.getChildren().clear();
 
-                for (Map.Entry<String, Map<String, Collection<Field>>>
schema : fields.entrySet()) {
+                for (Map.Entry<String, Map<String, List<Field>>> schema
: fields.entrySet()) {
                     CheckBoxTreeItem<String> schemaItem = new CheckBoxTreeItem<>(schema.getKey());
 
                     for(String tbl : schema.getValue().keySet())
@@ -277,6 +287,12 @@ public class SchemaLoadApp extends Application {
     private void generate() {
         lockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
 
+        final String outFolder = outFolderTf.getText();
+
+        final String pkg = pkgTf.getText();
+
+        final File destFolder = new File(outFolder);
+
         Task<Void> task = new Task<Void>() {
             private void checkEmpty(Collection<GridCacheQueryTypeDescriptor> items,
                 final TreeItem<String> treeItem, String msg) {
@@ -296,11 +312,6 @@ public class SchemaLoadApp extends Application {
             @Override protected Void call() throws Exception {
                 long started = System.currentTimeMillis();
 
-                String outFolder = outFolderTf.getText();
-                String pkg = pkgTf.getText();
-
-                File destFolder = new File(outFolder);
-
                 if (!destFolder.exists() && !destFolder.mkdirs())
                     throw new IOException("Failed to create output folder: " + destFolder);
 
@@ -375,6 +386,14 @@ public class SchemaLoadApp extends Application {
                 unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
 
                 MessageBox.informationDialog(owner, "Generation complete!");
+
+                if (openFolderCh.isSelected())
+                    try {
+                        Desktop.getDesktop().open(destFolder);
+                    }
+                    catch (IOException e) {
+                        MessageBox.errorDialog(owner, "Failed to open folder with results.",
e);
+                    }
             }
 
             /** {@inheritDoc} */
@@ -584,7 +603,7 @@ public class SchemaLoadApp extends Application {
         tbl.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
         tbl.setEditable(true);
 
-        final Button upBtn = button(imageView("navigate_up", 24), "Move selected column up",
+        final Button upBtn = button(imageView("navigate_up", 24), "Move selected row up",
             new EventHandler<ActionEvent>() {
                 @Override public void handle(ActionEvent evt) {
                     TableView.TableViewSelectionModel<Field> selMdl = tbl.getSelectionModel();
@@ -595,6 +614,7 @@ public class SchemaLoadApp extends Application {
                         ObservableList<Field> items = tbl.getItems();
 
                         items.add(selIdx - 1, items.remove(selIdx));
+                        curFields.add(selIdx - 1, curFields.remove(selIdx));
 
                         selMdl.select(selIdx - 1);
                     }
@@ -603,7 +623,7 @@ public class SchemaLoadApp extends Application {
 
         upBtn.setDisable(true);
 
-        final Button downBtn = button(imageView("navigate_down", 24), "Move selected column
down",
+        final Button downBtn = button(imageView("navigate_down", 24), "Move selected row
down",
             new EventHandler<ActionEvent>() {
                 @Override public void handle(ActionEvent evt) {
                     TableView.TableViewSelectionModel<Field> selMdl = tbl.getSelectionModel();
@@ -614,6 +634,7 @@ public class SchemaLoadApp extends Application {
 
                     if (selIdx < items.size() - 1) {
                         items.add(selIdx + 1, items.remove(selIdx));
+                        curFields.add(selIdx + 1, curFields.remove(selIdx));
 
                         selMdl.select(selIdx + 1);
                     }
@@ -630,26 +651,24 @@ public class SchemaLoadApp extends Application {
         });
 
         rootItem = new CheckBoxTreeItem<>("Database");
-        rootItem.setExpanded(true);
 
         tree = new TreeView<>(rootItem);
 
         tree.setShowRoot(false);
-
         tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
-
         tree.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>()
{
             /** {@inheritDoc} */
             @Override public void changed(ObservableValue<? extends TreeItem<String>>
val, TreeItem<String> oldItem,
                 TreeItem<String> newItem) {
                 if (newItem != null && newItem.getParent() != null && newItem.isLeaf())
{
-                    tbl.setItems(FXCollections.observableArrayList(
-                        fields.get(newItem.getParent().getValue()).get(newItem.getValue())));
+                    curFields = fields.get(newItem.getParent().getValue()).get(newItem.getValue());
 
+                    tbl.setItems(FXCollections.observableArrayList(curFields));
                     tbl.getSelectionModel().select(0);
                 }
                 else {
                     tbl.setItems(noData);
+
                     upBtn.setDisable(true);
                     downBtn.setDisable(true);
                 }
@@ -707,6 +726,9 @@ public class SchemaLoadApp extends Application {
 
         genPnl.add(hBox(10, false, dfltNamingCh, btnNaming), 3);
 
+        openFolderCh = genPnl.add(checkBox("Reveal output folder",
+            "Open output folder in system file manager after generation complete", true));
+
         genLayerPnl = stackPane(genPnl);
     }
 
@@ -746,22 +768,26 @@ public class SchemaLoadApp extends Application {
         Preferences userPrefs = Preferences.userNodeForPackage(getClass());
 
         // Restore window pos and size.
-        double x = userPrefs.getDouble("window.x", 100);
-        double y = userPrefs.getDouble("window.y", 100);
-        double w = userPrefs.getDouble("window.width", 500);
-        double h = userPrefs.getDouble("window.height", 600);
-
-        // Ensure that window fit any available screen.
-        if (!Screen.getScreensForRectangle(x, y, w, h).isEmpty()) {
-            if (x > 0)
-                primaryStage.setX(x);
-
-            if (y > 0)
-                primaryStage.setY(y);
-
-            primaryStage.setWidth(w);
-            primaryStage.setHeight(h);
+        if (userPrefs.get("window.x", null) != null) {
+            double x = userPrefs.getDouble("window.x", 100);
+            double y = userPrefs.getDouble("window.y", 100);
+            double w = userPrefs.getDouble("window.width", 500);
+            double h = userPrefs.getDouble("window.height", 600);
+
+            // Ensure that window fit any available screen.
+            if (!Screen.getScreensForRectangle(x, y, w, h).isEmpty()) {
+                if (x > 0)
+                    primaryStage.setX(x);
+
+                if (y > 0)
+                    primaryStage.setY(y);
+
+                primaryStage.setWidth(w);
+                primaryStage.setHeight(h);
+            }
         }
+        else
+            primaryStage.centerOnScreen();
 
         String userHome = System.getProperty("user.home").replace('\\', '/');
 
@@ -773,6 +799,7 @@ public class SchemaLoadApp extends Application {
 
         // Restore generation pane settings.
         outFolderTf.setText(userPrefs.get("out.folder", userHome + "/schema-load/out"));
+        openFolderCh.setSelected(userPrefs.getBoolean("out.folder.open", true));
         pkgTf.setText(userPrefs.get("pojo.package", "org.apache.ignite"));
         pojoIncludeKeysCh.setSelected(userPrefs.getBoolean("pojo.include", true));
         pojoConstructorCh.setSelected(userPrefs.getBoolean("pojo.constructor", false));
@@ -801,6 +828,7 @@ public class SchemaLoadApp extends Application {
 
         // Save generation pane settings.
         userPrefs.put("out.folder", outFolderTf.getText());
+        userPrefs.putBoolean("out.folder.open", openFolderCh.isSelected());
         userPrefs.put("pojo.package", pkgTf.getText());
         userPrefs.putBoolean("pojo.include", pojoIncludeKeysCh.isSelected());
         userPrefs.putBoolean("pojo.constructor", pojoConstructorCh.isSelected());


Mime
View raw message