001: package net.xoetrope.samples.travel;
002:
003: import net.xoetrope.awt.XComboBox;
004: import net.xoetrope.awt.XImage;
005: import net.xoetrope.awt.XPanel;
006: import net.xoetrope.xui.XPage;
007: import net.xoetrope.xui.XProjectManager;
008: import net.xoetrope.xui.XResourceManager;
009: import net.xoetrope.xui.data.XListBinding;
010: import net.xoetrope.xui.helper.BuddyHelper;
011: import net.xoetrope.xui.style.XStyleFactory;
012:
013: /**
014: * <p>Title: Xui</p>
015: * <p>Description: </p>
016: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
017: * <p>Company: Xoetrope Ltd.</p>
018: * @author not attributable
019: * @version 1.0
020: */
021:
022: public class CarHireDetails extends XPage {
023: XComboBox lstCars;
024: BuddyHelper buddy;
025: XImage imgCar;
026: XPanel pnlDetails;
027: XImage imgBack;
028:
029: public CarHireDetails() {
030: imgBack = (XImage) componentFactory.addComponent(XPage.IMAGE,
031: 220, 10, 18, 14, "home.gif");
032: buddy = new BuddyHelper((XStyleFactory) componentFactory);
033: this .componentFactory
034: .addComponent(
035: XPage.LABEL,
036: 10,
037: 20,
038: 220,
039: 40,
040: "The following cars meet your criteria. Select one for more details",
041: "normal");
042: lstCars = (XComboBox) buddy.addComponent(XPage.COMBO, 10, 70,
043: 70, 210, 25, "Cars:", "", null);
044: imgCar = (XImage) componentFactory.addComponent(XPage.IMAGE,
045: 40, 100, 150, 100, "");
046: pnlDetails = (XPanel) componentFactory.addComponent(
047: XPage.PANEL, 10, 200, 220, 100, null);
048: componentFactory.setParentComponent(pnlDetails);
049: componentFactory.addComponent(XPage.LABEL, 10, 10, 200, 20,
050: "Vehicle Features", "heading");
051: componentFactory.addComponent(XPage.LABEL, 10, 30, 200, 20,
052: "4 Adults");
053: componentFactory.addComponent(XPage.LABEL, 10, 50, 200, 20,
054: "1 large suitcase, 2 small suitcases");
055: componentFactory.addComponent(XPage.LABEL, 10, 70, 200, 20,
056: "Manual transmission");
057: addMappings();
058: pnlDetails.setVisible(true);
059: pnlDetails.setVisible(false);
060: }
061:
062: public void addMappings() {
063: addBinding(new XListBinding(lstCars, "carhiredata/carlist"));
064: addMouseHandler(imgBack, "goHome");
065: addItemHandler(lstCars, "selectCar");
066: }
067:
068: public void selectCar() {
069: switch (lstCars.getSelectedIndex()) {
070: case 0:
071: imgCar.setImage(XResourceManager.getImage("ka.gif"));
072: imgCar.setVisible(true);
073: pnlDetails.setVisible(true);
074: break;
075: case 1:
076: pnlDetails.setVisible(false);
077: imgCar.setVisible(false);
078: imgCar.setImage(XResourceManager.getImage("corsa.gif"));
079: break;
080: case 2:
081: imgCar.setVisible(false);
082: pnlDetails.setVisible(false);
083: imgCar.setImage(XResourceManager.getImage("astra.gif"));
084: break;
085: case 3:
086: imgCar.setVisible(false);
087: pnlDetails.setVisible(false);
088: imgCar.setImage(XResourceManager.getImage("mondeo.gif"));
089: break;
090: case 4:
091: imgCar.setImage(XResourceManager.getImage("micra.gif"));
092: imgCar.setVisible(true);
093: pnlDetails.setVisible(true);
094: break;
095: }
096: }
097:
098: public void goHome() {
099: if (wasMouseClicked())
100: XProjectManager.getPageManager().showPage("Services");
101: }
102:
103: }
|