incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1210467 - /incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/action/view/ObjectView.java
Date Mon, 05 Dec 2011 14:12:43 GMT
Author: kevin
Date: Mon Dec  5 14:12:43 2011
New Revision: 1210467

URL: http://svn.apache.org/viewvc?rev=1210467&view=rev
Log:
ISIS-142 and ISIS-143: Hack to support hidden() and disabled() in HTML viewer. Adding facet
to entity members does not seem to work.

Modified:
    incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/action/view/ObjectView.java

Modified: incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/action/view/ObjectView.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/action/view/ObjectView.java?rev=1210467&r1=1210466&r2=1210467&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/action/view/ObjectView.java
(original)
+++ incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/action/view/ObjectView.java
Mon Dec  5 14:12:43 2011
@@ -21,12 +21,15 @@ package org.apache.isis.viewer.html.acti
 
 import java.util.List;
 
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.exceptions.UnknownTypeException;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.hide.HiddenObjectFacet;
 import org.apache.isis.core.metamodel.facets.object.immutable.ImmutableFacetUtils;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters;
+import org.apache.isis.core.progmodel.facets.object.disabled.DisabledObjectFacet;
 import org.apache.isis.viewer.html.component.Block;
 import org.apache.isis.viewer.html.component.Component;
 import org.apache.isis.viewer.html.component.ComponentFactory;
@@ -35,7 +38,7 @@ import org.apache.isis.viewer.html.conte
 import org.apache.isis.viewer.html.request.Request;
 
 public class ObjectView extends ObjectViewAbstract {
-    
+
     @Override
     protected boolean addObjectToHistory() {
         return true;
@@ -45,35 +48,54 @@ public class ObjectView extends ObjectVi
     protected void doExecute(final Context context, final ViewPane content, final ObjectAdapter
adapter,
         final String field) {
         final String id = context.mapObject(adapter);
-        createObjectView(context, adapter, content, id);
         final ObjectSpecification specification = adapter.getSpecification();
 
-        // TODO: this test should be done by the ImmutableFacetFactory installing an immutableFacet
on every
-        // member
-        final boolean immutable =
-            ImmutableFacetUtils.isAlwaysImmutable(specification)
-                || (adapter.isPersistent() && ImmutableFacetUtils.isImmutableOncePersisted(specification));
-
-        boolean allFieldUneditable = true;
-        final List<ObjectAssociation> flds = specification.getAssociations();
-        for (int i = 0; i < flds.size(); i++) {
-            if (flds.get(i).isUsable(getAuthenticationSession(), adapter).isAllowed()) {
-                allFieldUneditable = false;
-                break;
-            }
+        final AuthenticationSession authenticationSession = getAuthenticationSession();
+
+        boolean isVisible = true;// adapter.isVisible(authenticationSession).isAllowed();
+        HiddenObjectFacet hf = specification.getFacet(HiddenObjectFacet.class);
+        if (hf != null) {
+            isVisible = hf.hiddenReason(adapter) == null;
         }
-        if (!immutable && !allFieldUneditable) {
-            content.add(context.getComponentFactory().createEditOption(id));
+
+        if (isVisible) {
+            createObjectView(context, adapter, content, id);
+
+            boolean isEditable = true;
+            DisabledObjectFacet df = specification.getFacet(DisabledObjectFacet.class);
+            if (df != null) {
+                isEditable = df.disabledReason(adapter) == null;
+            }
+
+            if (isEditable) {
+                // TODO: this test should be done by the ImmutableFacetFactory installing
an immutableFacet on every
+                // member
+                final boolean immutable =
+                    ImmutableFacetUtils.isAlwaysImmutable(specification)
+                        || (adapter.isPersistent() && ImmutableFacetUtils.isImmutableOncePersisted(specification));
+
+                boolean allFieldUneditable = true;
+                final List<ObjectAssociation> flds = specification.getAssociations();
+                for (int i = 0; i < flds.size(); i++) {
+                    if (flds.get(i).isUsable(authenticationSession, adapter).isAllowed())
{
+                        allFieldUneditable = false;
+                        break;
+                    }
+                }
+                if (!immutable && !allFieldUneditable) {
+                    content.add(context.getComponentFactory().createEditOption(id));
+                }
+            }
+            context.setObjectCrumb(adapter);
         }
-        context.setObjectCrumb(adapter);
     }
 
     private void createObjectView(final Context context, final ObjectAdapter object, final
ViewPane pane,
         final String id) {
         final ObjectSpecification specification = object.getSpecification();
         final List<ObjectAssociation> visibleFields =
-            specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(
-                getAuthenticationSession(), object));
+            specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(),
+                object));
         for (int i = 0; i < visibleFields.size(); i++) {
             final ObjectAssociation field = visibleFields.get(i);
 



Mime
View raw message