cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject [2/2] cayenne git commit: CAY-2047 | Relationship mapping with target inheritance
Date Wed, 20 Jan 2016 10:35:19 GMT
CAY-2047 | Relationship mapping with target inheritance


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

Branch: refs/heads/STABLE-3.1
Commit: a9ca65abebf25a72d8574123617c3cfdb1859e1d
Parents: 172a48c
Author: Savva Kolbachev <s.kolbachev@gmail.com>
Authored: Wed Jan 20 13:30:17 2016 +0300
Committer: Savva Kolbachev <s.kolbachev@gmail.com>
Committed: Wed Jan 20 13:30:17 2016 +0300

----------------------------------------------------------------------
 docs/doc/src/main/resources/RELEASE-NOTES.txt   |  1 +
 .../dialog/objentity/ObjRelationshipInfo.java   | 24 ++++++++++++++------
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/a9ca65ab/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index b6d43c7..3c8ef6a 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -21,6 +21,7 @@ CAY-1964 Fix convertAdditionalDataMaps() in CayenneGeneratorMojo.java
 CAY-1973 error while generating classes
 CAY-1978 ESCAPE clause should be included in LIKE parenthesis
 CAY-1979 Prefetches on Many-to-Many Relationships with Longvarchar
+CAY-2047 Relationship mapping with target inheritance
 CAY-2049 Changing the Relationship name in ObjRelationship Inspector has no effect
 
 ----------------------------------

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a9ca65ab/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
index d60962f..2d6b54a 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
@@ -48,6 +48,8 @@ import javax.swing.tree.TreePath;
 import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -93,10 +95,8 @@ public class ObjRelationshipInfo extends CayenneController implements
         super(mediator);
         this.view = new ObjRelationshipInfoView(mediator);
         this.mediator=mediator;
-        ObjEntity target = getObjectTarget();
         getPathBrowser().addTreeSelectionListener(this);
-        setObjectTarget(target);
-        view.sourceEntityLabel.setText(relationship.getSourceEntity().getName());    
+        view.sourceEntityLabel.setText(relationship.getSourceEntity().getName());
         this.relationship = relationship;
         this.view.getRelationshipName().setText(relationship.getName());
         this.mapKey = relationship.getMapKey();
@@ -108,6 +108,7 @@ public class ObjRelationshipInfo extends CayenneController implements
         this.objectTarget = (ObjEntity) relationship.getTargetEntity();
         if (objectTarget != null) {
             updateTargetCombo(objectTarget.getDbEntity());
+            view.targetCombo.setSelectedItem(objectTarget.getName());
         }
 
         // validate -
@@ -176,6 +177,19 @@ public class ObjRelationshipInfo extends CayenneController implements
                 setMapKey();
             }
         });
+        view.getTargetCombo().addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                if (e.getStateChange() == ItemEvent.SELECTED) {
+                    Object targetName = e.getItem();
+                    for (ObjEntity target : objectTargets) {
+                        if (target.getName() != null && target.getName().equals(targetName))
{
+                            setObjectTarget(target);
+                            return;
+                        }
+                    }
+                }
+            }
+        });
     }
     
     void initFromModel() {
@@ -420,16 +434,12 @@ public class ObjRelationshipInfo extends CayenneController implements
             relPath.add((DbRelationship) selectedPath.getPathComponent(i));
         }
         setDbRelationships(relPath);
-        setObjectTarget(objEntities.size() == 0 ? null : objEntities
-                .iterator()
-                .next());
 
         updateCollectionChoosers();
     }
     public void setObjectTarget(ObjEntity objectTarget) {
         if (this.objectTarget != objectTarget) {
              this.objectTarget = objectTarget;
-             view.targetCombo.setSelectedItem(objectTarget);
 
             // init available map keys
             initMapKeys();


Mime
View raw message