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/09/28 14:43:16 UTC
[isis] 02/05: ISIS-2086: refactors about 6 isis.viewer.wicket
config props to type-safe
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2086
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 545df3ae1397da077947ffe305ab6647de136309
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sat Sep 28 14:59:46 2019 +0100
ISIS-2086: refactors about 6 isis.viewer.wicket config props to type-safe
---
.../org/apache/isis/config/IsisConfiguration.java | 84 ++++++++++++++++++++++
.../settings/WicketViewerSettingsDefault.java | 18 ++---
.../wicket/model/isis/WicketViewerSettings.java | 65 +++++------------
3 files changed, 109 insertions(+), 58 deletions(-)
diff --git a/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java b/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java
index 93255ac..bad731f 100644
--- a/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java
+++ b/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java
@@ -128,6 +128,14 @@ public class IsisConfiguration {
private boolean suppressPasswordReset = false;
private boolean clearOriginalDestination = false;
+ /**
+ * Whether to use a modal dialog for property edits and for actions associated with properties.
+ * This can be overridden on a case-by-case basis using <code>@PropertyLayout#promptStyle</code> and
+ * <code>@ActionLayout#promptStyle</code>.
+ *
+ * This behaviour is disabled by default; the viewer will use an inline prompt in these cases, making for a smoother
+ * user experience. If enabled then this reinstates the pre-1.15.0 behaviour of using a dialog prompt in all cases.
+ */
private PromptStyle promptStyle = PromptStyle.INLINE;
private boolean showFooter = true;
@@ -138,6 +146,10 @@ public class IsisConfiguration {
public int getMaxTitleLengthInParentedTables() {
return maxTitleLengthInParentedTables != null ? maxTitleLengthInParentedTables : getMaxTitleLengthInTables();
}
+ /**
+ * The maximum length that a title of an object will be shown when rendered in a parented table;
+ * will be truncated beyond this (with ellipses to indicate the truncation).
+ */
public void setMaxTitleLengthInParentedTables(final int val) {
maxTitleLengthInParentedTables = val;
}
@@ -146,9 +158,81 @@ public class IsisConfiguration {
public int getMaxTitleLengthInStandaloneTables() {
return maxTitleLengthInStandaloneTables != null ? maxTitleLengthInStandaloneTables : getMaxTitleLengthInTables();
}
+ /**
+ * The maximum length that a title of an object will be shown when rendered in a standalone table;
+ * will be truncated beyond this (with ellipses to indicate the truncation).
+ */
public void setMaxTitleLengthInStandaloneTables(final int val) {
maxTitleLengthInStandaloneTables = val;
}
+
+ /**
+ * The pattern used for rendering and parsing dates.
+ *
+ * <p>
+ * Each Date scalar panel will use {@ #getDatePattern()} or {@linkplain #getDateTimePattern()} depending on its
+ * date type. In the case of panels with a date picker, the pattern will be dynamically adjusted so that it can be
+ * used by the <a href="https://github.com/Eonasdan/bootstrap-datetimepicker">Bootstrap Datetime Picker</a>
+ * component (which uses <a href="http://momentjs.com/docs/#/parsing/string-format/">Moment.js formats</a>, rather
+ * than those of regular Java code).
+ */
+ private String datePattern = "dd-MM-yyyy";
+ /**
+ * The pattern used for rendering and parsing date/times.
+ *
+ * <p>
+ * Each Date scalar panel will use {@link Wicket#getDatePattern()} or {@link Wicket#getDateTimePattern()} depending on its
+ * date type. In the case of panels with a date time picker, the pattern will be dynamically adjusted so that it can be
+ * used by the <a href="https://github.com/Eonasdan/bootstrap-datetimepicker">Bootstrap Datetime Picker</a>
+ * component (which uses <a href="http://momentjs.com/docs/#/parsing/string-format/">Moment.js formats</a>, rather
+ * than those of regular Java code).
+ */
+ private String dateTimePattern = "dd-MM-yyyy HH:mm";
+ /**
+ * The pattern used for rendering and parsing timestamps.
+ */
+ private String timestampPattern = "yyyy-MM-dd HH:mm:ss.SSS";
+ /**
+ * in Firefox and more recent versions of Chrome 54+, cannot copy out of disabled fields; instead we use the
+ * readonly attribute (https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-readonly-attribute)
+ * This behaviour is enabled by default but can be disabled using this flag
+ */
+ private boolean replaceDisabledTagWithReadonlyTag = true;
+ /**
+ * Whether to disable a form submit button after it has been clicked, to prevent users causing an error if they
+ * do a double click.
+ *
+ * This behaviour is enabled by default, but can be disabled using this flag.
+ */
+ private boolean preventDoubleClickForFormSubmit = true;
+ /**
+ * Whether to disable a no-arg action button after it has been clicked, to prevent users causing an error if they
+ * do a double click.
+ *
+ * This behaviour is enabled by default, but can be disabled using this flag.
+ */
+ private boolean preventDoubleClickForNoArgAction = true;
+ /**
+ * Whether to show an indicator for a form submit button that it has been clicked.
+ *
+ * This behaviour is enabled by default, but can be disabled using this flag.
+ */
+ private boolean useIndicatorForFormSubmit = true;
+ /**
+ * Whether to show an indicator for a no-arg action button that it has been clicked.
+ *
+ * This behaviour is enabled by default, but can be disabled using this flag.
+ */
+ private boolean useIndicatorForNoArgAction = true;
+
+ /**
+ * Whether to redirect to a new page, even if the object being shown (after an action invocation or a property edit)
+ * is the same as the previous page.
+ *
+ * This behaviour is disabled by default; the viewer will update the existing page if it can, making for a
+ * smoother user experience. If enabled then this reinstates the pre-1.15.0 behaviour of redirecting in all cases.
+ */
+ private boolean redirectEvenIfSameObject = false;
}
}
diff --git a/core/viewer-wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/settings/WicketViewerSettingsDefault.java b/core/viewer-wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/settings/WicketViewerSettingsDefault.java
index f1c9057..1c03f51 100644
--- a/core/viewer-wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/settings/WicketViewerSettingsDefault.java
+++ b/core/viewer-wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/settings/WicketViewerSettingsDefault.java
@@ -59,42 +59,42 @@ public class WicketViewerSettingsDefault implements WicketViewerSettings {
@Override
public String getDatePattern() {
- return getConfigurationLegacy().getString("isis.viewer.wicket.datePattern", "dd-MM-yyyy");
+ return getConfiguration().getViewer().getWicket().getDatePattern();
}
@Override
public String getDateTimePattern() {
- return getConfigurationLegacy().getString("isis.viewer.wicket.dateTimePattern", "dd-MM-yyyy HH:mm");
+ return getConfiguration().getViewer().getWicket().getDateTimePattern();
}
@Override
public String getTimestampPattern() {
- return getConfigurationLegacy().getString("isis.viewer.wicket.timestampPattern", "yyyy-MM-dd HH:mm:ss.SSS");
+ return getConfiguration().getViewer().getWicket().getTimestampPattern();
}
@Override
public boolean isReplaceDisabledTagWithReadonlyTag() {
- return getConfigurationLegacy().getBoolean("isis.viewer.wicket.replaceDisabledTagWithReadonlyTag", true);
+ return getConfiguration().getViewer().getWicket().isReplaceDisabledTagWithReadonlyTag();
}
@Override
public boolean isPreventDoubleClickForFormSubmit() {
- return getConfigurationLegacy().getBoolean("isis.viewer.wicket.preventDoubleClickForFormSubmit", true);
+ return getConfiguration().getViewer().getWicket().isPreventDoubleClickForFormSubmit();
}
@Override
public boolean isPreventDoubleClickForNoArgAction() {
- return getConfigurationLegacy().getBoolean("isis.viewer.wicket.preventDoubleClickForNoArgAction", true);
+ return getConfiguration().getViewer().getWicket().isPreventDoubleClickForNoArgAction();
}
@Override
public boolean isUseIndicatorForFormSubmit() {
- return getConfigurationLegacy().getBoolean("isis.viewer.wicket.useIndicatorForFormSubmit", true);
+ return getConfiguration().getViewer().getWicket().isUseIndicatorForFormSubmit();
}
@Override
public boolean isUseIndicatorForNoArgAction() {
- return getConfigurationLegacy().getBoolean("isis.viewer.wicket.useIndicatorForNoArgAction", true);
+ return getConfiguration().getViewer().getWicket().isUseIndicatorForNoArgAction();
}
@Override
@@ -104,6 +104,6 @@ public class WicketViewerSettingsDefault implements WicketViewerSettings {
@Override
public boolean isRedirectEvenIfSameObject() {
- return getConfigurationLegacy().getBoolean("isis.viewer.wicket.redirectEvenIfSameObject", false);
+ return getConfiguration().getViewer().getWicket().isRedirectEvenIfSameObject();
}
}
diff --git a/core/viewer-wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/isis/WicketViewerSettings.java b/core/viewer-wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/isis/WicketViewerSettings.java
index cd9b5ad..3f6191a 100644
--- a/core/viewer-wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/isis/WicketViewerSettings.java
+++ b/core/viewer-wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/isis/WicketViewerSettings.java
@@ -22,103 +22,70 @@ package org.apache.isis.viewer.wicket.model.isis;
import java.io.Serializable;
import org.apache.isis.applib.annotation.PromptStyle;
+import org.apache.isis.config.IsisConfiguration;
public interface WicketViewerSettings extends Serializable {
/**
- * The maximum length that a title of an object will be shown when rendered in a standalone table;
- * will be truncated beyond this (with ellipses to indicate the truncation).
+ * as per {@link IsisConfiguration.Viewer.Wicket#setMaxTitleLengthInStandaloneTables(int)}
*/
int getMaxTitleLengthInStandaloneTables();
/**
- * The maximum length that a title of an object will be shown when rendered in a parented table;
- * will be truncated beyond this (with ellipses to indicate the truncation).
+ * as per {@link IsisConfiguration.Viewer.Wicket#setMaxTitleLengthInParentedTables(int)}
+ * @return
*/
int getMaxTitleLengthInParentedTables();
/**
- * The pattern used for rendering and parsing dates.
- *
- * <p>
- * Each Date scalar panel will use {@ #getDatePattern()} or {@linkplain #getDateTimePattern()} depending on its
- * date type. In the case of panels with a date picker, the pattern will be dynamically adjusted so that it can be
- * used by the <a href="https://github.com/Eonasdan/bootstrap-datetimepicker">Bootstrap Datetime Picker</a>
- * component (which uses <a href="http://momentjs.com/docs/#/parsing/string-format/">Moment.js formats</a>, rather
- * than those of regular Java code).
+ * As per {@link IsisConfiguration.Viewer.Wicket#setDatePattern(String)}
+ * @return
*/
String getDatePattern();
/**
- * The pattern used for rendering and parsing date/times.
- *
- * <p>
- * Each Date scalar panel will use {@ #getDatePattern()} or {@linkplain #getDateTimePattern()} depending on its
- * date type. In the case of panels with a date time picker, the pattern will be dynamically adjusted so that it can be
- * used by the <a href="https://github.com/Eonasdan/bootstrap-datetimepicker">Bootstrap Datetime Picker</a>
- * component (which uses <a href="http://momentjs.com/docs/#/parsing/string-format/">Moment.js formats</a>, rather
- * than those of regular Java code).
+ * As per {@link IsisConfiguration.Viewer.Wicket#setDateTimePattern(String)}
+ * @return
*/
String getDateTimePattern();
/**
- * The pattern used for rendering and parsing timestamps.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setTimestampPattern(String)}
*/
String getTimestampPattern();
/**
- * in Firefox and more recent versions of Chrome 54+, cannot copy out of disabled fields; instead we use the
- * readonly attribute (https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-readonly-attribute)
- * This behaviour is enabled by default but can be disabled using this flag
+ * As per {@link IsisConfiguration.Viewer.Wicket#setReplaceDisabledTagWithReadonlyTag(boolean)}
*/
boolean isReplaceDisabledTagWithReadonlyTag();
/**
- * Whether to disable a form submit button after it has been clicked, to prevent users causing an error if they
- * do a double click.
- *
- * This behaviour is enabled by default, but can be disabled using this flag.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setPreventDoubleClickForFormSubmit(boolean)}
*/
boolean isPreventDoubleClickForFormSubmit();
/**
- * Whether to disable a no-arg action button after it has been clicked, to prevent users causing an error if they
- * do a double click.
- *
- * This behaviour is enabled by default, but can be disabled using this flag.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setPreventDoubleClickForNoArgAction(boolean)}
*/
boolean isPreventDoubleClickForNoArgAction();
/**
- * Whether to show an indicator for a form submit button that it has been clicked.
- *
- * This behaviour is enabled by default, but can be disabled using this flag.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setUseIndicatorForFormSubmit(boolean)}
*/
boolean isUseIndicatorForFormSubmit();
/**
- * Whether to show an indicator for a no-arg action button that it has been clicked.
- *
- * This behaviour is enabled by default, but can be disabled using this flag.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setUseIndicatorForNoArgAction(boolean)}
*/
boolean isUseIndicatorForNoArgAction();
/**
- * Whether to use a modal dialog for property edits and for actions associated with properties.
- * This can be overridden on a case-by-case basis using <code>@PropertyLayout#promptStyle</code> and
- * <code>@ActionLayout#promptStyle</code>.
- *
- * This behaviour is disabled by default; the viewer will use an inline prompt in these cases, making for a smoother
- * user experience. If enabled then this reinstates the pre-1.15.0 behaviour of using a dialog prompt in all cases.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setPromptStyle(PromptStyle)}
*/
PromptStyle getPromptStyle();
/**
- * Whether to redirect to a new page, even if the object being shown (after an action invocation or a property edit)
- * is the same as the previous page.
- *
- * This behaviour is disabled by default; the viewer will update the existing page if it can, making for a
- * smoother user experience. If enabled then this reinstates the pre-1.15.0 behaviour of redirecting in all cases.
+ * As per {@link IsisConfiguration.Viewer.Wicket#setRedirectEvenIfSameObject(boolean)}
*/
boolean isRedirectEvenIfSameObject();