01: /* ColSizeCommand.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Thu Dec 7 11:08:01 2006, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2006 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.zul.au.in;
20:
21: import org.zkoss.lang.Objects;
22:
23: import org.zkoss.zk.mesg.MZk;
24: import org.zkoss.zk.ui.Desktop;
25: import org.zkoss.zk.ui.Component;
26: import org.zkoss.zk.ui.UiException;
27: import org.zkoss.zk.ui.event.Events;
28: import org.zkoss.zk.ui.ext.client.Sizable;
29: import org.zkoss.zk.ui.sys.ComponentCtrl;
30: import org.zkoss.zk.au.AuRequest;
31: import org.zkoss.zk.au.Command;
32: import org.zkoss.zk.au.in.Commands;
33:
34: import org.zkoss.zul.event.ColSizeEvent;
35:
36: /**
37: * Used only by {@link AuRequest} to implement the {@link ColSizeEvent}
38: * related command.
39: *
40: * @author tomyeh
41: */
42: public class ColSizeCommand extends Command {
43: public ColSizeCommand(String evtnm, int flags) {
44: super (evtnm, flags);
45: }
46:
47: //-- super --//
48: protected void process(AuRequest request) {
49: final Component comp = request.getComponent();
50: if (comp == null)
51: throw new UiException(
52: MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this );
53: final String[] data = request.getData();
54: if (data == null || data.length != 4)
55: throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,
56: new Object[] { Objects.toString(data), this });
57:
58: final Desktop desktop = request.getDesktop();
59: final int icol = Integer.parseInt(data[0]);
60: final Component col1 = desktop.getComponentByUuid(data[1]);
61:
62: ((Sizable) ((ComponentCtrl) col1).getExtraCtrl())
63: .setWidthByClient(data[2]);
64: Events.postEvent(new ColSizeEvent(getId(), comp, icol, col1,
65: Commands.parseKeys(data[3])));
66: }
67: }
|