001: package net.xoetrope.samples.travel;
002:
003: import java.util.Calendar;
004: import java.util.Date;
005: import java.util.GregorianCalendar;
006:
007: import net.xoetrope.awt.XButton;
008: import net.xoetrope.awt.XComboBox;
009: import net.xoetrope.awt.XEdit;
010: import net.xoetrope.awt.XImage;
011: import net.xoetrope.awt.XLabel;
012: import net.xoetrope.xui.XPage;
013: import net.xoetrope.xui.XProjectManager;
014: import net.xoetrope.xui.data.XListBinding;
015: import net.xoetrope.xui.helper.BuddyHelper;
016: import net.xoetrope.xui.style.XStyleFactory;
017:
018: /**
019: * <p>Title: Xui</p>
020: * <p>Description: </p>
021: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
022: * <p>Company: Xoetrope Ltd.</p>
023: * @author not attributable
024: * @version 1.0
025: */
026:
027: public class CarHire extends XPage {
028: XComboBox lstCarClass, lstInsurance;
029: XButton btnGetClass, btnGetQuote;
030: XEdit txtDuration;
031: XImage imgBack, imgLogo;
032: XComboBox lstPUDay, lstPUMonth, lstPUYear, lstPULocation,
033: lstRetDay, lstRetMonth, lstRetYear, lstRetLocation;
034: XLabel lblPrompt;
035:
036: public CarHire() {
037: BuddyHelper buddy = new BuddyHelper(
038: (XStyleFactory) componentFactory);
039: imgBack = (XImage) componentFactory.addComponent(XPage.IMAGE,
040: 220, 10, 18, 14, "home.gif");
041: lblPrompt = (XLabel) componentFactory
042: .addComponent(XPage.LABEL, 10, 10, 300, 20,
043: "Car hire is provided by...", "prompt");
044: imgLogo = (XImage) componentFactory.addComponent(XPage.IMAGE,
045: 70, 25, 82, 45, "carzlogo.gif");
046: componentFactory.addComponent(XPage.LABEL, 10, 70, 100, 25,
047: "Pick up", "heading");
048: componentFactory.addComponent(XPage.LABEL, 10, 100, 30, 25,
049: "Date:", "prompt");
050: lstPUDay = (XComboBox) componentFactory.addComponent(
051: XPage.COMBO, 90, 100, 40, 25, "");
052: lstPUMonth = (XComboBox) componentFactory.addComponent(
053: XPage.COMBO, 130, 100, 50, 25, "");
054: lstPUYear = (XComboBox) componentFactory.addComponent(
055: XPage.COMBO, 180, 100, 60, 25, "");
056: componentFactory.addComponent(XPage.LABEL, 10, 130, 60, 25,
057: "Location:", "prompt");
058: lstPULocation = (XComboBox) componentFactory.addComponent(
059: XPage.COMBO, 90, 130, 150, 25, "");
060:
061: componentFactory.addComponent(XPage.LABEL, 10, 170, 100, 25,
062: "Return", "heading");
063: componentFactory.addComponent(XPage.LABEL, 10, 200, 30, 25,
064: "Date:", "prompt");
065: lstRetDay = (XComboBox) componentFactory.addComponent(
066: XPage.COMBO, 90, 200, 40, 25, "");
067: lstRetMonth = (XComboBox) componentFactory.addComponent(
068: XPage.COMBO, 130, 200, 50, 25, "");
069: lstRetYear = (XComboBox) componentFactory.addComponent(
070: XPage.COMBO, 180, 200, 60, 25, "");
071: componentFactory.addComponent(XPage.LABEL, 10, 230, 60, 25,
072: "Location:", "prompt");
073: lstRetLocation = (XComboBox) componentFactory.addComponent(
074: XPage.COMBO, 90, 230, 150, 25, "");
075:
076: btnGetQuote = (XButton) componentFactory.addComponent(
077: XPage.BUTTON, 80, 270, 80, 25, "Get Quote");
078:
079: addMouseHandler(imgBack, "goHome");
080: addMouseHandler(btnGetQuote, "getQuote");
081: // addMouseHandler( imgLogo, "setDates" );
082: addBindings();
083: // setDates();
084: }
085:
086: private void addBindings() {
087: addBinding(new XListBinding(lstPUDay, "datedata/days"));
088: addBinding(new XListBinding(lstPUMonth, "datedata/months"));
089: addBinding(new XListBinding(lstPUYear, "datedata/years"));
090: addBinding(new XListBinding(lstPULocation,
091: "carhiredata/locations"));
092: addBinding(new XListBinding(lstRetDay, "datedata/days"));
093: addBinding(new XListBinding(lstRetMonth, "datedata/months"));
094: addBinding(new XListBinding(lstRetYear, "datedata/years"));
095: addBinding(new XListBinding(lstRetLocation,
096: "carhiredata/locations"));
097: // addBinding( new XListBinding( lstCarClass, "carhiredata/classes" ) );
098: // addBinding( new XListBinding( lstInsurance, "carhiredata/insurance" ) );
099: }
100:
101: public void setDates() {
102: Date dat = new Date();
103: Calendar cal = new GregorianCalendar();
104: cal.setTime(dat);
105:
106: lstPUDay.select((Object) String.valueOf(cal
107: .get(cal.DAY_OF_MONTH)));
108: lstPUMonth.select(cal.get(cal.MONTH));
109: lstPUYear.select((Object) String.valueOf(cal.get(cal.YEAR)));
110:
111: cal.add(cal.DAY_OF_WEEK, 7);
112: lstRetDay.select((Object) String.valueOf(cal
113: .get(cal.DAY_OF_MONTH)));
114: lstRetMonth.select(cal.get(cal.MONTH));
115: lstRetYear.select((Object) String.valueOf(cal.get(cal.YEAR)));
116: }
117:
118: public void pageActivated() {
119: setDates();
120: }
121:
122: public void goHome() {
123: if (wasMouseClicked())
124: XProjectManager.getPageManager().showPage("Services");
125: }
126:
127: public void getQuote() {
128: if (wasMouseClicked())
129: XProjectManager.getPageManager().showPage("CarHireDetails");
130: }
131: }
|