01: package org.zkforge.timeline;
02:
03: import java.text.DateFormat;
04: import java.text.ParseException;
05: import java.text.SimpleDateFormat;
06: import java.util.Date;
07: import java.util.Locale;
08:
09: import org.zkforge.timeline.event.BandScrollEvent;
10: import org.zkoss.lang.Objects;
11: import org.zkoss.zk.au.AuRequest;
12: import org.zkoss.zk.au.Command;
13: import org.zkoss.zk.mesg.MZk;
14: import org.zkoss.zk.ui.Component;
15: import org.zkoss.zk.ui.UiException;
16: import org.zkoss.zk.ui.event.Events;
17:
18: /** The band-scroll command.
19: *
20: * @author WeiXing Gu, China
21: */
22: class BandScrollCommand extends Command {
23:
24: protected BandScrollCommand(String arg0, int arg1) {
25: super (arg0, arg1);
26: // TODO Auto-generated constructor stub
27: }
28:
29: // @Override
30: protected void process(AuRequest request) {
31: // TODO Auto-generated method stub
32: final Component comp = request.getComponent();
33: if (comp == null)
34: throw new UiException(
35: MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this );
36: if (!(comp instanceof Bandinfo))
37: throw new UiException(
38: MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this );
39: final String[] data = request.getData();
40: if (data == null || data.length < 2)
41: throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,
42: new Object[] { Objects.toString(data), this });
43:
44: SimpleDateFormat sdf = new SimpleDateFormat(
45: "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
46: Date min = null;
47: try {
48: min = sdf.parse(data[0]);
49: } catch (ParseException e) {
50: // TODO Auto-generated catch block
51: e.printStackTrace();
52: }
53: Date max = null;
54: try {
55: max = sdf.parse(data[1]);
56: } catch (ParseException e) {
57: // TODO Auto-generated catch block
58: e.printStackTrace();
59: }
60:
61: Events.postEvent(new BandScrollEvent(getId(), comp, min, max));
62: }
63:
64: }
|