01: /* CommandCommand.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Jun 1, 2007 3:20:43 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:
20: package org.zkoss.mil.au.in;
21:
22: import org.zkoss.lang.Objects;
23: import org.zkoss.mil.Command;
24: import org.zkoss.mil.event.CommandEvent;
25: import org.zkoss.zk.au.AuRequest;
26: import org.zkoss.zk.mesg.MZk;
27: import org.zkoss.zk.ui.Component;
28: import org.zkoss.zk.ui.UiException;
29: import org.zkoss.zk.ui.event.Events;
30:
31: /**
32: * Used only by {@link AuRequest} to implement the {@link CommandEvent}
33: * relevant command.
34: * @author henrichen
35: */
36: public class CommandCommand extends org.zkoss.zk.au.Command {
37:
38: public CommandCommand(String evtnm, int flags) {
39: super (evtnm, flags);
40: }
41:
42: protected void process(AuRequest request) {
43: final Component comp = request.getComponent();
44: if (comp == null)
45: throw new UiException(
46: MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this );
47: final String[] data = request.getData();
48: if (data == null || data.length != 1)
49: throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,
50: new Object[] { Objects.toString(data), this });
51:
52: final Command cmd = data[0] != null ? (Command) comp
53: .getDesktop().getComponentByUuidIfAny(data[0]) : null;
54:
55: Events.postEvent(new CommandEvent(getId(), comp, cmd));
56: }
57:
58: }
|