cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject [07/50] cayenne-modeler git commit: Fixed bug where table selection listener wasn't being removed.
Date Thu, 05 Jan 2017 22:09:15 GMT
Fixed bug where table selection listener wasn't being removed.


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

Branch: refs/heads/master
Commit: 74f74a459b5447541e1614b1ae91b840703fb90d
Parents: 432e8bf
Author: mrg <blacknext@gmail.com>
Authored: Mon Sep 26 07:58:05 2016 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Mon Sep 26 07:58:05 2016 -0400

----------------------------------------------------------------------
 .../layout/ObjectEntityAttributesTabLayout.java | 66 +++++++++-----------
 1 file changed, 30 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/74f74a45/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
b/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
index 7a70a14..d96bd25 100644
--- a/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
+++ b/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory;
 
 import de.jensd.fx.glyphs.GlyphsDude;
 import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
+import javafx.beans.value.ChangeListener;
 import javafx.event.Event;
 import javafx.fxml.FXML;
 import javafx.scene.control.ComboBox;
@@ -169,13 +170,36 @@ public class ObjectEntityAttributesTabLayout
         this.objectEntityAdapter = objectEntityAdapter;
     }
 
-    private ObjectAttributeAdapter currentObjectAttributeAdapter;
+//    private void attributesTableViewSelectionListener(ObservableValue obs, ObjectAttributeAdapter
oldSelection, ObjectAttributeAdapter newSelection)
+//    private ChangeListener<? super ObjectAttributeAdapter> attributesTableViewSelectionListener;
+    private ChangeListener<ObjectAttributeAdapter> attributesTableViewSelectionListener
= (obs, oldSelection, newSelection) ->
+        {
+            final String[] javaTypes = ObjectEntityUtilities.getRegisteredTypeNames();
+
+            if (oldSelection != null)
+            {
+                javaAttributeNameTextField.textProperty().unbindBidirectional(oldSelection.nameProperty());
+                javaTypeComboBox.valueProperty().unbindBidirectional(oldSelection.javaTypeProperty());
+            }
+
+            javaTypeComboBox.getItems().clear();
+
+            if (newSelection != null)
+            {
+                javaTypeComboBox.getItems().addAll(javaTypes);
+
+                javaAttributeNameTextField.textProperty().bindBidirectional(newSelection.nameProperty());
+                javaTypeComboBox.valueProperty().bindBidirectional(newSelection.javaTypeProperty());
+                databaseTypeLabel.setText(newSelection.getDatabaseType());
+            }
+
+            javaAttributeNameTextField.setDisable(newSelection == null);
+            javaTypeComboBox.setDisable(newSelection == null);
+        };
 
     @Override
     public void beginEditing()
     {
-//        nameTextField.textProperty().bindBidirectional(objectEntityAdapter.getNameProperty());
-
         javaAttributeNameTextField.setDisable(true);
         javaAttributeNameTextField.setText(null);
         javaTypeComboBox.setDisable(true);
@@ -184,50 +208,20 @@ public class ObjectEntityAttributesTabLayout
         databaseTypeLabel.setText("N/A");
         attributesTableView.setItems(objectEntityAdapter.getAttributes());
 
-        attributesTableView.getSelectionModel().selectedItemProperty().addListener((obs,
oldSelection, newSelection) ->
-            {
-                final String[] javaTypes = ObjectEntityUtilities.getRegisteredTypeNames();
-
-                currentObjectAttributeAdapter = newSelection;
-
-                if (oldSelection != null)
-                {
-                    javaAttributeNameTextField.textProperty().unbindBidirectional(oldSelection.nameProperty());
-                    javaTypeComboBox.valueProperty().unbindBidirectional(oldSelection.javaTypeProperty());
-
-//                    javaTypeComboBox.textProperty().unbindBidirectional(oldSelection.javaTypeProperty());
-                }
-
-                javaTypeComboBox.getItems().clear();
-
-                if (newSelection != null)
-                {
-                    javaTypeComboBox.getItems().addAll(javaTypes);
-
-                    javaAttributeNameTextField.textProperty().bindBidirectional(newSelection.nameProperty());
-                    javaTypeComboBox.valueProperty().bindBidirectional(newSelection.javaTypeProperty());
-//                    javaTypeComboBox.textProperty().bindBidirectional(oldSelection.javaTypeProperty());
-                    databaseTypeLabel.setText(newSelection.getDatabaseType());
-                }
-
-                javaAttributeNameTextField.setDisable(newSelection == null);
-                javaTypeComboBox.setDisable(newSelection == null);
-            });
+        attributesTableView.getSelectionModel().selectedItemProperty().addListener(attributesTableViewSelectionListener);
     }
 
     @Override
     public void endEditing()
     {
-//        nameTextField.textProperty().unbindBidirectional(objectEntityAdapter.getNameProperty());
+        ObjectAttributeAdapter currentObjectAttributeAdapter = attributesTableView.getSelectionModel().getSelectedItem();
 
         if (currentObjectAttributeAdapter != null)
         {
             javaAttributeNameTextField.textProperty().unbindBidirectional(currentObjectAttributeAdapter.nameProperty());
             javaTypeComboBox.valueProperty().unbindBidirectional(currentObjectAttributeAdapter.javaTypeProperty());
-
-            currentObjectAttributeAdapter = null;
         }
 
-//        attributesTableView.setItems(null);
+        attributesTableView.getSelectionModel().selectedItemProperty().removeListener(attributesTableViewSelectionListener);
     }
 }


Mime
View raw message