Refactor CMS UX API
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 23 Jun 2022 05:00:34 +0000 (07:00 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 23 Jun 2022 05:00:34 +0000 (07:00 +0200)
61 files changed:
eclipse/org.argeo.cms.e4/src/org/argeo/cms/e4/maintenance/Browse.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsIcon.java [deleted file]
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtTheme.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtUi.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtUtils.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/SimpleSwtUxContext.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/app/CmsUserApp.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/auth/CmsLogin.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/auth/CmsLoginShell.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/dialogs/ChangePasswordDialog.java
eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/osgi/BundleCmsSwtTheme.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsUiConstants.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/forms/FormEditorHeader.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/forms/FormPageViewer.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/forms/FormStyle.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/forms/FormUtils.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/internal/JcrFileUploadReceiver.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/internal/SimpleEditableImage.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsLink.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsUiUtils.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/util/DefaultImageManager.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/util/SimpleStyle.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/AbstractPageViewer.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/JcrVersionCmsEditable.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/widgets/EditableImage.java
jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/widgets/Img.java
org.argeo.api.cms/src/org/argeo/api/cms/Cms2DSize.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/CmsApp.java
org.argeo.api.cms/src/org/argeo/api/cms/CmsEditable.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/CmsEvent.java
org.argeo.api.cms/src/org/argeo/api/cms/CmsImageManager.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/CmsStyle.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/CmsTheme.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/CmsUi.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/CmsView.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/MvcProvider.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/UxContext.java [deleted file]
org.argeo.api.cms/src/org/argeo/api/cms/ux/Cms2DSize.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsEditable.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsIcon.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsImageManager.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsStyle.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsTheme.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsUi.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsView.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/MvcProvider.java [new file with mode: 0644]
org.argeo.api.cms/src/org/argeo/api/cms/ux/UxContext.java [new file with mode: 0644]
org.argeo.cms.ux/src/org/argeo/cms/ux/CmsUxUtils.java
org.argeo.cms.ux/src/org/argeo/cms/ux/widgets/Column.java
org.argeo.cms/src/org/argeo/cms/AbstractCmsApp.java
org.argeo.cms/src/org/argeo/cms/osgi/BundleCmsTheme.java
rap/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/CmsLoginLifecycle.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/ui/script/CmsScriptApp.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/AbstractCmsEntryPoint.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsThemeResourceLoader.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/SimpleErgonomics.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/WebThemeUtils.java
rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsE4Application.java
rcp/org.argeo.cms.ui.rcp/src/org/argeo/cms/ui/rcp/CmsRcpApp.java

index 260a114cd990f066c2db26852f55d8073562acc1..40a3c4e8bb8f039dcc1e8a4f6b9f5138f40bedac 100644 (file)
@@ -15,7 +15,7 @@ import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
-import org.argeo.api.cms.Cms2DSize;
+import org.argeo.api.cms.ux.Cms2DSize;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.ui.CmsUiProvider;
diff --git a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsIcon.java b/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsIcon.java
deleted file mode 100644 (file)
index 4ff89f2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.argeo.cms.swt;
-
-import org.argeo.api.cms.CmsTheme;
-import org.eclipse.swt.graphics.Image;
-
-/** Can be applied to {@link Enum}s in order to generated {@link Image}s. */
-public interface CmsIcon {
-       String name();
-
-       default Image getSmallIcon(CmsTheme theme) {
-               return ((CmsSwtTheme) theme).getIcon(name(), getSmallIconSize());
-       }
-
-       default Image getBigIcon(CmsTheme theme) {
-               return ((CmsSwtTheme) theme).getIcon(name(), getBigIconSize());
-       }
-
-       default Integer getSmallIconSize() {
-               return 16;
-       }
-
-       default Integer getBigIconSize() {
-               return 32;
-       }
-}
index b40c2a06ce497bf714e98bc760131ba306b9e018..7669b1554df2872954788e095ca645b9dafaedf3 100644 (file)
@@ -1,6 +1,7 @@
 package org.argeo.cms.swt;
 
-import org.argeo.api.cms.CmsTheme;
+import org.argeo.api.cms.ux.CmsIcon;
+import org.argeo.api.cms.ux.CmsTheme;
 import org.eclipse.swt.graphics.Image;
 
 /** SWT specific {@link CmsTheme}. */
@@ -18,4 +19,7 @@ public interface CmsSwtTheme extends CmsTheme {
         */
        Image getIcon(String name, Integer preferredSize);
 
+       Image getSmallIcon(CmsIcon icon);
+       
+       Image getBigIcon(CmsIcon icon);
 }
index 75fa197490e4aa838a7e22652ce5e9ec925ae1ae..2fb79f44394d19866ee65a3159a7c1f691fdedb1 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.cms.swt;
 
-import org.argeo.api.cms.CmsUi;
+import org.argeo.api.cms.ux.CmsUi;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 
index 784d03173bce51ec53285c39f1a1c87defc9490f..5d964090b9abbd908ff1fc3f007c85afe11a76f8 100644 (file)
@@ -6,12 +6,14 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import org.argeo.api.cms.CmsStyle;
-import org.argeo.api.cms.CmsTheme;
-import org.argeo.api.cms.CmsView;
+import org.argeo.api.cms.ux.CmsIcon;
+import org.argeo.api.cms.ux.CmsStyle;
+import org.argeo.api.cms.ux.CmsTheme;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
@@ -30,19 +32,18 @@ import org.eclipse.swt.widgets.Widget;
 
 /** SWT utilities. */
 public class CmsSwtUtils {
+       /*
+        * THEME AND VIEW
+        */
 
-       /** Singleton. */
-       private CmsSwtUtils() {
-       }
-
-       public static CmsTheme getCmsTheme(Composite parent) {
-               CmsTheme theme = (CmsTheme) parent.getData(CmsTheme.class.getName());
+       public static CmsSwtTheme getCmsTheme(Composite parent) {
+               CmsSwtTheme theme = (CmsSwtTheme) parent.getData(CmsTheme.class.getName());
                if (theme == null) {
                        // find parent shell
                        Shell topShell = parent.getShell();
                        while (topShell.getParent() != null)
                                topShell = (Shell) topShell.getParent();
-                       theme = (CmsTheme) topShell.getData(CmsTheme.class.getName());
+                       theme = (CmsSwtTheme) topShell.getData(CmsTheme.class.getName());
                        parent.setData(CmsTheme.class.getName(), theme);
                }
                return theme;
@@ -83,6 +84,10 @@ public class CmsSwtUtils {
                shell.setData(CmsView.class.getName(), view);
        }
 
+       /*
+        * EVENTS
+        */
+
        /** Sends an event via {@link CmsView#sendEvent(String, Map)}. */
        public static void sendEventOnSelect(Control control, String topic, Map<String, Object> properties) {
                SelectionListener listener = (Selected) (e) -> {
@@ -104,6 +109,19 @@ public class CmsSwtUtils {
                sendEventOnSelect(control, topic, properties);
        }
 
+       /*
+        * ICONS
+        */
+       /** Get a small icon from this theme. */
+       public static Image getSmallIcon(CmsTheme theme, CmsIcon icon) {
+               return ((CmsSwtTheme) theme).getSmallIcon(icon);
+       }
+
+       /** Get a big icon from this theme. */
+       public static Image getBigIcon(CmsTheme theme, CmsIcon icon) {
+               return ((CmsSwtTheme) theme).getBigIcon(icon);
+       }
+
        /*
         * LAYOUT INDEPENDENT
         */
@@ -285,8 +303,13 @@ public class CmsSwtUtils {
                        String encoded = URLEncoder.encode(st.nextToken(), StandardCharsets.UTF_8);
                        encoded = encoded.replace("+", "%20");
                        sb.append(encoded);
-       
+
                }
                return sb.toString();
        }
+
+       /** Singleton. */
+       private CmsSwtUtils() {
+       }
+
 }
index 9c55e8b108fbd47f753ed26541a72b6d4fb3cc86..e468c6d52af5641aa8262576406077fb7b2438dc 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.cms.swt;
 
-import org.argeo.api.cms.UxContext;
+import org.argeo.api.cms.ux.UxContext;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Display;
index 2eb2ce5dd029bd436879c72580117b4491abe821..add6e9edb933a6f97d556961c35af4862cf39653 100644 (file)
@@ -6,8 +6,8 @@ import java.util.Set;
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentRepository;
 import org.argeo.api.cms.CmsContext;
-import org.argeo.api.cms.CmsUi;
-import org.argeo.api.cms.CmsView;
+import org.argeo.api.cms.ux.CmsUi;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.AbstractCmsApp;
 import org.argeo.cms.swt.CmsSwtUi;
 import org.argeo.cms.swt.CmsSwtUtils;
index 43e57396b6279097d13165b98ff761804f969c92..afd1b54997f09a5f69af41ac953d9d0fce8f592f 100644 (file)
@@ -20,7 +20,7 @@ import javax.security.auth.login.LoginException;
 import org.argeo.api.cms.CmsAuth;
 import org.argeo.api.cms.CmsContext;
 import org.argeo.api.cms.CmsLog;
-import org.argeo.api.cms.CmsView;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.CmsMsg;
 import org.argeo.cms.LocaleUtils;
 import org.argeo.cms.auth.RemoteAuthCallback;
index a4d7c07704a8eceed53b7b33280d6a8952a29dc9..39cf82afcf729f0918bf2901b04485fad21f0ef4 100644 (file)
@@ -1,7 +1,7 @@
 package org.argeo.cms.swt.auth;
 
 import org.argeo.api.cms.CmsContext;
-import org.argeo.api.cms.CmsView;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Control;
index 8ff0862839536e45f12af7a0917a6a80dcc06a57..06e4d0f9f996374b651ad3695e2ce23e88e62ba7 100644 (file)
@@ -3,8 +3,8 @@ package org.argeo.cms.swt.dialogs;
 import java.security.PrivilegedAction;
 import java.util.Arrays;
 
-import org.argeo.api.cms.CmsView;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.CmsMsg;
 import org.argeo.cms.CmsUserManager;
 import org.argeo.cms.swt.CmsSwtUtils;
index c37a5b74476fdd361e951813270914dfcd9096ae..b3fec78ecc88375914bb5bc8bdf3c47869ba0d6f 100644 (file)
@@ -5,6 +5,7 @@ import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.argeo.api.cms.ux.CmsIcon;
 import org.argeo.cms.osgi.BundleCmsTheme;
 import org.argeo.cms.swt.CmsSwtTheme;
 import org.eclipse.swt.graphics.Image;
@@ -39,11 +40,11 @@ public class BundleCmsSwtTheme extends BundleCmsTheme implements CmsSwtTheme {
         * 
         * @param name          An icon file name without path and extension.
         * @param preferredSize the preferred size, if <code>null</code>,
-        *                      {@link #getDefaultIconSize()} will be tried.
+        *                      {@link #getSmallIconSize()} will be tried.
         */
        public Image getIcon(String name, Integer preferredSize) {
                if (preferredSize == null)
-                       preferredSize = getDefaultIconSize();
+                       preferredSize = getSmallIconSize();
                Map<Integer, String> subCache;
                if (!iconPaths.containsKey(name))
                        subCache = new HashMap<>();
@@ -97,4 +98,14 @@ public class BundleCmsSwtTheme extends BundleCmsTheme implements CmsSwtTheme {
                return image;
        }
 
+       @Override
+       public Image getSmallIcon(CmsIcon icon) {
+               return getIcon(icon.name(), getSmallIconSize());
+       }
+
+       @Override
+       public Image getBigIcon(CmsIcon icon) {
+               return getIcon(icon.name(), getBigIconSize());
+       }
+
 }
index 9df61dccaa62ae16bddc231a52e0752ef662d9f0..c6a62e9e09f498f8ce73fc99fd9ad9b1e3afd606 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.cms.ui;
 
-import org.argeo.api.cms.Cms2DSize;
+import org.argeo.api.cms.ux.Cms2DSize;
 
 /** Commons constants */
 @Deprecated
index f3a56f7b9215187e42e3c9ddc2a0df5d9125a490..a75c19150f12f09a9fdf1abcf6ae9a597eff4553 100644 (file)
@@ -5,7 +5,7 @@ import java.util.Observer;
 
 import javax.jcr.Node;
 
-import org.argeo.api.cms.CmsEditable;
+import org.argeo.api.cms.ux.CmsEditable;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
index cc732d49d5a0ff225baa36a7ae6943b9d6ce7932..3b1daf0aa60a53440aead8ec740795efd231cbad 100644 (file)
@@ -14,10 +14,10 @@ import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 
-import org.argeo.api.cms.Cms2DSize;
-import org.argeo.api.cms.CmsEditable;
-import org.argeo.api.cms.CmsImageManager;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.Cms2DSize;
+import org.argeo.api.cms.ux.CmsEditable;
+import org.argeo.api.cms.ux.CmsImageManager;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.ui.viewers.AbstractPageViewer;
 import org.argeo.cms.ui.viewers.EditablePart;
index 24067eaaa91de29d604ea2df51d16f1fc363d6c1..709ecd024c76b3e1785180185d433a872007a83c 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.cms.ui.forms;
 
-import org.argeo.api.cms.CmsStyle;
+import org.argeo.api.cms.ux.CmsStyle;
 
 /** Syles used */
 public enum FormStyle implements CmsStyle {
index 1a445bd7645d5f37ef06cd2ae7289830f65d1a8b..d5914d209478cc1cb0e4092d798b665eb9df0c32 100644 (file)
@@ -9,8 +9,8 @@ import java.util.GregorianCalendar;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.argeo.api.cms.CmsView;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.ui.util.CmsUiUtils;
 import org.argeo.eclipse.ui.EclipseUiUtils;
index c8582f0c124839552df82b55b22d3ba0febefaeb..60bb42b4686822c86dec365c4420699e47e9b915 100644 (file)
@@ -11,7 +11,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 
 import org.apache.commons.io.FilenameUtils;
-import org.argeo.api.cms.CmsImageManager;
+import org.argeo.api.cms.ux.CmsImageManager;
 import org.argeo.cms.ui.widgets.Img;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
index c5c1a01a2ac045a7d7e8ec6da9bf12fe62143c97..5e938d818f34db04efb1fb0729d6a458773f3e9d 100644 (file)
@@ -2,7 +2,7 @@ package org.argeo.cms.ui.internal;
 
 import javax.jcr.RepositoryException;
 
-import org.argeo.api.cms.Cms2DSize;
+import org.argeo.api.cms.ux.Cms2DSize;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.ui.util.CmsUiUtils;
 import org.argeo.cms.ui.widgets.EditableImage;
index 3821e604573782ed926a50397f6baf8475fe0352..e91f9ba482354231d381c92e8266fee6c3786ce1 100644 (file)
@@ -8,8 +8,8 @@ import java.net.URL;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.argeo.api.cms.CmsStyle;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsStyle;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.swt.CmsSwtUtils;
index 73c545d0da10492f9a190a2ff86fe5a31570b265..178fbcf242b48fa757ba6413c0130763d0c6ac2a 100644 (file)
@@ -9,9 +9,9 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.servlet.http.HttpServletRequest;
 
-import org.argeo.api.cms.Cms2DSize;
-import org.argeo.api.cms.CmsView;
 import org.argeo.api.cms.CmsConstants;
+import org.argeo.api.cms.ux.Cms2DSize;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.ui.CmsUiConstants;
index 1fc9bd1be625e90d5d16424bf0917e498357593f..1ec2622b0eb2a5a65925eebc97d639abcc69aa02 100644 (file)
@@ -18,9 +18,9 @@ import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 
 import org.apache.commons.io.IOUtils;
-import org.argeo.api.cms.Cms2DSize;
-import org.argeo.api.cms.CmsImageManager;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.Cms2DSize;
+import org.argeo.api.cms.ux.CmsImageManager;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
 import org.eclipse.rap.rwt.RWT;
index 8ed06a292943f628761d18fa4f153f8128a7fb0b..b5fca269929b56005011d24559c11626d1d782e9 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.cms.ui.util;
 
-import org.argeo.api.cms.CmsStyle;
+import org.argeo.api.cms.ux.CmsStyle;
 
 /** Simple styles used by the CMS UI utilities. */
 public enum SimpleStyle implements CmsStyle {
index ef24ee0d5021fd729ab8fe3a9b055c3aa9c5e896..1d0c9620a2b880099f62eecedd0bf4856f75493c 100644 (file)
@@ -11,8 +11,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.security.auth.Subject;
 
-import org.argeo.api.cms.CmsEditable;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsEditable;
 import org.argeo.cms.ui.widgets.ScrolledPage;
 import org.argeo.jcr.JcrException;
 import org.eclipse.jface.viewers.ContentViewer;
index 11162e87f344f768687e2a9df0c1289b7057f592..07724f4b11c51a1f00e05c6a068929d9d5c8dfe8 100644 (file)
@@ -8,7 +8,7 @@ import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.VersionManager;
 
-import org.argeo.api.cms.CmsEditable;
+import org.argeo.api.cms.ux.CmsEditable;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.ui.CmsEditionEvent;
 import org.eclipse.rap.rwt.RWT;
index c2393f267a384df28f141cf00f8d57c3615a8021..95d9e8ee9a0d5d957ec54b46dcecec9d761f9b90 100644 (file)
@@ -3,8 +3,8 @@ package org.argeo.cms.ui.widgets;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.argeo.api.cms.Cms2DSize;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.Cms2DSize;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.ui.util.CmsUiUtils;
 import org.eclipse.swt.graphics.Point;
index 3a4a60c9ff5ec6d2841f55f1d769ec4debd920be..41063fa47239d3ffb86166bf58de2d6e2d3e5c12 100644 (file)
@@ -3,8 +3,8 @@ package org.argeo.cms.ui.widgets;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.argeo.api.cms.Cms2DSize;
-import org.argeo.api.cms.CmsImageManager;
+import org.argeo.api.cms.ux.Cms2DSize;
+import org.argeo.api.cms.ux.CmsImageManager;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.ui.internal.JcrFileUploadReceiver;
 import org.argeo.cms.ui.viewers.NodePart;
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/Cms2DSize.java b/org.argeo.api.cms/src/org/argeo/api/cms/Cms2DSize.java
deleted file mode 100644 (file)
index 30b3d81..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.argeo.api.cms;
-
-/** A 2D size. */
-public class Cms2DSize {
-       private Integer width;
-       private Integer height;
-
-       public Cms2DSize() {
-
-       }
-
-       public Cms2DSize(Integer width, Integer height) {
-               super();
-               this.width = width;
-               this.height = height;
-       }
-
-       public Integer getWidth() {
-               return width;
-       }
-
-       public void setWidth(Integer width) {
-               this.width = width;
-       }
-
-       public Integer getHeight() {
-               return height;
-       }
-
-       public void setHeight(Integer height) {
-               this.height = height;
-       }
-
-}
index 99c619c807e3756517fb9c5f509ee45502abb859..745e5a4000b0d5d95e4c8673dc19601171c310d3 100644 (file)
@@ -2,6 +2,9 @@ package org.argeo.api.cms;
 
 import java.util.Set;
 
+import org.argeo.api.cms.ux.CmsTheme;
+import org.argeo.api.cms.ux.CmsUi;
+
 /** An extensible user interface base on the CMS backend. */
 public interface CmsApp {
        /**
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/CmsEditable.java b/org.argeo.api.cms/src/org/argeo/api/cms/CmsEditable.java
deleted file mode 100644 (file)
index 2deca01..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.argeo.api.cms;
-
-/** Abstraction of a simple edition life cycle. */
-public interface CmsEditable {
-
-       /** Whether the calling thread can edit, the value is immutable */
-       public Boolean canEdit();
-
-       public Boolean isEditing();
-
-       public void startEditing();
-
-       public void stopEditing();
-
-       public static CmsEditable NON_EDITABLE = new CmsEditable() {
-
-               @Override
-               public void stopEditing() {
-               }
-
-               @Override
-               public void startEditing() {
-               }
-
-               @Override
-               public Boolean isEditing() {
-                       return false;
-               }
-
-               @Override
-               public Boolean canEdit() {
-                       return false;
-               }
-       };
-
-       public static CmsEditable ALWAYS_EDITING = new CmsEditable() {
-
-               @Override
-               public void stopEditing() {
-               }
-
-               @Override
-               public void startEditing() {
-               }
-
-               @Override
-               public Boolean isEditing() {
-                       return true;
-               }
-
-               @Override
-               public Boolean canEdit() {
-                       return true;
-               }
-       };
-
-}
index b5dccbe9cb1b2e2d3ab810d42414c34daff14754..04771727550ce38082ab02437925db3962590e17 100644 (file)
@@ -1,5 +1,7 @@
 package org.argeo.api.cms;
 
+import org.argeo.api.cms.ux.CmsView;
+
 /**
  * Can be applied to {@link Enum}s in order to define events used by
  * {@link CmsView#sendEvent(String, java.util.Map)}.
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/CmsImageManager.java b/org.argeo.api.cms/src/org/argeo/api/cms/CmsImageManager.java
deleted file mode 100644 (file)
index 8c637b8..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.argeo.api.cms;
-
-import java.io.InputStream;
-
-/** Read and write access to images. */
-public interface CmsImageManager<V, M> {
-       /** Load image in control */
-       public Boolean load(M node, V control, Cms2DSize size);
-
-       /** @return (0,0) if not available */
-       public Cms2DSize getImageSize(M node);
-
-       /**
-        * The related &lt;img&gt; tag, with src, width and height set.
-        * 
-        * @return null if not available
-        */
-       public String getImageTag(M node);
-
-       /**
-        * The related &lt;img&gt; tag, with url, width and height set. Caller must
-        * close the tag (or add additional attributes).
-        * 
-        * @return null if not available
-        */
-       public StringBuilder getImageTagBuilder(M node, Cms2DSize size);
-
-       /**
-        * Returns the remotely accessible URL of the image (registering it if
-        * needed) @return null if not available
-        */
-       public String getImageUrl(M node);
-
-//     public Binary getImageBinary(Node node) throws RepositoryException;
-
-//     public Image getSwtImage(Node node) throws RepositoryException;
-
-       /** @return URL */
-       public String uploadImage(M context, M uploadFolder, String fileName, InputStream in, String contentType);
-
-       @Deprecated
-       default String uploadImage(M uploadFolder, String fileName, InputStream in) {
-               System.err.println("Context must be provided to " + CmsImageManager.class.getName());
-               return uploadImage(null, uploadFolder, fileName, in, null);
-       }
-}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/CmsStyle.java b/org.argeo.api.cms/src/org/argeo/api/cms/CmsStyle.java
deleted file mode 100644 (file)
index 8444e2f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.argeo.api.cms;
-
-/** Can be applied to {@link Enum}s in order to generate (CSS) class names. */
-public interface CmsStyle {
-       String name();
-
-       /** @deprecated use {@link #style()} instead. */
-       @Deprecated
-       default String toStyleClass() {
-               return style();
-       }
-
-       default String style() {
-               String classPrefix = getClassPrefix();
-               return "".equals(classPrefix) ? name() : classPrefix + "-" + name();
-       }
-
-       default String getClassPrefix() {
-               return "";
-       }
-
-}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/CmsTheme.java b/org.argeo.api.cms/src/org/argeo/api/cms/CmsTheme.java
deleted file mode 100644 (file)
index 50c3b1f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.argeo.api.cms;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-/** A CMS theme which can be applied to web apps as well as desktop apps. */
-public interface CmsTheme {
-       /** Unique ID of this theme. */
-       String getThemeId();
-
-       /**
-        * Load a resource as an input stream, base don its relative path, or
-        * <code>null</code> if not found
-        */
-       InputStream getResourceAsStream(String resourceName) throws IOException;
-
-       /** Relative paths to standard web CSS. */
-       Set<String> getWebCssPaths();
-
-       /** Relative paths to RAP specific CSS. */
-       Set<String> getRapCssPaths();
-
-       /** Relative paths to SWT specific CSS. */
-       Set<String> getSwtCssPaths();
-
-       /** Relative paths to images such as icons. */
-       Set<String> getImagesPaths();
-
-       /** Relative paths to fonts. */
-       Set<String> getFontsPaths();
-
-       /** Tags to be added to the header section of the HTML page. */
-       String getHtmlHeaders();
-
-       /** The HTML body to use. */
-       String getBodyHtml();
-
-       /** The default icon size (typically the smallest). */
-       Integer getDefaultIconSize();
-
-       /** Loads one of the relative path provided by the other methods. */
-       InputStream loadPath(String path) throws IOException;
-
-}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/CmsUi.java b/org.argeo.api.cms/src/org/argeo/api/cms/CmsUi.java
deleted file mode 100644 (file)
index fd91c6e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.api.cms;
-
-public interface CmsUi {
-       Object getData(String key);
-       void setData(String key, Object value);
-
-}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/CmsView.java b/org.argeo.api.cms/src/org/argeo/api/cms/CmsView.java
deleted file mode 100644 (file)
index c7ca1e9..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.argeo.api.cms;
-
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.security.auth.login.LoginContext;
-
-/** Provides interaction with the CMS system. */
-public interface CmsView {
-       final static String CMS_VIEW_UID_PROPERTY = "argeo.cms.view.uid";
-       // String KEY = "org.argeo.cms.ui.view";
-
-       String getUid();
-
-       UxContext getUxContext();
-
-       // NAVIGATION
-       void navigateTo(String state);
-
-       // SECURITY
-       void authChange(LoginContext loginContext);
-
-       void logout();
-
-       // void registerCallbackHandler(CallbackHandler callbackHandler);
-
-       // SERVICES
-       void exception(Throwable e);
-
-       CmsImageManager<?, ?> getImageManager();
-
-       boolean isAnonymous();
-
-       /**
-        * Send an event to this topic. Does nothing by default., but if implemented it
-        * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties.
-        */
-       default void sendEvent(String topic, Map<String, Object> properties) {
-
-       }
-
-       /**
-        * Convenience methods for when {@link #sendEvent(String, Map)} only requires
-        * one single parameter.
-        */
-       default void sendEvent(String topic, String param, Object value) {
-               Map<String, Object> properties = new HashMap<>();
-               properties.put(param, value);
-               sendEvent(topic, properties);
-       }
-
-       default void applyStyles(Object widget) {
-
-       }
-
-       default <T> T doAs(PrivilegedAction<T> action) {
-               throw new UnsupportedOperationException();
-       }
-
-       default Void runAs(Runnable runnable) {
-               return doAs(new PrivilegedAction<Void>() {
-
-                       @Override
-                       public Void run() {
-                               if (runnable != null)
-                                       runnable.run();
-                               return null;
-                       }
-               });
-       }
-
-       default void stateChanged(String state, String title) {
-       }
-
-       default CmsSession getCmsSession() {
-               throw new UnsupportedOperationException();
-       }
-
-       default Object getData(String key) {
-               throw new UnsupportedOperationException();
-       }
-
-       @SuppressWarnings("unchecked")
-       default <T> T getUiContext(Class<T> clss) {
-               return (T) getData(clss.getName());
-       }
-
-       default <T> void setUiContext(Class<T> clss, T instance) {
-               setData(clss.getName(), instance);
-       }
-
-       default void setData(String key, Object value) {
-               throw new UnsupportedOperationException();
-       }
-
-}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/MvcProvider.java b/org.argeo.api.cms/src/org/argeo/api/cms/MvcProvider.java
deleted file mode 100644 (file)
index 92864ea..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.argeo.api.cms;
-
-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
-@Deprecated
-public interface MvcProvider<V, M, W> extends BiFunction<V, M, W> {
-       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.api.cms/src/org/argeo/api/cms/UxContext.java b/org.argeo.api.cms/src/org/argeo/api/cms/UxContext.java
deleted file mode 100644 (file)
index fb99178..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.api.cms;
-
-public interface UxContext {
-       boolean isPortrait();
-
-       boolean isLandscape();
-
-       boolean isSquare();
-
-       boolean isSmall();
-
-       /**
-        * Is a production environment (must be false by default, and be explicitly
-        * set during the CMS deployment). When false, it can activate additional UI
-        * capabilities in order to facilitate QA.
-        */
-       boolean isMasterData();
-}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/Cms2DSize.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/Cms2DSize.java
new file mode 100644 (file)
index 0000000..9667e83
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.api.cms.ux;
+
+/** A 2D size. */
+public class Cms2DSize {
+       private Integer width;
+       private Integer height;
+
+       public Cms2DSize() {
+
+       }
+
+       public Cms2DSize(Integer width, Integer height) {
+               super();
+               this.width = width;
+               this.height = height;
+       }
+
+       public Integer getWidth() {
+               return width;
+       }
+
+       public void setWidth(Integer width) {
+               this.width = width;
+       }
+
+       public Integer getHeight() {
+               return height;
+       }
+
+       public void setHeight(Integer height) {
+               this.height = height;
+       }
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsEditable.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsEditable.java
new file mode 100644 (file)
index 0000000..9047004
--- /dev/null
@@ -0,0 +1,57 @@
+package org.argeo.api.cms.ux;
+
+/** Abstraction of a simple edition life cycle. */
+public interface CmsEditable {
+
+       /** Whether the calling thread can edit, the value is immutable */
+       public Boolean canEdit();
+
+       public Boolean isEditing();
+
+       public void startEditing();
+
+       public void stopEditing();
+
+       public static CmsEditable NON_EDITABLE = new CmsEditable() {
+
+               @Override
+               public void stopEditing() {
+               }
+
+               @Override
+               public void startEditing() {
+               }
+
+               @Override
+               public Boolean isEditing() {
+                       return false;
+               }
+
+               @Override
+               public Boolean canEdit() {
+                       return false;
+               }
+       };
+
+       public static CmsEditable ALWAYS_EDITING = new CmsEditable() {
+
+               @Override
+               public void stopEditing() {
+               }
+
+               @Override
+               public void startEditing() {
+               }
+
+               @Override
+               public Boolean isEditing() {
+                       return true;
+               }
+
+               @Override
+               public Boolean canEdit() {
+                       return true;
+               }
+       };
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsIcon.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsIcon.java
new file mode 100644 (file)
index 0000000..d4f86b2
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.api.cms.ux;
+
+/**
+ * Marker interface to be applied to {@link Enum}s in order to find or generate
+ * icons.
+ */
+public interface CmsIcon {
+       String name();
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsImageManager.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsImageManager.java
new file mode 100644 (file)
index 0000000..1ec54a9
--- /dev/null
@@ -0,0 +1,46 @@
+package org.argeo.api.cms.ux;
+
+import java.io.InputStream;
+
+/** Read and write access to images. */
+public interface CmsImageManager<V, M> {
+       /** Load image in control */
+       public Boolean load(M node, V control, Cms2DSize size);
+
+       /** @return (0,0) if not available */
+       public Cms2DSize getImageSize(M node);
+
+       /**
+        * The related &lt;img&gt; tag, with src, width and height set.
+        * 
+        * @return null if not available
+        */
+       public String getImageTag(M node);
+
+       /**
+        * The related &lt;img&gt; tag, with url, width and height set. Caller must
+        * close the tag (or add additional attributes).
+        * 
+        * @return null if not available
+        */
+       public StringBuilder getImageTagBuilder(M node, Cms2DSize size);
+
+       /**
+        * Returns the remotely accessible URL of the image (registering it if
+        * needed) @return null if not available
+        */
+       public String getImageUrl(M node);
+
+//     public Binary getImageBinary(Node node) throws RepositoryException;
+
+//     public Image getSwtImage(Node node) throws RepositoryException;
+
+       /** @return URL */
+       public String uploadImage(M context, M uploadFolder, String fileName, InputStream in, String contentType);
+
+       @Deprecated
+       default String uploadImage(M uploadFolder, String fileName, InputStream in) {
+               System.err.println("Context must be provided to " + CmsImageManager.class.getName());
+               return uploadImage(null, uploadFolder, fileName, in, null);
+       }
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsStyle.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsStyle.java
new file mode 100644 (file)
index 0000000..e3f2e77
--- /dev/null
@@ -0,0 +1,22 @@
+package org.argeo.api.cms.ux;
+
+/** Can be applied to {@link Enum}s in order to generate (CSS) class names. */
+public interface CmsStyle {
+       String name();
+
+       /** @deprecated use {@link #style()} instead. */
+       @Deprecated
+       default String toStyleClass() {
+               return style();
+       }
+
+       default String style() {
+               String classPrefix = getClassPrefix();
+               return "".equals(classPrefix) ? name() : classPrefix + "-" + name();
+       }
+
+       default String getClassPrefix() {
+               return "";
+       }
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsTheme.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsTheme.java
new file mode 100644 (file)
index 0000000..3a4a78e
--- /dev/null
@@ -0,0 +1,51 @@
+package org.argeo.api.cms.ux;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Set;
+
+/** A CMS theme which can be applied to web apps as well as desktop apps. */
+public interface CmsTheme {
+       /** Unique ID of this theme. */
+       String getThemeId();
+
+       /**
+        * Load a resource as an input stream, base don its relative path, or
+        * <code>null</code> if not found
+        */
+       InputStream getResourceAsStream(String resourceName) throws IOException;
+
+       /** Relative paths to standard web CSS. */
+       Set<String> getWebCssPaths();
+
+       /** Relative paths to RAP specific CSS. */
+       Set<String> getRapCssPaths();
+
+       /** Relative paths to SWT specific CSS. */
+       Set<String> getSwtCssPaths();
+
+       /** Relative paths to images such as icons. */
+       Set<String> getImagesPaths();
+
+       /** Relative paths to fonts. */
+       Set<String> getFontsPaths();
+
+       /** Tags to be added to the header section of the HTML page. */
+       String getHtmlHeaders();
+
+       /** The HTML body to use. */
+       String getBodyHtml();
+
+       /** The default icon size (typically the smallest). */
+       default int getDefaultIconSize() {
+               return getSmallIconSize();
+       }
+
+       int getSmallIconSize();
+
+       int getBigIconSize();
+
+       /** Loads one of the relative path provided by the other methods. */
+       InputStream loadPath(String path) throws IOException;
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsUi.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsUi.java
new file mode 100644 (file)
index 0000000..011cc1d
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.api.cms.ux;
+
+public interface CmsUi {
+       Object getData(String key);
+       void setData(String key, Object value);
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsView.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/CmsView.java
new file mode 100644 (file)
index 0000000..45629fb
--- /dev/null
@@ -0,0 +1,99 @@
+package org.argeo.api.cms.ux;
+
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.login.LoginContext;
+
+import org.argeo.api.cms.CmsSession;
+
+/** Provides interaction with the CMS system. */
+public interface CmsView {
+       final static String CMS_VIEW_UID_PROPERTY = "argeo.cms.view.uid";
+       // String KEY = "org.argeo.cms.ui.view";
+
+       String getUid();
+
+       UxContext getUxContext();
+
+       // NAVIGATION
+       void navigateTo(String state);
+
+       // SECURITY
+       void authChange(LoginContext loginContext);
+
+       void logout();
+
+       // void registerCallbackHandler(CallbackHandler callbackHandler);
+
+       // SERVICES
+       void exception(Throwable e);
+
+       CmsImageManager<?, ?> getImageManager();
+
+       boolean isAnonymous();
+
+       /**
+        * Send an event to this topic. Does nothing by default., but if implemented it
+        * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties.
+        */
+       default void sendEvent(String topic, Map<String, Object> properties) {
+
+       }
+
+       /**
+        * Convenience methods for when {@link #sendEvent(String, Map)} only requires
+        * one single parameter.
+        */
+       default void sendEvent(String topic, String param, Object value) {
+               Map<String, Object> properties = new HashMap<>();
+               properties.put(param, value);
+               sendEvent(topic, properties);
+       }
+
+       default void applyStyles(Object widget) {
+
+       }
+
+       default <T> T doAs(PrivilegedAction<T> action) {
+               throw new UnsupportedOperationException();
+       }
+
+       default Void runAs(Runnable runnable) {
+               return doAs(new PrivilegedAction<Void>() {
+
+                       @Override
+                       public Void run() {
+                               if (runnable != null)
+                                       runnable.run();
+                               return null;
+                       }
+               });
+       }
+
+       default void stateChanged(String state, String title) {
+       }
+
+       default CmsSession getCmsSession() {
+               throw new UnsupportedOperationException();
+       }
+
+       default Object getData(String key) {
+               throw new UnsupportedOperationException();
+       }
+
+       @SuppressWarnings("unchecked")
+       default <T> T getUiContext(Class<T> clss) {
+               return (T) getData(clss.getName());
+       }
+
+       default <T> void setUiContext(Class<T> clss, T instance) {
+               setData(clss.getName(), instance);
+       }
+
+       default void setData(String key, Object value) {
+               throw new UnsupportedOperationException();
+       }
+
+}
diff --git a/org.argeo.api.cms/src/org/argeo/api/cms/ux/MvcProvider.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/MvcProvider.java
new file mode 100644 (file)
index 0000000..3556ede
--- /dev/null
@@ -0,0 +1,45 @@
+package org.argeo.api.cms.ux;
+
+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
+@Deprecated
+public interface MvcProvider<V, M, W> extends BiFunction<V, M, W> {
+       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.api.cms/src/org/argeo/api/cms/ux/UxContext.java b/org.argeo.api.cms/src/org/argeo/api/cms/ux/UxContext.java
new file mode 100644 (file)
index 0000000..adb41d3
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.api.cms.ux;
+
+public interface UxContext {
+       boolean isPortrait();
+
+       boolean isLandscape();
+
+       boolean isSquare();
+
+       boolean isSmall();
+
+       /**
+        * Is a production environment (must be false by default, and be explicitly
+        * set during the CMS deployment). When false, it can activate additional UI
+        * capabilities in order to facilitate QA.
+        */
+       boolean isMasterData();
+}
index 1b2b0e9400390b8ad2605a6d8eda21b717b0d235..015f35db146b114f37aa38d07c307aa32bb06285 100644 (file)
@@ -3,7 +3,7 @@ package org.argeo.cms.ux;
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentRepository;
 import org.argeo.api.acr.ContentSession;
-import org.argeo.api.cms.CmsView;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.auth.CurrentUser;
 
 public class CmsUxUtils {
index 5890fc4f8bb92368d4424c35067893ce7046957a..9bfa9620a09fc563a411710c82c6e8d4c1c6981c 100644 (file)
@@ -6,4 +6,5 @@ public interface Column<T> {
        default int getWidth() {
                return 200;
        }
+       
 }
index c2d52f3d0c5eb4e2ae63ccec4838e68a001d5e94..cefdb86b3d71cdf480a5ad22528ad47141e54624 100644 (file)
@@ -9,7 +9,7 @@ import java.util.Map;
 import org.argeo.api.cms.CmsApp;
 import org.argeo.api.cms.CmsAppListener;
 import org.argeo.api.cms.CmsContext;
-import org.argeo.api.cms.CmsTheme;
+import org.argeo.api.cms.ux.CmsTheme;
 
 /** Base class for {@link CmsApp}s. */
 public abstract class AbstractCmsApp implements CmsApp {
index 3312d72f96eefff8ffa0552c0811e0870b87cdab..3ab799f713e1ab9e802a20654efc81426c7de5b7 100644 (file)
@@ -18,7 +18,7 @@ import java.util.TreeSet;
 import java.util.stream.Collectors;
 
 import org.apache.commons.io.IOUtils;
-import org.argeo.api.cms.CmsTheme;
+import org.argeo.api.cms.ux.CmsTheme;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
@@ -64,7 +64,8 @@ public class BundleCmsTheme implements CmsTheme {
 //     private String swtCssPath;
        private Bundle themeBundle;
 
-       private Integer defaultIconSize = 16;
+       private Integer smallIconSize = 16;
+       private Integer bigIconSize = 32;
 
        public BundleCmsTheme() {
 
@@ -320,8 +321,13 @@ public class BundleCmsTheme implements CmsTheme {
        }
 
        @Override
-       public Integer getDefaultIconSize() {
-               return defaultIconSize;
+       public int getSmallIconSize() {
+               return smallIconSize;
+       }
+
+       @Override
+       public int getBigIconSize() {
+               return bigIconSize;
        }
 
        @Override
index 95be53d5fd6238ac96bdada8fab90786f8b287db..471cdeca546f6a809107395df345d11b5e948bc1 100644 (file)
@@ -8,10 +8,10 @@ import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
 import org.argeo.api.cms.CmsAuth;
-import org.argeo.api.cms.CmsImageManager;
-import org.argeo.api.cms.CmsView;
 import org.argeo.api.cms.CmsLog;
-import org.argeo.api.cms.UxContext;
+import org.argeo.api.cms.ux.CmsImageManager;
+import org.argeo.api.cms.ux.CmsView;
+import org.argeo.api.cms.ux.UxContext;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.swt.SimpleSwtUxContext;
index edf558e9c7dc99e1df18f6b2d14c6a28ebe3fc21..a2b9440647b691f1ec745b3ab2d856fc7110695c 100644 (file)
@@ -20,8 +20,8 @@ import javax.script.ScriptEngine;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.argeo.api.cms.CmsTheme;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsTheme;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.ui.CmsUiConstants;
 import org.argeo.cms.ui.CmsUiProvider;
index a4d04568e837d1182dd29894f9b9071293b7bf3f..be1f30eb158a2fe752105e25906d47e141c91c44 100644 (file)
@@ -21,8 +21,8 @@ import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 import javax.servlet.http.HttpServletRequest;
 
-import org.argeo.api.cms.CmsView;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.api.cms.CmsAuth;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.CurrentUser;
index 5de0f91034b551d5caa8481ac2c6a71b27b0d3e8..102a4e10342bb82b7a168869fac7868dad39d80f 100644 (file)
@@ -3,7 +3,7 @@ package org.argeo.cms.web;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.argeo.api.cms.CmsTheme;
+import org.argeo.api.cms.ux.CmsTheme;
 import org.eclipse.rap.rwt.service.ResourceLoader;
 
 /** A RAP {@link ResourceLoader} based on a {@link CmsTheme}. */
index 68fd803b9e7fc75590e133086982fda5d4a58892..a1d54cfef8eda8c634731b139b131cd9c948f62f 100644 (file)
@@ -8,8 +8,8 @@ import java.util.Set;
 import org.argeo.api.cms.CmsApp;
 import org.argeo.api.cms.CmsAppListener;
 import org.argeo.api.cms.CmsLog;
-import org.argeo.api.cms.CmsTheme;
-import org.argeo.api.cms.CmsView;
+import org.argeo.api.cms.ux.CmsTheme;
+import org.argeo.api.cms.ux.CmsView;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.util.LangUtils;
 import org.eclipse.rap.rwt.RWT;
index 2236870f6e74ab2144fdd9ccf3b827a8b222a923..9e407366d2eaa6f7f98908246b56c28a865bc1a3 100644 (file)
@@ -14,12 +14,12 @@ import javax.security.auth.login.LoginException;
 
 import org.argeo.api.cms.CmsApp;
 import org.argeo.api.cms.CmsAuth;
-import org.argeo.api.cms.CmsImageManager;
 import org.argeo.api.cms.CmsLog;
 import org.argeo.api.cms.CmsSession;
-import org.argeo.api.cms.CmsUi;
-import org.argeo.api.cms.CmsView;
-import org.argeo.api.cms.UxContext;
+import org.argeo.api.cms.ux.CmsImageManager;
+import org.argeo.api.cms.ux.CmsUi;
+import org.argeo.api.cms.ux.CmsView;
+import org.argeo.api.cms.ux.UxContext;
 import org.argeo.cms.LocaleUtils;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.auth.RemoteAuthCallbackHandler;
index 26ca3705f24b6131881536df151d4fc062b7f117..1b50c19b7b042c20af2d2522467e9755fd6abfe4 100644 (file)
@@ -7,9 +7,9 @@ import javax.jcr.Node;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 
-import org.argeo.api.cms.CmsImageManager;
 import org.argeo.api.cms.CmsLog;
-import org.argeo.api.cms.UxContext;
+import org.argeo.api.cms.ux.CmsImageManager;
+import org.argeo.api.cms.ux.UxContext;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.swt.CmsStyles;
 import org.argeo.cms.swt.CmsSwtUtils;
index ea2ebdfb44b5df142102f13a37b23c2656a7c573..e51644b9fb2788e464080b33dabd6cd4824f12b3 100644 (file)
@@ -1,7 +1,7 @@
 package org.argeo.cms.web;
 
-import org.argeo.api.cms.CmsTheme;
 import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.ux.CmsTheme;
 import org.eclipse.rap.rwt.application.Application;
 import org.eclipse.rap.rwt.service.ResourceLoader;
 
index a708af13f2bf7e59a025f51aeb7734ffdc149420..a13c0170fc9a6d302ba1f217c504f64a5e5b29ea 100644 (file)
@@ -8,9 +8,9 @@ import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
 import org.argeo.api.cms.CmsAuth;
-import org.argeo.api.cms.CmsImageManager;
-import org.argeo.api.cms.CmsView;
-import org.argeo.api.cms.UxContext;
+import org.argeo.api.cms.ux.CmsImageManager;
+import org.argeo.api.cms.ux.CmsView;
+import org.argeo.api.cms.ux.UxContext;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.swt.CmsSwtUtils;
index ed019d706b1114f6f545319ffbf7e43dcc0649dc..e6a24b92b0fee4f77901e9a95fbc480323119a5f 100644 (file)
@@ -13,13 +13,13 @@ import javax.security.auth.login.LoginException;
 
 import org.argeo.api.cms.CmsApp;
 import org.argeo.api.cms.CmsAuth;
-import org.argeo.api.cms.CmsImageManager;
 import org.argeo.api.cms.CmsLog;
 import org.argeo.api.cms.CmsSession;
-import org.argeo.api.cms.CmsTheme;
-import org.argeo.api.cms.CmsUi;
-import org.argeo.api.cms.CmsView;
-import org.argeo.api.cms.UxContext;
+import org.argeo.api.cms.ux.CmsImageManager;
+import org.argeo.api.cms.ux.CmsTheme;
+import org.argeo.api.cms.ux.CmsUi;
+import org.argeo.api.cms.ux.CmsView;
+import org.argeo.api.cms.ux.UxContext;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.eclipse.e4.ui.css.core.engine.CSSEngine;
 import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;