From: Mathieu Baudier Date: Fri, 9 Oct 2020 05:27:13 +0000 (+0200) Subject: Move MVC provider. X-Git-Tag: argeo-commons-2.1.89~78 X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=commitdiff_plain;h=b2c3ef991bc34596830e31e58a2b74147010374f Move MVC provider. --- diff --git a/org.argeo.api/src/org/argeo/api/MvcProvider.java b/org.argeo.api/src/org/argeo/api/MvcProvider.java deleted file mode 100644 index 5d48873ab..000000000 --- a/org.argeo.api/src/org/argeo/api/MvcProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.argeo.api; - -import java.util.function.BiFunction; - -/** - * Stateless UI part creator. Takes a parent view (V) and a model context (M) in - * order to create a view part (W) which can then be further configured. Such - * object can be used as services and reference other part of the model which - * are relevant for all created UI part. - */ -@FunctionalInterface -public interface MvcProvider extends BiFunction { - W createUiPart(V parent, M context); - - /** - * Whether this parent view is supported. - * - * @return true by default. - */ - default boolean isViewSupported(V parent) { - return true; - } - - /** - * Whether this context is supported. - * - * @return true by default. - */ - default boolean isModelSupported(M context) { - return true; - } - - default W apply(V parent, M context) { - if (!isViewSupported(parent)) - throw new IllegalArgumentException("Parent view " + parent + "is not supported."); - if (!isModelSupported(context)) - throw new IllegalArgumentException("Model context " + context + "is not supported."); - return createUiPart(parent, context); - } - - default W createUiPart(V parent) { - return createUiPart(parent, null); - } -} diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/MvcProvider.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/MvcProvider.java new file mode 100644 index 000000000..5d48873ab --- /dev/null +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/MvcProvider.java @@ -0,0 +1,44 @@ +package org.argeo.api; + +import java.util.function.BiFunction; + +/** + * Stateless UI part creator. Takes a parent view (V) and a model context (M) in + * order to create a view part (W) which can then be further configured. Such + * object can be used as services and reference other part of the model which + * are relevant for all created UI part. + */ +@FunctionalInterface +public interface MvcProvider extends BiFunction { + W createUiPart(V parent, M context); + + /** + * Whether this parent view is supported. + * + * @return true by default. + */ + default boolean isViewSupported(V parent) { + return true; + } + + /** + * Whether this context is supported. + * + * @return true by default. + */ + default boolean isModelSupported(M context) { + return true; + } + + default W apply(V parent, M context) { + if (!isViewSupported(parent)) + throw new IllegalArgumentException("Parent view " + parent + "is not supported."); + if (!isModelSupported(context)) + throw new IllegalArgumentException("Model context " + context + "is not supported."); + return createUiPart(parent, context); + } + + default W createUiPart(V parent) { + return createUiPart(parent, null); + } +}