From: Mathieu Baudier Date: Wed, 14 Oct 2020 08:18:30 +0000 (+0200) Subject: Improve single sourcing. X-Git-Tag: argeo-commons-2.1.89~65 X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=commitdiff_plain;h=b94bc29e6cb5aa29283a380fdc775ecded7f5734 Improve single sourcing. --- diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsConstants.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsConstants.java index 53e2aee6c..157168508 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsConstants.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsConstants.java @@ -1,17 +1,21 @@ package org.argeo.cms.ui; -import org.eclipse.rap.rwt.RWT; +import org.argeo.eclipse.ui.specific.EclipseUiConstants; import org.eclipse.swt.graphics.Point; /** Commons constants */ public interface CmsConstants { // DATAKEYS - public final static String STYLE = RWT.CUSTOM_VARIANT; - public final static String MARKUP = RWT.MARKUP_ENABLED; - public final static String ITEM_HEIGHT = RWT.CUSTOM_ITEM_HEIGHT; + public final static String STYLE = EclipseUiConstants.CSS_CLASS; + public final static String MARKUP = EclipseUiConstants.MARKUP_SUPPORT; + @Deprecated + /* RWT.CUSTOM_ITEM_HEIGHT */ + public final static String ITEM_HEIGHT = "org.eclipse.rap.rwt.customItemHeight"; // EVENT DETAILS - public final static int HYPERLINK = RWT.HYPERLINK; + @Deprecated + /* RWT.HYPERLINK */ + public final static int HYPERLINK = 1 << 26; // STANDARD RESOURCES public final static String LOADING_IMAGE = "icons/loading.gif"; diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java index 9f5e4f797..b403a2088 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java @@ -51,6 +51,10 @@ public interface CmsView { properties.put(param, value); sendEvent(topic, properties); } + + default void applyStyles(Object widget) { + + } static CmsView getCmsView(Composite parent) { // find parent shell diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsUiUtils.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsUiUtils.java index 915b03336..4e5572dbd 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsUiUtils.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsUiUtils.java @@ -181,18 +181,20 @@ public class CmsUiUtils implements CmsConstants { if (style == null) return widget;// does nothing widget.setData(CmsConstants.STYLE, style); + if (widget instanceof Control) + CmsView.getCmsView(((Control) widget).getParent()).applyStyles(widget); return widget; } /** Style widget */ public static T style(T widget, CmsStyle style) { - widget.setData(CmsConstants.STYLE, style.toStyleClass()); - return widget; + return style(widget, style.toStyleClass()); } /** Enable markups on widget */ public static T markup(T widget) { - widget.setData(CmsConstants.MARKUP, true); + if (CmsConstants.MARKUP != null) + widget.setData(CmsConstants.MARKUP, true); return widget; } @@ -232,6 +234,7 @@ public class CmsUiUtils implements CmsConstants { return text(new Text(parent, SWT.NONE), txt); } + @Deprecated public static void setItemHeight(Table table, int height) { table.setData(CmsConstants.ITEM_HEIGHT, height); } diff --git a/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/EclipseUiConstants.java b/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/EclipseUiConstants.java new file mode 100644 index 000000000..76ad973ae --- /dev/null +++ b/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/EclipseUiConstants.java @@ -0,0 +1,9 @@ +package org.argeo.eclipse.ui.specific; + +import org.eclipse.rap.rwt.RWT; + +/** Constants which are specific to RWT.*/ +public interface EclipseUiConstants { + final static String CSS_CLASS = RWT.CUSTOM_VARIANT; + final static String MARKUP_SUPPORT = RWT.MARKUP_ENABLED; +}