Clarify MVC UI provider.
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 28 Apr 2020 07:54:20 +0000 (09:54 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 28 Apr 2020 07:54:20 +0000 (09:54 +0200)
org.argeo.api/src/org/argeo/api/MvcProvider.java
org.argeo.cms.ui/src/org/argeo/cms/ui/CmsUiProvider.java

index 9c5c4a06bdafbb6d68265570aa6551ceae78d32c..5d48873ab89e04bf6feb970919a6cf75ed6dc377 100644 (file)
@@ -10,6 +10,8 @@ import java.util.function.BiFunction;
  */
 @FunctionalInterface
 public interface MvcProvider<V, M, W> extends BiFunction<V, M, W> {
+       W createUiPart(V parent, M context);
+       
        /**
         * Whether this parent view is supported.
         * 
@@ -28,11 +30,15 @@ public interface MvcProvider<V, M, W> extends BiFunction<V, M, W> {
                return true;
        }
 
-       default W createUiPart(V parent, M context) {
+       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 apply(parent, context);
+               return createUiPart(parent, context);
+       }
+
+       default W createUiPart(V parent) {
+               return createUiPart(parent, null);
        }
 }
index 8a12c100ec7368ccff6d4acaec3c4b0f78304f55..6b1dde38a879cd22688265c2ef120e270b8fa8e0 100644 (file)
@@ -16,10 +16,10 @@ public interface CmsUiProvider extends MvcProvider<Composite, Node, Control> {
         * @param parent  the parent composite
         * @param context a context node (holding the JCR underlying session), or null
         */
-       public Control createUi(Composite parent, Node context) throws RepositoryException;
+       Control createUi(Composite parent, Node context) throws RepositoryException;
 
        @Override
-       public default Control apply(Composite parent, Node context) {
+       default Control createUiPart(Composite parent, Node context) {
                try {
                        return createUi(parent, context);
                } catch (RepositoryException e) {