01: /*
02: * Created on 2 Nov 2006
03: */
04: package uk.org.ponder.rsf.renderer.html.decorators;
05:
06: import java.util.HashMap;
07: import java.util.Iterator;
08: import java.util.Map;
09:
10: import uk.org.ponder.htmlutil.HTMLUtil;
11: import uk.org.ponder.rsf.components.decorators.UICSSDecorator;
12: import uk.org.ponder.rsf.components.decorators.UIDecorator;
13: import uk.org.ponder.rsf.renderer.decorator.DecoratorRenderer;
14:
15: public class CSSDecoratorRenderer implements DecoratorRenderer {
16:
17: public String getContentTypes() {
18: return "HTML, HTML-FRAGMENT, XUL, SVG";
19: }
20:
21: public Class getRenderedType() {
22: return UICSSDecorator.class;
23: }
24:
25: public String attrName = "style";
26:
27: public void modifyAttributes(UIDecorator decoratoro,
28: String tagname, Map tomodify) {
29: UICSSDecorator decorator = (UICSSDecorator) decoratoro;
30: String oldstyle = (String) tomodify.get(attrName);
31: Map stylemap = new HashMap();
32: if (oldstyle != null) {
33: HTMLUtil.parseStyle(oldstyle, stylemap);
34: }
35:
36: for (Iterator sit = decorator.stylemap.keySet().iterator(); sit
37: .hasNext();) {
38: String key = (String) sit.next();
39: String value = (String) decorator.stylemap.get(key);
40: stylemap.put(key, value);
41: }
42: String newstyle = HTMLUtil.renderStyle(stylemap);
43: tomodify.put(attrName, newstyle);
44: }
45:
46: }
|