01: /* $Id: ClassEditor.java 746 2006-11-08 13:34:23Z hengels $ */
02: package org.conform.wings.editor;
03:
04: import org.conform.*;
05: import org.conform.wings.Editor;
06: import org.conform.wings.PropertyAdapter;
07: import org.wings.SComponent;
08: import org.wings.SLabel;
09:
10: public class ClassEditor implements Editor {
11: public SComponent createComponent(PropertyMeta propertyMeta) {
12: PropertyDataLabel propertyDataLabel = new PropertyDataLabel(
13: propertyMeta);
14: configureComponent(propertyMeta, propertyDataLabel, false);
15: return propertyDataLabel;
16: }
17:
18: public void configureComponent(PropertyMeta propertyMeta,
19: SComponent component, boolean erroneous) {
20: PropertyDataLabel propertyDataLabel = (PropertyDataLabel) component;
21: propertyDataLabel.setVisible(propertyMeta.isReadable());
22: DefaultEditorStyles.applyEditorAlignment(propertyMeta,
23: component);
24: DefaultEditorStyles.applyEditorState(propertyMeta, component,
25: erroneous);
26: }
27:
28: public void setPropertyData(SComponent component,
29: PropertyData propertyData) {
30: BeanData beanData = propertyData.getBeanData();
31: if (beanData != null)
32: beanData.addPropertyChangeListener(propertyData
33: .getPropertyMeta().getName(),
34: new ComponentInvalidator(component));
35: ((PropertyDataLabel) component).setPropertyData(propertyData);
36: }
37:
38: public PropertyData getPropertyData(SComponent component) {
39: return ((PropertyDataLabel) component).getPropertyData();
40: }
41:
42: static class PropertyDataLabel extends SLabel implements
43: PropertyAdapter {
44: private PropertyData propertyData;
45: private PropertyMeta property;
46:
47: public PropertyDataLabel(PropertyMeta field) {
48: this .property = field;
49: }
50:
51: public void setPropertyData(PropertyData propertyData) {
52: this .propertyData = propertyData;
53: }
54:
55: public PropertyData getPropertyData() {
56: return propertyData;
57: }
58:
59: public void setText(String string) {
60: }
61:
62: public String getText() {
63: Class value = (Class) propertyData.getValue();
64: return value.getName();
65: }
66: }
67: }
|