]>
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 /** To be overridden in order to provide themes. */
20 protected String
getThemeId(String uiName
) {
25 public CmsTheme
getTheme(String uiName
) {
26 String themeId
= getThemeId(uiName
);
29 if (!themes
.containsKey(themeId
))
30 throw new IllegalArgumentException("Theme " + themeId
+ " not found.");
31 return themes
.get(themeId
);
35 public boolean allThemesAvailable() {
36 boolean themeMissing
= false;
37 uiNames
: for (String uiName
: getUiNames()) {
38 String themeId
= getThemeId(uiName
);
39 if ("org.eclipse.rap.rwt.theme.Default".equals(themeId
))
41 if (themeId
!= null && !themes
.containsKey(themeId
)) {
49 public void addTheme(CmsTheme theme
, Map
<String
, String
> properties
) {
50 themes
.put(theme
.getThemeId(), theme
);
51 if (allThemesAvailable())
52 for (CmsAppListener listener
: cmsAppListeners
)
53 listener
.themingUpdated();
56 public void removeTheme(CmsTheme theme
, Map
<String
, String
> properties
) {
57 themes
.remove(theme
.getThemeId());
61 public void addCmsAppListener(CmsAppListener listener
) {
62 cmsAppListeners
.add(listener
);
63 if (allThemesAvailable())
64 listener
.themingUpdated();
68 public void removeCmsAppListener(CmsAppListener listener
) {
69 cmsAppListeners
.remove(listener
);