You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/11/06 08:16:37 UTC

[09/11] isis git commit: ISIS-1151: slight change to behaviour - have 'defaultView' take precedence over 'render'.

ISIS-1151: slight change to behaviour - have 'defaultView' take precedence over 'render'.

Also updating the reference guide.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/2bbf6a72
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/2bbf6a72
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/2bbf6a72

Branch: refs/heads/master
Commit: 2bbf6a72c444c01c25575e24fffeaa60ca81b1e2
Parents: d38cc1f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Nov 6 06:44:31 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri Nov 6 06:44:31 2015 +0000

----------------------------------------------------------------------
 ...rg_annotations_manpage-CollectionLayout.adoc |  9 ++++
 ...ns_manpage-CollectionLayout_defaultView.adoc | 43 ++++++++++++++++++++
 ...ns_manpage-CollectionLayout_describedAs.adoc |  5 ++-
 ...tations_manpage-CollectionLayout_render.adoc |  2 +
 .../selector/CollectionSelectorHelper.java      | 10 ++---
 5 files changed, 62 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/2bbf6a72/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout.adoc b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout.adoc
index 1b46556..2e9699f 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout.adoc
@@ -24,6 +24,14 @@ The table below summarizes the annotation's attributes.
 |the css class that a collection should have, to allow more targetted styling in xref:rg.adoc#_rg_runtime_application-specific_application-css[`application.css`]
 
 
+|xref:rg.adoc#_rg_annotations_manpage-CollectionLayout_defaultView[`defaultView()`]
+|`table`, `excel`, `calendar`, `map`, ...
+|Which view is selected by default, if multiple views are available.
+
+See (non-ASF) link:http://isisaddons.org[Isis Addons] for further views.
+
+
+
 |xref:rg.adoc#_rg_annotations_manpage-CollectionLayout_describedAs[`describedAs()`]
 |String.
 |description of this collection, eg to be rendered in a tooltip.
@@ -114,6 +122,7 @@ so that boilerplate-busting tools such as link:https://projectlombok.org/[Projec
 
 
 include::_rg_annotations_manpage-CollectionLayout_cssClass.adoc[leveloffset=+1]
+include::_rg_annotations_manpage-CollectionLayout_defaultView.adoc[leveloffset=+1]
 include::_rg_annotations_manpage-CollectionLayout_describedAs.adoc[leveloffset=+1]
 include::_rg_annotations_manpage-CollectionLayout_hidden.adoc[leveloffset=+1]
 include::_rg_annotations_manpage-CollectionLayout_named.adoc[leveloffset=+1]

http://git-wip-us.apache.org/repos/asf/isis/blob/2bbf6a72/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_defaultView.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_defaultView.adoc b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_defaultView.adoc
new file mode 100644
index 0000000..359a33e
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_defaultView.adoc
@@ -0,0 +1,43 @@
+[[_rg_annotations_manpage-CollectionLayout_defaultView]]
+= `defaultView()`
+:Notice: 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.
+:_basedir: ../
+:_imagesdir: images/
+
+
+The xref:ug.adoc#_ug_wicket-viewer[Wicket viewer] allows additional views to be configured to render collections of objects; at the time of writing thesee include the (non-ASF) (non-ASF) link:http://isisaddons.org[Isis Addons]' (non-ASF) http://github.com/isisaddons/isis-wicket-excel[excel] view, the http://github.com/isisaddons/isis-wicket-fullcalendar2[fullcalendar2] view, and the http://github.com/isisaddons/isis-wicket-gmap3[gmap3] view.  If the objects to be rendered have the correct "shape", then the appropriate view will be made available.  For example, objects with a date can be rendered using `calendar`; objects with locations can be rendered using `map`.
+
+The `defaultView()` attribute is used to select which of these views should be used by default for a given collection.
+
+
+For example:
+
+[source,java]
+----
+public class BusRoute {
+    @CollectionLayout(
+        defaultView="map"
+    )
+    public SortedSet<BusStop> getStops() { ... }
+    ...
+}
+----
+
+
+As an alternative to using the annotation, the dynamic xref:rg.adoc#_rg_object-layout_dynamic[`.layout.json`]
+can be used instead, eg:
+
+[source,javascript]
+----
+"dependencies": {
+    "collectionLayout": {
+        "defaultView": "map"
+    }
+}
+----
+
+[NOTE]
+====
+This attribute takes precedence over any value for the xref:rg.adoc#_rg_annotations_manpage-CollectionLayout_render[`@CollectionLayout#render()`] attribute.  For example, if the
+`defaultView` attribute is defined to "table", then the table will be show even if `render` is set to `LAZILY`.
+====

http://git-wip-us.apache.org/repos/asf/isis/blob/2bbf6a72/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_describedAs.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_describedAs.adoc b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_describedAs.adoc
index 68cafeb..467ac5a 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_describedAs.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_describedAs.adoc
@@ -16,8 +16,9 @@ For example:
 ----
 public class ToDoItem {
     @CollectionLayout(
-        describedAs="Other todo items that must be completed before this one")
-    public SortedSet<ToDoItem getDependencies() { ... }
+        describedAs="Other todo items that must be completed before this one"
+    )
+    public SortedSet<ToDoItem> getDependencies() { ... }
     ...
 }
 ----

http://git-wip-us.apache.org/repos/asf/isis/blob/2bbf6a72/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_render.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_render.adoc b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_render.adoc
index 6d85f2c..b3298b5 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_render.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rg_annotations_manpage-CollectionLayout_render.adoc
@@ -36,5 +36,7 @@ can be used instead, eg:
 [NOTE]
 ====
 Note that xref:ug.adoc#_ug_how-tos_contributed-members[contributed collections] (which, under the covers are just action invocations against a domain service) are always rendered eagerly.
+
+Also, if a xref:rg.adoc#_rg_annotations_manpage-CollectionLayout_defaultView[`@CollectionLayout#defaultView()`] attribute has been specified then that will take precedence over the value of the `render()` attribute.
 ====
 

http://git-wip-us.apache.org/repos/asf/isis/blob/2bbf6a72/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
index 6380e6b..b35663e 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
@@ -108,17 +108,17 @@ public class CollectionSelectorHelper implements Serializable {
      * otherwise first factory.
      */
     private int determineInitialFactory() {
-        if (!hasRenderEagerlyFacet(model)) {
+        if (hasDefaultViewFacet(model)) {
+            DefaultViewFacet defaultViewFacet = model.getCollectionMemento().getCollection().getFacet(DefaultViewFacet.class);
             for (int i = 0; i < componentFactories.size(); i++) {
-                if (componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
+                if (componentFactories.get(i).getName().equals(defaultViewFacet.value())) {
                     return i;
                 }
             }
         }
-        if (hasDefaultViewFacet(model)) {
-            DefaultViewFacet defaultViewFacet = model.getCollectionMemento().getCollection().getFacet(DefaultViewFacet.class);
+        if (!hasRenderEagerlyFacet(model)) {
             for (int i = 0; i < componentFactories.size(); i++) {
-                if (componentFactories.get(i).getName().equals(defaultViewFacet.value())) {
+                if (componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
                     return i;
                 }
             }