01: package net.xoetrope.builder.editor.components.swing;
02:
03: import net.xoetrope.swing.XTextArea;
04: import net.xoetrope.builder.editor.XPageResource;
05: import java.awt.Component;
06: import net.xoetrope.xui.data.XTextBinding;
07: import java.awt.AWTEvent;
08: import net.xoetrope.builder.editor.components.PropertyHelper;
09: import net.xoetrope.xui.XPage;
10:
11: /**
12: * A helper for the XTextArea types
13: * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
14: * <p> $Revision: 1.10 $</p>
15: */
16: public class XTextAreaHelper extends PropertyHelper {
17: protected String extraProperties[] = { "Content", "Rows",
18: "Columns", "Wrap", "WordWrap", "FocusHandler",
19: "KeyHandler", "Validation", "Data" };
20:
21: public XTextAreaHelper() {
22: className = XTextArea.class.toString();
23: componentType = XPage.TEXTAREA;
24: extraPropertyNames = extraProperties;
25: }
26:
27: /**
28: * Get the value of the property exposed by the component
29: * @param pageResource the page resource to which this component belongs
30: * @param comp the component instance
31: * @param i the component property index
32: * @return the value
33: */
34: public String getPropertyValue(XPageResource pageResource,
35: Component comp, int i) {
36: if (i == numBasicProperties)
37: return ((XTextArea) comp).getText();
38: else if (i == numBasicProperties + 1)
39: return Integer.toString(((XTextArea) comp).getRows());
40: else if (i == numBasicProperties + 2)
41: return Integer.toString(((XTextArea) comp).getColumns());
42: else if (i == numBasicProperties + 3)
43: return booleanOptions[((XTextArea) comp).getLineWrap() ? 0
44: : 1];
45: else if (i == numBasicProperties + 4)
46: return booleanOptions[((XTextArea) comp).getWrapStyleWord() ? 0
47: : 1];
48:
49: return super .getPropertyValue(pageResource, comp, i);
50: }
51:
52: /**
53: * Set the value of the property exposed by the component
54: * @param pageResource the pageResource that owns/manages the component
55: * @param comp the component instance
56: * @param i the component property index
57: * @return the value
58: */
59: public void setPropertyValue(XPageResource pageResource,
60: Component comp, int i, String value) {
61: if (i == numBasicProperties)
62: ((XTextArea) comp).setText(value);
63: else if (i == numBasicProperties + 1)
64: ((XTextArea) comp).setRows(Integer.parseInt(value));
65: else if (i == numBasicProperties + 2)
66: ((XTextArea) comp).setColumns(Integer.parseInt(value));
67: else if (i == numBasicProperties + 3)
68: ((XTextArea) comp).setLineWrap(value
69: .equalsIgnoreCase("true"));
70: else if (i == numBasicProperties + 4)
71: ((XTextArea) comp).setWrapStyleWord(value
72: .equalsIgnoreCase("true"));
73: else
74: super.setPropertyValue(pageResource, comp, i, value);
75: }
76: }
|