incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmatth...@apache.org
Subject svn commit: r1084356 [2/2] - in /incubator/isis/trunk/viewer/scimpi: dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/ dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ dispatcher/src/main/java/org/apache/isis/v...
Date Tue, 22 Mar 2011 21:27:40 GMT
Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Debug.java
Tue Mar 22 21:27:39 2011
@@ -20,70 +20,71 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
 
-import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebugHtmlString;
 import org.apache.isis.core.commons.debug.DebugString;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.spec.ActionType;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
 import org.apache.isis.runtimes.dflt.runtime.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.util.Dump;
 import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
 import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
 import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
 
 
 public class Debug extends AbstractElementProcessor {
 
+    private final Dispatcher dispatcher;
+
+    public Debug(Dispatcher dispatcher) {
+        this.dispatcher = dispatcher;}
+    
     @Override
     public void process(Request request) {
         if (request.getContext().isDebugDisabled()) {
             return;
         }
+          
+        //  Application  | System  | Specifications  | Dispatcher  | Context  | Variables
 | Object  | I18N File  | Authorization File  | Hide Debug  
         
-        String type = request.getOptionalProperty("type");
-        String value = request.getOptionalProperty("value");
+        String type = request.getOptionalProperty(TYPE);
+       
         boolean alwaysShow = request.isRequested("force", false);
-        if (type != null) {
+         if (type != null) {
             if (type.equals("system")) {
-                DebuggableWithTitle[] debug = IsisContext.debugSystem();
-                request.appendHtml("<h2>System</h2>");
-                for (int i = 0; i < debug.length; i++) {
-                    DebugString str = new DebugString();
-                    debug[i].debugData(str);
-                    request.appendHtml("<h4>" + debug[i].debugTitle() + "</h4>");
-                    request.appendHtml("<pre class=\"debug\">" + str + "</pre>");
-                }
+                displaySystem(request);
+            } else if (type.equals("variables")) {
+                displayVariables(request);
+            } else if (type.equals("dispatcher")) {
+                displayDispatcher(request);
+            } else if (type.equals("context")) {
+                displayContext(request);
+             } else if (type.equals("specifications")) {
+                listSpecifications(request);
+            } else if (type.equals("specification")) {
+                specification(request);
 
-            } else if (type.equals("list-specifications")) {
-                Collection<ObjectSpecification> allSpecifications = getSpecificationLoader().allSpecifications();
-                final List<String> fullIdentifierList = Lists.newArrayList(
-                    Collections2.transform(allSpecifications, ObjectSpecification.FUNCTION_FULLY_QUALIFIED_CLASS_NAME));
-                Collections.sort(fullIdentifierList);
-                request.appendHtml("<h2>Specifications</h2><ol>");
-                for (String fullIdentifier : fullIdentifierList) {
-                    request.appendHtml("<li><a href=\"specification.shtml?spec="
+ fullIdentifier + "\">" + fullIdentifier + "</a></p>");
-                }
-                request.appendHtml("</ol>");
                 
-            } else if (type.equals("list-objects")) {
-                request.appendHtml("<h2>Objects</h2><ol>");
-                request.getContext().append(request, "variables");
                 
-            } else if (type.equals("specification")) {
-                ObjectSpecification spec = getSpecificationLoader().loadSpecification(value);
-                DebugString str = new DebugString();
-                Dump.specification(spec, str);
-                request.appendHtml("<h2>" + spec.getFullIdentifier() + "</h2>");
-                request.appendHtml("<pre class=\"debug\">" + str + "</pre>");
-
             } else if (type.equals("object")) {
+                String value = request.getOptionalProperty(VALUE);
                 RequestContext context = request.getContext();
                 ObjectAdapter object = context.getMappedObject(value);
                 DebugString str = new DebugString();
@@ -120,15 +121,11 @@ public class Debug extends AbstractEleme
                 request.appendHtml(variable + " => " + (object == null ? "null" : object.toString()));
             }
 
-            if (value != null) {
-                request.appendHtml(value);
-            }
-
             String list = request.getOptionalProperty("list");
             if (list != null) {
-                request.appendHtml("<pre class=\"debug\">");
-                context.append(request, list);
-                request.appendHtml("</pre>");
+                DebugString debug = new DebugString();
+                context.append(debug, list);
+                request.appendHtml(debug.toString());
             }
 
             String uri = request.getOptionalProperty("uri");
@@ -141,6 +138,69 @@ public class Debug extends AbstractEleme
         }
     }
 
+    protected void specification(Request request) {
+        String name = request.getOptionalProperty(VALUE);
+        ObjectSpecification spec = getSpecificationLoader().loadSpecification(name);
+        request.appendHtml("<h1>Specification - " + spec.getFullIdentifier() + "</h1>");
+        DebugBuilder debug = new DebugHtmlString();
+        specification(spec, debug);
+        request.appendHtml(debug.toString());
+    }
+
+    private void displayContext(Request request) {
+        request.appendHtml("<h1>Context</h1>");
+        DebugHtmlString debugString = new DebugHtmlString();
+        request.getContext().append(debugString);
+        request.appendHtml(debugString.toString());
+    }
+
+    private void displayDispatcher(Request request) {
+        request.appendHtml("<h1>Dispatcher</h1>");
+        DebugHtmlString debugString = new DebugHtmlString();
+        dispatcher.debug(debugString);
+        request.appendHtml(debugString.toString());
+    }
+
+    protected void displayVariables(Request request) {
+        request.appendHtml("<h1>Variables</h1>");
+        DebugHtmlString debug = new DebugHtmlString();
+        RequestContext context = request.getContext();
+        context.append(debug, "variables");
+        request.appendHtml(debug.toString());
+    }
+
+    protected void displaySystem(Request request) {
+        request.appendHtml("<h1>System</h1>");
+        DebuggableWithTitle[] debug = IsisContext.debugSystem();
+        for (int i = 0; i < debug.length; i++) {
+            DebugHtmlString str = new DebugHtmlString();
+            str.appendTitle(debug[i].debugTitle());
+            debug[i].debugData(str);
+            request.appendHtml(str.toString());
+        }
+    }
+
+    protected void listSpecifications(Request request) {
+        request.appendHtml("<h1>Specifications</h1>");
+        List<ObjectSpecification> fullIdentifierList = new ArrayList<ObjectSpecification>(getSpecificationLoader().allSpecifications());
+        Collections.sort(fullIdentifierList, ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE);
+        DebugHtmlString debug = new DebugHtmlString();
+        for (ObjectSpecification spec : fullIdentifierList) {
+            String name = spec.getSingularName();
+            debug.appendln(name, specificationLink(spec));
+        }
+        request.appendHtml(debug.toString());
+    }
+
+    private String specificationLink(ObjectSpecification specification) {
+        if (specification == null) {
+            return "none";
+        } else {
+            String name = specification.getFullIdentifier();
+            return "<a href=\"./debug.shtml?type=specification&value=" + name + "\">"
+ name + "</a>";
+        }
+    }
+    
     protected SpecificationLoader getSpecificationLoader() {
         return IsisContext.getSpecificationLoader();
     }
@@ -150,5 +210,139 @@ public class Debug extends AbstractEleme
         return "debug";
     }
 
+    private void specification(ObjectSpecification spec, DebugBuilder view) {
+        view.startSection("Summary");
+        view.appendln("Hash code", "#" + Integer.toHexString(spec.hashCode()));
+        view.appendln("ID", spec.getIdentifier());
+        view.appendln("Full name", spec.getFullIdentifier());
+        view.appendln("Short name", spec.getShortIdentifier());
+        view.appendln("Singular name", spec.getSingularName());
+        view.appendln("Plural name", spec.getPluralName());
+        view.appendln("Description", spec.getDescription());
+    
+        view.appendln("Type", "?");
+        view.appendln("Value/aggregated", String.valueOf(!spec.isValueOrIsAggregated()));
+    
+        view.appendln("Parent specification", specificationLink(spec.superclass()));
+        specificationClasses(view, "Child specifications",  spec.subclasses());
+        specificationClasses(view, "Implemented interfaces", spec.interfaces());
+        speficationFacets(view, spec);
+        
+        List<ObjectAssociation> fields = spec.getAssociations();
+        specificationMembers(view, "Fields", fields);
+        List<ObjectAction> userActions = spec.getObjectActions(ActionType.USER);
+        specificationMembers(view, "User Actions", userActions);
+        specificationMembers(view, "Exploration Actions", spec.getObjectActions(ActionType.EXPLORATION));
+        specificationMembers(view, "Prototype Actions", spec.getObjectActions(ActionType.PROTOTYPE));
+        specificationMembers(view, "Debug Actions", spec.getObjectActions(ActionType.DEBUG));
+        view.endSection();
+        
+        view.startSection("Fields");
+        for (int i = 0; i < fields.size(); i++) {
+            ObjectAssociation field = fields.get(i);
+            view.appendTitle("<span id=\"" + field.getId() + "\"><em>Field:</em>
" + field.getId() + "</span>");
+            view.appendln("ID", field.getIdentifier());
+            view.appendln("Short ID", field.getId());
+            view.appendln("Name", field.getName());
+            view.appendln("Specification", specificationLink(field.getSpecification()));
+    
+            view.appendln("Type",  field.isOneToManyAssociation() ? "Collection" : field.isOneToOneAssociation()
? "Object" : "Unknown");
+            view.appendln("Flags", (field.isAlwaysHidden() ? "": "Visible ") + (field.isNotPersisted()
? "Not-Persisted ": " ")
+                    + (field.isMandatory() ? "Mandatory " : ""));
+    
+            speficationFacets(view, field);
+        }
+        view.endSection();
+        
+        view.startSection("Actions");
+        for (int i = 0; i < userActions.size(); i++) {
+            final ObjectAction action = userActions.get(i);
+            view.appendTitle("<span id=\"" + action.getId() + "\"><em>Action:</em>
" + action.getId() + "</span>");
+            view.appendln("ID", action.getIdentifier());
+            view.appendln("Short ID", action.getId());
+            view.appendln("Name", action.getName());
+            view.appendln("Specification", specificationLink(action.getSpecification()));
+    
+            view.appendln("Target", action.getTarget());
+            view.appendln("On type", specificationLink(action.getOnType()));
+    
+            ObjectSpecification returnType = action.getReturnType();
+            view.appendln("Returns", returnType == null ? "VOID" : specificationLink(returnType));
+            
+            speficationFacets(view, action);
+    
+            List<ObjectActionParameter> parameters = action.getParameters();
+            if (parameters.size() == 0) {
+                view.appendln("Parameters", "none");
+            } else {
+                StringBuffer buffer = new StringBuffer();
+                List<ObjectActionParameter> p = action.getParameters();
+                for (int j = 0; j < parameters.size(); j++) {
+                    buffer.append(p.get(j).getName());
+                    buffer.append(" (");
+                    buffer.append(specificationLink(parameters.get(j).getSpecification()));
+                    buffer.append(")");
+                    view.appendln("Parameters", buffer.toString());
+                    
+                    view.indent();
+                    Class<? extends Facet>[] parameterFacets = p.get(j).getFacetTypes();
+                    for (int k = 0; k < parameterFacets.length; k++) {
+                        view.append(p.get(j).getFacet(parameterFacets[k]).toString());
+                    }
+                    view.unindent();
+                }
+            }
+        }
+    }
+
+    private void specificationClasses(DebugBuilder view, String label, List<ObjectSpecification>
subclasses) {
+        StringBuffer buffer = new StringBuffer();
+        if (subclasses.size() == 0) {
+            buffer.append("none");
+        } else {
+            for (int i = 0; i < subclasses.size(); i++) {
+                buffer.append(specificationLink(subclasses.get(i)) + "<br>");
+            }
+        }
+        view.appendln(label, buffer.toString());
+    }
+
+    private void specificationMembers(DebugBuilder view, String label, List<? extends
ObjectMember> members) {
+        StringBuffer buffer = new StringBuffer();
+        if (members.size() == 0) {
+            buffer.append("none");
+        } else {
+            for (int i = 0; i < members.size(); i++) {
+                buffer.append("<a href=\"#" + members.get(i).getId() + "\">" + members.get(i).getId()
+ "</a><br>");
+            }
+        }
+        view.appendln(label, buffer.toString());
+    }
+
+    private void speficationFacets(DebugBuilder view, FacetHolder facetHolder) {
+        Facet[] facets = facetHolder.getFacets(new Filter<Facet>() {
+            @Override
+            public boolean accept(Facet facet) {
+                return true;
+            }
+        });
+        StringBuffer buffer = new StringBuffer();
+        if (facets == null || facets.length == 0) {
+            buffer.append("none");
+        } else {
+            Arrays.sort(facets, new Comparator<Facet>() {
+                public int compare(Facet o1, Facet o2) {
+                    String facetType1 = o1.facetType().getName();
+                    String facetType2 = o2.facetType().getName();
+                    return facetType1.substring(facetType1.lastIndexOf('.') + 1).compareTo(facetType2.substring(facetType2.lastIndexOf('.')
+ 1));
+                }});
+            for (int i = 0; i < facets.length; i++) {
+                String facetType = facets[i].facetType().getName();
+                buffer.append("<span class=\"facet-type\">" + facetType .substring(facetType.lastIndexOf('.')
+ 1)  + "</span>:  " + facets[i] + "<br>");
+            }
+        }
+        view.appendln("Facets", buffer.toString());
+    }
+
 }
 

Added: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java?rev=1084356&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
(added)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
Tue Mar 22 21:27:39 2011
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+
+public class DebuggerLink extends AbstractElementProcessor {
+
+    public void process(Request request) {
+        if (request.getContext().isDebugDisabled()) {
+            return;
+        }
+
+        RequestContext context = request.getContext();
+        Object result = context.getVariable(RequestContext.RESULT); 
+        request.appendHtml("<div class=\"debug\">");
+        request.appendHtml("<a href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\"
>...</a>");
+        if (result != null) {
+            request.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\"
target=\"debug\"  title=\"debug instance\">...</a>");
+        }
+        request.appendHtml("</div>");
+    }
+
+    public String getName() {
+        return "debugger";
+    }
+
+}

Propchange: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
Tue Mar 22 21:27:39 2011
@@ -21,6 +21,7 @@
 package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
 
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugHtmlString;
 import org.apache.isis.runtimes.dflt.runtime.context.IsisContext;
 import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
 import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
@@ -33,30 +34,33 @@ public class Diagnostics extends Abstrac
         if (request.getContext().isDebugDisabled()) {
             return;
         }
-        
+
+        String type = request.getOptionalProperty(TYPE, "page");
         boolean isForced = request.isRequested("force");
-        boolean isExcludeVariables = request.isRequested("exclude-variables");
-        boolean isExcludeProcessing = request.isRequested("exclude-processing");
-        if (isForced || request.getContext().getDebug() == RequestContext.Debug.ON) {
-            RequestContext context = request.getContext();
+        if (isForced || request.getContext().showDebugData()) {
             request.appendHtml("<div class=\"debug\">");
-            request.appendHtml("<pre>");  
-            request.appendHtml("URI:  " + context.getUri());
-            request.appendHtml("\n");
-            request.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
-            request.appendHtml("\n");
-            
-            AuthenticationSession session = IsisContext.getAuthenticationSession();
-            request.appendHtml("Session:  " + session.getUserName() + " " + session.getRoles());
-            
-            if (!isExcludeVariables) {
-                request.appendHtml("\n\n");
-                request.appendHtml("<a class=\"option\" target=\"debug\" href=\"debug.app\">Object</a>");
-                context.append(request, "variables");
-            }
-            if (!isExcludeProcessing) {
-                request.appendHtml("\n\n"); 
+            request.appendHtml("<pre>");
+            if ("page".equals(type)) {
+                RequestContext context = request.getContext();
+                request.appendHtml("URI:  " + context.getUri());
+                request.appendHtml("\n");
+                request.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
+                String result = (String) request.getContext().getVariable(RequestContext.RESULT);
+                if (result != null) {
+                    request.appendHtml("\n");
+                    request.appendHtml("Object: " + result);
+                }
+            } else  if ("session".equals(type)) {
+                AuthenticationSession session = IsisContext.getAuthenticationSession();
+                request.appendHtml("Session:  " + session.getUserName() + " " + session.getRoles());
+            } else  if ("variables".equals(type)) {
+                RequestContext context = request.getContext();
+                DebugHtmlString debug = new DebugHtmlString();
+                context.append(debug, "variables");
+            } else  if ("processing".equals(type)) {
                 request.appendHtml(request.getContext().getDebugTrace());      
+            } else {
+                request.appendHtml("<i>No such type " + type + "</i>");
             }
             request.appendHtml("</pre>");
             request.appendHtml("</div>");

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
Tue Mar 22 21:27:39 2011
@@ -20,6 +20,7 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher.view.edit;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
@@ -29,6 +30,8 @@ import org.apache.isis.core.metamodel.fa
 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.choices.enums.EnumFacet;
+import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
 import org.apache.isis.runtimes.dflt.runtime.context.IsisContext;
 import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
 import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
@@ -100,7 +103,7 @@ public class EditObject extends Abstract
         
         request.setBlockContent(containedBlock);
         request.processUtilCloseTag();
-
+        
         AuthenticationSession session = IsisContext.getAuthenticationSession();
         List<ObjectAssociation> fields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(session,
object));
         fields = containedBlock.includedFields(fields);
@@ -118,14 +121,40 @@ public class EditObject extends Abstract
         }
 
         String errorView = context.fullFilePath(forwardErrorTo == null ? context.getResourceFile()
: forwardErrorTo);
-        HiddenInputField[] hiddenFields = new HiddenInputField[] { 
-                new HiddenInputField(OBJECT, actualObjectId),
-                new HiddenInputField(VERSION, version),
-                completionMessage == null ? null : new HiddenInputField(MESSAGE, completionMessage),
-                forwardEditedTo == null ? null : new HiddenInputField(VIEW, context.fullFilePath(forwardEditedTo)),
-                new HiddenInputField(ERRORS, errorView), variable == null ? null : new HiddenInputField(RESULT_NAME,
variable),
-                resultOverride == null ? null : new HiddenInputField(RESULT_OVERRIDE, resultOverride),
-                scope == null ? null : new HiddenInputField(SCOPE, scope) };
+        List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
+        hiddenFields.add(new HiddenInputField(OBJECT, actualObjectId));
+        hiddenFields.add(new HiddenInputField(VERSION, version));
+        hiddenFields.add(completionMessage == null ? null : new HiddenInputField(MESSAGE,
completionMessage));
+        hiddenFields.add(forwardEditedTo == null ? null : new HiddenInputField(VIEW, context.fullFilePath(forwardEditedTo)));
+        hiddenFields.add(new HiddenInputField(ERRORS, errorView));
+        hiddenFields.add(variable == null ? null : new HiddenInputField(RESULT_NAME, variable));
+        hiddenFields.add(resultOverride == null ? null : new HiddenInputField(RESULT_OVERRIDE,
resultOverride));
+        hiddenFields.add(scope == null ? null : new HiddenInputField(SCOPE, scope));
+
+        if (object.isTransient()) {
+            // restore transient details
+            List<ObjectAssociation> fields2 = object.getSpecification().getAssociations();
+            for (int i = 0; i < fields2.size(); i++) {
+                ObjectAssociation field = fields2.get(i);
+                if (!fields.contains(field)) {
+                    String fieldId = field.getId();
+                    String value = getValue(context, field.get(object)); 
+                    hiddenFields.add(new HiddenInputField(fieldId, value));
+                }
+            }
+        } else {
+            // ensure all booleans are included so the pass back TRUE if set. 
+            List<ObjectAssociation> fields2 = object.getSpecification().getAssociations();
+            for (int i = 0; i < fields2.size(); i++) {
+                ObjectAssociation field = fields2.get(i);
+                if (!fields.contains(field) && field.getSpecification().containsFacet(BooleanValueFacet.class))
{
+                    String fieldId = field.getId();
+                    String value = getValue(context, field.get(object)); 
+                    hiddenFields.add(new HiddenInputField(fieldId, value));
+                }
+            }
+            
+        }
 
 
         if (formTitle == null) {
@@ -138,7 +167,8 @@ public class EditObject extends Abstract
             buttonTitle = "Save";
         }
         
-        HtmlFormBuilder.createForm(request, EditAction.ACTION + ".app", hiddenFields, formFields,
className, id, formTitle, null, null, buttonTitle, errors);
+        HiddenInputField[] hiddenFieldArray = hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]);
+        HtmlFormBuilder.createForm(request, EditAction.ACTION + ".app", hiddenFieldArray,
formFields, className, id, formTitle, null, null, buttonTitle, errors);
         request.popBlockContent();
     }
 
@@ -168,19 +198,18 @@ public class EditObject extends Abstract
             InputField formField = formFields[i];
             
             AuthenticationSession session = IsisContext.getAuthenticationSession();
-            if (field.isVisible(session, object).isAllowed() && (includeUnusableFields
|| field.isUsable(session, object).isAllowed())) {
-                ObjectAdapter[] options = field.getChoices(object);
-                FieldFactory.initializeField(context, object, field, options, field.isMandatory(),
formField);
-                
-                Consent usable = field.isUsable(session, object);
-                boolean isEditable = true;
-                isEditable = isEditable && usable.isAllowed();
-                if (usable.isVetoed()) {
-                    formField.setDescription(usable.getReason());
-                }
-                formField.setEditable(isEditable);
-            } else {
-                formFields[i].setHidden(true);
+            Consent usable = field.isUsable(session, object);
+            ObjectAdapter[] options = field.getChoices(object);
+            FieldFactory.initializeField(context, object, field, options, field.isMandatory(),
formField);
+            
+            boolean isEditable =  usable.isAllowed();
+            if (!isEditable) {
+                formField.setDescription(usable.getReason());
+            }
+            formField.setEditable(isEditable);
+            boolean notVisible = field.isVisible(session, object).isVetoed() || (!includeUnusableFields
&& usable.isAllowed());
+            if (notVisible) {
+                formField.setHidden(true);
             }
         }
     }
@@ -279,8 +308,10 @@ public class EditObject extends Abstract
         if (field == null) {
             return "";
         }
-        ParseableFacet facet = field.getSpecification().getFacet(ParseableFacet.class);
-        if (facet == null) {
+        ObjectSpecification specification = field.getSpecification();
+        if (specification.containsFacet(EnumFacet.class)) {
+            return String.valueOf(field.getObject());
+        } else if (specification.getFacet(ParseableFacet.class) == null) {
             return context.mapObject(field, Scope.INTERACTION);
         } else {
             return field.titleString();

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/field/InclusionList.java
Tue Mar 22 21:27:39 2011
@@ -24,13 +24,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import com.google.common.collect.Lists;
-
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
 import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
 
+import com.google.common.collect.Lists;
+
 
 public class InclusionList implements BlockContent {
     private Set<String> includedList = new HashSet<String>();

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/HtmlFormBuilder.java
Tue Mar 22 21:27:39 2011
@@ -167,7 +167,7 @@ public class HtmlFormBuilder {
         int length = options.length;
         boolean offerOther = false;
         for (int i = 0; i < length; i++) {
-            String selectedSegment = field.getValue() == null || options[i].equals(field.getValue())
? " selected=\"selected\"" : "";
+            String selectedSegment = field.getValue() == null || ids[i].equals(field.getValue())
? " selected=\"selected\"" : "";
             if (field.getType() == InputField.TEXT &&  options[i].equals("__other"))
{
                 offerOther = true;
             } else {

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
Tue Mar 22 21:27:39 2011
@@ -393,8 +393,8 @@ class TestVariableExists extends Test {
 
 class TestVariableTrue extends Test {
     boolean test(Request request, String attributeName, String targetId) {
-        String value = (String) request.getContext().getVariable(attributeName);
-        return Attributes.isTrue(value);
+        Boolean value = (Boolean) request.getContext().getVariable(attributeName);
+        return value != null &&  value.booleanValue();
     }
 }
 

Modified: incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java?rev=1084356&r1=1084355&r2=1084356&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/servlet/src/main/java/org/apache/isis/viewer/scimpi/servlet/ServletRequestContext.java
Tue Mar 22 21:27:39 2011
@@ -39,7 +39,7 @@ import org.apache.isis.viewer.scimpi.dis
 import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
 import org.apache.isis.viewer.scimpi.dispatcher.ScimpiNotFoundException;
 import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
-import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugView;
+import org.apache.isis.viewer.scimpi.dispatcher.debug.DebugWriter;
 
 
 public class ServletRequestContext extends RequestContext {
@@ -48,72 +48,72 @@ public class ServletRequestContext exten
     private ServletContext servletContext;
     private boolean isAborted;
 
-    public void append(DebugView view) {
+    public void append(DebugWriter view) {
         /*
         view.divider("System");
         Runtime.getRuntime().
 		*/
-        view.divider("Request");
-        view.appendRow("Auth type", request.getAuthType());
-        view.appendRow("Character encoding", request.getCharacterEncoding());
-        view.appendRow("Class", request.getClass());
-        view.appendRow("Content type", request.getContentType());
-        view.appendRow("Context path", getContextPath());
-        view.appendRow("Locale", request.getLocale());
-        view.appendRow("Method", request.getMethod());
-        view.appendRow("Path info", request.getPathInfo());
-        view.appendRow("Path translated", request.getPathTranslated());
-        view.appendRow("Protocol", request.getProtocol());
-        view.appendRow("Query string", request.getQueryString());
-        view.appendRow("Remote host", request.getRemoteHost());
-        view.appendRow("Remote user", request.getRemoteUser());
-        view.appendRow("Real path", servletContext.getRealPath("/"));
-        view.appendRow("Scheme", request.getScheme());
-        view.appendRow("Server name", request.getServerName());
-        view.appendRow("Servlet path", request.getServletPath());
-        view.appendRow("Session", request.getSession());
-        view.appendRow("Session ID", request.getRequestedSessionId());
-        view.appendRow("URI", request.getRequestURI());
-        view.appendRow("URL", request.getRequestURL());
-        view.appendRow("User principle", request.getUserPrincipal());
+        view.appendTitle("Request");
+        view.appendln("Auth type", request.getAuthType());
+        view.appendln("Character encoding", request.getCharacterEncoding());
+        view.appendln("Class", request.getClass());
+        view.appendln("Content type", request.getContentType());
+        view.appendln("Context path", getContextPath());
+        view.appendln("Locale", request.getLocale());
+        view.appendln("Method", request.getMethod());
+        view.appendln("Path info", request.getPathInfo());
+        view.appendln("Path translated", request.getPathTranslated());
+        view.appendln("Protocol", request.getProtocol());
+        view.appendln("Query string", request.getQueryString());
+        view.appendln("Remote host", request.getRemoteHost());
+        view.appendln("Remote user", request.getRemoteUser());
+        view.appendln("Real path", servletContext.getRealPath("/"));
+        view.appendln("Scheme", request.getScheme());
+        view.appendln("Server name", request.getServerName());
+        view.appendln("Servlet path", request.getServletPath());
+        view.appendln("Session", request.getSession());
+        view.appendln("Session ID", request.getRequestedSessionId());
+        view.appendln("URI", request.getRequestURI());
+        view.appendln("URL", request.getRequestURL());
+        view.appendln("User principle", request.getUserPrincipal());
 
-        view.divider("Cookies");
+        view.appendTitle("Cookies");
         Cookie[] cookies = request.getCookies();
         for (int i = 0; i < cookies.length; i++) {
-            view.appendRow(cookies[i].getName(), cookies[i].getValue());
+            view.appendln(cookies[i].getName(), cookies[i].getValue());
         }
 
         Enumeration attributeNames = request.getAttributeNames();
         if (attributeNames.hasMoreElements()) {
-            view.divider("Attributes");
+            view.appendTitle("Attributes");
             while (attributeNames.hasMoreElements()) {
                 String name = (String) attributeNames.nextElement();
-                view.appendRow(name, request.getAttribute(name));
+                view.appendln(name, request.getAttribute(name));
             }
         }
 
-        view.divider("Headers");
+        view.appendTitle("Headers");
         Enumeration headerNames = request.getHeaderNames();
         while (headerNames.hasMoreElements()) {
             String name = (String) headerNames.nextElement();
-            view.appendRow(name, request.getHeader(name));
+            view.appendln(name, request.getHeader(name));
         }
 
-        view.divider("Parameters");
+        view.appendTitle("Parameters");
         Enumeration parameterNames = request.getParameterNames();
         while (parameterNames.hasMoreElements()) {
             String name = (String) parameterNames.nextElement();
-            view.appendRow(name, request.getParameter(name));
+            view.appendln(name, request.getParameter(name));
         }
 
-        view.divider("Servlet Context");
+        view.appendTitle("Servlet Context");
         ServletContext context = getServletContext();
-        view.appendRow("Name", context.getServletContextName());
-        view.appendRow("Server Info", context.getServerInfo());
-        view.appendRow("Version", context.getMajorVersion() + "." + context.getMinorVersion());
-        view.appendRow("Attributes", getAttributes(context));
-        view.appendRow("Init parameters", getParameters(context));
-        view.appendRow("Real path", context.getRealPath("/"));
+        view.appendln("Name", context.getServletContextName());
+        view.appendln("Server Info", context.getServerInfo());
+        view.appendln("Version", context.getMajorVersion() + "." + context.getMinorVersion());
+        view.appendln("Attributes", getAttributes(context));
+        view.appendln("Init parameters", getParameters(context));
+        view.appendln("Real path", context.getRealPath("/"));
 
         super.append(view);
     }



Mime
View raw message