]>
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
.CmsContext
;
12 import org
.argeo
.api
.cms
.ux
.CmsTheme
;
14 /** Base class for {@link CmsApp}s. */
15 public abstract class AbstractCmsApp
implements CmsApp
{
16 private CmsContext cmsContext
;
18 private Map
<String
, CmsTheme
> themes
= Collections
.synchronizedMap(new HashMap
<>());
20 private List
<CmsAppListener
> cmsAppListeners
= new ArrayList
<>();
22 /** To be overridden in order to provide themes. */
23 protected String
getThemeId(String uiName
) {
28 public CmsTheme
getTheme(String uiName
) {
29 String themeId
= getThemeId(uiName
);
32 if (!themes
.containsKey(themeId
))
33 throw new IllegalArgumentException("Theme " + themeId
+ " not found.");
34 return themes
.get(themeId
);
38 public boolean allThemesAvailable() {
39 boolean themeMissing
= false;
40 uiNames
: for (String uiName
: getUiNames()) {
41 String themeId
= getThemeId(uiName
);
42 if ("org.eclipse.rap.rwt.theme.Default".equals(themeId
))
44 if (themeId
!= null && !themes
.containsKey(themeId
)) {
52 public void addTheme(CmsTheme theme
, Map
<String
, String
> properties
) {
53 themes
.put(theme
.getThemeId(), theme
);
54 if (allThemesAvailable())
55 for (CmsAppListener listener
: cmsAppListeners
)
56 listener
.themingUpdated();
59 public void removeTheme(CmsTheme theme
, Map
<String
, String
> properties
) {
60 themes
.remove(theme
.getThemeId());
64 public void addCmsAppListener(CmsAppListener listener
) {
65 cmsAppListeners
.add(listener
);
66 if (allThemesAvailable())
67 listener
.themingUpdated();
71 public void removeCmsAppListener(CmsAppListener listener
) {
72 cmsAppListeners
.remove(listener
);
76 public CmsContext
getCmsContext() {
80 public void setCmsContext(CmsContext cmsContext
) {
81 this.cmsContext
= cmsContext
;