01: package net.xoetrope.samples.travel;
02:
03: import java.awt.Color;
04:
05: import net.xoetrope.awt.XButton;
06: import net.xoetrope.awt.XComboBox;
07: import net.xoetrope.awt.XImage;
08: import net.xoetrope.awt.XTable;
09: import net.xoetrope.xui.XPage;
10: import net.xoetrope.xui.XProjectManager;
11: import net.xoetrope.xui.data.XListBinding;
12: import net.xoetrope.xui.data.XModel;
13: import net.xoetrope.xui.helper.BuddyHelper;
14:
15: /**
16: * <p>Title: Xui</p>
17: * <p>Description: </p>
18: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
19: * <p>Company: Xoetrope Ltd.</p>
20: * @author not attributable
21: * @version 1.0
22: */
23:
24: public class FoodIndex extends XPage {
25: XImage imgBack;
26: XComboBox lstCounties, lstFoodStyle;
27: XButton btnSearch, btnDetails;
28: XTable table;
29:
30: public FoodIndex() {
31: BuddyHelper buddy = new BuddyHelper(componentFactory);
32:
33: setBackground(Color.white);
34: imgBack = (XImage) componentFactory.addComponent(XPage.IMAGE,
35: 220, 10, 18, 14, "home.gif");
36: componentFactory.addComponent(XPage.LABEL, 10, 10, 300, 30,
37: "How do you want to search?", "prompt");
38: lstCounties = (XComboBox) buddy.addComponent(XPage.COMBO, 10,
39: 40, 210, 20, "County", null, null);
40: lstFoodStyle = (XComboBox) buddy.addComponent(XPage.COMBO, 10,
41: 70, 210, 20, "Food style", null, null);
42: btnSearch = (XButton) componentFactory.addComponent(
43: XPage.BUTTON, 80, 95, 70, 20, "Search");
44:
45: table = (XTable) componentFactory.addComponent(XPage.TABLE, 10,
46: 120, 215, 140);
47: table.setStyle("base/TableData");
48: table.setHeaderStyle("base/TableHeading");
49: table.setSelectedStyle("base/TableSelection");
50:
51: btnDetails = (XButton) componentFactory.addComponent(
52: XPage.BUTTON, 80, 275, 70, 20, "Details");
53:
54: mapEvents();
55: addBindings();
56: }
57:
58: public void mapEvents() {
59: addMouseHandler(imgBack, "goHome");
60: addMouseHandler(btnSearch, "search");
61: addMouseHandler(btnDetails, "showDetails");
62: }
63:
64: public void goHome() {
65: if (wasMouseClicked())
66: XProjectManager.getPageManager().showPage("Services");
67: }
68:
69: private void addBindings() {
70: addBinding(new XListBinding(lstCounties, "fooddata/counties"));
71: addBinding(new XListBinding(lstFoodStyle, "fooddata/foodtypes"));
72: }
73:
74: public void search() {
75: if (wasMouseClicked()) {
76: table.setModel((XModel) XProjectManager.getModel().get(
77: "base/restaurants/items"));
78: table.setInteractiveTable(true);
79: table.repaint();
80: }
81: }
82:
83: public void showDetails() {
84: if (wasMouseClicked()) {
85: XProjectManager.getPageManager().showPage("FoodDetails");
86: }
87: }
88: }
|