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 2017/12/22 16:49:51 UTC
[isis] branch master updated: ISIS-1761: now dynamically computes
visibility of PropertyGroup based on visibility of its children
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 74c4f78 ISIS-1761: now dynamically computes visibility of PropertyGroup based on visibility of its children
74c4f78 is described below
commit 74c4f78ea1046f534598157ba24357172841e65e
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Dec 22 16:49:01 2017 +0000
ISIS-1761: now dynamically computes visibility of PropertyGroup based on visibility of its children
---
.../components/entity/fieldset/PropertyGroup.java | 43 ++++++++++++++++++----
.../components/scalars/ScalarPanelAbstract2.java | 2 +-
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/fieldset/PropertyGroup.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/fieldset/PropertyGroup.java
index 367ebaf..71b0ed3 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/fieldset/PropertyGroup.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/fieldset/PropertyGroup.java
@@ -29,6 +29,7 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
@@ -52,6 +53,7 @@ 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.LinkAndLabelUtil;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelAbstract2;
import org.apache.isis.viewer.wicket.ui.panels.HasDynamicallyVisibleContent;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.util.Components;
@@ -69,13 +71,14 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
private final FieldSet fieldSet;
private final boolean visible;
+ private final List<ScalarPanelAbstract2> childComponents;
public PropertyGroup(final String id, final EntityModel model, final FieldSet fieldSet) {
super(id, model);
this.fieldSet = fieldSet;
// the UI is only ever built once.
- buildGui();
+ childComponents = buildGui();
final ImmutableList<ObjectAssociation> associations = getObjectAssociations();
this.visible = !associations.isEmpty();
@@ -86,7 +89,13 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
}
- private void buildGui() {
+
+ private List<ScalarPanelAbstract2> buildGui() {
+
+ final List<ScalarPanelAbstract2> childComponents = Lists.newArrayList();
+
+ setOutputMarkupPlaceholderTag(true);
+ setOutputMarkupId(true);
final WebMarkupContainer div = new WebMarkupContainer(ID_MEMBER_GROUP);
@@ -101,7 +110,11 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
for (final ObjectAssociation association : associations) {
final WebMarkupContainer propertyRvContainer = new WebMarkupContainer(propertyRv.newChildId());
propertyRv.addOrReplace(propertyRvContainer);
- addPropertyToForm(getModel(), (OneToOneAssociation) association, propertyRvContainer, memberGroupActions);
+ final Component component = addPropertyToForm(getModel(), (OneToOneAssociation) association,
+ propertyRvContainer, memberGroupActions);
+ if(component instanceof ScalarPanelAbstract2) {
+ childComponents.add((ScalarPanelAbstract2) component);
+ }
}
WebMarkupContainer panelHeading = new WebMarkupContainer("panelHeading");
@@ -132,6 +145,8 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
} else {
this.addOrReplace(div);
}
+
+ return childComponents;
}
private ImmutableList<ObjectAssociation> getObjectAssociations() {
@@ -193,7 +208,7 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
.toList();
}
- private void addPropertyToForm(
+ private Component addPropertyToForm(
final EntityModel entityModel,
final OneToOneAssociation otoa,
final WebMarkupContainer container,
@@ -203,8 +218,7 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
final ScalarModel scalarModel = entityModel.getPropertyModel(pm);
-
- getComponentFactoryRegistry()
+ final Component component = getComponentFactoryRegistry()
.addOrReplaceComponent(container, ID_PROPERTY, ComponentType.SCALAR_NAME_AND_VALUE, scalarModel);
final ObjectAdapter adapter = entityModel.load(AdapterManager.ConcurrencyChecking.NO_CHECK);
@@ -213,11 +227,26 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
entityActions.addAll(
LinkAndLabelUtil.asActionLinksForAdditionalLinksPanel(entityModel, associatedActions, null));
+
+ return component;
+ }
+
+ @Override
+ public void onConfigure() {
+ for (final ScalarPanelAbstract2 childComponent : childComponents) {
+ childComponent.configure();
+ }
+ super.onConfigure();
}
@Override
public boolean isVisible() {
- return visible;
+ for (final ScalarPanelAbstract2 childComponent : childComponents) {
+ if(childComponent.isVisibilityAllowed()) {
+ return true;
+ }
+ }
+ return false;
}
}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract2.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract2.java
index 1d0a6cf..3f16905 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract2.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract2.java
@@ -401,7 +401,7 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
final boolean hidden = scalarModel.whetherHidden(whereAreWeRendering());
setVisibilityAllowed(!hidden);
-
+
super.onConfigure();
}
--
To stop receiving notification emails like this one, please contact
['"commits@isis.apache.org" <co...@isis.apache.org>'].