cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject [38/50] cayenne-modeler git commit: Added window closing stub.
Date Thu, 05 Jan 2017 22:09:46 GMT
Added window closing stub.


Project: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/commit/ceebf01d
Tree: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/tree/ceebf01d
Diff: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/diff/ceebf01d

Branch: refs/heads/master
Commit: ceebf01da83535d667845f2b4c638c34e46a421d
Parents: 8db0ac3
Author: mrg <blacknext@gmail.com>
Authored: Sun Oct 9 13:37:40 2016 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Sun Oct 9 13:37:40 2016 -0400

----------------------------------------------------------------------
 .../modeler/layout/DataDomainLayout.java        |  6 +-
 .../modeler/layout/MainWindowLayout.java        | 77 +++++++++++---------
 2 files changed, 44 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/ceebf01d/src/main/java/org/apache/cayenne/modeler/layout/DataDomainLayout.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/layout/DataDomainLayout.java b/src/main/java/org/apache/cayenne/modeler/layout/DataDomainLayout.java
index 6a2f28c..1eed531 100644
--- a/src/main/java/org/apache/cayenne/modeler/layout/DataDomainLayout.java
+++ b/src/main/java/org/apache/cayenne/modeler/layout/DataDomainLayout.java
@@ -83,9 +83,9 @@ public class DataDomainLayout
         objectCacheSizeSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0,
Integer.MAX_VALUE, DataRowStore.SNAPSHOT_CACHE_SIZE_DEFAULT, 100));
 
         useSharedCacheCheckBox.selectedProperty().addListener((obs, oldValue, newValue) ->
-        {
-            configureRemoteNotifications(newValue);
-        });
+            {
+                configureRemoteNotifications(newValue);
+            });
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/ceebf01d/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java b/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
index 99d38dd..1ba4613 100644
--- a/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
+++ b/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
@@ -82,6 +82,15 @@ public class MainWindowLayout
         super(new Stage(), "/layouts/MainWindowLayout.fxml");
 
         setMinimumWindowSize(900, 700);
+
+        getStage().setOnCloseRequest(event ->
+            {
+                LOGGER.debug("Window is closing!");
+                // ideas for checking if window should save before closing or cancel, etc:
+                // event.consume();  <- Prevents window from closing
+                // http://stackoverflow.com/questions/31540500/alert-box-for-when-user-attempts-to-close-application-using-setoncloserequest-in
+                // http://stackoverflow.com/questions/23160573/javafx-stage-setoncloserequest-without-function
+            });
     }
 
     @Override
@@ -137,37 +146,33 @@ public class MainWindowLayout
         // System.out.println(CayenneModelManager.getModels().size());
 
         treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue,
newValue) ->
-        {
-            LOGGER.debug("observable: " + observable + ", new: " + newValue + ", old: " +
oldValue);
-
-            try
             {
-                if (oldValue != null)
-                {
-                    final DetailEditorSupport<?> detailEditor = getDetailEditor(oldValue);
-
-                    if (detailEditor != null)
-                        detailEditor.endEditing();
-                }
+                LOGGER.debug("observable: " + observable + ", new: " + newValue + ", old:
" + oldValue);
 
-                if (newValue != null)
+                try
                 {
-                    observable.getValue().getParent();
-//                    System.out.println("observable: " + observable.getValue() + ", new:
" + newValue.getValue() + ", old: " + oldValue.getValue());
-
-//                    LOGGER.debug(observable.getValue().getValue().getClass());
-//                    LOGGER.debug(newValue.getValue().getClass());
-
-                    if (newValue instanceof DataDomainTreeItem)
-                        displayDataDomain((DataDomainTreeItem) newValue);
-                    else if (newValue instanceof DataMapTreeItem)
-                        displayDataMap((DataMapTreeItem) newValue);
-                    else if (newValue instanceof ObjectEntityTreeItem)
-                        displayObjectEntity((ObjectEntityTreeItem) newValue);
-                    else if (newValue instanceof DatabaseEntityTreeItem)
-                        displayDatabaseEntity((DatabaseEntityTreeItem) newValue);
-                    else if (newValue instanceof DataNodeTreeItem)
-                        displayDataNode((DataNodeTreeItem) newValue);
+                    if (oldValue != null)
+                    {
+                        final DetailEditorSupport<?> detailEditor = getDetailEditor(oldValue);
+
+                        if (detailEditor != null)
+                            detailEditor.endEditing();
+                    }
+
+                    if (newValue != null)
+                    {
+                        observable.getValue().getParent();
+
+                        if (newValue instanceof DataDomainTreeItem)
+                            displayDataDomain((DataDomainTreeItem) newValue);
+                        else if (newValue instanceof DataMapTreeItem)
+                            displayDataMap((DataMapTreeItem) newValue);
+                        else if (newValue instanceof ObjectEntityTreeItem)
+                            displayObjectEntity((ObjectEntityTreeItem) newValue);
+                        else if (newValue instanceof DatabaseEntityTreeItem)
+                            displayDatabaseEntity((DatabaseEntityTreeItem) newValue);
+                        else if (newValue instanceof DataNodeTreeItem)
+                            displayDataNode((DataNodeTreeItem) newValue);
 //                    if (newValue.getValue() instanceof DataDomainTreeViewModel)
 //                        displayDataDomain((DataDomainTreeViewModel) newValue.getValue());
 //                    else if (newValue.getValue() instanceof DataMapTreeViewModel)
@@ -179,17 +184,17 @@ public class MainWindowLayout
 //                        displayObjectEntity((ObjectEntityTreeViewModel) newValue.getValue());
 //                    else if (newValue.getValue() instanceof DatabaseEntityTreeViewModel)
 //                        displayDatabaseEntity((DatabaseEntityTreeViewModel) newValue.getValue());
+                    }
+                    else
+                    {
+                        treeView.getSelectionModel().select(0);
+                    }
                 }
-                else
+                catch (IOException e)
                 {
-                    treeView.getSelectionModel().select(0);
+                    LOGGER.fatal("Cannot load UI.");
                 }
-            }
-            catch (IOException e)
-            {
-                LOGGER.fatal("Cannot load UI.");
-            }
-        });
+            });
 
         setTitle();
 //        displayDataDomain(domain);


Mime
View raw message