01: package org.osbl.client.wings.form.layouter;
02:
03: import org.wings.*;
04:
05: import java.awt.*;
06:
07: import org.osbl.client.wings.form.ComponentProvider;
08:
09: /**
10: * Place an editor component obtained from the ComponentProvider.
11: */
12: public class Editor extends Line {
13: public GridBagConstraints editorConstraints = new GridBagConstraints();
14: {
15: editorConstraints = new GridBagConstraints();
16: editorConstraints.anchor = GridBagConstraints.NORTH;
17: editorConstraints.insets = LINE_INSETS;
18: editorConstraints.gridwidth = GridBagConstraints.REMAINDER;
19: }
20: public String bean;
21: public String property;
22:
23: protected Editor() {
24: }
25:
26: protected Editor(double weight) {
27: super (weight);
28: }
29:
30: /**
31: * Construct an editor component placement description.
32: * @param bean the bean, whose property is getting editable (typically BeanMeta)
33: * @param property the property, which is getting editable (typically PropertyMeta)
34: */
35: public Editor(String bean, String property) {
36: this .bean = bean;
37: this .property = property;
38: }
39:
40: /**
41: * Construct an editor component placement description.
42: * @param weight how much of the available vertical space should the line span
43: * @param bean the bean, whose property is getting editable (typically BeanMeta)
44: * @param property the property, which is getting editable (typically PropertyMeta)
45: */
46: public Editor(double weight, String bean, String property) {
47: super (weight);
48: this .bean = bean;
49: this .property = property;
50: }
51:
52: public void build(ComponentProvider componentProvider,
53: SContainer container) {
54: SComponent propertyComponent = component(componentProvider);
55: propertyComponent.putClientProperty("instruction", this );
56: if (propertyComponent.getPreferredSize() == null)
57: propertyComponent.setPreferredSize(SDimension.FULLWIDTH);
58:
59: editorConstraints.weighty = weight;
60: container.add(propertyComponent, editorConstraints);
61: }
62:
63: protected SComponent component(ComponentProvider componentProvider) {
64: return componentProvider.getEditorComponent(bean, property);
65: }
66: }
|