01: package net.xoetrope.samples.travel;
02:
03: import java.awt.Color;
04: import java.awt.event.ItemEvent;
05:
06: import net.xoetrope.awt.XButton;
07: import net.xoetrope.awt.XComboBox;
08: import net.xoetrope.awt.XImage;
09: import net.xoetrope.xui.XPage;
10: import net.xoetrope.xui.XProjectManager;
11: import net.xoetrope.xui.data.XListBinding;
12: import net.xoetrope.xui.helper.BuddyHelper;
13:
14: /**
15: * <p>Title: Xui</p>
16: * <p>Description: </p>
17: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
18: * <p>Company: Xoetrope Ltd.</p>
19: * @author not attributable
20: * @version 1.0
21: */
22:
23: public class BusSchedules extends XPage {
24: XImage imgBack;
25: XComboBox lstRegionStart, lstRegionEnd, lstAreaStart, lstAreaEnd;
26: XButton btnSearch;
27:
28: public BusSchedules() {
29: BuddyHelper buddy = new BuddyHelper(componentFactory);
30:
31: setBackground(Color.white);
32: imgBack = (XImage) componentFactory.addComponent(XPage.IMAGE,
33: 220, 10, 18, 14, "home.gif");
34: componentFactory.addComponent(XPage.LABEL, 10, 10, 300, 20,
35: "Where do you starting from?", "prompt");
36: lstRegionStart = (XComboBox) buddy.addComponent(XPage.COMBO,
37: 10, 40, 210, 20, "Region", null, null);
38: lstAreaStart = (XComboBox) buddy.addComponent(XPage.COMBO, 10,
39: 65, 210, 20, "Area", null, null);
40: componentFactory.addComponent(XPage.LABEL, 10, 100, 300, 20,
41: "Where do you going to?", "prompt");
42: lstRegionEnd = (XComboBox) buddy.addComponent(XPage.COMBO, 10,
43: 130, 210, 20, "Region", null, null);
44: lstAreaEnd = (XComboBox) buddy.addComponent(XPage.COMBO, 10,
45: 155, 210, 20, "Area", null, null);
46: btnSearch = (XButton) componentFactory.addComponent(
47: XPage.BUTTON, 80, 260, 70, 20, "Search");
48: mapEvents();
49: addBindings();
50: }
51:
52: public void pageActivated() {
53: lstRegionStart.select(4);
54: lstRegionEnd.select(2);
55: }
56:
57: public void mapEvents() {
58: addMouseHandler(imgBack, "goHome");
59: addMouseHandler(btnSearch, "search");
60: addItemHandler(lstRegionStart, "drillDown");
61: addItemHandler(lstRegionEnd, "drillDown");
62: }
63:
64: public void goHome() {
65: if (wasMouseClicked())
66: XProjectManager.getPageManager().showPage("Services");
67: }
68:
69: private void addBindings() {
70: addBinding(new XListBinding(lstRegionStart, "dublin/areas"));
71: addBinding(new XListBinding(lstRegionEnd, "dublin/areas"));
72: }
73:
74: public void search() {
75: if (wasMouseClicked())
76: XProjectManager.getPageManager().showPage("BusRoutes");
77: }
78:
79: public void drillDown() {
80: ItemEvent evt = (ItemEvent) getCurrentEvent();
81: XComboBox cmbReg = (XComboBox) evt.getSource();
82: XComboBox cmbArea = evt.getSource() == lstRegionStart ? lstAreaStart
83: : lstAreaEnd;
84:
85: String str = cmbReg.getSelectedObject().toString();
86: str = str.substring(str.length() - 2, str.length()).trim();
87: XListBinding lb = new XListBinding(cmbArea, "dublin/area" + str);
88: addBinding(lb);
89: lb.get();
90: }
91: }
|