From 74105798d545a400d46825ff20cc70758a90507e Mon Sep 17 00:00:00 2001 From: Fabian Peters Date: Wed, 6 Jan 2016 18:11:59 +0100 Subject: [PATCH] Always hide the "query related" button when the relationship is owned. --- .../ERMODEditRelationshipPage.wod | 2 +- .../look/pages/ERMODEditRelationshipPage.java | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Frameworks/D2W/ERModernLook/Components/Nonlocalized.lproj/ERMODEditRelationshipPage.wo/ERMODEditRelationshipPage.wod b/Frameworks/D2W/ERModernLook/Components/Nonlocalized.lproj/ERMODEditRelationshipPage.wo/ERMODEditRelationshipPage.wod index 787ab016b8a..ec76d5f959d 100644 --- a/Frameworks/D2W/ERModernLook/Components/Nonlocalized.lproj/ERMODEditRelationshipPage.wo/ERMODEditRelationshipPage.wod +++ b/Frameworks/D2W/ERModernLook/Components/Nonlocalized.lproj/ERMODEditRelationshipPage.wo/ERMODEditRelationshipPage.wod @@ -219,5 +219,5 @@ ListNotEmpty: WOConditional { } ShowFind: WOConditional { - condition = d2wContext.shouldShowQueryRelatedButton; + condition = shouldShowQueryRelatedButton; } diff --git a/Frameworks/D2W/ERModernLook/Sources/er/modern/look/pages/ERMODEditRelationshipPage.java b/Frameworks/D2W/ERModernLook/Sources/er/modern/look/pages/ERMODEditRelationshipPage.java index 919b05d678d..3896dee81c9 100644 --- a/Frameworks/D2W/ERModernLook/Sources/er/modern/look/pages/ERMODEditRelationshipPage.java +++ b/Frameworks/D2W/ERModernLook/Sources/er/modern/look/pages/ERMODEditRelationshipPage.java @@ -80,6 +80,7 @@ public interface Keys extends ERD2WEditRelationshipPage.Keys { public static String displayPropertyKeys = "displayPropertyKeys"; public static String subTask = "subTask"; public static String isEntityCreatable = "isEntityCreatable"; + public static String shouldShowQueryRelatedButton = "shouldShowQueryRelatedButton"; } @@ -349,17 +350,17 @@ public void setMasterObjectAndRelationshipKey(EOEnterpriseObject eo, String rela * @see er.directtoweb.pages.ERD2WPage#settings() */ @Override - public NSDictionary settings() { + public NSDictionary settings() { String pc = d2wContext().dynamicPage(); if (pc != null) { if (d2wContext().valueForKey("currentRelationship") != null) { // set parentRelationship key to allow subcomponents to // reference the correct ID (wonder-140) - return new NSDictionary(new Object[] { pc, - d2wContext().valueForKey("currentRelationship") }, new Object[] { + return new NSDictionary(new Object[] { pc, + d2wContext().valueForKey("currentRelationship") }, new String[] { "parentPageConfiguration", "parentRelationship" }); } else { - return new NSDictionary(pc, "parentPageConfiguration"); + return new NSDictionary(pc, "parentPageConfiguration"); } } return null; @@ -539,6 +540,24 @@ public boolean isEntityCreatable() { return ERXValueUtilities.booleanValue(d2wContext().valueForKey(Keys.isEntityCreatable)) && !isEntityReadOnly(); } + public boolean shouldShowQueryRelatedButton() { + boolean shouldShowQueryRelatedButton = ERXValueUtilities + .booleanValue(d2wContext().valueForKey(Keys.shouldShowQueryRelatedButton)); + if (isRelationshipOwned()) { + // if the relationship is owned, search makes no sense + shouldShowQueryRelatedButton = false; + } + return shouldShowQueryRelatedButton; + } + + public boolean isRelationshipOwned() { + boolean isRelationshipOwned = false; + if (masterObject().allPropertyKeys().contains(relationshipKey())) { + isRelationshipOwned = masterObject().classDescription().ownsDestinationObjectsForRelationshipKey(relationshipKey()); + } + return isRelationshipOwned; + } + private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(_masterObject); out.writeObject(_objectToAddToRelationship);