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 2018/02/13 16:14:25 UTC
[isis] 02/02: ISIS-1759: avoids calls to getter if property is
hidden.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 6ed8ec4caa015b4a78cf53f26663d15fb4720d7f
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Feb 13 16:09:07 2018 +0000
ISIS-1759: avoids calls to getter if property is hidden.
Along the way removed nasty thread-local hack in ScalarPanelAbstract2; the information we require is now in ScalarModel (extended the RenderingHint enum).
---
.../wicket/model/models/EntityCollectionModel.java | 17 ++++++
.../viewer/wicket/model/models/EntityModel.java | 68 +++++++++++++++-------
.../viewer/wicket/model/models/ScalarModel.java | 57 +++++++++++++-----
.../wicket/model/models/EntityModel_hintsTest.java | 2 +-
.../CollectionContentsAsAjaxTablePanel.java | 2 +-
.../ajaxtable/IsisAjaxFallbackDataTable.java | 18 ------
.../columns/ObjectAdapterPropertyColumn.java | 14 ++---
.../components/entity/fieldset/PropertyGroup.java | 3 +-
.../ui/components/property/PropertyEditPanel.java | 7 +--
.../ui/components/scalars/ScalarPanelAbstract.java | 2 +-
.../components/scalars/ScalarPanelAbstract2.java | 47 +--------------
11 files changed, 125 insertions(+), 112 deletions(-)
diff --git a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java
index a49e365..e40d778 100644
--- a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java
+++ b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityCollectionModel.java
@@ -140,6 +140,11 @@ public class EntityCollectionModel extends ModelAbstract<List<ObjectAdapter>> im
return model.mementoList.size();
}
+ @Override
+ public EntityModel.RenderingHint renderingHint() {
+ return EntityModel.RenderingHint.STANDALONE_PROPERTY_COLUMN;
+ }
+
},
/**
* A collection of an entity (eg Order/OrderDetail).
@@ -191,6 +196,12 @@ public class EntityCollectionModel extends ModelAbstract<List<ObjectAdapter>> im
public int getCount(EntityCollectionModel model) {
return load(model).size();
}
+
+ @Override
+ public EntityModel.RenderingHint renderingHint() {
+ return EntityModel.RenderingHint.PARENTED_PROPERTY_COLUMN;
+ }
+
};
abstract List<ObjectAdapter> load(EntityCollectionModel entityCollectionModel);
@@ -200,6 +211,8 @@ public class EntityCollectionModel extends ModelAbstract<List<ObjectAdapter>> im
public abstract String getName(EntityCollectionModel entityCollectionModel);
public abstract int getCount(EntityCollectionModel entityCollectionModel);
+
+ public abstract EntityModel.RenderingHint renderingHint();
}
static class LowestCommonSuperclassClosure implements Closure<Class<?>>{
@@ -294,6 +307,10 @@ public class EntityCollectionModel extends ModelAbstract<List<ObjectAdapter>> im
private final Type type;
+ public Type getType() {
+ return type;
+ }
+
private final Class<?> typeOf;
private transient ObjectSpecification typeOfSpec;
diff --git a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
index 182faa1..a58f409 100644
--- a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
+++ b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
@@ -29,6 +29,7 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.isis.applib.annotation.BookmarkPolicy;
+import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.layout.component.CollectionLayoutData;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager.ConcurrencyChecking;
@@ -96,21 +97,31 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements Obj
}
public enum RenderingHint {
- REGULAR,
- PROPERTY_COLUMN,
- PARENTED_TITLE_COLUMN,
- STANDALONE_TITLE_COLUMN;
+ REGULAR(Where.OBJECT_FORMS),
+ PARENTED_PROPERTY_COLUMN(Where.PARENTED_TABLES),
+ PARENTED_TITLE_COLUMN(Where.PARENTED_TABLES),
+ STANDALONE_PROPERTY_COLUMN(Where.STANDALONE_TABLES),
+ STANDALONE_TITLE_COLUMN(Where.STANDALONE_TABLES);
+
+ private final Where where;
+
+ RenderingHint(final Where where) {
+ this.where = where;
+ }
public boolean isRegular() {
return this == REGULAR;
}
- public boolean isInTablePropertyColumn() {
- return this == PROPERTY_COLUMN;
+ public boolean isInParentedTable() {
+ return this == PARENTED_PROPERTY_COLUMN;
+ }
+ public boolean isInStandaloneTable() {
+ return this == STANDALONE_PROPERTY_COLUMN;
}
public boolean isInTable() {
- return isInTablePropertyColumn() || isInTableTitleColumn();
+ return isInParentedTable() || isInStandaloneTable() || isInTableTitleColumn();
}
public boolean isInTableTitleColumn() {
@@ -124,6 +135,10 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements Obj
public boolean isInStandaloneTableTitleColumn() {
return this == STANDALONE_TITLE_COLUMN;
}
+
+ public Where asWhere() {
+ return this.where;
+ }
}
public enum Mode {
@@ -134,8 +149,8 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements Obj
private ObjectAdapterMemento adapterMemento;
private ObjectAdapterMemento contextAdapterIfAny;
- private Mode mode = Mode.VIEW;
- private RenderingHint renderingHint = RenderingHint.REGULAR;
+ private Mode mode;
+ private RenderingHint renderingHint;
private final PendingModel pendingModel;
@@ -150,10 +165,13 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements Obj
// constructors
// //////////////////////////////////////////////////////////
- public EntityModel() {
- this.adapterMemento = null;
- this.pendingModel = new PendingModel(this);
- this.propertyScalarModels = Maps.newHashMap();
+ /**
+ * As used by ScalarModel
+ */
+ public EntityModel(
+ final Mode mode,
+ final RenderingHint renderingHint) {
+ this(Maps.<PropertyMemento, ScalarModel>newHashMap(), null, mode, renderingHint);
}
public EntityModel(final PageParameters pageParameters) {
@@ -180,12 +198,21 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements Obj
private EntityModel(
final Map<PropertyMemento, ScalarModel> propertyScalarModels,
final ObjectAdapterMemento adapterMemento) {
+ this(propertyScalarModels, adapterMemento, Mode.VIEW, RenderingHint.REGULAR);
+ }
+
+ private EntityModel(
+ final Map<PropertyMemento, ScalarModel> propertyScalarModels,
+ final ObjectAdapterMemento adapterMemento,
+ final Mode mode,
+ final RenderingHint renderingHint) {
this.adapterMemento = adapterMemento;
this.pendingModel = new PendingModel(this);
this.propertyScalarModels = propertyScalarModels;
+ this.mode = mode;
+ this.renderingHint = renderingHint;
}
-
public static String oidStr(final PageParameters pageParameters) {
return PageParameterNames.OBJECT_OID.getStringFrom(pageParameters);
}
@@ -351,15 +378,14 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements Obj
/**
* Lazily populates with the current value of each property.
*/
- public ScalarModel getPropertyModel(final PropertyMemento pm) {
+ public ScalarModel getPropertyModel(
+ final PropertyMemento pm,
+ final Mode mode,
+ final RenderingHint renderingHint) {
ScalarModel scalarModel = propertyScalarModels.get(pm);
if (scalarModel == null) {
- scalarModel = new ScalarModel(this, pm);
- if (isViewMode()) {
- scalarModel.toViewMode();
- } else {
- scalarModel.toEditMode();
- }
+ scalarModel = new ScalarModel(this, pm, mode, renderingHint);
+
propertyScalarModels.put(pm, scalarModel);
}
return scalarModel;
diff --git a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
index dc37190..035d795 100644
--- a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
+++ b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
@@ -67,6 +67,16 @@ import org.apache.isis.viewer.wicket.model.mementos.SpecUtils;
* <p>
* Is the backing model to each of the fields that appear in forms (for entities
* or action dialogs).
+ *
+ * <p>
+ * NOTE: although this inherits from {@link EntityModel}, this is wrong I think; what is being shared
+ * is just some of the implementation - both objects have to wrap some arbitrary memento holding some state
+ * (a value or entity reference in a ScalarModel's case, an entity reference in an EntityModel's), they have
+ * a view mode, they have a rendering hint, and scalar models have a pending value (not sure if Entity Model really
+ * requires this).
+ * Fundamentally though a ScalarModel is NOT really an EntityModel, so this hierarchy should be broken out with a
+ * common superclass for both EntityModel and ScalarModel.
+ * </p>
*/
public class ScalarModel extends EntityModel implements LinksProvider,FormExecutorContext, ActionArgumentModel {
@@ -289,9 +299,7 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
final ObjectAdapter parentAdapter = scalarModel.getParentEntityModel().load();
- final ObjectAdapter associatedAdapter =
- property.get(parentAdapter, InteractionInitiatedBy.USER);
- scalarModel.setObject(associatedAdapter);
+ setObjectFromPropertyIfVisible(scalarModel, property, parentAdapter);
}
@Override
@@ -625,7 +633,6 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
public abstract String toStringOf(final ScalarModel scalarModel);
}
-
private final Kind kind;
private final EntityModel parentEntityModel;
@@ -656,12 +663,12 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
* value (if any) of that action parameter.
*/
public ScalarModel(final EntityModel parentEntityModel, final ActionParameterMemento apm) {
+ super(EntityModel.Mode.EDIT, EntityModel.RenderingHint.REGULAR);
this.kind = Kind.PARAMETER;
this.parentEntityModel = parentEntityModel;
this.parameterMemento = apm;
init();
- setMode(Mode.EDIT);
}
/**
@@ -669,14 +676,16 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
* {@link #getObject() value of this model} to be current value of the
* property.
*/
- public ScalarModel(final EntityModel parentEntityModel, final PropertyMemento pm) {
+ public ScalarModel(
+ final EntityModel parentEntityModel, final PropertyMemento pm,
+ final EntityModel.Mode mode, final EntityModel.RenderingHint renderingHint) {
+ super(mode, renderingHint);
this.kind = Kind.PROPERTY;
this.parentEntityModel = parentEntityModel;
this.propertyMemento = pm;
init();
getAndStore(parentEntityModel);
- setMode(Mode.VIEW);
}
private void init() {
@@ -701,10 +710,31 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
final OneToOneAssociation property = propertyMemento.getProperty(getSpecificationLoader());
final ObjectAdapter parentAdapter = parentAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK,
getPersistenceSession(), getSpecificationLoader());
- final ObjectAdapter associatedAdapter = property.get(parentAdapter, InteractionInitiatedBy.USER);
- setObject(associatedAdapter);
+
+ setObjectFromPropertyIfVisible(ScalarModel.this, property, parentAdapter);
}
+ private static void setObjectFromPropertyIfVisible(
+ final ScalarModel scalarModel,
+ final OneToOneAssociation property,
+ final ObjectAdapter parentAdapter) {
+
+ final Where where = scalarModel.getRenderingHint().asWhere();
+
+ final Consent visibility =
+ property.isVisible(parentAdapter, InteractionInitiatedBy.FRAMEWORK, where);
+
+ final ObjectAdapter associatedAdapter;
+ if (visibility.isAllowed()) {
+ associatedAdapter = property.get(parentAdapter, InteractionInitiatedBy.USER);
+ } else {
+ associatedAdapter = null;
+ }
+
+ scalarModel.setObject(associatedAdapter);
+ }
+
+
public boolean isCollection() {
return kind.isCollection(this);
}
@@ -804,11 +834,13 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
setObject(adapter);
}
- public boolean whetherHidden(Where where) {
+ public boolean whetherHidden() {
+ final Where where = getRenderingHint().asWhere();
return kind.whetherHidden(this, where);
}
- public String whetherDisabled(Where where) {
+ public String whetherDisabled() {
+ final Where where = getRenderingHint().asWhere();
return kind.whetherDisabled(this, where);
}
@@ -977,8 +1009,7 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
}
public boolean isEnabled() {
- Where where = getRenderingHint().isInTable() ? Where.PARENTED_TABLES : Where.OBJECT_FORMS;
- return whetherDisabled(where) == null;
+ return whetherDisabled() == null;
}
public String getReasonInvalidIfAny() {
diff --git a/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/EntityModel_hintsTest.java b/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/EntityModel_hintsTest.java
index 97e1bd5..4e8948f 100644
--- a/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/EntityModel_hintsTest.java
+++ b/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/EntityModel_hintsTest.java
@@ -43,7 +43,7 @@ public class EntityModel_hintsTest {
@Before
public void setUp() throws Exception {
- target = new EntityModel();
+ target = new EntityModel(EntityModel.Mode.VIEW, EntityModel.RenderingHint.REGULAR);
mockParent = context.mock(MarkupContainer.class, "parent");
mockComponent1 = context.mock(Component.class, "component1");
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
index 8093034..b329237 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
@@ -262,7 +262,7 @@ public class CollectionContentsAsAjaxTablePanel
final boolean escaped = facet == null || facet.escaped();
final String parentTypeName = property.getOnType().getShortIdentifier();
- return new ObjectAdapterPropertyColumn(Model.of(property.getName()), property.getId(), property.getId(), escaped, parentTypeName);
+ return new ObjectAdapterPropertyColumn(getModel().getType(), Model.of(property.getName()), property.getId(), property.getId(), escaped, parentTypeName);
}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/IsisAjaxFallbackDataTable.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/IsisAjaxFallbackDataTable.java
index 9838d8b..d72a7aa 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/IsisAjaxFallbackDataTable.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/IsisAjaxFallbackDataTable.java
@@ -39,7 +39,6 @@ import org.apache.wicket.util.lang.Generics;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
-import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.columns.ObjectAdapterToggleboxColumn;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
@@ -87,29 +86,12 @@ public class IsisAjaxFallbackDataTable<T, S> extends DataTable<T, S> {
addBottomToolbar(new NoRecordsToolbar(this));
}
- private final static ThreadLocal<EntityCollectionModel> entityCollectionModel = new ThreadLocal<>();
-
- public static Boolean isParented() {
- EntityCollectionModel entityCollectionModel = IsisAjaxFallbackDataTable.entityCollectionModel.get();
- return entityCollectionModel != null ? entityCollectionModel.isParented() : null;
- }
-
@Override
protected void onConfigure() {
super.onConfigure();
}
@Override
- protected void onBeforeRender() {
- try {
- entityCollectionModel.set(dataProvider.getEntityCollectionModel());
- super.onBeforeRender();
- } finally {
- entityCollectionModel.set(null);
- }
- }
-
- @Override
protected Item<T> newRowItem(final String id, final int index, final IModel<T> model)
{
return new OddEvenItem<T>(id, index, model) {
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ObjectAdapterPropertyColumn.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ObjectAdapterPropertyColumn.java
index 87f120c..e94de22 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ObjectAdapterPropertyColumn.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ObjectAdapterPropertyColumn.java
@@ -30,8 +30,8 @@ import org.apache.wicket.model.IModel;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
import org.apache.isis.viewer.wicket.model.mementos.PropertyMemento;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
-import org.apache.isis.viewer.wicket.model.models.EntityModel.RenderingHint;
import org.apache.isis.viewer.wicket.model.models.ScalarModel;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
@@ -51,17 +51,20 @@ public final class ObjectAdapterPropertyColumn extends ColumnAbstract<ObjectAdap
private static final long serialVersionUID = 1L;
+ private final EntityCollectionModel.Type type;
private final String propertyExpression;
private final boolean escaped;
private final String parentTypeName;
public ObjectAdapterPropertyColumn(
+ final EntityCollectionModel.Type type,
final IModel<String> columnNameModel,
final String sortProperty,
final String propertyName,
final boolean escaped,
final String parentTypeName) {
super(columnNameModel, sortProperty);
+ this.type = type;
this.propertyExpression = propertyName;
this.escaped = escaped;
this.parentTypeName = parentTypeName;
@@ -94,15 +97,10 @@ public final class ObjectAdapterPropertyColumn extends ColumnAbstract<ObjectAdap
final OneToOneAssociation property = (OneToOneAssociation) adapter.getSpecification().getAssociation(propertyExpression);
final PropertyMemento pm = new PropertyMemento(property, entityModel.getIsisSessionFactory());
- final ScalarModel scalarModel = entityModel.getPropertyModel(pm);
-
- scalarModel.setRenderingHint(RenderingHint.PROPERTY_COLUMN);
- scalarModel.toViewMode();
+ final ScalarModel scalarModel = entityModel.getPropertyModel(pm, EntityModel.Mode.VIEW, type.renderingHint());
final ComponentFactory componentFactory = findComponentFactory(ComponentType.SCALAR_NAME_AND_VALUE, scalarModel);
- final Component component = componentFactory.createComponent(id, scalarModel);
-
- return component;
+ return componentFactory.createComponent(id, scalarModel);
}
}
\ No newline at end of file
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 6c30278..2e7373d 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
@@ -216,7 +216,8 @@ public class PropertyGroup extends PanelAbstract<EntityModel> implements HasDyna
final PropertyMemento pm = new PropertyMemento(otoa, entityModel.getIsisSessionFactory());
- final ScalarModel scalarModel = entityModel.getPropertyModel(pm);
+ final ScalarModel scalarModel =
+ entityModel.getPropertyModel(pm, EntityModel.Mode.VIEW, EntityModel.RenderingHint.REGULAR);
final Component component = getComponentFactoryRegistry()
.addOrReplaceComponent(container, ID_PROPERTY, ComponentType.SCALAR_NAME_AND_VALUE, scalarModel);
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/property/PropertyEditPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/property/PropertyEditPanel.java
index 89ab5cae..5f6240a 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/property/PropertyEditPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/property/PropertyEditPanel.java
@@ -28,6 +28,7 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+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.actions.ActionParametersPanel;
@@ -53,7 +54,8 @@ public class PropertyEditPanel extends PanelAbstract<ScalarModel> {
public PropertyEditPanel(
final String id,
final ScalarModel scalarModel) {
- super(id, new ScalarModel(scalarModel.getParentEntityModel(), scalarModel.getPropertyMemento()));
+ super(id, new ScalarModel(scalarModel.getParentEntityModel(), scalarModel.getPropertyMemento(),
+ EntityModel.Mode.EDIT, EntityModel.RenderingHint.REGULAR));
buildGui(scalarModel);
}
@@ -83,9 +85,6 @@ public class PropertyEditPanel extends PanelAbstract<ScalarModel> {
WebMarkupContainer header = addHeader();
try {
-
- scalarModel.toEditMode();
-
getComponentFactoryRegistry().addOrReplaceComponent(this, ComponentType.PROPERTY_EDIT_FORM, getScalarModel());
getComponentFactoryRegistry().addOrReplaceComponent(header, ComponentType.ENTITY_ICON_AND_TITLE, scalarModel.getParentEntityModel());
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
index 6fa41f2..75c5a57 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
@@ -177,7 +177,7 @@ public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> imp
}
final ScalarModel scalarModel = getModel();
- final String disableReasonIfAny = scalarModel.whetherDisabled(getRendering().getWhere());
+ final String disableReasonIfAny = scalarModel.whetherDisabled();
if (scalarModel.isViewMode()) {
onBeforeRenderWhenViewMode();
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 7b9bd0f..348a25e 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
@@ -42,7 +42,6 @@ import org.apache.wicket.model.Model;
import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.PromptStyle;
-import org.apache.isis.applib.annotation.Where;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
@@ -59,7 +58,6 @@ 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.collectioncontents.ajaxtable.IsisAjaxFallbackDataTable;
import org.apache.isis.viewer.wicket.ui.components.property.PropertyEditFormPanel;
import org.apache.isis.viewer.wicket.ui.components.property.PropertyEditPanel;
import org.apache.isis.viewer.wicket.ui.components.propertyheader.PropertyEditPromptHeaderPanel;
@@ -188,11 +186,11 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
}
final ScalarModel scalarModel = getModel();
- final String disableReasonIfAny = scalarModel.whetherDisabled(whereAreWeRendering());
if (scalarModel.isViewMode()) {
onInitializeWhenViewMode();
} else {
+ final String disableReasonIfAny = scalarModel.whetherDisabled();
if (disableReasonIfAny != null) {
onInitializeWhenDisabled(disableReasonIfAny);
} else {
@@ -399,8 +397,8 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
protected void onConfigure() {
final ScalarModel scalarModel = getModel();
-
- final boolean hidden = scalarModel.whetherHidden(whereAreWeRendering());
+
+ final boolean hidden = scalarModel.whetherHidden();
setVisibilityAllowed(!hidden);
super.onConfigure();
@@ -521,45 +519,6 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
return Rendering.renderingFor(scalarModel.getRenderingHint());
}
- /**
- * Returns the current rendering context of this component, one of
- * <ul>
- * <li>standalone table</li>
- * <li>parented table</li>
- * <li>form</li>
- * </ul>
- * @return
- */
- protected Where whereAreWeRendering() {
- switch (scalarModel.getRenderingHint()) {
- case PARENTED_TITLE_COLUMN:
- return Where.PARENTED_TABLES;
- case STANDALONE_TITLE_COLUMN:
- return Where.STANDALONE_TABLES;
- case PROPERTY_COLUMN:
- // this is pretty hacky, but can't (for the moment) think of another way to
- // pass through the context other than a thread-local
- Boolean parented = IsisAjaxFallbackDataTable.isParented();
- if(parented == null) {
- // this code is wrong (but kept in because it's what we had before) ...
- // the parentEntityModel *isn't* the "parented" collection (eg Parent#child, a java.util.List),
- // rather it is the parent of this field (the Child object itself).
- EntityModel parentEntityModel = scalarModel.getParentEntityModel();
- final ObjectAdapter parentAdapter =
- parentEntityModel.load(AdapterManager.ConcurrencyChecking.NO_CHECK);
- parented = parentAdapter.isParentedCollection();
- }
- // this bit is correct, I think; earlier in the stack trace is the IsisAjaxFallbackDataTable which
- // tells us whether it's being used to render a parented collection or a standalone collection.
- return parented ? Where.PARENTED_TABLES : Where.STANDALONE_TABLES;
-
- case REGULAR:
- return Where.OBJECT_FORMS;
- default:
- throw new RuntimeException("unmatched case "+scalarModel.getRenderingHint());
- }
- }
-
// ///////////////////////////////////////////////////////////////////
protected Component getComponentForRegular() {
--
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.