ISIS-993: started to add tab component
Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/abdbcc15 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/abdbcc15 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/abdbcc15 Branch: refs/heads/ISIS-993 Commit: abdbcc15835664c71a6c65175f2326b2b51c30dc Parents: 499366f Author: Dan Haywood <d...@haywood-associates.co.uk> Authored: Thu Jan 7 08:20:40 2016 +0000 Committer: Dan Haywood <d...@haywood-associates.co.uk> Committed: Mon Jan 25 15:06:07 2016 +0000 ---------------------------------------------------------------------- .../schema/applib/layout/layout-1.0.xsd | 10 ++-- .../asciidoc/schema/applib/layout/layout.xsd | 10 ++-- .../isis/applib/layout/v1_0/Collection.java | 3 ++ .../isis/applib/layout/v1_0/DomainObject.java | 8 +++ .../isis/applib/layout/v1_0/Property.java | 26 +++++---- .../isis/applib/layout/v1_0/PropertyGroup.java | 3 ++ .../org/apache/isis/applib/layout/v1_0/Tab.java | 3 +- .../layoutxml/v1_0/DomainObjectTest.java | 1 + .../EntityTabbedPanel$EntityTabPanel.html | 29 ++++++++++ .../entity/tabbed/EntityTabbedPanel.html | 4 +- .../entity/tabbed/EntityTabbedPanel.java | 56 ++++++++++++++++++-- .../dom/simple/SimpleObject.layout.xml | 16 +++++- 12 files changed, 140 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout-1.0.xsd ---------------------------------------------------------------------- diff --git a/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout-1.0.xsd b/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout-1.0.xsd index 63fa0a5..221c807 100644 --- a/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout-1.0.xsd +++ b/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout-1.0.xsd @@ -1,9 +1,9 @@ <?xml version="1.0" standalone="yes"?> <xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="http://isis.apache.org/schema/applib/layout" xmlns:tns="http://isis.apache.org/schema/applib/layout" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xs:element name="domainObject" type="tns:domain-object"/> + <xs:element name="domainObject" type="tns:domainObject"/> - <xs:complexType name="domain-object"> + <xs:complexType name="domainObject"> <xs:sequence> <xs:element name="actions"> <xs:complexType> @@ -45,11 +45,11 @@ <xs:complexType name="tab"> <xs:sequence> - <xs:element name="name" type="xs:string" minOccurs="0"/> <xs:element name="left" type="tns:column"/> <xs:element name="middle" type="tns:column" minOccurs="0"/> <xs:element name="right" type="tns:column" minOccurs="0"/> </xs:sequence> + <xs:attribute name="name" type="xs:string" use="required"/> </xs:complexType> <xs:complexType name="column"> @@ -78,10 +78,10 @@ <xs:complexType name="property"> <xs:sequence> - <xs:element name="actions" minOccurs="0"> + <xs:element name="actions"> <xs:complexType> <xs:sequence> - <xs:element name="action" type="tns:action" maxOccurs="unbounded"/> + <xs:element name="action" type="tns:action" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout.xsd ---------------------------------------------------------------------- diff --git a/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout.xsd b/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout.xsd index 63fa0a5..221c807 100644 --- a/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout.xsd +++ b/adocs/documentation/src/main/asciidoc/schema/applib/layout/layout.xsd @@ -1,9 +1,9 @@ <?xml version="1.0" standalone="yes"?> <xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="http://isis.apache.org/schema/applib/layout" xmlns:tns="http://isis.apache.org/schema/applib/layout" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xs:element name="domainObject" type="tns:domain-object"/> + <xs:element name="domainObject" type="tns:domainObject"/> - <xs:complexType name="domain-object"> + <xs:complexType name="domainObject"> <xs:sequence> <xs:element name="actions"> <xs:complexType> @@ -45,11 +45,11 @@ <xs:complexType name="tab"> <xs:sequence> - <xs:element name="name" type="xs:string" minOccurs="0"/> <xs:element name="left" type="tns:column"/> <xs:element name="middle" type="tns:column" minOccurs="0"/> <xs:element name="right" type="tns:column" minOccurs="0"/> </xs:sequence> + <xs:attribute name="name" type="xs:string" use="required"/> </xs:complexType> <xs:complexType name="column"> @@ -78,10 +78,10 @@ <xs:complexType name="property"> <xs:sequence> - <xs:element name="actions" minOccurs="0"> + <xs:element name="actions"> <xs:complexType> <xs:sequence> - <xs:element name="action" type="tns:action" maxOccurs="unbounded"/> + <xs:element name="action" type="tns:action" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Collection.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Collection.java b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Collection.java index 4c48c2a..cf2dc48 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Collection.java +++ b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Collection.java @@ -61,6 +61,9 @@ public class Collection implements ColumnContent, ActionHolder { private List<Action> actions = Lists.newArrayList(); + /** + * The <code><actions></code> element must be present but can be empty. + */ @XmlElementWrapper(name = "actions", required = true) @XmlElement(name = "action", required = false) public List<Action> getActions() { http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/DomainObject.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/DomainObject.java b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/DomainObject.java index c1868fc..c5fa00d 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/DomainObject.java +++ b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/DomainObject.java @@ -45,6 +45,10 @@ public class DomainObject implements Dto, ActionHolder { private List<Action> actions = Lists.newArrayList(); + + /** + * The <code><actions></code> element must be present but can be empty. + */ @XmlElementWrapper(name = "actions", required = true) @XmlElement(name = "action", required = false) public List<Action> getActions() { @@ -62,6 +66,10 @@ public class DomainObject implements Dto, ActionHolder { }}; // no wrapper + + /** + * Must have at least one tab group; no wrapper. + */ @XmlElement(name = "tabGroup", required = true) public List<TabGroup> getTabGroups() { return tabGroups; http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Property.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Property.java b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Property.java index d3ee9b2..5345d06 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Property.java +++ b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Property.java @@ -58,6 +58,21 @@ public class Property implements ActionHolder { } + private List<Action> actions = Lists.newArrayList(); + + /** + * The <code><actions></code> element must be present but can be empty. + */ + @XmlElementWrapper(required = true) + @XmlElement(name = "action", required = false) + public List<Action> getActions() { + return actions; + } + + public void setActions(List<Action> actions) { + this.actions = actions; + } + private PropertyLayout layout = new PropertyLayout(); @XmlElement(required = true) @@ -70,15 +85,4 @@ public class Property implements ActionHolder { } - private List<Action> actions = Lists.newArrayList(); - - @XmlElementWrapper(required = false) - @XmlElement(name = "action", required = true) - public List<Action> getActions() { - return actions; - } - - public void setActions(List<Action> actions) { - this.actions = actions; - } } http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/PropertyGroup.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/PropertyGroup.java b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/PropertyGroup.java index 9d883fa..e7b169f 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/PropertyGroup.java +++ b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/PropertyGroup.java @@ -64,6 +64,9 @@ public class PropertyGroup implements ColumnContent, ActionHolder { private List<Action> actions = Lists.newArrayList(); + /** + * The <code><actions></code> element must be present but can be empty. + */ @XmlElementWrapper(required = true) @XmlElement(name = "action", required = false) public List<Action> getActions() { http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Tab.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Tab.java b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Tab.java index 43ea13f..988d1e8 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Tab.java +++ b/core/applib/src/main/java/org/apache/isis/applib/layout/v1_0/Tab.java @@ -18,6 +18,7 @@ */ package org.apache.isis.applib.layout.v1_0; +import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @@ -34,7 +35,7 @@ public class Tab { private String name; - @XmlElement(required = false) + @XmlAttribute(required = true) public String getName() { return name; } http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java index 26f361c..51269c5 100644 --- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java +++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java @@ -63,6 +63,7 @@ public class DomainObjectTest { TabGroup tabGroup = domainObject.getTabGroups().get(0); Tab tab = tabGroup.getTabs().get(0); + tab.setName("Common"); Column left = tab.getLeft(); PropertyGroup leftPropGroup = new PropertyGroup(); http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel$EntityTabPanel.html ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel$EntityTabPanel.html b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel$EntityTabPanel.html new file mode 100644 index 0000000..94582b1 --- /dev/null +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel$EntityTabPanel.html @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<html xmlns:wicket="http://wicket.apache.org"> +<body> +<wicket:panel> + <div class="tabPanel"> + <div wicket:id="entityPropertiesAndCollections"></div> + + </div> +</wicket:panel> +</body> +</html> http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.html ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.html b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.html index 8165722..999a22e 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.html +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.html @@ -22,7 +22,9 @@ <wicket:panel> <div class="entityTabbed"> <div wicket:id="entitySummary"></div> - <div wicket:id="entityPropertiesAndCollections"></div> + + <div wicket:id="tabs">[tabbed panel will be here]</div> + </div> </wicket:panel> </body> http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.java index c1e37cd..c1c65ba 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabbed/EntityTabbedPanel.java @@ -19,7 +19,18 @@ package org.apache.isis.viewer.wicket.ui.components.entity.tabbed; +import java.util.List; + +import com.google.common.collect.Lists; + +import org.apache.wicket.extensions.markup.html.tabs.AbstractTab; +import org.apache.wicket.extensions.markup.html.tabs.ITab; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.Model; + import org.apache.isis.applib.layout.v1_0.DomainObject; +import org.apache.isis.applib.layout.v1_0.Tab; +import org.apache.isis.applib.layout.v1_0.TabGroup; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet; import org.apache.isis.core.metamodel.facets.object.layoutxml.LayoutXmlFacet; @@ -28,6 +39,8 @@ import org.apache.isis.viewer.wicket.ui.ComponentType; import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract; import org.apache.isis.viewer.wicket.ui.util.CssClassAppender; +import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel; + /** * {@link PanelAbstract Panel} to represent an entity on a single page made up * of several <div> regions. @@ -53,13 +66,48 @@ public class EntityTabbedPanel extends PanelAbstract<EntityModel> { CssClassAppender.appendCssClassTo(this, cssClass); } - LayoutXmlFacet layoutXmlFacet = model.getTypeOfSpecification().getFacet(LayoutXmlFacet.class); - // force metadata to be derived && synced - DomainObject currentlyUnused = layoutXmlFacet.getLayoutMetadata(); + // forces metadata to be derived && synced + final LayoutXmlFacet layoutXmlFacet = model.getTypeOfSpecification().getFacet(LayoutXmlFacet.class); + final DomainObject domainObject = layoutXmlFacet.getLayoutMetadata(); + addOrReplace(ComponentType.ENTITY_SUMMARY, model); - getComponentFactoryRegistry().addOrReplaceComponent(this, ID_ENTITY_PROPERTIES_AND_COLLECTIONS, ComponentType.ENTITY_PROPERTIES, model); + + List<TabGroup> tabGroups = domainObject.getTabGroups(); + TabGroup tabGroup = tabGroups.get(0); + + List<ITab> tabs = Lists.newArrayList(); + List<Tab> tabList = tabGroup.getTabs(); + + for (Tab tab : tabList) { + + tabs.add(new AbstractTab(Model.of(tab.getName())) { + private static final long serialVersionUID = 1L; + + @Override + public Panel getPanel(String panelId) { + return new EntityTabPanel(panelId, getModel()); + } + + }); + + } + + + addOrReplace(new AjaxBootstrapTabbedPanel("tabs", tabs)); + + } + + private static class EntityTabPanel extends PanelAbstract { + private static final long serialVersionUID = 1L; + + public EntityTabPanel(String id, final EntityModel model) { + super(id); + getComponentFactoryRegistry().addOrReplaceComponent(this, ID_ENTITY_PROPERTIES_AND_COLLECTIONS, ComponentType.ENTITY_PROPERTIES, model); + + } + } http://git-wip-us.apache.org/repos/asf/isis/blob/abdbcc15/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 b479d1c..036b99d 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 @@ -4,15 +4,27 @@ <action id="delete"/> </actions> <tabGroup> - <tab> + <tab name="Common"> <left span="4"> <propertyGroup name="General"> <actions/> <property id="name"> <actions> <action id="updateName"/> - <action id="downloadJdoMetadata"/> </actions> + <layout/> + </property> + </propertyGroup> + </left> + </tab> + <tab name="Other"> + <left span="4"> + <propertyGroup name="Metadata"> + <actions> + <action id="downloadJdoMetadata"/> + </actions> + <property id="versionSequence"> + <actions/> <layout labelPosition="TOP" multiLine="5" cssClass="abcde"/> </property> </propertyGroup>