01: /* ZkDateField.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: May 29, 2007 3:17:38 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 java.util.Date;
22: import java.util.TimeZone;
23:
24: import javax.microedition.lcdui.DateField;
25: import javax.microedition.lcdui.Form;
26:
27: import org.zkoss.zkmob.Itemable;
28: import org.zkoss.zkmob.ZkComponent;
29:
30: /**
31: * DateField with id.
32: * @author henrichen
33: *
34: */
35: public class ZkDateField extends DateField implements ZkComponent,
36: Itemable {
37: private String _id;
38: private ZkDesktop _zk;
39: private ZkForm _form;
40: private Boolean _onChange;
41:
42: public ZkDateField(ZkDesktop zk, String id, String label, int mode,
43: TimeZone tz, Boolean onChange) {
44: super (label, mode, tz);
45: _id = id;
46: _zk = zk;
47: _onChange = onChange;
48: }
49:
50: public Boolean getOnChange() {
51: return _onChange;
52: }
53:
54: //--ZkComponent --//
55: public String getId() {
56: return _id;
57: }
58:
59: public ZkComponent getParent() {
60: return (ZkComponent) getForm();
61: }
62:
63: public void setParent(ZkComponent parent) {
64: if (_form != parent) { //yes, !=, not !equals
65: if (_form != null) {
66: _form.removeItem(this );
67: }
68: _form = (ZkForm) parent;
69: ZkDesktop newzk = null;
70: if (_form != null) {
71: _form.appendChild(this );
72: newzk = _form.getZkDesktop();
73: }
74: if (_zk != newzk) {
75: _zk = newzk;
76: }
77: }
78: }
79:
80: public ZkDesktop getZkDesktop() {
81: return _zk;
82: }
83:
84: public void setAttr(String attr, String val) {
85: if ("dt".equals(attr)) {
86: setDate(new Date(Long.parseLong(val)));
87: }
88: }
89:
90: //--Itemable--//
91: public Form getForm() {
92: return _form;
93: }
94: }
|