X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2FCmsSwtUtils.java;h=5d964090b9abbd908ff1fc3f007c85afe11a76f8;hb=df60fd8de17590b8f4ab32fd0278e57aaaedbfa2;hp=784d03173bce51ec53285c39f1a1c87defc9490f;hpb=dc27b57704278684e72efcaf72b01c5b91df39f8;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtUtils.java b/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtUtils.java index 784d03173..5d964090b 100644 --- a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtUtils.java +++ b/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/CmsSwtUtils.java @@ -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 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() { + } + }