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 2016/02/09 00:39:05 UTC

[2/3] isis git commit: ISIS-993: changed the suppression algorithm: now, will render any tab group with only a single tab as that tab's rows. This allows tab groups to alternate with field sets etc.

ISIS-993: changed the suppression algorithm: now, will render any tab group with only a single tab as that tab's rows.  This allows tab groups to alternate with field sets etc.


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

Branch: refs/heads/ISIS-993
Commit: 082916aeb4dcf34949789b0fa01caf47b27437b9
Parents: 2ae2df1
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Feb 8 09:34:04 2016 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Feb 8 09:34:04 2016 +0000

----------------------------------------------------------------------
 .../ui/components/layout/bs3/col/Col.java       | 80 +++++++++++---------
 .../dom/simple/SimpleObject.layout.xml          | 12 ++-
 2 files changed, 53 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/082916ae/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
index 643a32d..a2b8fbb 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
@@ -145,56 +145,49 @@ public class Col extends PanelAbstract<EntityModel> {
 
         // rows
         final List<BS3Row> rows = Lists.newArrayList(this.bs3Col.getRows());
-        final List<BS3TabGroup> tabGroups = bs3Col.getTabGroups();
-        final List<BS3TabGroup> tabGroupsWithTabs =
-                FluentIterable.from(bs3Col.getTabGroups())
-                .filter(new Predicate<BS3TabGroup>() {
-                    @Override public boolean apply(@Nullable final BS3TabGroup bs3TabGroup) {
-                        return !bs3TabGroup.getTabs().isEmpty();
-                    }
-                }).toList();
-        BS3Tab singleTabIfAny = null;
-        if(tabGroupsWithTabs.size() == 1) {
-            final BS3TabGroup firstTabGroup = tabGroupsWithTabs.get(0);
-            final List<BS3Tab> firstTabGroupTabs = firstTabGroup.getTabs();
-            if(firstTabGroupTabs.size() == 1) {
-                singleTabIfAny = firstTabGroupTabs.get(0);
-            }
-        }
-        if(singleTabIfAny != null) {
-            rows.addAll(singleTabIfAny.getRows());
-        }
-
         if(!rows.isEmpty()) {
-            final RepeatingView rowRv = new RepeatingView(ID_ROWS);
-
-            for(final BS3Row bs3Row: rows) {
-
-                final String id = rowRv.newChildId();
-                final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(bs3Row);
-
-                final WebMarkupContainer row = new Row(id, entityModelWithHints);
-
-                rowRv.add(row);
-            }
-            div.add(rowRv);
+            final RepeatingView rowsRv = buildRows(ID_ROWS, rows);
+            div.add(rowsRv);
         } else {
             Components.permanentlyHide(div, ID_ROWS);
         }
 
 
         // tab groups
-        if(!tabGroupsWithTabs.isEmpty() && singleTabIfAny == null) {
+        final List<BS3TabGroup> tabGroupsWithTabs =
+                FluentIterable.from(bs3Col.getTabGroups())
+                        .filter(new Predicate<BS3TabGroup>() {
+                            @Override public boolean apply(@Nullable final BS3TabGroup bs3TabGroup) {
+                                return !bs3TabGroup.getTabs().isEmpty();
+                            }
+                        }).toList();
+        if(!tabGroupsWithTabs.isEmpty()) {
             final RepeatingView tabGroupRv = new RepeatingView(ID_TAB_GROUPS);
 
             for (BS3TabGroup bs3TabGroup : tabGroupsWithTabs) {
 
                 final String id = tabGroupRv.newChildId();
-                final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(bs3TabGroup);
-
-                final WebMarkupContainer tabGroup = new TabGroupPanel(id, entityModelWithHints);
+                final List<BS3Tab> tabs = bs3TabGroup.getTabs();
+                switch (tabs.size()) {
+                case 0:
+                    // shouldn't occur; previously have filtered these out
+                    throw new IllegalStateException("Cannot render tabGroup with no tabs");
+                case 1:
+                    final BS3Tab bs3Tab = tabs.get(0);
+                    // render the rows of the one-and-only tab of this tab group.
+                    final List<BS3Row> tabRows = bs3Tab.getRows();
+                    final RepeatingView rowsRv = buildRows(id, tabRows);
+                    tabGroupRv.add(rowsRv);
+                    break;
+                default:
+                    final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(bs3TabGroup);
+
+                    final WebMarkupContainer tabGroup = new TabGroupPanel(id, entityModelWithHints);
+
+                    tabGroupRv.add(tabGroup);
+                    break;
+                }
 
-                tabGroupRv.add(tabGroup);
             }
             div.add(tabGroupRv);
         } else {
@@ -243,7 +236,20 @@ public class Col extends PanelAbstract<EntityModel> {
 
     }
 
+    private RepeatingView buildRows(final String owningId, final List<BS3Row> rows) {
+        final RepeatingView rowRv = new RepeatingView(owningId);
 
+        for(final BS3Row bs3Row: rows) {
+
+            final String id = rowRv.newChildId();
+            final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(bs3Row);
+
+            final WebMarkupContainer row = new Row(id, entityModelWithHints);
+
+            rowRv.add(row);
+        }
+        return rowRv;
+    }
 
     ///////////////////////////////////////////////////////
     // Dependencies (from context)

http://git-wip-us.apache.org/repos/asf/isis/blob/082916ae/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
index 65dcb4a..9e8718d 100644
--- a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
+++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
@@ -45,13 +45,21 @@
                 <bs3:tab name="General">
                     <bs3:row>
                         <bs3:col span="12">
-                            <c:fieldSet name="Properties" unreferencedProperties="true"/>
+                            <c:fieldSet name="Properties">
+                                <c:property id="name"/>
+                            </c:fieldSet>
+                        </bs3:col>
+                    </bs3:row>
+                </bs3:tab>
+                <bs3:tab name="Other">
+                    <bs3:row>
+                        <bs3:col span="12">
+                            <c:fieldSet name="Other" unreferencedProperties="true"/>
                         </bs3:col>
                     </bs3:row>
                 </bs3:tab>
             </bs3:tabGroup>
             <bs3:tabGroup>
-
             </bs3:tabGroup>
         </bs3:col>
         <bs3:col span="6">