X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2FCmsTheme.java;h=c93991b274e7126bf609284015c01e574fc61a70;hb=958c7142baa531d444d56725609c43c6a1ebd762;hp=37f52a35e5e40722224697f370f1bd2f63231c46;hpb=1233dcea2383bfe5c83e5ec33d0c502afff22601;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java index 37f52a35e..c93991b27 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java @@ -19,21 +19,36 @@ public interface CmsTheme { */ InputStream getResourceAsStream(String resourceName) throws IOException; + /** Relative paths to standard web CSS. */ + Set getWebCssPaths(); + /** Relative paths to RAP specific CSS. */ Set getRapCssPaths(); + /** Relative paths to SWT specific CSS. */ + Set getSwtCssPaths(); + /** Relative paths to images such as icons. */ Set getImagesPaths(); + /** Relative paths to fonts. */ + Set getFontsPaths(); + /** Tags to be added to the header section of the HTML page. */ String getHtmlHeaders(); + /** The HTML body to use. */ + String getBodyHtml(); + /** The image registered at this path, or null if not found. */ Image getImage(String path); /** 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; + /** * And icon with this file name (without the extension), with a best effort to * find the appropriate size, or null if not found. @@ -45,11 +60,16 @@ public interface CmsTheme { Image getIcon(String name, Integer preferredSize); static CmsTheme getCmsTheme(Composite parent) { - // find parent shell - Shell topShell = parent.getShell(); - while (topShell.getParent() != null) - topShell = (Shell) topShell.getParent(); - return (CmsTheme) topShell.getData(CmsTheme.class.getName()); + CmsTheme theme = (CmsTheme) 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()); + parent.setData(CmsTheme.class.getName(), theme); + } + return theme; } static void registerCmsTheme(Shell shell, CmsTheme theme) {