cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject [6/7] cayenne-modeler git commit: Updated interface to try and use more generic bind/unbind mechanism.
Date Sat, 03 Jun 2017 11:36:44 GMT
Updated interface to try and use more generic bind/unbind mechanism.


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

Branch: refs/heads/master
Commit: 4861004e86f324963e73346da761cd5bdf9b982f
Parents: 74696f3
Author: mrg <blacknext@gmail.com>
Authored: Sat Jun 3 07:35:59 2017 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Sat Jun 3 07:35:59 2017 -0400

----------------------------------------------------------------------
 .../modeler/layout/DetailEditorSupport.java     | 40 +++++++++++++++++++-
 1 file changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/4861004e/src/main/java/org/apache/cayenne/modeler/layout/DetailEditorSupport.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/layout/DetailEditorSupport.java b/src/main/java/org/apache/cayenne/modeler/layout/DetailEditorSupport.java
index 133f57b..5073f86 100644
--- a/src/main/java/org/apache/cayenne/modeler/layout/DetailEditorSupport.java
+++ b/src/main/java/org/apache/cayenne/modeler/layout/DetailEditorSupport.java
@@ -19,11 +19,47 @@
 
 package org.apache.cayenne.modeler.layout;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.cayenne.modeler.adapters.CayennePropertyAdapter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public interface DetailEditorSupport<T extends CayennePropertyAdapter>
 {
+    static final Log LOGGER = LogFactory.getLog(DetailEditorSupport.class);
+
+    default void showLayout(final T propertyAdapter)
+    {
+        setPropertyAdapter(propertyAdapter);
+        initializeBindings();
+        beginEditing();
+    }
+
+    default void initializeBindings()
+    {
+        // Implementors should override.
+    }
+
+    default List<Binding<?>> getBindings()
+    {
+        return new ArrayList<>();
+    }
+
     void setPropertyAdapter(final T propertyAdapter);
-    void beginEditing();
-    void endEditing();
+
+    default void beginEditing()
+    {
+        LOGGER.debug("begin editing " + this);
+
+        getBindings().stream().forEach(binding -> binding.bind());
+    }
+
+    default void endEditing()
+    {
+        LOGGER.debug("end editing " + this);
+
+        getBindings().stream().forEach(binding -> binding.unbind());
+    }
 }


Mime
View raw message