01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.template.propertymanagers;
14:
15: import org.wings.SComponent;
16: import org.wings.template.TemplateUtil;
17: import org.wings.template.PropertyValueConverter;
18: import org.wings.style.CSSAttributeSet;
19:
20: import java.awt.*;
21:
22: /**
23: * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
24: */
25: public class SComponentPropertyManager extends DefaultPropertyManager {
26: static final Class[] classes = { SComponent.class };
27:
28: public SComponentPropertyManager() {
29: }
30:
31: public void setProperty(SComponent comp, String name, String value) {
32: if ("BACKGROUND".equals(name))
33: comp.setBackground(Color.decode(value));
34: else if ("FOREGROUND".equals(name))
35: comp.setForeground(Color.decode(value));
36: else if ("FONT".equals(name))
37: comp.setFont(TemplateUtil.parseFont(value));
38: else if ("TABINDEX".equals(name))
39: comp.setFocusTraversalIndex(Integer.parseInt(value));
40: else if ("STYLE".equals(name)) {
41: PropertyValueConverter valueConverter = getValueConverter(CSSAttributeSet.class);
42: comp.setAttributes(SComponent.SELECTOR_ALL,
43: (CSSAttributeSet) valueConverter
44: .convertPropertyValue(value,
45: CSSAttributeSet.class));
46: } else if ("CLASS".equals(name)) {
47: comp.setStyle(value);
48: } else if ("ALIGN".equals(name)) {
49: comp.setHorizontalAlignment(TemplateUtil
50: .parseAlignment(value));
51: } else if ("VALIGN".equals(name)) {
52: comp.setVerticalAlignment(TemplateUtil
53: .parseAlignment(value));
54: } else {
55: super .setProperty(comp, name, value);
56: } // end of else
57:
58: }
59:
60: public Class[] getSupportedClasses() {
61: return classes;
62: }
63: }
|