01: /* ZkStringItem.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: May 29, 2007 3:31:22 PM, Created by henrichen
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zkmob.ui;
20:
21: import javax.microedition.lcdui.Form;
22: import javax.microedition.lcdui.StringItem;
23:
24: import org.zkoss.zkmob.Itemable;
25: import org.zkoss.zkmob.ZkComponent;
26: import org.zkoss.zkmob.UiManager;
27:
28: /**
29: * ZK StringItem.
30: * @author henrichen
31: *
32: */
33: public class ZkStringItem extends StringItem implements ZkComponent,
34: Itemable {
35: private String _id;
36: private ZkDesktop _zk;
37: private ZkForm _form;
38:
39: public ZkStringItem(ZkDesktop zk, String id, String label,
40: String text) {
41: super (label, text);
42: _id = id;
43: _zk = zk;
44: }
45:
46: //--ZkComponent--//
47: public String getId() {
48: return _id;
49: }
50:
51: public ZkComponent getParent() {
52: return (ZkComponent) getForm();
53: }
54:
55: public void setParent(ZkComponent parent) {
56: if (_form != parent) { //yes, !=, not !equals
57: if (_form != null) {
58: _form.removeItem(this );
59: }
60: _form = (ZkForm) parent;
61: ZkDesktop newzk = null;
62: if (_form != null) {
63: _form.appendChild(this );
64: newzk = _form.getZkDesktop();
65: }
66: if (_zk != newzk) {
67: _zk = newzk;
68: }
69: }
70: }
71:
72: public ZkDesktop getZkDesktop() {
73: return _zk;
74: }
75:
76: public void setAttr(String attr, String val) {
77: UiManager.setItemAttr(this , attr, val);
78: if ("tx".equals(attr)) {
79: setText(val);
80: }
81: }
82:
83: //--Itemable--//
84: public Form getForm() {
85: return _form;
86: }
87: }
|