]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/AbstractCmsApp.java
3 import java
.util
.ArrayList
;
4 import java
.util
.Collections
;
5 import java
.util
.HashMap
;
9 import org
.argeo
.api
.cms
.CmsApp
;
10 import org
.argeo
.api
.cms
.CmsAppListener
;
11 import org
.argeo
.api
.cms
.CmsTheme
;
13 /** Base class for {@link CmsApp}s. */
14 public abstract class AbstractCmsApp
implements CmsApp
{
15 private Map
<String
, CmsTheme
> themes
= Collections
.synchronizedMap(new HashMap
<>());
17 private List
<CmsAppListener
> cmsAppListeners
= new ArrayList
<>();
19 protected abstract String
getThemeId(String uiName
);
22 public CmsTheme
getTheme(String uiName
) {
23 String themeId
= getThemeId(uiName
);
26 if (!themes
.containsKey(themeId
))
27 throw new IllegalArgumentException("Theme " + themeId
+ " not found.");
28 return themes
.get(themeId
);
32 public boolean allThemesAvailable() {
33 boolean themeMissing
= false;
34 uiNames
: for (String uiName
: getUiNames()) {
35 String themeId
= getThemeId(uiName
);
36 if ("org.eclipse.rap.rwt.theme.Default".equals(themeId
))
38 if (!themes
.containsKey(themeId
)) {
46 public void addTheme(CmsTheme theme
, Map
<String
, String
> properties
) {
47 themes
.put(theme
.getThemeId(), theme
);
48 if (allThemesAvailable())
49 for (CmsAppListener listener
: cmsAppListeners
)
50 listener
.themingUpdated();
53 public void removeTheme(CmsTheme theme
, Map
<String
, String
> properties
) {
54 themes
.remove(theme
.getThemeId());
58 public void addCmsAppListener(CmsAppListener listener
) {
59 cmsAppListeners
.add(listener
);
60 if (allThemesAvailable())
61 listener
.themingUpdated();
65 public void removeCmsAppListener(CmsAppListener listener
) {
66 cmsAppListeners
.remove(listener
);