01: package org.osbl.client.wings.form.layouter;
02:
03: import org.osbl.client.wings.form.ComponentProvider;
04:
05: import org.wings.*;
06:
07: /**
08: * Place an editor component along with a label, both obtained from the ComponentProvider in one line.
09: */
10: public class LabelAndCustomEditor extends LabelAndEditor {
11: public String name;
12:
13: /**
14: * Construct a label and editor component placement description.
15: * @param name the name of the custom component
16: */
17: public LabelAndCustomEditor(String name) {
18: this .name = name;
19: }
20:
21: /**
22: * Construct a label and editor component placement description.
23: * @param weight how much of the available vertical space should the line span
24: * @param name the name of the custom component
25: */
26: public LabelAndCustomEditor(double weight, String name) {
27: super (weight);
28: this .name = name;
29: }
30:
31: protected SLabel label(ComponentProvider componentProvider) {
32: SLabel label = componentProvider.getCustomLabel(name);
33: label.setVerticalAlignment(SConstants.TOP_ALIGN);
34: return label;
35: }
36:
37: protected SComponent component(ComponentProvider componentProvider) {
38: SComponent component = componentProvider
39: .getCustomComponent(name);
40: if (component.getVerticalAlignment() == SConstants.NO_ALIGN)
41: component.setVerticalAlignment(SConstants.TOP_ALIGN);
42: if (component.getHorizontalAlignment() == SConstants.NO_ALIGN)
43: component.setHorizontalAlignment(SConstants.LEFT_ALIGN);
44: return component;
45: }
46: }
|