package net.xoetrope.samples.travel;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import net.xoetrope.awt.XButton;
import net.xoetrope.awt.XComboBox;
import net.xoetrope.awt.XEdit;
import net.xoetrope.awt.XImage;
import net.xoetrope.awt.XLabel;
import net.xoetrope.xui.XPage;
import net.xoetrope.xui.XProjectManager;
import net.xoetrope.xui.data.XListBinding;
import net.xoetrope.xui.helper.BuddyHelper;
import net.xoetrope.xui.style.XStyleFactory;
/**
* <p>Title: Xui</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
* <p>Company: Xoetrope Ltd.</p>
* @author not attributable
* @version 1.0
*/
public class CarHire extends XPage
{
XComboBox lstCarClass, lstInsurance;
XButton btnGetClass, btnGetQuote;
XEdit txtDuration;
XImage imgBack, imgLogo;
XComboBox lstPUDay, lstPUMonth, lstPUYear, lstPULocation, lstRetDay, lstRetMonth, lstRetYear, lstRetLocation;
XLabel lblPrompt;
public CarHire()
{
BuddyHelper buddy = new BuddyHelper( (XStyleFactory)componentFactory );
imgBack = (XImage)componentFactory.addComponent( XPage.IMAGE, 220, 10, 18, 14, "home.gif" );
lblPrompt = (XLabel)componentFactory.addComponent( XPage.LABEL, 10, 10, 300, 20, "Car hire is provided by...", "prompt" );
imgLogo = (XImage)componentFactory.addComponent( XPage.IMAGE, 70, 25, 82, 45, "carzlogo.gif" );
componentFactory.addComponent( XPage.LABEL, 10, 70, 100, 25, "Pick up", "heading");
componentFactory.addComponent( XPage.LABEL, 10, 100, 30, 25, "Date:", "prompt");
lstPUDay = (XComboBox)componentFactory.addComponent( XPage.COMBO, 90, 100, 40, 25, "");
lstPUMonth = (XComboBox)componentFactory.addComponent( XPage.COMBO, 130, 100, 50, 25, "");
lstPUYear = (XComboBox)componentFactory.addComponent( XPage.COMBO, 180, 100, 60, 25, "");
componentFactory.addComponent( XPage.LABEL, 10, 130, 60, 25, "Location:", "prompt");
lstPULocation = (XComboBox)componentFactory.addComponent( XPage.COMBO, 90, 130, 150, 25, "");
componentFactory.addComponent( XPage.LABEL, 10, 170, 100, 25, "Return", "heading");
componentFactory.addComponent( XPage.LABEL, 10, 200, 30, 25, "Date:", "prompt");
lstRetDay = (XComboBox)componentFactory.addComponent( XPage.COMBO, 90, 200, 40, 25, "");
lstRetMonth = (XComboBox)componentFactory.addComponent( XPage.COMBO, 130, 200, 50, 25, "");
lstRetYear = (XComboBox)componentFactory.addComponent( XPage.COMBO, 180, 200, 60, 25, "");
componentFactory.addComponent( XPage.LABEL, 10, 230, 60, 25, "Location:", "prompt");
lstRetLocation = (XComboBox)componentFactory.addComponent( XPage.COMBO, 90, 230, 150, 25, "");
btnGetQuote = (XButton)componentFactory.addComponent( XPage.BUTTON, 80, 270, 80, 25, "Get Quote");
addMouseHandler( imgBack, "goHome" );
addMouseHandler( btnGetQuote, "getQuote" );
// addMouseHandler( imgLogo, "setDates" );
addBindings();
// setDates();
}
private void addBindings()
{
addBinding( new XListBinding( lstPUDay, "datedata/days" ) );
addBinding( new XListBinding( lstPUMonth, "datedata/months" ) );
addBinding( new XListBinding( lstPUYear, "datedata/years" ) );
addBinding( new XListBinding( lstPULocation, "carhiredata/locations" ) );
addBinding( new XListBinding( lstRetDay, "datedata/days" ) );
addBinding( new XListBinding( lstRetMonth, "datedata/months" ) );
addBinding( new XListBinding( lstRetYear, "datedata/years" ) );
addBinding( new XListBinding( lstRetLocation, "carhiredata/locations" ) );
// addBinding( new XListBinding( lstCarClass, "carhiredata/classes" ) );
// addBinding( new XListBinding( lstInsurance, "carhiredata/insurance" ) );
}
public void setDates()
{
Date dat = new Date();
Calendar cal = new GregorianCalendar();
cal.setTime(dat);
lstPUDay.select( (Object)String.valueOf(cal.get(cal.DAY_OF_MONTH)) );
lstPUMonth.select( cal.get(cal.MONTH) );
lstPUYear.select( (Object)String.valueOf(cal.get(cal.YEAR)) );
cal.add( cal.DAY_OF_WEEK, 7 );
lstRetDay.select( (Object)String.valueOf(cal.get(cal.DAY_OF_MONTH)) );
lstRetMonth.select( cal.get(cal.MONTH) );
lstRetYear.select( (Object)String.valueOf(cal.get(cal.YEAR)) );
}
public void pageActivated()
{
setDates();
}
public void goHome()
{
if ( wasMouseClicked() )
XProjectManager.getPageManager().showPage("Services");
}
public void getQuote()
{
if ( wasMouseClicked() )
XProjectManager.getPageManager().showPage("CarHireDetails");
}
}
|