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;
+++ /dev/null
-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;
- }
-}
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}. */
*/
Image getIcon(String name, Integer preferredSize);
+ Image getSmallIcon(CmsIcon icon);
+
+ Image getBigIcon(CmsIcon icon);
}
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;
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;
/** 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;
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) -> {
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
*/
String encoded = URLEncoder.encode(st.nextToken(), StandardCharsets.UTF_8);
encoded = encoded.replace("+", "%20");
sb.append(encoded);
-
+
}
return sb.toString();
}
+
+ /** Singleton. */
+ private CmsSwtUtils() {
+ }
+
}
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;
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;
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;
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;
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;
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;
*
* @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<>();
return image;
}
+ @Override
+ public Image getSmallIcon(CmsIcon icon) {
+ return getIcon(icon.name(), getSmallIconSize());
+ }
+
+ @Override
+ public Image getBigIcon(CmsIcon icon) {
+ return getIcon(icon.name(), getBigIconSize());
+ }
+
}
package org.argeo.cms.ui;
-import org.argeo.api.cms.Cms2DSize;
+import org.argeo.api.cms.ux.Cms2DSize;
/** Commons constants */
@Deprecated
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;
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;
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 {
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;
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;
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;
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;
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;
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;
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 {
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;
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;
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;
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;
+++ /dev/null
-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;
- }
-
-}
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 {
/**
+++ /dev/null
-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;
- }
- };
-
-}
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)}.
+++ /dev/null
-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 <img> tag, with src, width and height set.
- *
- * @return null if not available
- */
- public String getImageTag(M node);
-
- /**
- * The related <img> 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);
- }
-}
+++ /dev/null
-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 "";
- }
-
-}
+++ /dev/null
-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;
-
-}
+++ /dev/null
-package org.argeo.api.cms;
-
-public interface CmsUi {
- Object getData(String key);
- void setData(String key, Object value);
-
-}
+++ /dev/null
-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();
- }
-
-}
+++ /dev/null
-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);
- }
-}
+++ /dev/null
-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();
-}
--- /dev/null
+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;
+ }
+
+}
--- /dev/null
+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;
+ }
+ };
+
+}
--- /dev/null
+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();
+
+}
--- /dev/null
+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 <img> tag, with src, width and height set.
+ *
+ * @return null if not available
+ */
+ public String getImageTag(M node);
+
+ /**
+ * The related <img> 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);
+ }
+}
--- /dev/null
+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 "";
+ }
+
+}
--- /dev/null
+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;
+
+}
--- /dev/null
+package org.argeo.api.cms.ux;
+
+public interface CmsUi {
+ Object getData(String key);
+ void setData(String key, Object value);
+
+}
--- /dev/null
+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();
+ }
+
+}
--- /dev/null
+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);
+ }
+}
--- /dev/null
+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();
+}
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 {
default int getWidth() {
return 200;
}
+
}
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 {
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;
// private String swtCssPath;
private Bundle themeBundle;
- private Integer defaultIconSize = 16;
+ private Integer smallIconSize = 16;
+ private Integer bigIconSize = 32;
public BundleCmsTheme() {
}
@Override
- public Integer getDefaultIconSize() {
- return defaultIconSize;
+ public int getSmallIconSize() {
+ return smallIconSize;
+ }
+
+ @Override
+ public int getBigIconSize() {
+ return bigIconSize;
}
@Override
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;
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;
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;
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}. */
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;
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;
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;
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;
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;
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;