incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1394445 - in /incubator/isis/trunk/framework: applib/src/docbkx/guide/ applib/src/main/java/org/apache/isis/applib/annotation/ core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/facets/ core/metamodel/src/main/java/org/apac...
Date Fri, 05 Oct 2012 11:20:39 GMT
Author: danhaywood
Date: Fri Oct  5 11:20:38 2012
New Revision: 1394445

URL: http://svn.apache.org/viewvc?rev=1394445&view=rev
Log:
ISIS-232: allow property members to be grouped

- new @MemberGroups annotation and corresponding MemberGroupsFacet annotation
- ObjectSpecificationDefault.getAssociations() now includes associations that have been grouped using @MemberOrder(name=...)
  - previously it just ignored them;
  - are returned in 'flattened' form
- Wicket viewer now uses the MemberOrderFacet and MemberGroupsFacet to render properties inside groups

Added:
    incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/annotation/MemberGroups.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/facets/
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/facets/FacetsFacet.java
      - copied, changed from r1394123, incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/facets/FacetsFacet.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/membergroups/
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/membergroups/MemberGroupsFacet.java
      - copied, changed from r1394123, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsFacetAbstract.java
      - copied, changed from r1394123, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsAnnotationElseFallbackFacetFactory.java
      - copied, changed from r1394123, incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetAnnotation.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetFallback.java
      - copied, changed from r1394123, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java
    incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/membergroups/
    incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsAnnotationElseFallbackFacetFactoryTest.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecifications.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/util/
    incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecificationsTest.java
Removed:
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/facets/FacetsFacet.java
Modified:
    incubator/isis/trunk/framework/applib/src/docbkx/guide/isis-applib.xml
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsFacetAbstract.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java
    incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsAnnotationFacetFactoryTest.java
    incubator/isis/trunk/framework/progmodels/dflt/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.html
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.java

Modified: incubator/isis/trunk/framework/applib/src/docbkx/guide/isis-applib.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/applib/src/docbkx/guide/isis-applib.xml?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/applib/src/docbkx/guide/isis-applib.xml (original)
+++ incubator/isis/trunk/framework/applib/src/docbkx/guide/isis-applib.xml Fri Oct  5 11:20:38 2012
@@ -6771,13 +6771,48 @@ public class CustomerFirstName {
         parameters.</para>
       </sect1>
 
+      <sect1 id="sec.MemberGroupsAnnotation">
+        <title>@MemberGroups</title>
+
+        <para><code>@MemberGroups</code> is designed to work in conjunction
+        with <classname>@MemberOrder</classname> (see <xref
+        linkend="sec.MemberOrderAnnotation" />), and specifies the order in
+        which groups of members should be rendered.</para>
+
+        <para>For example:</para>
+
+        <programlisting>@MemberGroups({"General", "Dates", "Other"})
+public Class Customer {
+    @MemberOrder(name="General", sequence="1.1")
+    Public String getFirstName() {...}
+    Public void setFirstName(value as String) {...}
+
+    @MemberOrder(name="General", sequence="1.2")
+    Public String getLastName() {...}
+    Public void setLastName(value as String) {...}
+
+    @MemberOrder(name="Other", sequence="1")
+    Public String getAddress() {...}
+    Public void setAddress(value as String) {...}
+
+    @MemberOrder(name="Dates", sequence="1")
+    Public Date getDateOfBirth() {...}
+    Public void setDateOfBirth(value as Date) {...}
+    ...
+}   </programlisting>
+
+        <para>If the <classname>@MemberOrder</classname>'s name is not
+        specified, then its group is assumed to be
+        "<literal>General</literal>".</para>
+      </sect1>
+
       <sect1 id="sec.MemberOrderAnnotation">
         <title>@MemberOrder</title>
 
         <para><code>@MemberOrder</code> is the recommended mechanism for
         specifying the order in which fields and/or actions are presented to
         the user. (<code>@ActionOrder</code> and <code>@FieldOrder</code>
-        provide alternative mechanisms).</para>
+        provide alternative, deprecated mechanisms).</para>
 
         <para><code>@MemberOrder</code> is specified at the individual member
         level, relative to other members, as a string. The simplest convention
@@ -6791,7 +6826,7 @@ public class CustomerFirstName {
 
         <para>For example:</para>
 
-        <programlisting>Public Class Customer {
+        <programlisting>public Class Customer {
     @MemberOrder(sequence="2.1")
     Public String getAddress() {...}
     Public void setAddress(value as String) {...}
@@ -6823,6 +6858,37 @@ public class CustomerFirstName {
           properties and collections together, and of all actions
           together.</para>
         </note>
+
+        <para>As a refinement to this, some viewers support the notion of
+        grouping members together. In this case the <varname>name</varname>
+        attribute can be specified.</para>
+
+        <para>For example:</para>
+
+        <programlisting>public Class Customer {
+    @MemberOrder(name="General", sequence="1.1")
+    Public String getFirstName() {...}
+    Public void setFirstName(value as String) {...}
+
+    @MemberOrder(name="General", sequence="1.2")
+    Public String getLastName() {...}
+    Public void setLastName(value as String) {...}
+
+    @MemberOrder(name="Other", sequence="1")
+    Public String getAddress() {...}
+    Public void setAddress(value as String) {...}
+
+    @MemberOrder(name="Dates", sequence="1")
+    Public Date getDateOfBirth() {...}
+    Public void setDateOfBirth(value as Date) {...}
+    ...
+}   </programlisting>
+
+        <para>In this case the <varname>sequence</varname> is ordered with
+        respect to the <varname>name</varname>. If using group names in this
+        way, typically the MemberGroups annotation (see <xref
+        linkend="sec.MemberGroupsAnnotation" />) should also be specified,
+        allowing the order of the groups themselves to be sorted.</para>
       </sect1>
 
       <sect1>

Added: incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/annotation/MemberGroups.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/annotation/MemberGroups.java?rev=1394445&view=auto
==============================================================================
--- incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/annotation/MemberGroups.java (added)
+++ incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/annotation/MemberGroups.java Fri Oct  5 11:20:38 2012
@@ -0,0 +1,51 @@
+/*
+ *  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.applib.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that the class has additional facets, and specifies the how to
+ * obtain the <tt>FacetFactory</tt> to manufacture them.
+ * 
+ * <p>
+ * At least one named factory (as per {@link #facetFactoryNames()}) or one class
+ * factory (as per {@link #facetFactoryClasses()}) should be specified.
+ */
+@Inherited
+@Target({ ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface MemberGroups {
+
+    /**
+     * Array of group names, as they appear as names in the {@link MemberOrder} annotation.
+     * 
+     * <p>
+     * The order in this list determines the order that the groups will be rendered.  By convention
+     * any {@link MemberOrder} that does not have a {@link MemberOrder#name() name} is considered
+     * to be in the default group, whose name is hard-coded as <i>General</i>.
+     */
+    String[] value() default {};
+
+}

Copied: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/facets/FacetsFacet.java (from r1394123, incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/facets/FacetsFacet.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/facets/FacetsFacet.java?p2=incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/facets/FacetsFacet.java&p1=incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/facets/FacetsFacet.java&r1=1394123&r2=1394445&rev=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/facets/FacetsFacet.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/facets/FacetsFacet.java Fri Oct  5 11:20:38 2012
@@ -17,8 +17,9 @@
  *  under the License.
  */
 
-package org.apache.isis.core.metamodel.facets.facets;
+package org.apache.isis.core.metamodel.facets.object.facets;
 
+import org.apache.isis.applib.annotation.Facets;
 import org.apache.isis.core.metamodel.facetapi.Facet;
 import org.apache.isis.core.metamodel.facets.FacetFactory;
 import org.apache.isis.core.metamodel.facets.MultipleValueFacet;
@@ -27,7 +28,7 @@ import org.apache.isis.core.metamodel.fa
  * Indicates that this class has additional arbitrary facets, to be processed.
  * 
  * <p>
- * Corresponds to the <tt>@Facets</tt> annotation in the applib.
+ * Corresponds to the {@link Facets} annotation in the applib.
  * 
  * <p>
  * <i>This</i> {@link Facet} allows the {@link FacetFactory}(s) that will create

Copied: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/membergroups/MemberGroupsFacet.java (from r1394123, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/membergroups/MemberGroupsFacet.java?p2=incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/membergroups/MemberGroupsFacet.java&p1=incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java&r1=1394123&r2=1394445&rev=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/membergroups/MemberGroupsFacet.java Fri Oct  5 11:20:38 2012
@@ -17,25 +17,25 @@
  *  under the License.
  */
 
-package org.apache.isis.viewer.wicket.model.util;
+package org.apache.isis.core.metamodel.facets.object.membergroups;
 
-import com.google.common.base.Function;
+import java.util.List;
 
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-
-public final class ObjectAssociations {
-
-    private ObjectAssociations() {
-    }
-
-    public static Function<String, OneToOneAssociation> fromId(final ObjectSpecification noSpec) {
-        return new Function<String, OneToOneAssociation>() {
-            @Override
-            public OneToOneAssociation apply(final String from) {
-                return (OneToOneAssociation) noSpec.getAssociation(from);
-            }
-        };
-    }
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.core.metamodel.facets.SingleValueFacet;
+import org.apache.isis.core.metamodel.facets.members.order.MemberOrderFacet;
+
+/**
+ * Indicates the order in which the member groups (as defined by {@link MemberOrderFacet})
+ * should be rendered.
+ * 
+ * <p>
+ * Corresponds to the {@link MemberOrder} annotation in the applib.
+ */
+public interface MemberGroupsFacet extends SingleValueFacet<List<String>> {
 
+    /**
+     * The default group if not otherwise specified.
+     */
+    public final static String DEFAULT_GROUP = "General";
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java Fri Oct  5 11:20:38 2012
@@ -42,7 +42,7 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessClassContext;
 import org.apache.isis.core.metamodel.facets.FacetedMethod;
 import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.facets.facets.FacetsFacet;
+import org.apache.isis.core.metamodel.facets.object.facets.FacetsFacet;
 import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
 import org.apache.isis.core.metamodel.methodutils.MethodFinderUtils;
 import org.apache.isis.core.metamodel.methodutils.MethodScope;

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java Fri Oct  5 11:20:38 2012
@@ -183,7 +183,7 @@ public class ObjectSpecificationDefault 
 
         if(isNotIntrospected()) {
             final OrderSet associationOrderSet = getMemberLayoutArranger().createAssociationOrderSetFor(this, associationFacetedMethods);
-            updateAssociations(asAssociations(associationOrderSet));
+            updateAssociations(asFlattenedAssociations(associationOrderSet));
         }
 
         if(isNotIntrospected()) {
@@ -218,11 +218,17 @@ public class ObjectSpecificationDefault 
         }
     }
 
-    private List<ObjectAssociation> asAssociations(final OrderSet orderSet) {
+    private List<ObjectAssociation> asFlattenedAssociations(final OrderSet orderSet) {
         if (orderSet == null) {
             return null;
         }
         final List<ObjectAssociation> associations = Lists.newArrayList();
+        addAssociations(orderSet, associations);
+
+        return associations;
+    }
+
+    private void addAssociations(final OrderSet orderSet, final List<ObjectAssociation> associations) {
         for (final Object element : orderSet) {
             if (element instanceof FacetedMethod) {
                 final FacetedMethod facetMethod = (FacetedMethod) element;
@@ -232,13 +238,13 @@ public class ObjectSpecificationDefault 
                     associations.add(createProperty(facetMethod));
                 }
             } else if (element instanceof OrderSet) {
-                // Not supported at present
+                // just flatten.
+                OrderSet childOrderSet = (OrderSet) element;
+                addAssociations(childOrderSet, associations);
             } else {
                 throw new UnknownTypeException(element);
             }
         }
-
-        return associations;
     }
 
     private List<ObjectAction> asObjectActions(final OrderSet orderSet) {

Modified: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsFacetAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsFacetAbstract.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsFacetAbstract.java (original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsFacetAbstract.java Fri Oct  5 11:20:38 2012
@@ -28,7 +28,7 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.metamodel.facets.FacetFactory;
-import org.apache.isis.core.metamodel.facets.facets.FacetsFacet;
+import org.apache.isis.core.metamodel.facets.object.facets.FacetsFacet;
 
 public abstract class FacetsFacetAbstract extends FacetAbstract implements FacetsFacet {
 

Modified: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java (original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java Fri Oct  5 11:20:38 2012
@@ -25,7 +25,7 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facetapi.FeatureType;
 import org.apache.isis.core.metamodel.facets.Annotations;
 import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.facets.FacetsFacet;
+import org.apache.isis.core.metamodel.facets.object.facets.FacetsFacet;
 
 public class FacetsAnnotationFacetFactory extends FacetFactoryAbstract {
 

Copied: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsFacetAbstract.java (from r1394123, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsFacetAbstract.java?p2=incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsFacetAbstract.java&p1=incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java&r1=1394123&r2=1394445&rev=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java (original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsFacetAbstract.java Fri Oct  5 11:20:38 2012
@@ -17,25 +17,22 @@
  *  under the License.
  */
 
-package org.apache.isis.viewer.wicket.model.util;
+package org.apache.isis.core.progmodel.facets.object.membergroups;
 
-import com.google.common.base.Function;
+import java.util.List;
 
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.SingleValueFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupsFacet;
 
-public final class ObjectAssociations {
+public abstract class MemberGroupsFacetAbstract extends SingleValueFacetAbstract<List<String>> implements MemberGroupsFacet {
 
-    private ObjectAssociations() {
+    public static Class<? extends Facet> type() {
+        return MemberGroupsFacet.class;
     }
 
-    public static Function<String, OneToOneAssociation> fromId(final ObjectSpecification noSpec) {
-        return new Function<String, OneToOneAssociation>() {
-            @Override
-            public OneToOneAssociation apply(final String from) {
-                return (OneToOneAssociation) noSpec.getAssociation(from);
-            }
-        };
+    public MemberGroupsFacetAbstract(List<String> value, FacetHolder holder) {
+        super(type(), value, holder);
     }
-
 }

Copied: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsAnnotationElseFallbackFacetFactory.java (from r1394123, incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsAnnotationElseFallbackFacetFactory.java?p2=incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsAnnotationElseFallbackFacetFactory.java&p1=incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java&r1=1394123&r2=1394445&rev=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/facets/annotation/FacetsAnnotationFacetFactory.java (original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsAnnotationElseFallbackFacetFactory.java Fri Oct  5 11:20:38 2012
@@ -17,25 +17,26 @@
  *  under the License.
  */
 
-package org.apache.isis.core.progmodel.facets.object.facets.annotation;
+package org.apache.isis.core.progmodel.facets.object.membergroups.annotation;
 
-import org.apache.isis.applib.annotation.Facets;
+import org.apache.isis.applib.annotation.MemberGroups;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.metamodel.facetapi.FacetUtil;
 import org.apache.isis.core.metamodel.facetapi.FeatureType;
 import org.apache.isis.core.metamodel.facets.Annotations;
 import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.facets.FacetsFacet;
+import org.apache.isis.core.metamodel.facets.object.facets.FacetsFacet;
+import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupsFacet;
 
-public class FacetsAnnotationFacetFactory extends FacetFactoryAbstract {
+public class MemberGroupsAnnotationElseFallbackFacetFactory extends FacetFactoryAbstract {
 
-    public FacetsAnnotationFacetFactory() {
+    public MemberGroupsAnnotationElseFallbackFacetFactory() {
         super(FeatureType.OBJECTS_ONLY);
     }
 
     @Override
     public void process(final ProcessClassContext processClassContaxt) {
-        final Facets annotation = Annotations.getAnnotation(processClassContaxt.getCls(), Facets.class);
+        final MemberGroups annotation = Annotations.getAnnotation(processClassContaxt.getCls(), MemberGroups.class);
         FacetUtil.addFacet(create(annotation, processClassContaxt.getFacetHolder()));
     }
 
@@ -43,12 +44,10 @@ public class FacetsAnnotationFacetFactor
      * Returns a {@link FacetsFacet} impl provided that at least one valid
      * {@link FacetsFacet#facetFactories() factory} was specified.
      */
-    private FacetsFacet create(final Facets annotation, final FacetHolder holder) {
+    private MemberGroupsFacet create(final MemberGroups annotation, final FacetHolder holder) {
         if (annotation == null) {
-            return null;
+            return new MemberGroupsFacetFallback(holder);
         }
-        final FacetsFacetAnnotation facetsFacetAnnotation = new FacetsFacetAnnotation(annotation, holder);
-        return facetsFacetAnnotation.facetFactories().length > 0 ? facetsFacetAnnotation : null;
+        return new MemberGroupsFacetAnnotation(annotation, holder);
     }
-
 }

Added: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetAnnotation.java?rev=1394445&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetAnnotation.java (added)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetAnnotation.java Fri Oct  5 11:20:38 2012
@@ -0,0 +1,42 @@
+/*
+ *  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.core.progmodel.facets.object.membergroups.annotation;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.isis.applib.annotation.MemberGroups;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupsFacet;
+import org.apache.isis.core.progmodel.facets.object.membergroups.MemberGroupsFacetAbstract;
+
+public class MemberGroupsFacetAnnotation extends MemberGroupsFacetAbstract {
+
+    private static List<String> asList(final String[] value) {
+        return value == null || value.length == 0 
+                ? Arrays.asList(MemberGroupsFacet.DEFAULT_GROUP) 
+                : Arrays.asList(value);
+    }
+    
+    public MemberGroupsFacetAnnotation(final MemberGroups annotation, final FacetHolder holder) {
+        super(asList(annotation.value()), holder);
+    }
+
+}

Copied: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetFallback.java (from r1394123, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetFallback.java?p2=incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetFallback.java&p1=incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java&r1=1394123&r2=1394445&rev=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java (original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/object/membergroups/annotation/MemberGroupsFacetFallback.java Fri Oct  5 11:20:38 2012
@@ -17,25 +17,18 @@
  *  under the License.
  */
 
-package org.apache.isis.viewer.wicket.model.util;
+package org.apache.isis.core.progmodel.facets.object.membergroups.annotation;
 
-import com.google.common.base.Function;
+import java.util.Arrays;
 
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupsFacet;
+import org.apache.isis.core.progmodel.facets.object.membergroups.MemberGroupsFacetAbstract;
 
-public final class ObjectAssociations {
+public class MemberGroupsFacetFallback extends MemberGroupsFacetAbstract {
 
-    private ObjectAssociations() {
-    }
-
-    public static Function<String, OneToOneAssociation> fromId(final ObjectSpecification noSpec) {
-        return new Function<String, OneToOneAssociation>() {
-            @Override
-            public OneToOneAssociation apply(final String from) {
-                return (OneToOneAssociation) noSpec.getAssociation(from);
-            }
-        };
+    public MemberGroupsFacetFallback(final FacetHolder holder) {
+        super(Arrays.asList(MemberGroupsFacet.DEFAULT_GROUP), holder);
     }
 
 }

Modified: incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsAnnotationFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsAnnotationFacetFactoryTest.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsAnnotationFacetFactoryTest.java (original)
+++ incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/facets/FacetsAnnotationFacetFactoryTest.java Fri Oct  5 11:20:38 2012
@@ -26,7 +26,7 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facetapi.FeatureType;
 import org.apache.isis.core.metamodel.facets.FacetFactory;
 import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessClassContext;
-import org.apache.isis.core.metamodel.facets.facets.FacetsFacet;
+import org.apache.isis.core.metamodel.facets.object.facets.FacetsFacet;
 import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
 import org.apache.isis.core.progmodel.facets.object.facets.annotation.FacetsAnnotationFacetFactory;
 import org.apache.isis.core.progmodel.facets.object.facets.annotation.FacetsFacetAnnotation;

Added: incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsAnnotationElseFallbackFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsAnnotationElseFallbackFacetFactoryTest.java?rev=1394445&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsAnnotationElseFallbackFacetFactoryTest.java (added)
+++ incubator/isis/trunk/framework/core/progmodel/src/test/java/org/apache/isis/core/progmodel/facets/object/membergroups/MemberGroupsAnnotationElseFallbackFacetFactoryTest.java Fri Oct  5 11:20:38 2012
@@ -0,0 +1,103 @@
+/*
+ *  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.core.progmodel.facets.object.membergroups;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.isis.applib.annotation.MemberGroups;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessClassContext;
+import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupsFacet;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.core.progmodel.facets.object.membergroups.annotation.MemberGroupsAnnotationElseFallbackFacetFactory;
+import org.apache.isis.core.progmodel.facets.object.membergroups.annotation.MemberGroupsFacetAnnotation;
+import org.apache.isis.core.progmodel.facets.object.membergroups.annotation.MemberGroupsFacetFallback;
+
+public class MemberGroupsAnnotationElseFallbackFacetFactoryTest extends AbstractFacetFactoryTest {
+
+    private MemberGroupsAnnotationElseFallbackFacetFactory facetFactory;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        facetFactory = new MemberGroupsAnnotationElseFallbackFacetFactory();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        facetFactory = null;
+        super.tearDown();
+    }
+
+    @MemberGroups({"General","Foo", "Bar"})
+    public static class ClassWithMemberGroupsAnnotation {
+        
+    }
+    
+    @MemberGroups()
+    public static class ClassWithMemberGroupsAnnotationButNoGroupsNamed {
+    }
+    
+    public static class ClassWithoutMemberGroupsAnnotation {
+    }
+    
+
+    public void testWithMemberGroups() {
+        facetFactory.process(new ProcessClassContext(ClassWithMemberGroupsAnnotation.class, methodRemover, facetHolder));
+
+        final Facet facet = facetHolder.getFacet(MemberGroupsFacet.class);
+        assertNotNull(facet);
+        assertTrue(facet instanceof MemberGroupsFacetAnnotation);
+        final MemberGroupsFacetAnnotation memberGroupsFacet = (MemberGroupsFacetAnnotation) facet;
+        final List<String> groupNames = memberGroupsFacet.value();
+        assertEquals(Arrays.asList("General", "Foo", "Bar"), groupNames);
+
+        assertNoMethodsRemoved();
+    }
+
+    public void testWithMemberGroupsButNoGroupsNamed() {
+        facetFactory.process(new ProcessClassContext(ClassWithMemberGroupsAnnotationButNoGroupsNamed.class, methodRemover, facetHolder));
+
+        final Facet facet = facetHolder.getFacet(MemberGroupsFacet.class);
+        assertNotNull(facet);
+        assertTrue(facet instanceof MemberGroupsFacetAnnotation);
+        final MemberGroupsFacetAnnotation memberGroupsFacet = (MemberGroupsFacetAnnotation) facet;
+        final List<String> groupNames = memberGroupsFacet.value();
+        assertEquals(Arrays.asList("General"), groupNames);
+
+        assertNoMethodsRemoved();
+    }
+
+    public void testWithoutMemberGroups() {
+        facetFactory.process(new ProcessClassContext(ClassWithoutMemberGroupsAnnotation.class, methodRemover, facetHolder));
+
+        final Facet facet = facetHolder.getFacet(MemberGroupsFacet.class);
+        assertNotNull(facet);
+        assertTrue(facet instanceof MemberGroupsFacetFallback);
+        final MemberGroupsFacetFallback memberGroupsFacet = (MemberGroupsFacetFallback) facet;
+        final List<String> groupNames = memberGroupsFacet.value();
+        assertEquals(Arrays.asList("General"), groupNames);
+
+        assertNoMethodsRemoved();
+    }
+
+}

Modified: incubator/isis/trunk/framework/progmodels/dflt/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/dflt/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/dflt/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java (original)
+++ incubator/isis/trunk/framework/progmodels/dflt/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java Fri Oct  5 11:20:38 2012
@@ -92,6 +92,7 @@ import org.apache.isis.core.progmodel.fa
 import org.apache.isis.core.progmodel.facets.object.immutable.markerifc.ImmutableMarkerInterfaceFacetFactory;
 import org.apache.isis.core.progmodel.facets.object.mask.annotation.MaskAnnotationForTypeFacetFactory;
 import org.apache.isis.core.progmodel.facets.object.maxlen.annotation.MaxLengthAnnotationForTypeFacetFactory;
+import org.apache.isis.core.progmodel.facets.object.membergroups.annotation.MemberGroupsAnnotationElseFallbackFacetFactory;
 import org.apache.isis.core.progmodel.facets.object.multiline.annotation.MultiLineAnnotationOnTypeFacetFactory;
 import org.apache.isis.core.progmodel.facets.object.named.annotation.NamedAnnotationOnTypeFacetFactory;
 import org.apache.isis.core.progmodel.facets.object.named.staticmethod.NamedFacetViaSingularNameStaticMethodFacetFactory;
@@ -281,7 +282,11 @@ public class ProgrammingModelFacetsJava5
         addFactory(TitleAnnotationFacetFactory.class);
         addFactory(TitleMethodFacetFactory.class);
 
+        addFactory(MemberOrderAnnotationFacetFactory.class);
         addFactory(ActionOrderAnnotationFacetFactory.class);
+        addFactory(FieldOrderAnnotationFacetFactory.class);
+        addFactory(MemberGroupsAnnotationElseFallbackFacetFactory.class);
+        
         addFactory(AggregatedAnnotationFacetFactory.class);
         addFactory(BoundedAnnotationFacetFactory.class);
         addFactory(BoundedMarkerInterfaceFacetFactory.class);
@@ -302,7 +307,6 @@ public class ProgrammingModelFacetsJava5
         addFactory(NotContributedAnnotationFacetFactory.class);
         addFactory(NotInServiceMenuAnnotationFacetFactory.class);
         addFactory(NotInServiceMenuMethodFacetFactory.class);
-        addFactory(FieldOrderAnnotationFacetFactory.class);
 
         addFactory(HiddenAnnotationForTypeFacetFactory.class);
         // must come after the TitleAnnotationFacetFactory, because can act as an override
@@ -323,8 +327,6 @@ public class ProgrammingModelFacetsJava5
         addFactory(MaxLengthAnnotationForPropertyFacetFactory.class);
         addFactory(MaxLengthAnnotationForParameterFacetFactory.class);
 
-        addFactory(MemberOrderAnnotationFacetFactory.class);
-
         addFactory(MustSatisfySpecificationOnTypeFacetFactory.class);
         addFactory(MustSatisfySpecificationOnPropertyFacetFactory.class);
         addFactory(MustSatisfySpecificationOnParameterFacetFactory.class);
@@ -353,12 +355,10 @@ public class ProgrammingModelFacetsJava5
 
         addFactory(AutoCompleteAnnotationFacetFactory.class);
 
-
         // must come after any facets that install titles
         addFactory(MaskAnnotationForTypeFacetFactory.class);
         addFactory(MaskAnnotationForPropertyFacetFactory.class);
         addFactory(MaskAnnotationForParameterFacetFactory.class);
-        
 
         // must come after any facets that install titles, and after mask
         // if takes precedence over mask.

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectAssociations.java Fri Oct  5 11:20:38 2012
@@ -19,9 +19,17 @@
 
 package org.apache.isis.viewer.wicket.model.util;
 
+import java.util.List;
+import java.util.Map;
+
 import com.google.common.base.Function;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 
+import org.apache.isis.core.metamodel.facets.members.order.MemberOrderFacet;
 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.OneToOneAssociation;
 
 public final class ObjectAssociations {
@@ -38,4 +46,34 @@ public final class ObjectAssociations {
         };
     }
 
+    public static Map<String, List<ObjectAssociation>> groupByMemberOrderName(List<ObjectAssociation> associations) {
+        Map<String, List<ObjectAssociation>> associationsByGroup = Maps.newHashMap();
+        for(ObjectAssociation association: associations) {
+            addAssociationIntoGroup(associationsByGroup, association);
+        }
+        return associationsByGroup;
+    }
+
+    private static void addAssociationIntoGroup(Map<String, List<ObjectAssociation>> associationsByGroup, ObjectAssociation association) {
+        final MemberOrderFacet memberOrderFacet = association.getFacet(MemberOrderFacet.class);
+        if(memberOrderFacet != null) {
+            final String name = memberOrderFacet.name();
+            if(!Strings.isNullOrEmpty(name)) {
+                getFrom(associationsByGroup, name).add(association);
+                return;
+            }
+        }
+        getFrom(associationsByGroup, "General").add(association);
+    }
+
+    private static List<ObjectAssociation> getFrom(Map<String, List<ObjectAssociation>> associationsByGroup, final String groupName) {
+        List<ObjectAssociation> list = associationsByGroup.get(groupName);
+        if(list == null) {
+            list = Lists.newArrayList();
+            associationsByGroup.put(groupName, list);
+        }
+        return list;
+    }
+
+
 }

Added: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecifications.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecifications.java?rev=1394445&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecifications.java (added)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecifications.java Fri Oct  5 11:20:38 2012
@@ -0,0 +1,63 @@
+/*
+ *  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.wicket.model.util;
+
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupsFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+
+public final class ObjectSpecifications {
+
+    private ObjectSpecifications() {
+    }
+
+    public static List<String> orderByMemberGroups(ObjectSpecification objSpec, Set<String> groupNamesToOrder) {
+        final MemberGroupsFacet facet = objSpec.getFacet(MemberGroupsFacet.class);
+        final List<String> groupNames = Lists.newArrayList(groupNamesToOrder);
+        
+        // not expected to happen
+        if(facet == null) {
+            return groupNames;
+        }
+        
+        final List<String> groupNamedInRequiredOrder = facet.value();
+        return order(groupNames, groupNamedInRequiredOrder);
+    }
+
+    static List<String> order(final List<String> valuesToOrder, final List<String> valuesInRequiredOrder) {
+        int i=0;
+        for(String memberGroup: valuesInRequiredOrder) {
+            if(valuesToOrder.contains(memberGroup)) {
+                // move to next position
+                valuesToOrder.remove(memberGroup);
+                valuesToOrder.add(i++, memberGroup);
+            }
+        }
+        
+        return valuesToOrder;
+    }
+
+
+}

Added: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecificationsTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecificationsTest.java?rev=1394445&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecificationsTest.java (added)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/util/ObjectSpecificationsTest.java Fri Oct  5 11:20:38 2012
@@ -0,0 +1,82 @@
+/*
+ *  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.wicket.model.util;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class ObjectSpecificationsTest {
+    
+    @Parameters
+    public static Collection<Object[][]> data() {
+        return Arrays.asList(new Object[][][]{
+                {
+                    {"X","Y","Z"}, {"X","Y","Z"}, {"X","Y","Z"},
+                },
+                {
+                    {"X","Y","Z"}, {"A","B","C"}, {"X","Y","Z"}
+                },
+                {
+                    {"X","Y","Z"}, {"Z","B","C"}, {"Z","X","Y"}
+                },
+                {
+                    {"X","Y","Z"}, {"Z","Y","X"}, {"Z","Y","X"}
+                },
+                {
+                    {"Dates","General"}, {"General"}, {"General","Dates"}
+                },
+        });
+    }
+
+    private static List<String> asListOfStrings(Object[] values) {
+        final List<String> list = Lists.newArrayList();
+        for(Object value: values) {
+            list.add((String) value);
+        }
+        return list;
+    }
+
+    private final List<String> valuesToOrder;
+    private final List<String> valuesInRequiredOrder;
+    private final List<String> expected;
+     
+    public ObjectSpecificationsTest(Object[] valuesToOrder, Object[] valuesInRequiredOrder, Object[] expected) {
+        this.valuesToOrder = asListOfStrings(valuesToOrder);
+        this.valuesInRequiredOrder = asListOfStrings(valuesInRequiredOrder);
+        this.expected = asListOfStrings(expected);
+    }
+    
+    @Test
+    public void test() throws Exception {
+        assertThat(ObjectSpecifications.order(valuesToOrder, valuesInRequiredOrder), is(expected));
+    }
+}

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.html
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/EntityPropertiesPanel.html?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.html (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.html Fri Oct  5 11:20:38 2012
@@ -24,7 +24,7 @@
 			    <form wicket:id="entityProperties" class="inputForm">
 			    	<div class="inputFormTable properties">
 		    	    	<fieldset wicket:id="memberGroup" class="memberGroup">
-		    	    		<legend>General</legend>
+		    	    		<legend wicket:id="memberGroupName">[group name]</legend>
 					    	<div wicket:id="properties">
 				              <div wicket:id="property" class="property">[property]</div>
 					    	</div>

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.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/EntityPropertiesPanel.java?rev=1394445&r1=1394444&r2=1394445&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/blocks/propcoll/EntityPropertiesPanel.java Fri Oct  5 11:20:38 2012
@@ -20,12 +20,14 @@
 package org.apache.isis.viewer.wicket.ui.components.entity.blocks.propcoll;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.wicket.Component;
 import org.apache.wicket.Session;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.feedback.FeedbackMessage;
 import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.form.Button;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.FormComponent;
@@ -52,6 +54,8 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.viewer.wicket.model.mementos.PropertyMemento;
 import org.apache.isis.viewer.wicket.model.models.EntityModel;
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+import org.apache.isis.viewer.wicket.model.util.ObjectAssociations;
+import org.apache.isis.viewer.wicket.model.util.ObjectSpecifications;
 import org.apache.isis.viewer.wicket.ui.ComponentType;
 import org.apache.isis.viewer.wicket.ui.components.widgets.formcomponent.CancelHintRequired;
 import org.apache.isis.viewer.wicket.ui.panels.AjaxButtonWithPreSubmitHook;
@@ -68,8 +72,8 @@ public class EntityPropertiesPanel exten
 
     private static final long serialVersionUID = 1L;
 
-    private static final String ID_MEMBER_GROUP = "memberGroup";
     private static final String ID_ENTITY_PROPERTIES = "entityProperties";
+    
 
     private PropCollForm form;
 
@@ -99,6 +103,9 @@ public class EntityPropertiesPanel exten
 
         private static final long serialVersionUID = 1L;
 
+        private static final String ID_MEMBER_GROUP = "memberGroup";
+        private static final String ID_MEMBER_GROUP_NAME = "memberGroupName";
+
         private static final String ID_PROPERTIES = "properties";
         private static final String ID_PROPERTY = "property";
         private static final String ID_EDIT_BUTTON = "edit";
@@ -137,30 +144,40 @@ public class EntityPropertiesPanel exten
         private void addPropertiesAndOrCollections() {
             final EntityModel entityModel = (EntityModel) getModel();
             final ObjectAdapter adapter = entityModel.getObject();
-            final ObjectSpecification noSpec = adapter.getSpecification();
+            final ObjectSpecification objSpec = adapter.getSpecification();
 
-            final List<ObjectAssociation> associations = visibleAssociations(adapter, noSpec, Where.OBJECT_FORMS);
+            final List<ObjectAssociation> associations = visibleAssociations(adapter, objSpec, Where.OBJECT_FORMS);
 
             final RepeatingView memberGroupRv = new RepeatingView(ID_MEMBER_GROUP);
             add(memberGroupRv);
-            final WebMarkupContainer memberGroupRvContainer = new WebMarkupContainer(memberGroupRv.newChildId());
-            memberGroupRv.add(memberGroupRvContainer);
+
+            Map<String, List<ObjectAssociation>> associationsByGroup = ObjectAssociations.groupByMemberOrderName(associations);
+            final List<String> groupNames = ObjectSpecifications.orderByMemberGroups(objSpec, associationsByGroup.keySet());
             
-            final RepeatingView propertyRv = new RepeatingView(ID_PROPERTIES);
-            final EvenOrOddCssClassAppenderFactory eo = new EvenOrOddCssClassAppenderFactory();
-            memberGroupRvContainer.add(propertyRv);
-
-            @SuppressWarnings("unused")
-            Component component;
-            for (final ObjectAssociation association : associations) {
-                final WebMarkupContainer propertyRvContainer = new WebMarkupContainer(propertyRv.newChildId());
-                propertyRv.add(propertyRvContainer);
-                propertyRvContainer.add(eo.nextClass());
-                addPropertyToForm(entityModel, association, propertyRvContainer);
+            for(String groupName: groupNames) {
+                final List<ObjectAssociation> associationsInGroup = associationsByGroup.get(groupName);
+
+                final WebMarkupContainer memberGroupRvContainer = new WebMarkupContainer(memberGroupRv.newChildId());
+                memberGroupRv.add(memberGroupRvContainer);
+                memberGroupRvContainer.add(new Label(ID_MEMBER_GROUP_NAME, groupName));
+
+
+                final RepeatingView propertyRv = new RepeatingView(ID_PROPERTIES);
+                final EvenOrOddCssClassAppenderFactory eo = new EvenOrOddCssClassAppenderFactory();
+                memberGroupRvContainer.add(propertyRv);
+
+                @SuppressWarnings("unused")
+                Component component;
+                for (final ObjectAssociation association : associationsInGroup) {
+                    final WebMarkupContainer propertyRvContainer = new WebMarkupContainer(propertyRv.newChildId());
+                    propertyRv.add(propertyRvContainer);
+                    propertyRvContainer.add(eo.nextClass());
+                    addPropertyToForm(entityModel, association, propertyRvContainer);
+                }
             }
         }
 
-		private void addPropertyToForm(final EntityModel entityModel,
+        private void addPropertyToForm(final EntityModel entityModel,
 				final ObjectAssociation association,
 				final WebMarkupContainer container) {
 			final OneToOneAssociation otoa = (OneToOneAssociation) association;



Mime
View raw message