01: /* ZkCommand.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Jun 1, 2007 12:17:20 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.ChoiceGroup;
22: import javax.microedition.lcdui.Command;
23: import javax.microedition.lcdui.List;
24:
25: import org.zkoss.zkmob.UiManager;
26: import org.zkoss.zkmob.ZkComponent;
27:
28: /**
29: * A ZK Command.
30: * @author henrichen
31: *
32: */
33: public class ZkCommand extends Command implements ZkComponent {
34: private String _id;
35: private ZkComponent _parent;
36: private int _type;
37:
38: public ZkCommand(String id, String label, String longLabel,
39: int type, int priority) {
40: super (label, longLabel, type == 0x100 ? Command.OK : type,
41: priority);
42: _id = id;
43: _type = type;
44: }
45:
46: public void setParent(ZkComponent parent) {
47: if (parent != _parent) {
48: if (_parent != null) {
49: _parent.removeCommand(this );
50: }
51: if (parent != null) {
52: if (_type == 0x100) { //special selection command
53: if (parent instanceof List) {
54: ((List) parent).setSelectCommand(this );
55: }
56: } else {
57: parent.addCommand(this );
58: }
59: UiManager.registerCommand(parent, this , parent
60: .getZkDesktop());
61: }
62: _parent = parent;
63: }
64: }
65:
66: public ZkComponent getParent() {
67: return _parent;
68: }
69:
70: public void addCommand(Command cmd) {
71: // do nothing
72: }
73:
74: public void removeCommand(Command cmd) {
75: //do nothing
76: }
77:
78: public String getId() {
79: return _id;
80: }
81:
82: public ZkDesktop getZkDesktop() {
83: return _parent == null ? null : _parent.getZkDesktop();
84: }
85:
86: public void setAttr(String attr, String val) {
87: // TODO Auto-generated method stub
88:
89: }
90: }
|