You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/02/15 18:33:38 UTC
git commit: ISIS-344: implemented Where.REFERENCES_PARENT
Updated Branches:
refs/heads/master a88c33a54 -> 05d31e6da
ISIS-344: implemented Where.REFERENCES_PARENT
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/05d31e6d
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/05d31e6d
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/05d31e6d
Branch: refs/heads/master
Commit: 05d31e6da39b35e173f80f3a814191ef5aef4e49
Parents: a88c33a
Author: Dan Haywood <da...@apache.org>
Authored: Fri Feb 15 17:32:53 2013 +0000
Committer: Dan Haywood <da...@apache.org>
Committed: Fri Feb 15 17:32:53 2013 +0000
----------------------------------------------------------------------
.../CollectionContentsAsAjaxTablePanel.java | 33 ++++++++++++++-
.../org/apache/isis/applib/annotation/Where.java | 8 ++++
.../ObjectAssociationFiltersTest_visibleWhere.java | 4 ++
3 files changed, 44 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/05d31e6d/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
index 00b172e..1788757 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
@@ -34,10 +34,13 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.Model;
+import org.apache.isis.applib.annotation.When;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.filter.Filter;
import org.apache.isis.applib.filter.Filters;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager.ConcurrencyChecking;
+import org.apache.isis.core.metamodel.facets.hide.HiddenFacet;
import org.apache.isis.core.metamodel.spec.ActionType;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
@@ -161,11 +164,17 @@ public class CollectionContentsAsAjaxTablePanel extends PanelAbstract<EntityColl
if (getModel().hasSelectionHandler()) {
return;
}
+
+ final ObjectSpecification parentSpecIfAny =
+ getModel().isParented()
+ ? getModel().getParentObjectAdapterMemento().getObjectAdapter(ConcurrencyChecking.NO_CHECK).getSpecification()
+ : null;
@SuppressWarnings("unchecked")
final Filter<ObjectAssociation> filter = Filters.and(
ObjectAssociationFilters.PROPERTIES,
- ObjectAssociationFilters.staticallyVisible(getModel().isParented()? Where.PARENTED_TABLES: Where.STANDALONE_TABLES));
+ ObjectAssociationFilters.staticallyVisible(getModel().isParented()? Where.PARENTED_TABLES: Where.STANDALONE_TABLES),
+ associationDoesNotReferenceParent(parentSpecIfAny));
final List<? extends ObjectAssociation> propertyList = typeOfSpec.getAssociations(filter);
for (final ObjectAssociation property : propertyList) {
final ColumnAbstract<ObjectAdapter> nopc = createObjectAdapterPropertyColumn(property);
@@ -173,6 +182,28 @@ public class CollectionContentsAsAjaxTablePanel extends PanelAbstract<EntityColl
}
}
+ Filter<ObjectAssociation> associationDoesNotReferenceParent(final ObjectSpecification parentSpec) {
+ if(parentSpec == null) {
+ return Filters.any();
+ }
+ return new Filter<ObjectAssociation>() {
+ @Override
+ public boolean accept(ObjectAssociation association) {
+ final HiddenFacet facet = association.getFacet(HiddenFacet.class);
+ if(facet == null) {
+ return true;
+ }
+ if (facet.where() != Where.REFERENCES_PARENT) {
+ return true;
+ }
+ final ObjectSpecification assocSpec = association.getSpecification();
+ final boolean associationSpecIsOfParentSpec = assocSpec.isOfType(parentSpec);
+ final boolean isVisible = !associationSpecIsOfParentSpec;
+ return isVisible;
+ }
+ };
+ }
+
private void addSelectedButtonIfRequired(final List<IColumn<ObjectAdapter,String>> columns) {
if (!getModel().hasSelectionHandler()) {
return;
http://git-wip-us.apache.org/repos/asf/isis/blob/05d31e6d/core/applib/src/main/java/org/apache/isis/applib/annotation/Where.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Where.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Where.java
index 3959d87..b61628c 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Where.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Where.java
@@ -56,6 +56,14 @@ public enum Where {
*/
OBJECT_FORMS,
/**
+ * The member should be disabled/hidden when displayed as a column of a table
+ * within parent object's collection, and references that parent.
+ *
+ * <p>
+ * For most (all?) viewers, this will have meaning only if applied to a property member.
+ */
+ REFERENCES_PARENT,
+ /**
* The member should be disabled/hidden when displayed as a column of a table within
* a parent object's collection.
*
http://git-wip-us.apache.org/repos/asf/isis/blob/05d31e6d/core/metamodel/src/test/java/org/apache/isis/core/metamodel/feature/ObjectAssociationFiltersTest_visibleWhere.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/feature/ObjectAssociationFiltersTest_visibleWhere.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/feature/ObjectAssociationFiltersTest_visibleWhere.java
index 9abb199..c5828fc 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/feature/ObjectAssociationFiltersTest_visibleWhere.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/feature/ObjectAssociationFiltersTest_visibleWhere.java
@@ -77,16 +77,20 @@ public class ObjectAssociationFiltersTest_visibleWhere {
{When.ALWAYS, Where.OBJECT_FORMS, Where.OBJECT_FORMS, false},
{When.ALWAYS, Where.OBJECT_FORMS, Where.ALL_TABLES, true},
{When.ALWAYS, Where.OBJECT_FORMS, Where.PARENTED_TABLES, true},
+ {When.ALWAYS, Where.OBJECT_FORMS, Where.REFERENCES_PARENT, true},
{When.ALWAYS, Where.OBJECT_FORMS, Where.STANDALONE_TABLES, true},
{When.ALWAYS, Where.STANDALONE_TABLES, Where.OBJECT_FORMS, true},
{When.ALWAYS, Where.STANDALONE_TABLES, Where.PARENTED_TABLES, true},
+ {When.ALWAYS, Where.STANDALONE_TABLES, Where.REFERENCES_PARENT, true},
{When.ALWAYS, Where.STANDALONE_TABLES, Where.STANDALONE_TABLES, false},
{When.ALWAYS, Where.PARENTED_TABLES, Where.OBJECT_FORMS, true},
{When.ALWAYS, Where.PARENTED_TABLES, Where.PARENTED_TABLES, false},
+ {When.ALWAYS, Where.PARENTED_TABLES, Where.REFERENCES_PARENT, true},
{When.ALWAYS, Where.PARENTED_TABLES, Where.STANDALONE_TABLES, true},
{When.ALWAYS, Where.ALL_TABLES, Where.OBJECT_FORMS, true},
{When.ALWAYS, Where.ALL_TABLES, Where.PARENTED_TABLES, false},
{When.ALWAYS, Where.ALL_TABLES, Where.STANDALONE_TABLES, false},
+ {When.ALWAYS, Where.ALL_TABLES, Where.REFERENCES_PARENT, true},
});
}