incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1380413 [4/4] - in /incubator/isis/trunk/framework: applib/src/main/java/org/apache/isis/applib/annotation/ core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/hide/ core/metamodel/src/main/java/org/apache/isis/core/metamode...
Date Tue, 04 Sep 2012 00:50:08 GMT
Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.display;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -29,6 +30,13 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class FieldLabel extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     public void process(final Request request) {
         final String id = request.getOptionalProperty(OBJECT);
@@ -38,7 +46,7 @@ public class FieldLabel extends Abstract
         if (field == null) {
             throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
         }
-        if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) {
+        if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
             throw new ForbiddenException(field, ForbiddenException.VISIBLE);
         }
         String delimiter = request.getOptionalProperty("delimiter");

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.display;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -35,6 +36,13 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class FieldValue extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     public void process(final Request request) {
         final String className = request.getOptionalProperty(CLASS);
@@ -45,7 +53,7 @@ public class FieldValue extends Abstract
         if (field == null) {
             throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
         }
-        if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) {
+        if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
             throw new ForbiddenException(field, ForbiddenException.VISIBLE);
         }
         final boolean isIconShowing = request.isRequested(SHOW_ICON, showIconByDefault());

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java Tue Sep  4 00:50:04 2012
@@ -24,6 +24,7 @@ import java.text.Format;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
@@ -38,6 +39,13 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class GetField extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     public void process(final Request request) {
         final String id = request.getOptionalProperty(OBJECT);
@@ -51,7 +59,7 @@ public class GetField extends AbstractEl
             throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
         }
         final AuthenticationSession session = IsisContext.getAuthenticationSession();
-        if (field.isVisible(session, object).isVetoed()) {
+        if (field.isVisible(session, object, where).isVetoed()) {
             throw new ForbiddenException(field, ForbiddenException.VISIBLE);
         }
 

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java Tue Sep  4 00:50:04 2012
@@ -26,6 +26,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -39,6 +40,13 @@ import org.apache.isis.viewer.scimpi.dis
  */
 public class IncludeObject extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     public void process(final Request request) {
         final String path = request.getOptionalProperty("file");
@@ -47,7 +55,7 @@ public class IncludeObject extends Abstr
         ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
         if (fieldName != null) {
             final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
-            if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) {
+            if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
                 throw new ForbiddenException(field, ForbiddenException.VISIBLE);
             }
             object = field.get(object);

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.display;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -30,6 +31,13 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class TableCell extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with
+    // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
+    // be hidden from all tables but will be visible/enabled (perhaps incorrectly) 
+    // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
+    private final Where where = Where.ALL_TABLES;
+
     @Override
     public void process(final Request request) {
         final TableBlock tableBlock = (TableBlock) request.getBlockContent();
@@ -45,7 +53,7 @@ public class TableCell extends AbstractE
             throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
         }
         request.appendHtml("<td" + className + ">");
-        if (field.isVisible(IsisContext.getAuthenticationSession(), object).isAllowed()) {
+        if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
             final ObjectAdapter fieldReference = field.get(object);
             final String source = fieldReference == null ? "" : context.mapObject(fieldReference, Scope.REQUEST);
             final String name = request.getOptionalProperty(RESULT_NAME, fieldName);

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.display;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -40,7 +41,7 @@ public class Title extends AbstractEleme
         ObjectAdapter object = MethodsUtils.findObject(request.getContext(), id);
         if (fieldName != null) {
             final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
-            if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) {
+            if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
                 throw new ForbiddenException(field, ForbiddenException.VISIBLE);
             }
             object = field.get(object);

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java Tue Sep  4 00:50:04 2012
@@ -22,6 +22,7 @@ package org.apache.isis.viewer.scimpi.di
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.consent.Consent;
@@ -45,6 +46,9 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class EditObject extends AbstractElementProcessor {
 
+    // REVIEW: confirm this rendering context
+    private final Where where = Where.OBJECT_FORM;
+
     @Override
     public void process(final Request request) {
         final RequestContext context = request.getContext();
@@ -77,8 +81,8 @@ public class EditObject extends Abstract
             @Override
             public boolean isVisible(final String name) {
                 final ObjectAssociation fld = specification.getAssociation(name);
-                final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object).isAllowed();
-                final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object).isAllowed();
+                final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+                final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
                 return isVisible && isUseable;
             }
 
@@ -107,7 +111,7 @@ public class EditObject extends Abstract
         request.processUtilCloseTag();
 
         final AuthenticationSession session = IsisContext.getAuthenticationSession();
-        List<ObjectAssociation> viewFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object));
+        List<ObjectAssociation> viewFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
         viewFields = containedBlock.includedFields(viewFields);
         final InputField[] formFields = createFields(viewFields);
 
@@ -187,7 +191,7 @@ public class EditObject extends Abstract
             final String fieldId = formField.getName();
             final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
             final AuthenticationSession session = IsisContext.getAuthenticationSession();
-            final Consent usable = field.isUsable(session, object);
+            final Consent usable = field.isUsable(session, object, where);
             final ObjectAdapter[] options = field.getChoices(object);
             FieldFactory.initializeField(context, object, field, options, field.isMandatory(), formField);
 
@@ -196,7 +200,7 @@ public class EditObject extends Abstract
                 formField.setDescription(usable.getReason());
             }
             formField.setEditable(isEditable);
-            final boolean hiddenField = field.isVisible(session, object).isVetoed();
+            final boolean hiddenField = field.isVisible(session, object, where).isVetoed();
             final boolean unusable = usable.isVetoed();
             final boolean hideAsUnusable = unusable && !includeUnusableFields;
             if (hiddenField || hideAsUnusable) {
@@ -209,7 +213,7 @@ public class EditObject extends Abstract
         for (final InputField inputField : formFields) {
             final String fieldName = inputField.getName();
             final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
-            if (field.isVisible(IsisContext.getAuthenticationSession(), object).isAllowed()) {
+            if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
                 IsisContext.getPersistenceSession().resolveField(object, field);
                 final ObjectAdapter fieldValue = field.get(object);
                 if (inputField.isEditable()) {
@@ -281,7 +285,7 @@ public class EditObject extends Abstract
         for (final InputField formField : formFields) {
             final String fieldId = formField.getName();
             final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
-            if (field.isVisible(IsisContext.getAuthenticationSession(), object).isAllowed() && formField.isEditable()) {
+            if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed() && formField.isEditable()) {
                 final FieldEditState fieldState = entryState.getField(field.getId());
                 final String entry = fieldState == null ? "" : fieldState.getEntry();
                 formField.setValue(entry);

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java Tue Sep  4 00:50:04 2012
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.consent.Consent;
@@ -401,7 +402,7 @@ class TestMethodVisible extends Test {
         final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
         // TODO needs to work irrespective of parameters
         final ObjectAction objectAction = object.getSpecification().getObjectAction(ActionType.USER, attributeName, ObjectSpecification.EMPTY_LIST);
-        final Consent visible = objectAction.isVisible(IsisContext.getAuthenticationSession(), object);
+        final Consent visible = objectAction.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
         return visible.isAllowed();
     }
 }
@@ -412,7 +413,7 @@ class TestMethodUseable extends Test {
         final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
         // TODO needs to work irrespective of parameters
         final ObjectAction objectAction = object.getSpecification().getObjectAction(ActionType.USER, attributeName, ObjectSpecification.EMPTY_LIST);
-        final Consent usable = objectAction.isUsable(IsisContext.getAuthenticationSession(), object);
+        final Consent usable = objectAction.isUsable(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
         return usable.isAllowed();
     }
 }
@@ -438,7 +439,7 @@ class TestFieldVisible extends Test {
     boolean test(final Request request, final String attributeName, final String targetId) {
         final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
         final ObjectAssociation objectField = object.getSpecification().getAssociation(attributeName);
-        final Consent visible = objectField.isVisible(IsisContext.getAuthenticationSession(), object);
+        final Consent visible = objectField.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
         return visible.isAllowed();
     }
 }
@@ -448,7 +449,7 @@ class TestFieldEditable extends Test {
     boolean test(final Request request, final String attributeName, final String targetId) {
         final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId);
         final ObjectAssociation objectField = object.getSpecification().getAssociation(attributeName);
-        final Consent usable = objectField.isUsable(IsisContext.getAuthenticationSession(), object);
+        final Consent usable = objectField.isUsable(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE);
         return usable.isAllowed();
     }
 }

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractLink.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -51,7 +52,15 @@ public abstract class AbstractLink exten
             if (field == null) {
                 throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
             }
-            if (field.isVisible(IsisContext.getAuthenticationSession(), adapter).isVetoed()) {
+            
+            // REVIEW: should provide this rendering context, rather than hardcoding.
+            // the net effect currently is that class members annotated with 
+            // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+            // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+            // for any other value for Where
+            final Where where = Where.ANYWHERE;
+            
+            if (field.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
                 throw new ForbiddenException(field, ForbiddenException.VISIBLE);
             }
             IsisContext.getPersistenceSession().resolveField(adapter, field);

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/EditLink.java Tue Sep  4 00:50:04 2012
@@ -22,6 +22,7 @@ package org.apache.isis.viewer.scimpi.di
 import java.util.List;
 
 import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.immutable.ImmutableFacet;
@@ -34,11 +35,18 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class EditLink extends AbstractLink {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     protected boolean valid(final Request request, final ObjectAdapter adapter) {
         final ObjectSpecification specification = adapter.getSpecification();
         final AuthenticationSession session = IsisContext.getAuthenticationSession();
-        final List<ObjectAssociation> visibleFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, adapter));
+        final List<ObjectAssociation> visibleFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, adapter, where));
         final ImmutableFacet facet = specification.getFacet(ImmutableFacet.class);
         final boolean isImmutable = facet != null && facet.when() == When.ALWAYS;
         final boolean isImmutableOncePersisted = facet != null && facet.when() == When.ONCE_PERSISTED && adapter.representsPersistent();

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/NewActionLink.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.simple;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
@@ -27,11 +28,14 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class NewActionLink extends AbstractLink {
 
+    // REVIEW: confirm this rendering context
+    private final Where where = Where.OBJECT_FORM;
+
     @Override
     protected boolean valid(final Request request, final ObjectAdapter object) {
         final String method = request.getRequiredProperty(METHOD);
         final ObjectAction action = MethodsUtils.findAction(object, method);
-        return MethodsUtils.isVisibleAndUsable(object, action);
+        return MethodsUtils.isVisibleAndUsable(object, action, where);
     }
 
     @Override

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/ObjectLink.java Tue Sep  4 00:50:04 2012
@@ -21,6 +21,7 @@ package org.apache.isis.viewer.scimpi.di
 
 import java.util.List;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
@@ -31,10 +32,17 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class ObjectLink extends AbstractLink {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     protected boolean valid(final Request request, final ObjectAdapter object) {
         final AuthenticationSession session = IsisContext.getAuthenticationSession();
-        final List<ObjectAssociation> visibleFields = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object));
+        final List<ObjectAssociation> visibleFields = object.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(session, object, where));
         return visibleFields.size() > 0;
     }
 

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/RemoveElement.java Tue Sep  4 00:50:04 2012
@@ -21,6 +21,7 @@ package org.apache.isis.viewer.scimpi.di
 
 import java.util.List;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.applib.filter.Filter;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -41,6 +42,13 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class RemoveElement extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final static Where where = Where.ANYWHERE;
+
     @Override
     public void process(final Request request) {
         final String title = request.getOptionalProperty(BUTTON_TITLE, "Remove From List");
@@ -79,12 +87,12 @@ public class RemoveElement extends Abstr
         if (!field.isOneToManyAssociation()) {
             throw new ScimpiException("Field " + fieldName + " not a collection, in " + adapter.getSpecification().getFullIdentifier());
         }
-        if (field.isVisible(IsisContext.getAuthenticationSession(), adapter).isVetoed()) {
+        if (field.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
             throw new ForbiddenException(field, ForbiddenException.VISIBLE);
         }
         IsisContext.getPersistenceSession().resolveField(adapter, field);
 
-        Consent usable = field.isUsable(IsisContext.getAuthenticationSession(), adapter);
+        Consent usable = field.isUsable(IsisContext.getAuthenticationSession(), adapter, where);
         if (usable.isAllowed()) {
             usable = ((OneToManyAssociation) field).isValidToRemove(adapter, element);
         }
@@ -124,7 +132,7 @@ public class RemoveElement extends Abstr
 
         // TODO check is valid to remove element
         final AuthenticationSession session = IsisContext.getAuthenticationSession();
-        final Filter<ObjectAssociation> filter = ObjectAssociationFilters.dynamicallyVisible(session, adapter);
+        final Filter<ObjectAssociation> filter = ObjectAssociationFilters.dynamicallyVisible(session, adapter, where);
         final List<ObjectAssociation> visibleFields = adapter.getSpecification().getAssociations(filter);
         if (visibleFields.size() == 0) {
             return false;

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/FieldName.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.value;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -29,6 +30,13 @@ import org.apache.isis.viewer.scimpi.dis
 
 public class FieldName extends AbstractElementProcessor {
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     @Override
     public void process(final Request request) {
         final String id = request.getOptionalProperty(OBJECT);
@@ -38,7 +46,7 @@ public class FieldName extends AbstractE
         if (field == null) {
             throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
         }
-        if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) {
+        if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
             throw new ForbiddenException(field, ForbiddenException.VISIBLE);
         }
         request.appendAsHtmlEncoded(field.getName());

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/value/TitleString.java Tue Sep  4 00:50:04 2012
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.value;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -45,7 +46,7 @@ public class TitleString extends Abstrac
             titleString = object.titleString();
         } else {
             final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
-            if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) {
+            if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
                 throw new ForbiddenException(field, ForbiddenException.VISIBLE);
             }
             final ObjectAdapter fieldReference = field.get(object);

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java Tue Sep  4 00:50:04 2012
@@ -25,12 +25,12 @@ import java.util.List;
 
 import org.apache.wicket.Session;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.applib.profiles.Localization;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager.ConcurrencyChecking;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
 import org.apache.isis.core.metamodel.consent.Consent;
 import org.apache.isis.core.metamodel.facetapi.Facet;
@@ -86,12 +86,12 @@ public class ScalarModel extends EntityM
             }
 
             @Override
-            public String disable(final ScalarModel scalarModel) {
+            public String disable(final ScalarModel scalarModel, final Where where) {
                 final ObjectAdapter parentAdapter = scalarModel.parentObjectAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK);
                 final OneToOneAssociation property = scalarModel.getPropertyMemento().getProperty();
                 try {
                     final AuthenticationSession session = scalarModel.getAuthenticationSession();
-                    final Consent usable = property.isUsable(session, parentAdapter);
+                    final Consent usable = property.isUsable(session, parentAdapter, where);
                     return usable.isAllowed() ? null : usable.getReason();
                 } catch (final Exception ex) {
                     return ex.getLocalizedMessage();
@@ -188,7 +188,7 @@ public class ScalarModel extends EntityM
             }
 
             @Override
-            public String disable(final ScalarModel scalarModel) {
+            public String disable(final ScalarModel scalarModel, Where where) {
                 // always enabled
                 return null;
             }
@@ -255,7 +255,7 @@ public class ScalarModel extends EntityM
 
         public abstract String getIdentifier(ScalarModel scalarModel);
 
-        public abstract String disable(ScalarModel scalarModel);
+        public abstract String disable(ScalarModel scalarModel, Where where);
 
         public abstract String parseAndValidate(ScalarModel scalarModel, String proposedPojoAsStr);
 
@@ -406,8 +406,8 @@ public class ScalarModel extends EntityM
         setObject(adapter);
     }
 
-    public String disable() {
-        return kind.disable(this);
+    public String disable(Where where) {
+        return kind.disable(this, where);
     }
 
     public String parseAndValidate(final String proposedPojoAsStr) {

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTable.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTable.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTable.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTable.java Tue Sep  4 00:50:04 2012
@@ -84,7 +84,7 @@ public class CollectionContentsAsAjaxTab
         @SuppressWarnings("unchecked")
         final Filter<ObjectAssociation> filter = Filters.and(
                 ObjectAssociationFilters.PROPERTIES, 
-                ObjectAssociationFilters.visibleWhere(getModel().isParented()? Where.PARENTED_TABLE: Where.STANDALONE_TABLE));
+                ObjectAssociationFilters.staticallyVisible(getModel().isParented()? Where.PARENTED_TABLE: Where.STANDALONE_TABLE));
         final List<? extends ObjectAssociation> propertyList = typeOfSpec.getAssociations(filter);
         for (final ObjectAssociation property : propertyList) {
             final ColumnAbstract<ObjectAdapter> nopc = createObjectAdapterPropertyColumn(property);

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityCollectionsReadOnlyFormPanel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityCollectionsReadOnlyFormPanel.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityCollectionsReadOnlyFormPanel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityCollectionsReadOnlyFormPanel.java Tue Sep  4 00:50:04 2012
@@ -34,6 +34,7 @@ import org.apache.wicket.markup.html.for
 import org.apache.wicket.markup.repeater.RepeatingView;
 import org.apache.wicket.model.Model;
 
+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;
@@ -177,7 +178,7 @@ public class EntityCollectionsReadOnlyFo
 
         @SuppressWarnings("unchecked")
 		private Filter<ObjectAssociation> visibleAssociationFilter(final ObjectAdapter adapter) {
-            return Filters.and(ObjectAssociationFilters.COLLECTIONS, ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter));
+            return Filters.and(ObjectAssociationFilters.COLLECTIONS, ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter, Where.PARENTED_TABLE));
         }
 
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesAndOrCollectionsPanel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesAndOrCollectionsPanel.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesAndOrCollectionsPanel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesAndOrCollectionsPanel.java Tue Sep  4 00:50:04 2012
@@ -40,6 +40,7 @@ import org.apache.wicket.markup.repeater
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
 
+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;
@@ -89,6 +90,7 @@ public class EntityPropertiesAndOrCollec
             }
         },
         PROPERTIES_AND_COLLECTIONS {
+            @SuppressWarnings("unchecked")
             @Override
             public Filter<ObjectAssociation> getFilters() {
                 return Filters.or(PROPERTIES_ONLY.getFilters(), COLLECTIONS_ONLY.getFilters());
@@ -171,7 +173,7 @@ public class EntityPropertiesAndOrCollec
             final ObjectAdapter adapter = entityModel.getObject();
             final ObjectSpecification noSpec = adapter.getSpecification();
 
-            final List<ObjectAssociation> associations = visibleAssociations(adapter, noSpec);
+            final List<ObjectAssociation> associations = visibleAssociations(adapter, noSpec, Where.OBJECT_FORM);
 
             final RepeatingView rv = new RepeatingView(ID_PROPERTIES_AND_OR_COLLECTIONS);
             final EvenOrOddCssClassAppenderFactory eo = new EvenOrOddCssClassAppenderFactory();
@@ -228,13 +230,13 @@ public class EntityPropertiesAndOrCollec
 			component = getComponentFactoryRegistry().addOrReplaceComponent(container, ID_PROPERTY_OR_COLLECTION, ComponentType.COLLECTION_NAME_AND_CONTENTS, entityCollectionModel);
 		}
 
-        private List<ObjectAssociation> visibleAssociations(final ObjectAdapter adapter, final ObjectSpecification noSpec) {
-            return noSpec.getAssociations(visibleAssociationFilter(adapter));
+        private List<ObjectAssociation> visibleAssociations(final ObjectAdapter adapter, final ObjectSpecification objSpec, Where where) {
+            return objSpec.getAssociations(visibleAssociationFilter(adapter, where));
         }
 
         @SuppressWarnings("unchecked")
-        private Filter<ObjectAssociation> visibleAssociationFilter(final ObjectAdapter adapter) {
-            return Filters.and(render.getFilters(), ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter));
+        private Filter<ObjectAssociation> visibleAssociationFilter(final ObjectAdapter adapter, Where where) {
+            return Filters.and(render.getFilters(), ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter, where));
         }
 
         private void addButtons() {

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java Tue Sep  4 00:50:04 2012
@@ -25,6 +25,7 @@ import org.apache.wicket.markup.html.for
 import org.apache.wicket.markup.html.form.LabeledWebMarkupContainer;
 import org.apache.wicket.model.Model;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
 import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
 
@@ -54,6 +55,11 @@ public abstract class ScalarPanelAbstrac
             public void buildGui(final ScalarPanelAbstract panel) {
                 panel.getComponentForRegular().setVisible(false);
             }
+
+            @Override
+            public Where getWhere() {
+                return Where.PARENTED_TABLE;
+            }
         },
         /**
          * Does show labels, eg for use in forms.
@@ -68,11 +74,18 @@ public abstract class ScalarPanelAbstrac
             public void buildGui(final ScalarPanelAbstract panel) {
                 panel.getLabelForCompact().setVisible(false);
             }
+
+            @Override
+            public Where getWhere() {
+                return Where.OBJECT_FORM;
+            }
         };
 
         public abstract String getLabelCaption(LabeledWebMarkupContainer labeledContainer);
 
         public abstract void buildGui(ScalarPanelAbstract panel);
+
+        public abstract Where getWhere();
     }
 
     private Format format;
@@ -112,7 +125,7 @@ public abstract class ScalarPanelAbstrac
         if (scalarModel.isViewMode()) {
             onBeforeRenderWhenViewMode();
         } else {
-            final String disableReasonIfAny = scalarModel.disable();
+            final String disableReasonIfAny = scalarModel.disable(format.getWhere());
             if (disableReasonIfAny != null) {
                 onBeforeRenderWhenDisabled(disableReasonIfAny);
             } else {

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java Tue Sep  4 00:50:04 2012
@@ -38,6 +38,7 @@ import org.apache.wicket.markup.html.lin
 import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.model.Model;
 
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
 import org.apache.isis.core.commons.ensure.Ensure;
@@ -186,6 +187,13 @@ public class CssMenuItem implements Seri
     // To add submenu items
     // //////////////////////////////////////////////////////////////
 
+    // REVIEW: should provide this rendering context, rather than hardcoding.
+    // the net effect currently is that class members annotated with 
+    // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+    // be hidden/disabled, but will be visible/enabled (perhaps incorrectly) 
+    // for any other value for Where
+    private final Where where = Where.ANYWHERE;
+
     /**
      * @return the builder, else <tt>null</tt> if the action is not visible for
      *         the current user.
@@ -197,7 +205,7 @@ public class CssMenuItem implements Seri
         final CssMenuItem parentMenuItem = this;
 
         final ObjectAdapter adapter = adapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK);
-        final Consent visibility = noAction.isVisible(session, adapter);
+        final Consent visibility = noAction.isVisible(session, adapter, where);
         if (visibility.isVetoed()) {
             return null;
         }
@@ -207,7 +215,7 @@ public class CssMenuItem implements Seri
         final AbstractLink link = linkAndLabel.getLink();
         final String actionLabel = linkAndLabel.getLabel();
 
-        final Consent usability = noAction.isUsable(session, adapter);
+        final Consent usability = noAction.isUsable(session, adapter, where);
         final String reasonDisabledIfAny = usability.getReason();
 
         return parentMenuItem.newSubMenuItem(actionLabel).link(link).enabled(reasonDisabledIfAny);

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/ProcessObjectPanelAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/ProcessObjectPanelAbstract.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/ProcessObjectPanelAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/ProcessObjectPanelAbstract.java Tue Sep  4 00:50:04 2012
@@ -29,6 +29,7 @@ import org.apache.wicket.markup.html.Web
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.repeater.RepeatingView;
 
+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;
@@ -56,9 +57,12 @@ import org.apache.isis.viewer.wicket.ui.
 public abstract class ProcessObjectPanelAbstract extends PanelAbstract<EntityModel> {
 
     private static final long serialVersionUID = 1L;
+    
+    private final Where where;
 
-    public ProcessObjectPanelAbstract(final String id, final EntityModel model) {
+    public ProcessObjectPanelAbstract(final String id, final EntityModel model, Where where) {
         super(id, model);
+        this.where = where;
     }
 
     protected EntityModel getEntityModel() {
@@ -92,7 +96,7 @@ public abstract class ProcessObjectPanel
     }
 
     private Filter<ObjectAssociation> visiblePropertyFilter(final ObjectAdapter adapter) {
-        return Filters.and(ObjectAssociationFilters.PROPERTIES, ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter));
+        return Filters.and(ObjectAssociationFilters.PROPERTIES, ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter, where));
     }
 
     private List<PropertyMemento> buildPropertyMementos(final List<OneToOneAssociation> properties) {

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/fixtures/ActionFixtures.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/fixtures/ActionFixtures.java?rev=1380413&r1=1380412&r2=1380413&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/fixtures/ActionFixtures.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/test/java/org/apache/isis/viewer/wicket/ui/fixtures/ActionFixtures.java Tue Sep  4 00:50:04 2012
@@ -23,6 +23,7 @@ import org.jmock.Expectations;
 import org.jmock.Mockery;
 
 import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.consent.ConsentAbstract;
@@ -96,7 +97,7 @@ public final class ActionFixtures {
     public void isVisible(final ObjectAction mockAction, final boolean returns) {
         context.checking(new Expectations() {
             {
-                allowing(mockAction).isVisible(with(any(AuthenticationSession.class)), with(any(ObjectAdapter.class)));
+                allowing(mockAction).isVisible(with(any(AuthenticationSession.class)), with(any(ObjectAdapter.class)), Where.ANYWHERE);
                 will(returnValue(ConsentAbstract.allowIf(returns)));
             }
         });
@@ -105,7 +106,7 @@ public final class ActionFixtures {
     public void isUsable(final ObjectAction mockAction, final boolean returns) {
         context.checking(new Expectations() {
             {
-                allowing(mockAction).isUsable(with(any(AuthenticationSession.class)), with(any(ObjectAdapter.class)));
+                allowing(mockAction).isUsable(with(any(AuthenticationSession.class)), with(any(ObjectAdapter.class)), Where.ANYWHERE);
                 will(returnValue(ConsentAbstract.allowIf(returns)));
             }
         });



Mime
View raw message