Repository: isis Updated Branches: refs/heads/ISIS-993 b04c27ff3 -> f33e0e243 (forced update)
ISIS-993: factored out PropertyGroup component. Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/1f764b50 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/1f764b50 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/1f764b50 Branch: refs/heads/ISIS-993 Commit: 1f764b506970528862c5cf81209335674d53ea62 Parents: 205cf85 Author: Dan Haywood <d...@haywood-associates.co.uk> Authored: Fri Jan 15 09:25:03 2016 +0000 Committer: Dan Haywood <d...@haywood-associates.co.uk> Committed: Mon Jan 25 15:06:07 2016 +0000 ---------------------------------------------------------------------- .../entityactions/EntityActionUtil.java | 9 +- .../components/entity/column/EntityColumn.html | 19 +-- .../components/entity/column/EntityColumn.java | 100 +-------------- .../entity/propgroup/PropertyGroup.html | 41 ++++++ .../entity/propgroup/PropertyGroup.java | 125 +++++++++++++++++++ 5 files changed, 180 insertions(+), 114 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/1f764b50/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java index ed28333..de6e2ca 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java @@ -32,6 +32,7 @@ import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager.ConcurrencyChecking; import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy; +import org.apache.isis.core.metamodel.deployment.DeploymentCategory; import org.apache.isis.core.metamodel.facets.members.order.MemberOrderFacet; import org.apache.isis.core.metamodel.layout.memberorderfacet.MemberOrderFacetComparator; import org.apache.isis.core.metamodel.spec.ActionType; @@ -76,10 +77,16 @@ public final class EntityActionUtil { final EntityModel entityModel, final ObjectAssociation association, final DeploymentType deploymentType) { + return getObjectActionsForAssociation(entityModel, association, deploymentType.getDeploymentCategory()); + } + + public static List<ObjectAction> getObjectActionsForAssociation( + final EntityModel entityModel, + final ObjectAssociation association, final DeploymentCategory deploymentCategory) { final List<ObjectAction> associatedActions = Lists.newArrayList(); addActions(ActionType.USER, entityModel, association, associatedActions); - if(deploymentType.isPrototyping()) { + if(deploymentCategory.isPrototyping()) { addActions(ActionType.EXPLORATION, entityModel, association, associatedActions); addActions(ActionType.PROTOTYPE, entityModel, association, associatedActions); } http://git-wip-us.apache.org/repos/asf/isis/blob/1f764b50/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.html ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.html b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.html index cab6833..44e3a23 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.html +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.html @@ -22,24 +22,7 @@ <wicket:panel> <div class="columnMembers"> <div class="inputFormTable properties"> - <div wicket:id="memberGroup"> - <fieldset class="memberGroup myBlockContainer"> - <div class="panel panel-default"> - <div class="panel-heading"> - <span wicket:id="memberGroupName" class="panel-title">[group name]</span> - <div class="pull-right additionalLinks"> - <div wicket:id="associatedActionLinksPanel"></div> - <div wicket:id="associatedActionLinksPanelDropDown"></div> - </div> - </div> - <div class="properties panel-body"> - <div wicket:id="properties"> - <div wicket:id="property" class="property">[property]</div> - </div> - </div> - </div> - </fieldset> - </div> + <div wicket:id="propertyGroup">[propertyGroup]</div> </div> <div wicket:id="collections"></div> </div> http://git-wip-us.apache.org/repos/asf/isis/blob/1f764b50/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.java index 147d276..79abdb8 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/column/EntityColumn.java @@ -25,15 +25,12 @@ import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.repeater.RepeatingView; -import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.layout.v1_0.ColumnMetadata; import org.apache.isis.applib.layout.v1_0.PropertyGroupMetadata; import org.apache.isis.applib.layout.v1_0.PropertyLayoutMetadata; @@ -41,21 +38,14 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupLayoutFacet; import org.apache.isis.core.metamodel.spec.ObjectSpecification; import org.apache.isis.core.metamodel.spec.ObjectSpecifications; -import org.apache.isis.core.metamodel.spec.feature.ObjectAction; import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation; -import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation; import org.apache.isis.core.runtime.system.DeploymentType; import org.apache.isis.core.runtime.system.context.IsisContext; import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant; -import org.apache.isis.viewer.wicket.model.links.LinkAndLabel; -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.ui.ComponentType; -import org.apache.isis.viewer.wicket.ui.components.actionmenu.entityactions.AdditionalLinksPanel; -import org.apache.isis.viewer.wicket.ui.components.actionmenu.entityactions.EntityActionUtil; import org.apache.isis.viewer.wicket.ui.components.entity.PropUtil; -import org.apache.isis.viewer.wicket.ui.components.widgets.containers.UiHintPathSignificantWebMarkupContainer; +import org.apache.isis.viewer.wicket.ui.components.entity.propgroup.PropertyGroup; import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract; import org.apache.isis.viewer.wicket.ui.util.Components; @@ -73,14 +63,8 @@ public class EntityColumn extends PanelAbstract<EntityModel> implements UiHintPa 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_PROPERTY_GROUP = "propertyGroup"; - private static final String ID_ASSOCIATED_ACTION_LINKS_PANEL = "associatedActionLinksPanel"; - private static final String ID_ASSOCIATED_ACTION_LINKS_PANEL_DROPDOWN = "associatedActionLinksPanelDropDown"; - - private static final String ID_PROPERTIES = "properties"; - private static final String ID_PROPERTY = "property"; // view metadata (populated for EntityTabbedPanel, absent for EntityEditablePanel) private final ColumnMetadata columnMetaDataIfAny; @@ -119,7 +103,7 @@ public class EntityColumn extends PanelAbstract<EntityModel> implements UiHintPa final Map<String, List<ObjectAssociation>> associationsByGroup = PropUtil.propertiesByMemberOrder(adapter); - final RepeatingView memberGroupRv = new RepeatingView(ID_MEMBER_GROUP); + final RepeatingView memberGroupRv = new RepeatingView(ID_PROPERTY_GROUP); markupContainer.add(memberGroupRv); final ImmutableMap<String, PropertyGroupMetadata> propertyGroupMetadataByNameIfAny = @@ -134,16 +118,13 @@ public class EntityColumn extends PanelAbstract<EntityModel> implements UiHintPa for(final String groupName: groupNames) { - final List<ObjectAssociation> associationsInGroup = associationsByGroup.get(groupName); - if(associationsInGroup==null) { - continue; - } final PropertyGroupMetadata propertyGroupMetadata; if (propertyGroupMetadataByNameIfAny != null) { propertyGroupMetadata = propertyGroupMetadataByNameIfAny.get(groupName); } else { + final List<ObjectAssociation> associationsInGroup = associationsByGroup.get(groupName); propertyGroupMetadata = new PropertyGroupMetadata(groupName); propertyGroupMetadata.setProperties( FluentIterable @@ -164,67 +145,12 @@ public class EntityColumn extends PanelAbstract<EntityModel> implements UiHintPa final String id = memberGroupRv.newChildId(); final EntityModel entityModelWithHints = entityModel.cloneWithPropertyGroupMetadata(propertyGroupMetadata); - final WebMarkupContainer memberGroupRvContainer = newPropertyGroup(id, entityModelWithHints); + final WebMarkupContainer memberGroupRvContainer = new PropertyGroup(id, entityModelWithHints); memberGroupRv.add(memberGroupRvContainer); } } - private WebMarkupContainer newPropertyGroup( - final String id, - final EntityModel entityModel) { - - final PropertyGroupMetadata propertyGroupMetadata = entityModel.getPropertyGroupMetadata(); - String groupName = propertyGroupMetadata.getName(); - - final ObjectAdapter adapter = entityModel.getObject(); - - - final WebMarkupContainer memberGroupRvContainer = new WebMarkupContainer(id); - - memberGroupRvContainer.add(new Label(ID_MEMBER_GROUP_NAME, groupName)); - - final List<LinkAndLabel> memberGroupActions = Lists.newArrayList(); - - final RepeatingView propertyRv = new RepeatingView(ID_PROPERTIES); - memberGroupRvContainer.add(propertyRv); - - - final List<PropertyLayoutMetadata> properties = propertyGroupMetadata.getProperties(); - for (PropertyLayoutMetadata property : properties) { - final ObjectAssociation association = adapter.getSpecification().getAssociation(property.getId()); - - final WebMarkupContainer propertyRvContainer = new UiHintPathSignificantWebMarkupContainer(propertyRv.newChildId()); - propertyRv.add(propertyRvContainer); - - addPropertyToForm(entityModel, (OneToOneAssociation) association, propertyRvContainer, memberGroupActions); - } - -// final Map<String, List<ObjectAssociation>> associationsByGroup = PropUtil.propertiesByMemberOrder(adapter); -// final List<ObjectAssociation> associationsInGroup = associationsByGroup.get(groupName); -// @SuppressWarnings("unused") -// Component component; -// for (final ObjectAssociation association : associationsInGroup) { -// final WebMarkupContainer propertyRvContainer = new UiHintPathSignificantWebMarkupContainer(propertyRv.newChildId()); -// propertyRv.add(propertyRvContainer); -// -// addPropertyToForm(entityModel, (OneToOneAssociation) association, propertyRvContainer, memberGroupActions); -// } - - final List<LinkAndLabel> actionsPanel = LinkAndLabel.positioned(memberGroupActions, ActionLayout.Position.PANEL); - final List<LinkAndLabel> actionsPanelDropDown = LinkAndLabel.positioned(memberGroupActions, ActionLayout.Position.PANEL_DROPDOWN); - - AdditionalLinksPanel.addAdditionalLinks( - memberGroupRvContainer, ID_ASSOCIATED_ACTION_LINKS_PANEL, - actionsPanel, - AdditionalLinksPanel.Style.INLINE_LIST); - AdditionalLinksPanel.addAdditionalLinks( - memberGroupRvContainer, ID_ASSOCIATED_ACTION_LINKS_PANEL_DROPDOWN, - actionsPanelDropDown, - AdditionalLinksPanel.Style.DROPDOWN); - return memberGroupRvContainer; - } - private void addCollectionsIfRequired( final MarkupContainer column, final EntityModel entityModel) { @@ -237,22 +163,6 @@ public class EntityColumn extends PanelAbstract<EntityModel> implements UiHintPa } } - private void addPropertyToForm( - final EntityModel entityModel, - final OneToOneAssociation otoa, - final WebMarkupContainer container, - final List<LinkAndLabel> entityActions) { - final PropertyMemento pm = new PropertyMemento(otoa); - - final ScalarModel scalarModel = entityModel.getPropertyModel(pm); - getComponentFactoryRegistry().addOrReplaceComponent(container, ID_PROPERTY, ComponentType.SCALAR_NAME_AND_VALUE, scalarModel); - - final List<ObjectAction> associatedActions = EntityActionUtil.getObjectActionsForAssociation(entityModel, - otoa, getDeploymentType()); - - entityActions.addAll(EntityActionUtil.asLinkAndLabelsForAdditionalLinksPanel(entityModel, associatedActions)); - } - /////////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/isis/blob/1f764b50/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.html ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.html b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.html new file mode 100644 index 0000000..0e8b3fc --- /dev/null +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.html @@ -0,0 +1,41 @@ +<?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> + <fieldset class="memberGroup myBlockContainer"> + <div class="panel panel-default"> + <div class="panel-heading"> + <span wicket:id="memberGroupName" class="panel-title">[group name]</span> + <div class="pull-right additionalLinks"> + <div wicket:id="associatedActionLinksPanel"></div> + <div wicket:id="associatedActionLinksPanelDropDown"></div> + </div> + </div> + <div class="properties panel-body"> + <div wicket:id="properties"> + <div wicket:id="property" class="property">[property]</div> + </div> + </div> + </div> + </fieldset> + </wicket:panel> + </body> +</html> http://git-wip-us.apache.org/repos/asf/isis/blob/1f764b50/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.java new file mode 100644 index 0000000..3eb03d1 --- /dev/null +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/propgroup/PropertyGroup.java @@ -0,0 +1,125 @@ +/* + * 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.ui.components.entity.propgroup; + +import java.util.List; + +import com.google.common.collect.Lists; + +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.repeater.RepeatingView; + +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.layout.v1_0.PropertyGroupMetadata; +import org.apache.isis.applib.layout.v1_0.PropertyLayoutMetadata; +import org.apache.isis.core.metamodel.adapter.ObjectAdapter; +import org.apache.isis.core.metamodel.spec.feature.ObjectAction; +import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation; +import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation; +import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant; +import org.apache.isis.viewer.wicket.model.links.LinkAndLabel; +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.ui.ComponentType; +import org.apache.isis.viewer.wicket.ui.components.actionmenu.entityactions.AdditionalLinksPanel; +import org.apache.isis.viewer.wicket.ui.components.actionmenu.entityactions.EntityActionUtil; +import org.apache.isis.viewer.wicket.ui.components.widgets.containers.UiHintPathSignificantWebMarkupContainer; +import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract; + +public class PropertyGroup extends PanelAbstract<EntityModel> implements UiHintPathSignificant { + + private static final String ID_MEMBER_GROUP_NAME = "memberGroupName"; + + private static final String ID_ASSOCIATED_ACTION_LINKS_PANEL = "associatedActionLinksPanel"; + private static final String ID_ASSOCIATED_ACTION_LINKS_PANEL_DROPDOWN = "associatedActionLinksPanelDropDown"; + + private static final String ID_PROPERTIES = "properties"; + private static final String ID_PROPERTY = "property"; + + private final PropertyGroupMetadata propertyGroupMetadata; + + public PropertyGroup(final String id, final EntityModel model) { + super(id, model); + propertyGroupMetadata = model.getPropertyGroupMetadata(); + + buildGui(); + } + + public EntityModel getModel() { + return (EntityModel) getDefaultModel(); + } + + private void buildGui() { + String groupName = propertyGroupMetadata.getName(); + final ObjectAdapter adapter = getModel().getObject(); + + add(new Label(ID_MEMBER_GROUP_NAME, groupName)); + + final List<LinkAndLabel> memberGroupActions = Lists.newArrayList(); + + final RepeatingView propertyRv = new RepeatingView(ID_PROPERTIES); + add(propertyRv); + + final List<PropertyLayoutMetadata> properties = propertyGroupMetadata.getProperties(); + for (PropertyLayoutMetadata property : properties) { + final ObjectAssociation association = adapter.getSpecification().getAssociation(property.getId()); + + final WebMarkupContainer propertyRvContainer = new UiHintPathSignificantWebMarkupContainer( + propertyRv.newChildId()); + propertyRv.add(propertyRvContainer); + + addPropertyToForm(getModel(), (OneToOneAssociation) association, propertyRvContainer, + memberGroupActions); + } + + final List<LinkAndLabel> actionsPanel = LinkAndLabel + .positioned(memberGroupActions, ActionLayout.Position.PANEL); + final List<LinkAndLabel> actionsPanelDropDown = LinkAndLabel + .positioned(memberGroupActions, ActionLayout.Position.PANEL_DROPDOWN); + + AdditionalLinksPanel.addAdditionalLinks( + this, ID_ASSOCIATED_ACTION_LINKS_PANEL, + actionsPanel, + AdditionalLinksPanel.Style.INLINE_LIST); + AdditionalLinksPanel.addAdditionalLinks( + this, ID_ASSOCIATED_ACTION_LINKS_PANEL_DROPDOWN, + actionsPanelDropDown, + AdditionalLinksPanel.Style.DROPDOWN); + } + + private void addPropertyToForm( + final EntityModel entityModel, + final OneToOneAssociation otoa, + final WebMarkupContainer container, + final List<LinkAndLabel> entityActions) { + final PropertyMemento pm = new PropertyMemento(otoa); + + final ScalarModel scalarModel = entityModel.getPropertyModel(pm); + getComponentFactoryRegistry() + .addOrReplaceComponent(container, ID_PROPERTY, ComponentType.SCALAR_NAME_AND_VALUE, scalarModel); + + final List<ObjectAction> associatedActions = + EntityActionUtil.getObjectActionsForAssociation(entityModel, otoa, getDeploymentCategory()); + + entityActions.addAll( + EntityActionUtil.asLinkAndLabelsForAdditionalLinksPanel(entityModel, associatedActions)); + } +}