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 2019/05/14 19:42:00 UTC
[isis] branch master updated (2fa3745 -> c814687)
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.
from 2fa3745 ISIS-2116: fixes download of metamodel
new d10c537 ISIS-2001: pushes logic from ScalarPanelAbstract2 into ScalarModel
new c814687 ISIS-2001: blob/clob properties now visible once more even if not editable.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../viewer/wicket/model/models/ScalarModel.java | 85 +++++++++++++++++++--
.../actionmenu/entityactions/LinkAndLabelUtil.java | 41 ++++-------
.../components/scalars/ScalarPanelAbstract2.java | 86 +++++++++++-----------
.../isisapplib/IsisBlobOrClobPanelAbstract.java | 39 +++++-----
.../components/scalars/primitive/BooleanPanel.java | 5 +-
.../scalars/reference/ReferencePanel.java | 3 +-
6 files changed, 158 insertions(+), 101 deletions(-)
[isis] 01/02: ISIS-2001: pushes logic from ScalarPanelAbstract2
into ScalarModel
Posted by da...@apache.org.
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
commit d10c5373501371f231e51ee5d7793706adab45ba
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue May 14 20:29:18 2019 +0100
ISIS-2001: pushes logic from ScalarPanelAbstract2 into ScalarModel
- specifically, whether the panel has inline edits, and so will need to be in "view mode" rather than "disabled".
This allows us to remove the special case hacks of checking for the disabledReason of either "Always disabled" or "Immutable".
---
.../viewer/wicket/model/models/ScalarModel.java | 85 +++++++++++++++++++--
.../actionmenu/entityactions/LinkAndLabelUtil.java | 41 ++++-------
.../components/scalars/ScalarPanelAbstract2.java | 86 +++++++++++-----------
.../components/scalars/primitive/BooleanPanel.java | 5 +-
.../scalars/reference/ReferencePanel.java | 3 +-
5 files changed, 138 insertions(+), 82 deletions(-)
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 1e1b8cc..919ab2a 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
@@ -1154,21 +1154,92 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
this.inlinePromptContext = inlinePromptContext;
}
+ private transient AssociatedActions associatedActions;
+
+ public static class AssociatedActions {
+ private final ObjectAction firstAssociatedWithInlineAsIfEdit;
+ private final List<ObjectAction> remainingAssociated;
+
+ AssociatedActions(final List<ObjectAction> allAssociated) {
+ final List<ObjectAction> temp = Lists.newArrayList(allAssociated);
+ this.firstAssociatedWithInlineAsIfEdit = firstAssociatedActionWithInlineAsIfEdit(allAssociated);
+ if(this.firstAssociatedWithInlineAsIfEdit != null) {
+ temp.remove(firstAssociatedWithInlineAsIfEdit);
+ }
+ remainingAssociated = Collections.unmodifiableList(temp);
+ }
+
+ public List<ObjectAction> getRemainingAssociated() {
+ return remainingAssociated;
+ }
+ public ObjectAction getFirstAssociatedWithInlineAsIfEdit() {
+ return firstAssociatedWithInlineAsIfEdit;
+ }
+ public boolean hasAssociatedActionWithInlineAsIfEdit() {
+ return firstAssociatedWithInlineAsIfEdit != null;
+ }
+
+ private static ObjectAction firstAssociatedActionWithInlineAsIfEdit(final List<ObjectAction> objectActions) {
+ for (ObjectAction objectAction : objectActions) {
+ final PromptStyle promptStyle = ObjectAction.Util.promptStyleFor(objectAction);
+ if(promptStyle.isInlineAsIfEdit()) {
+ return objectAction;
+ }
+ }
+ return null;
+ }
+ }
+
+ public AssociatedActions associatedActionsIfProperty(final DeploymentCategory deploymentCategory) {
+ if (associatedActions == null) {
+ associatedActions = new AssociatedActions(calcAssociatedActionsIfProperty(deploymentCategory));
+ }
+ return associatedActions;
+ }
+
+ private List<ObjectAction> calcAssociatedActionsIfProperty(final DeploymentCategory deploymentCategory) {
+
+ if (getKind() != Kind.PROPERTY) {
+ return Collections.emptyList();
+ }
+
+ final EntityModel parentEntityModel1 = this.getParentEntityModel();
+ final ObjectAdapter parentAdapter = parentEntityModel1.load(ConcurrencyChecking.NO_CHECK);
+
+ final OneToOneAssociation oneToOneAssociation =
+ this.getPropertyMemento().getProperty(this.getSpecificationLoader());
+
+ return ObjectAction.Util.findForAssociation(parentAdapter, oneToOneAssociation, deploymentCategory);
+ }
- private boolean actionWithInlineAsIfEdit;
/**
- * Whether there is an action configured for {@link PromptStyle#INLINE_AS_IF_EDIT} for this property.
+ * Whether this model should be surfaced in the UI using a widget rendered such that it is either already in
+ * edit mode (eg for a parameter), or can be switched into edit mode, eg for an editable property or an
+ * associated action of a property with 'inline_as_if_edit'
+ *
+ * @param deploymentCategory - used to determine the actions to discover (can vary, eg if prototyping).
+ * @return <tt>true</tt> if the widget for this model must be editable.
*/
- public boolean hasActionWithInlineAsIfEdit() {
- return actionWithInlineAsIfEdit;
+ public boolean mustBeEditable(final DeploymentCategory deploymentCategory) {
+ return getMode() == Mode.EDIT ||
+ associatedActionsIfProperty(deploymentCategory).hasAssociatedActionWithInlineAsIfEdit() ||
+ getKind() == Kind.PARAMETER;
}
- public void setHasActionWithInlineAsIfEdit(final boolean inlineAsIfEditHint) {
- this.actionWithInlineAsIfEdit = inlineAsIfEditHint;
+ /**
+ * Similar to {@link #mustBeEditable(DeploymentCategory)}, though not called from the same locations.
+ *
+ * My suspicion is that it amounts to more or less the same set of conditions.
+ *
+ * @param deploymentCategory
+ * @return
+ */
+ public boolean isInlinePrompt(final DeploymentCategory deploymentCategory) {
+ return (getPromptStyle().isInline() && canEnterEditMode()) ||
+ associatedActionsIfProperty(deploymentCategory).hasAssociatedActionWithInlineAsIfEdit();
}
-
// //////////////////////////////////////
/**
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/LinkAndLabelUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/LinkAndLabelUtil.java
index 441449c..901322c 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/LinkAndLabelUtil.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/LinkAndLabelUtil.java
@@ -25,11 +25,7 @@ import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
import org.apache.isis.viewer.wicket.model.models.ScalarModel;
@@ -40,26 +36,19 @@ public final class LinkAndLabelUtil {
private LinkAndLabelUtil(){}
- public static List<LinkAndLabel> asActionLinksForAssociation(
- final ScalarModel scalarModelForAssociation,
- final DeploymentCategory deploymentCategory) {
+ public static List<LinkAndLabel> asActionLinks(
+ final ScalarModel scalarModel,
+ final List<ObjectAction> associatedActions) {
- if (scalarModelForAssociation.getKind() != ScalarModel.Kind.PROPERTY) {
- return Collections.emptyList();
- }
-
- final EntityModel parentEntityModel = scalarModelForAssociation.getParentEntityModel();
-
- final ObjectAdapter parentAdapter = parentEntityModel.load(AdapterManager.ConcurrencyChecking.NO_CHECK);
-
- final OneToOneAssociation oneToOneAssociation =
- scalarModelForAssociation.getPropertyMemento().getProperty(scalarModelForAssociation.getSpecificationLoader());
-
- final List<ObjectAction> associatedActions =
- ObjectAction.Util.findForAssociation(parentAdapter, oneToOneAssociation, deploymentCategory);
+ final EntityModel parentEntityModel = scalarModel.getParentEntityModel();
+ return asActionLinksForAdditionalLinksPanel(parentEntityModel, associatedActions, scalarModel);
+ }
- return asActionLinksForAdditionalLinksPanel(parentEntityModel, associatedActions,
- scalarModelForAssociation);
+ public static LinkAndLabel asActionLink(final ScalarModel scalarModel, final ObjectAction inlineActionIfAny) {
+ if(inlineActionIfAny == null) {
+ return null;
+ }
+ return asActionLinks(scalarModel, Collections.singletonList(inlineActionIfAny)).get(0);
}
/**
@@ -75,18 +64,18 @@ public final class LinkAndLabelUtil {
public static List<LinkAndLabel> asActionLinksForAdditionalLinksPanel(
final EntityModel parentEntityModel,
final List<ObjectAction> objectActions,
- final ScalarModel scalarModelForAssociationIfAny) {
+ final ScalarModel scalarModelIfAny) {
- return asActionLinksForAdditionalLinksPanel(parentEntityModel, objectActions, scalarModelForAssociationIfAny, null);
+ return asActionLinksForAdditionalLinksPanel(parentEntityModel, objectActions, scalarModelIfAny, null);
}
public static List<LinkAndLabel> asActionLinksForAdditionalLinksPanel(
final EntityModel parentEntityModel,
final List<ObjectAction> objectActions,
- final ScalarModel scalarModelForAssociationIfAny,
+ final ScalarModel scalarModelIfAny,
final ToggledMementosProvider toggledMementosProviderIfAny) {
- final ActionLinkFactory linkFactory = new EntityActionLinkFactory(parentEntityModel, scalarModelForAssociationIfAny);
+ final ActionLinkFactory linkFactory = new EntityActionLinkFactory(parentEntityModel, scalarModelIfAny);
return FluentIterable.from(objectActions)
.transform(new Function<ObjectAction, LinkAndLabel>() {
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 6ee3864..9e98786 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
@@ -37,7 +37,6 @@ import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.LabeledWebMarkupContainer;
-import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -51,7 +50,6 @@ import org.apache.isis.core.metamodel.consent.Consent;
import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
-import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacet;
import org.apache.isis.core.metamodel.facets.objectvalue.labelat.LabelAtFacet;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
@@ -318,8 +316,9 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
final ScalarModel scalarModel = getModel();
final String disableReasonIfAny = scalarModel.whetherDisabled();
+ final boolean mustBeEditable = scalarModel.mustBeEditable(getDeploymentCategory());
if (disableReasonIfAny != null) {
- if(disableReasonIfAny.contains(DisabledFacet.ALWAYS_DISABLED_REASON) || disableReasonIfAny.contains("Immutable")) {
+ if(mustBeEditable) {
onInitializeWhenViewMode();
} else {
onInitializeWhenDisabled(disableReasonIfAny);
@@ -381,8 +380,15 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
scalarTypeContainer.addOrReplace(scalarIfCompact, scalarIfRegular);
- List<LinkAndLabel> linkAndLabels =
- LinkAndLabelUtil.asActionLinksForAssociation(this.scalarModel, getDeploymentCategory());
+ // find associated actions for this scalar property (only properties will have any.)
+ final ScalarModel.AssociatedActions associatedActionsIfProperty =
+ scalarModel.associatedActionsIfProperty(getDeploymentCategory());
+ final ObjectAction inlineActionIfAny =
+ associatedActionsIfProperty.getFirstAssociatedWithInlineAsIfEdit();
+ final List<ObjectAction> remainingAssociated = associatedActionsIfProperty.getRemainingAssociated();
+
+ // convert those actions into UI layer widgets
+ final List<LinkAndLabel> linkAndLabels = LinkAndLabelUtil.asActionLinks(this.scalarModel, remainingAssociated);
final InlinePromptConfig inlinePromptConfig = getInlinePromptConfig();
if(inlinePromptConfig.isSupported()) {
@@ -403,9 +409,6 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
// are using inline prompts
Component componentToHideIfAny = inlinePromptLink;
- // check if one of the associated actions is configured to use an inline form "as if edit"
- final LinkAndLabel linkAndLabelAsIfEdit = inlineAsIfEditIfAny(linkAndLabels);
-
if (this.scalarModel.getPromptStyle().isInline() && scalarModel.canEnterEditMode()) {
// we configure the prompt link if _this_ property is configured for inline edits...
configureInlinePromptLinkCallback(inlinePromptLink);
@@ -414,11 +417,9 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
} else {
// not editable property, but maybe one of the actions is.
- if(linkAndLabelAsIfEdit != null) {
-
- scalarModel.setHasActionWithInlineAsIfEdit(true);
+ if(inlineActionIfAny != null) {
- // safe to do this, the inlineAsEditIfAny(...) method checks for us
+ final LinkAndLabel linkAndLabelAsIfEdit = LinkAndLabelUtil.asActionLink(this.scalarModel, inlineActionIfAny);
final ActionLink actionLinkInlineAsIfEdit = (ActionLink) linkAndLabelAsIfEdit.getLink();
if(actionLinkInlineAsIfEdit.isVisible() && actionLinkInlineAsIfEdit.isEnabled()) {
@@ -428,17 +429,13 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
}
}
- if(linkAndLabelAsIfEdit != null) {
- // irrespective of whether the property is itself editable, if the action is annotated as
- // INLINE_AS_IF_EDIT then we never render it as an action
- linkAndLabels = Lists.newArrayList(linkAndLabels);
- linkAndLabels.remove(linkAndLabelAsIfEdit);
- }
if(componentToHideIfAny != null) {
componentToHideIfAny.setVisibilityAllowed(false);
}
}
+
+ // prevent from tabbing into non-editable widgets.
if(scalarModel.getKind() == ScalarModel.Kind.PROPERTY &&
scalarModel.getMode() == EntityModel.Mode.VIEW &&
(scalarModel.getPromptStyle().isDialog() || !scalarModel.canEnterEditMode())) {
@@ -460,51 +457,52 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
}
/**
- * @return the first {@link ActionLink} (if any) configured with a
- * {@link LinkAndLabel#getPromptStyle() prompt style} of {@link PromptStyle#INLINE_AS_IF_EDIT}.
- */
- private static LinkAndLabel inlineAsIfEditIfAny(final List<LinkAndLabel> linkAndLabels) {
- for (LinkAndLabel linkAndLabel : linkAndLabels) {
- AbstractLink link = linkAndLabel.getLink();
- if(link instanceof ActionLink) {
-
- PromptStyle promptStyle = linkAndLabel.getPromptStyle();
-
- if(promptStyle.isInlineAsIfEdit()) {
- return linkAndLabel;
- }
- }
- }
- return null;
- }
-
- /**
- * Optional hook.
+ * The widget starts off in read-only, but should be possible to activate into edit mode.
+ *
+ * <p>
+ * TODO: perhaps rename to 'notEditable'
+ * </p>
*/
protected void onInitializeWhenViewMode() {
}
/**
- * Optional hook.
+ * The widget starts off read-only, and CANNOT be activated into edit mode.
+ *
+ * <p>
+ * TODO: perhaps rename to 'readOnly'
+ * </p>
*/
protected void onInitializeWhenDisabled(final String disableReason) {
}
/**
- * Optional hook.
+ * The widget starts off immediately editable.
+ *
+ * <p>
+ * TODO: perhaps rename to 'editable'.
+ * </p>
*/
protected void onInitializeWhenEnabled() {
}
/**
- * Optional hook.
+ * The widget is no longer editable.
+ *
+ * <p>
+ * TODO: perhaps rename to 'onNotEditable', because the semantics here aren't the same as 'onInitializeWhenDisabled'
+ * (the latter is never editable).
+ * </p>
*/
protected void onDisabled(final String disableReason, final AjaxRequestTarget target) {
}
/**
- * Optional hook.
- * @param target
+ * The widget should be made editable.
+ *
+ * <p>
+ * TODO: perhaps rename to 'onEditable'?
+ * </p>
*/
protected void onEnabled(final AjaxRequestTarget target) {
}
@@ -850,7 +848,7 @@ public abstract class ScalarPanelAbstract2 extends PanelAbstract<ScalarModel> im
editProperty.add(new AjaxEventBehavior("click") {
protected void onEvent(AjaxRequestTarget target) {
- final ObjectSpecification specification = scalarModel.getObject().getSpecification();
+ final ObjectSpecification specification = scalarModel.getTypeOfSpecification();
final MetaModelService2 metaModelService2 = getIsisSessionFactory().getServicesInjector()
.lookupService(MetaModelService2.class);
final MetaModelService2.Sort sort = metaModelService2.sortOf(specification.getCorrespondingClass());
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
index 31b3ad0..b4afff1 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
@@ -32,7 +32,6 @@ import org.apache.isis.applib.annotation.LabelPosition;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.objectvalue.labelat.LabelAtFacet;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-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.components.scalars.ScalarPanelAbstract2;
import org.apache.isis.viewer.wicket.ui.components.widgets.bootstrap.FormGroup;
@@ -100,8 +99,8 @@ public class BooleanPanel extends ScalarPanelAbstract2 {
@Override
protected InlinePromptConfig getInlinePromptConfig() {
return InlinePromptConfig.supportedAndHide(
- scalarModel.getMode() == EntityModel.Mode.EDIT || scalarModel.hasActionWithInlineAsIfEdit() ||
- scalarModel.getKind() == ScalarModel.Kind.PARAMETER
+ // TODO: not sure why this is needed when the other subtypes have no similar guard...
+ scalarModel.mustBeEditable(getDeploymentCategory())
? this.checkBox
: null
);
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/reference/ReferencePanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/reference/ReferencePanel.java
index 32ed670..e1b8238 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/reference/ReferencePanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/reference/ReferencePanel.java
@@ -270,8 +270,7 @@ public class ReferencePanel extends ScalarPanelSelect2Abstract {
componentForRegular.addOrReplace(component);
- boolean inlinePrompt = (scalarModel.getPromptStyle().isInline() && scalarModel.canEnterEditMode()) ||
- scalarModel.hasActionWithInlineAsIfEdit();
+ boolean inlinePrompt = scalarModel.isInlinePrompt(getDeploymentCategory());
if(inlinePrompt) {
// bit of a hack... allows us to suppress the title using CSS
component.add(new CssClassAppender("inlinePrompt"));
[isis] 02/02: ISIS-2001: blob/clob properties now visible once more
even if not editable.
Posted by da...@apache.org.
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
commit c8146874a9633a3afd9da1621131c6d67277ac3f
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue May 14 20:38:10 2019 +0100
ISIS-2001: blob/clob properties now visible once more even if not editable.
---
.../isisapplib/IsisBlobOrClobPanelAbstract.java | 39 +++++++++++-----------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/isisapplib/IsisBlobOrClobPanelAbstract.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/isisapplib/IsisBlobOrClobPanelAbstract.java
index e0c0c60..219ad43 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/isisapplib/IsisBlobOrClobPanelAbstract.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/isisapplib/IsisBlobOrClobPanelAbstract.java
@@ -194,15 +194,15 @@ public abstract class IsisBlobOrClobPanelAbstract<T extends NamedWithMimeType> e
// //////////////////////////////////////
protected void onInitializeWhenViewMode() {
- updateRegularFormComponents(InputFieldVisibility.NOT_VISIBLE, null, null, null);
+ updateRegularFormComponents(InputFieldVisibility.VISIBLE, InputFieldEditability.NOT_EDITABLE, null, null);
}
protected void onInitializeWhenDisabled(final String disableReason) {
- updateRegularFormComponents(InputFieldVisibility.NOT_VISIBLE, null, null, null);
+ updateRegularFormComponents(InputFieldVisibility.VISIBLE, InputFieldEditability.NOT_EDITABLE, null, null);
}
protected void onInitializeWhenEnabled() {
- updateRegularFormComponents(InputFieldVisibility.VISIBLE, null, null, null);
+ updateRegularFormComponents(InputFieldVisibility.VISIBLE, InputFieldEditability.EDITABLE, null, null);
}
private FileUploadField createFileUploadField(String componentId) {
@@ -238,12 +238,12 @@ public abstract class IsisBlobOrClobPanelAbstract<T extends NamedWithMimeType> e
@Override
protected void onDisabled(final String disableReason, final AjaxRequestTarget target) {
- updateRegularFormComponents(null, InputFieldEditability.NOT_EDITABLE, disableReason, target);
+ updateRegularFormComponents(InputFieldVisibility.VISIBLE, InputFieldEditability.NOT_EDITABLE, disableReason, target);
}
@Override
protected void onEnabled(final AjaxRequestTarget target) {
- updateRegularFormComponents(null, InputFieldEditability.EDITABLE, null, target);
+ updateRegularFormComponents(InputFieldVisibility.VISIBLE, InputFieldEditability.EDITABLE, null, target);
}
protected abstract T getBlobOrClobFrom(final List<FileUpload> fileUploads);
@@ -268,12 +268,15 @@ public abstract class IsisBlobOrClobPanelAbstract<T extends NamedWithMimeType> e
sync(formComponent, visibility, editability, disabledReason, target);
final Component component = formComponent.get(ID_SCALAR_VALUE);
- sync(component, visibility, editability, disabledReason, target);
+ final InputFieldVisibility editingWidgetVisibility = editability == InputFieldEditability.EDITABLE ?
+ InputFieldVisibility.VISIBLE :
+ InputFieldVisibility.NOT_VISIBLE;
+ sync(component, editingWidgetVisibility, null, disabledReason, target);
addAcceptFilterTo(component);
fileNameLabel = updateFileNameLabel(ID_FILE_NAME, formComponent);
- updateClearLink(visibility, editability, target);
+ updateClearLink(editingWidgetVisibility, null, target);
// the visibility of download link is intentionally 'backwards';
// if in edit mode then do NOT show
@@ -305,12 +308,12 @@ public abstract class IsisBlobOrClobPanelAbstract<T extends NamedWithMimeType> e
if(editability != null) {
- // dynamic disablement doesn't yet work, this exception is thrown when form is submitted:
- //
- // Caused by: java.lang.IllegalStateException: ServletRequest does not contain multipart content.
- // One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to
- // auto-detect multipart forms but there are certain situation where it cannot.
-
+// // dynamic disablement doesn't yet work, this exception is thrown when form is submitted:
+// //
+// // Caused by: java.lang.IllegalStateException: ServletRequest does not contain multipart content.
+// // One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to
+// // auto-detect multipart forms but there are certain situation where it cannot.
+//
// component.setEnabled(editability == InputFieldEditability.EDITABLE);
//
// final AttributeModifier title = new AttributeModifier("title", Model.of(disabledReason != null ? disabledReason : ""));
@@ -320,8 +323,6 @@ public abstract class IsisBlobOrClobPanelAbstract<T extends NamedWithMimeType> e
// target.add(component);
// }
- // as a workaround, use VISIBILITY instead.
-
}
@@ -386,13 +387,13 @@ public abstract class IsisBlobOrClobPanelAbstract<T extends NamedWithMimeType> e
formComponent.addOrReplace(ajaxLink);
final T blobOrClob = getBlobOrClobFromModel();
- final Component component = formComponent.get(ID_SCALAR_IF_REGULAR_CLEAR);
- component.setVisible(blobOrClob != null && visibility == InputFieldVisibility.VISIBLE);
- component.setEnabled(blobOrClob != null && editability == InputFieldEditability.EDITABLE);
+ final Component clearButton = formComponent.get(ID_SCALAR_IF_REGULAR_CLEAR);
+ clearButton.setVisible(blobOrClob != null && visibility == InputFieldVisibility.VISIBLE);
+ clearButton.setEnabled(blobOrClob != null);
if(target != null) {
target.add(formComponent);
- target.add(component);
+ target.add(clearButton);
target.add(ajaxLink);
}
}