The demo code is as follows: 
 
Hotelreservation.java 
 
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Org.eclipse.jface.dialogs.Dialog; 
 
 
 
Import Org.eclipse.jface.window.ApplicationWindow; 
 
 
 
Import Org.eclipse.jface.wizard.WizardDialog; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.widgets.Button; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import Org.eclipse.swt.widgets.Control; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
Import Org.eclipse.swt.widgets.Shell; 
 
 
 
public class Hotelreservation extends Applicationwindow { 
 
 
 
Protected control createcontents (composite parent) { 
 
 
 
Button button = New button (parent, SWT. PUSH); 
 
 
 
Button.settext ("Make a Reservation"); 
 
 
 
Button.addlistener (SWT. Selection, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
Reservationwizard wizard = new Reservationwizard (); 
 
 
 
 
 
 
 
Wizarddialog dialog = new Wizarddialog (Getshell (), wizard); 
 
 
 
Dialog.setblockonopen (TRUE); 
 
 
 
int returncode = Dialog.open (); 
 
 
 
if (ReturnCode = = Dialog.ok) 
 
 
 
System.out.println (Wizard.data); 
 
 
 
Else 
 
 
 
System.out.println ("cancelled"); 
 
 
 
} 
 
 
 
}); 
 
 
 
return button; 
 
 
 
} 
 
 
 
Public hotelreservation (Shell Parentshell) { 
 
 
 
Super (Parentshell); 
 
 
 
} 
 
 
 
public static void Main (string[] args) { 
 
 
 
hotelreservation reservation = new hotelreservation (null); 
 
 
 
Reservation.setblockonopen (TRUE); 
 
 
 
Reservation.open (); 
 
 
 
} 
 
 
 
} 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Org.eclipse.jface.dialogs.Dialog; 
 
 
 
Import Org.eclipse.jface.window.ApplicationWindow; 
 
 
 
Import Org.eclipse.jface.wizard.WizardDialog; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.widgets.Button; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import Org.eclipse.swt.widgets.Control; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
Import Org.eclipse.swt.widgets.Shell; 
 
 
 
public class Hotelreservation extends Applicationwindow { 
 
 
 
Protected control createcontents (composite parent) { 
 
 
 
Button button = New button (parent, SWT. PUSH); 
 
 
 
Button.settext ("Make a Reservation"); 
 
 
 
Button.addlistener (SWT. Selection, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
Reservationwizard wizard = new Reservationwizard (); 
 
 
 
 
 
 
 
Wizarddialog dialog = new Wizarddialog (Getshell (), wizard); 
 
 
 
Dialog.setblockonopen (TRUE); 
 
 
 
int returncode = Dialog.open (); 
 
 
 
if (ReturnCode = = Dialog.ok) 
 
 
 
System.out.println (Wizard.data); 
 
 
 
Else 
 
 
 
System.out.println ("cancelled"); 
 
 
 
} 
 
 
 
}); 
 
 
 
return button; 
 
 
 
} 
 
 
 
Public hotelreservation (Shell Parentshell) { 
 
 
 
Super (Parentshell); 
 
 
 
} 
 
 
 
public static void Main (string[] args) { 
 
 
 
hotelreservation reservation = new hotelreservation (null); 
 
 
 
Reservation.setblockonopen (TRUE); 
 
 
 
Reservation.open (); 
 
 
 
} 
 
 
 
} 
 
 
 
 
 
 
Customerinfopage.java 
 
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Org.eclipse.jface.wizard.WizardPage; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.layout.GridData; 
 
 
 
Import Org.eclipse.swt.layout.GridLayout; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Label; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
Import Org.eclipse.swt.widgets.Text; 
 
 
 
public class Customerinfopage extends Wizardpage { 
 
 
 
 
 
 
 
Text Textname; 
 
 
 
Text Textphone; 
 
 
 
Text TextEmail; 
 
 
 
Text textaddress; 
 
 
 
Public Customerinfopage () { 
 
 
 
Super ("CustomerInfo"); 
 
 
 
Settitle ("Customer information"); 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
public void CreateControl (composite parent) { 
 
 
 
 
 
 
 
Composite composite = new Composite (parent, SWT. NULL); 
 
 
 
Composite.setlayout (New GridLayout (2, false)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Full name:"); 
 
 
 
Textname = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textname.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Phone number:"); 
 
 
 
Textphone = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textphone.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Email address:"); 
 
 
 
TextEmail = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textemail.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Address:"); 
 
 
 
textaddress = new Text (composite, SWT. MULTI | Swt. BORDER); 
 
 
 
Textaddress.settext ("\r\n\r\n\r\n"); 
 
 
 
Textaddress.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
Listener Listener = new Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
if (Event.widget = NULL | |!) ( Event.widget instanceof Text) return; 
 
 
 
String string = ((Text) event.widget). GetText (); 
 
 
 
if (Event.widget = = textname) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.customername = string; 
 
 
 
else if (Event.widget = = Textphone) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.customerphone = string; 
 
 
 
else if (Event.widget = = TextEmail) { 
 
 
 
if (String.IndexOf (' @ ') < 0) { 
 
 
 
Seterrormessage ("Invalid Email Address:" + string); 
 
 
 
((Reservationwizard) Getwizard ()). Data.customeremail = null; 
 
 
 
} else { 
 
 
 
Seterrormessage (NULL); 
 
 
 
((Reservationwizard) Getwizard ()). Data.customeremail = string; 
 
 
 
} 
 
 
 
else if (Event.widget = = textaddress) { 
 
 
 
((Reservationwizard) Getwizard ()). data.customeraddress = string; 
 
 
 
} 
 
 
 
Reservationdata data = ((Reservationwizard) Getwizard ()). data; 
 
 
 
if (Data.customername!= null 
 
 
 
&& data.customerphone!= NULL 
 
 
 
&& data.customeremail!= NULL 
 
 
 
&& data.customeraddress!= null) { 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
} else { 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
} 
 
 
 
}; 
 
 
 
Textname.addlistener (SWT. Modify, listener); 
 
 
 
Textphone.addlistener (SWT. Modify, listener); 
 
 
 
Textemail.addlistener (SWT. Modify, listener); 
 
 
 
Textaddress.addlistener (SWT. Modify, listener); 
 
 
 
if (getdialogsettings ()!= null && validdialogsettings ()) { 
 
 
 
Textname.settext (Getdialogsettings (). Get (Reservationwizard.key_customer_name)); 
 
 
 
Textphone.settext (Getdialogsettings (). Get (Reservationwizard.key_customer_phone)); 
 
 
 
Textemail.settext (Getdialogsettings (). Get (Reservationwizard.key_customer_email)); 
 
 
 
Textaddress.settext (Getdialogsettings (). Get (reservationwizard.key_customer_address)); 
 
 
 
} 
 
 
 
Setcontrol (composite); 
 
 
 
} 
 
 
 
 
 
 
 
Private Boolean validdialogsettings () { 
 
 
 
if (Getdialogsettings (). Get (Reservationwizard.key_customer_name) = null 
 
 
 
|| Getdialogsettings (). Get (reservationwizard.key_customer_address) = null 
 
 
 
|| Getdialogsettings (). Get (Reservationwizard.key_customer_email) = null 
 
 
 
|| Getdialogsettings (). Get (Reservationwizard.key_customer_phone) = null) return false; 
 
 
 
return true; 
 
 
 
} 
 
 
 
} 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Org.eclipse.jface.wizard.WizardPage; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.layout.GridData; 
 
 
 
Import Org.eclipse.swt.layout.GridLayout; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Label; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
Import Org.eclipse.swt.widgets.Text; 
 
 
 
public class Customerinfopage extends Wizardpage { 
 
 
 
 
 
 
 
Text Textname; 
 
 
 
Text Textphone; 
 
 
 
Text TextEmail; 
 
 
 
Text textaddress; 
 
 
 
Public Customerinfopage () { 
 
 
 
Super ("CustomerInfo"); 
 
 
 
Settitle ("Customer information"); 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
public void CreateControl (composite parent) { 
 
 
 
 
 
 
 
Composite composite = new Composite (parent, SWT. NULL); 
 
 
 
Composite.setlayout (New GridLayout (2, false)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Full name:"); 
 
 
 
Textname = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textname.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Phone number:"); 
 
 
 
Textphone = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textphone.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Email address:"); 
 
 
 
TextEmail = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textemail.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Address:"); 
 
 
 
textaddress = new Text (composite, SWT. MULTI | Swt. BORDER); 
 
 
 
Textaddress.settext ("\r\n\r\n\r\n"); 
 
 
 
Textaddress.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
Listener Listener = new Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
if (Event.widget = NULL | |!) ( Event.widget instanceof Text) return; 
 
 
 
String string = ((Text) event.widget). GetText (); 
 
 
 
if (Event.widget = = textname) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.customername = string; 
 
 
 
else if (Event.widget = = Textphone) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.customerphone = string; 
 
 
 
else if (Event.widget = = TextEmail) { 
 
 
 
if (String.IndexOf (' @ ') < 0) { 
 
 
 
Seterrormessage ("Invalid Email Address:" + string); 
 
 
 
((Reservationwizard) Getwizard ()). Data.customeremail = null; 
 
 
 
} else { 
 
 
 
Seterrormessage (NULL); 
 
 
 
((Reservationwizard) Getwizard ()). Data.customeremail = string; 
 
 
 
} 
 
 
 
else if (Event.widget = = textaddress) { 
 
 
 
((Reservationwizard) Getwizard ()). data.customeraddress = string; 
 
 
 
} 
 
 
 
Reservationdata data = ((Reservationwizard) Getwizard ()). data; 
 
 
 
if (Data.customername!= null 
 
 
 
&& data.customerphone!= NULL 
 
 
 
&& data.customeremail!= NULL 
 
 
 
&& data.customeraddress!= null) { 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
} else { 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
} 
 
 
 
}; 
 
 
 
Textname.addlistener (SWT. Modify, listener); 
 
 
 
Textphone.addlistener (SWT. Modify, listener); 
 
 
 
Textemail.addlistener (SWT. Modify, listener); 
 
 
 
Textaddress.addlistener (SWT. Modify, listener); 
 
 
 
if (getdialogsettings ()!= null && validdialogsettings ()) { 
 
 
 
Textname.settext (Getdialogsettings (). Get (Reservationwizard.key_customer_name)); 
 
 
 
Textphone.settext (Getdialogsettings (). Get (Reservationwizard.key_customer_phone)); 
 
 
 
Textemail.settext (Getdialogsettings (). Get (Reservationwizard.key_customer_email)); 
 
 
 
Textaddress.settext (Getdialogsettings (). Get (reservationwizard.key_customer_address)); 
 
 
 
} 
 
 
 
Setcontrol (composite); 
 
 
 
} 
 
 
 
 
 
 
 
Private Boolean validdialogsettings () { 
 
 
 
if (Getdialogsettings (). Get (Reservationwizard.key_customer_name) = null 
 
 
 
|| Getdialogsettings (). Get (reservationwizard.key_customer_address) = null 
 
 
 
|| Getdialogsettings (). Get (Reservationwizard.key_customer_email) = null 
 
 
 
|| Getdialogsettings (). Get (Reservationwizard.key_customer_phone) = null) return false; 
 
 
 
return true; 
 
 
 
} 
 
 
 
} 
 
 
 
 
 
 
Frontpage.java 
 
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Java.util.Calendar; 
 
 
 
Import Java.util.Date; 
 
 
 
Import Java.util.GregorianCalendar; 
 
 
 
Import Org.eclipse.jface.wizard.WizardPage; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.layout.GridData; 
 
 
 
Import Org.eclipse.swt.layout.GridLayout; 
 
 
 
Import Org.eclipse.swt.layout.RowLayout; 
 
 
 
Import Org.eclipse.swt.widgets.Combo; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Label; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
public class FrontPage extends Wizardpage { 
 
 
 
 
 
 
 
Combo comboroomtypes; 
 
 
 
Combo comboarrivalyear; 
 
 
 
Combo Comboarrivalmonth; 
 
 
 
Combo Comboarrivalday; 
 
 
 
Combo combodepartureyear; 
 
 
 
Combo Combodeparturemonth; 
 
 
 
Combo Combodepartureday; 
 
 
 
 
 
 
 
FrontPage () { 
 
 
 
Super ("FrontPage"); 
 
 
 
Settitle ("Your Reservation Information"); 
 
 
 
SetDescription ("Select the type of room and your arrival date & departure date"); 
 
 
 
} 
 
 
 
public void CreateControl (composite parent) { 
 
 
 
 
 
 
 
Composite composite = new Composite (parent, SWT. NULL); 
 
 
 
GridLayout GridLayout = new GridLayout (2, false); 
 
 
 
Composite.setlayout (gridLayout); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Arrival date:"); 
 
 
 
Composite Compositearrival = new Composite (composite, SWT. NULL); 
 
 
 
Compositearrival.setlayout (New Rowlayout ()); 
 
 
 
months = new string[]{"string[", "Feb", "Mar", "APR", "may", "June", 
 
 
 
"June", "Aug", "Sep", "Oct", "Nov", "Dec" 
 
 
 
}; 
 
 
 
Calendar calendar = new GregorianCalendar (); 
 
 
 
((Reservationwizard) Getwizard ()). Data.arrivaldate = Calendar.gettime (); 
 
 
 
Comboarrivalmonth = new Combo (Compositearrival, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<months.length; i++) Comboarrivalmonth.add (months[i)); 
 
 
 
Comboarrivalmonth.select (Calendar.get (calendar.month)); 
 
 
 
Comboarrivalday = new Combo (Compositearrival, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<31; i++) Comboarrivalday.add ("" + (i+1)); 
 
 
 
Comboarrivalday.select (Calendar.get (Calendar.day_of_month)-1); 
 
 
 
Comboarrivalyear = new Combo (Compositearrival, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
for (int i=2004; i<2010; i++) Comboarrivalyear.add ("" + i); 
 
 
 
Comboarrivalyear.select (Calendar.get (Calendar.year)-2004); 
 
 
 
Calendar.add (calendar.date, 1); 
 
 
 
((Reservationwizard) Getwizard ()). Data.departuredate = Calendar.gettime (); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Departure date:"); 
 
 
 
Composite compositedeparture = new Composite (composite, SWT. NULL | Swt. READ_ONLY); 
 
 
 
Compositedeparture.setlayout (New Rowlayout ()); 
 
 
 
Combodeparturemonth = new Combo (Compositedeparture, SWT. NULL | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<months.length; i++) Combodeparturemonth.add (months[i)); 
 
 
 
Combodeparturemonth.select (Calendar.get (calendar.month)); 
 
 
 
Combodepartureday = new Combo (Compositedeparture, SWT. NULL | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<31; i++) Combodepartureday.add ("" + (i+1)); 
 
 
 
Combodepartureday.select (Calendar.get (Calendar.day_of_month)-1); 
 
 
 
Combodepartureyear = new Combo (Compositedeparture, SWT. NULL | Swt. READ_ONLY); 
 
 
 
for (int i=2004; i<2010; i++) Combodepartureyear.add ("" + i); 
 
 
 
Combodepartureyear.select (Calendar.get (Calendar.year)-2004); 
 
 
 
Label line = new label (composite, SWT. SEPARATOR | Swt. horizontal); 
 
 
 
Griddata griddata = new Griddata (griddata.fill_horizontal); 
 
 
 
Griddata.horizontalspan = 2; 
 
 
 
Line.setlayoutdata (Griddata); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Room type:"); 
 
 
 
Comboroomtypes = new Combo (composite, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
Comboroomtypes.add ("Standard Room (Rate: $198)"); 
 
 
 
Comboroomtypes.add ("Deluxe Room (Rate: $298)"); 
 
 
 
Comboroomtypes.select (0); 
 
 
 
Listener Selectionlistener = new Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
int arrivalday = Comboarrivalday.getselectionindex () + 1; 
 
 
 
int arrivalmonth = Comboarrivalmonth.getselectionindex (); 
 
 
 
int arrivalyear = Comboarrivalyear.getselectionindex () + 2004; 
 
 
 
int departureday = Combodepartureday.getselectionindex () + 1; 
 
 
 
int departuremonth = Combodeparturemonth.getselectionindex (); 
 
 
 
int departureyear = Combodepartureyear.getselectionindex () + 2004; 
 
 
 
Setdates (Arrivalday, Arrivalmonth, Arrivalyear, Departureday, Departuremonth, departureyear); 
 
 
 
} 
 
 
 
}; 
 
 
 
 
 
 
 
Comboarrivalday.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Comboarrivalmonth.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Comboarrivalyear.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Combodepartureday.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Combodeparturemonth.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Combodepartureyear.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Comboroomtypes.addlistener (SWT. Selection, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.roomtype = Comboroomtypes.getselectionindex (); 
 
 
 
} 
 
 
 
}); 
 
 
 
Setcontrol (composite); 
 
 
 
} 
 
 
 
 
 
 
 
private void setdates (int arrivalday, int arrivalmonth, int arrivalyear, int departureday, int departuremonth, int departu Reyear) { 
 
 
 
Calendar calendar = new GregorianCalendar (); 
 
 
 
Calendar.set (Calendar.day_of_month, arrivalday); 
 
 
 
Calendar.set (Calendar.month, arrivalmonth); 
 
 
 
Calendar.set (Calendar.year, arrivalyear); 
 
 
 
Date arrivaldate = Calendar.gettime (); 
 
 
 
Calendar.set (Calendar.day_of_month, departureday); 
 
 
 
Calendar.set (Calendar.month, departuremonth); 
 
 
 
Calendar.set (Calendar.year, departureyear); 
 
 
 
Date departuredate = Calendar.gettime (); 
 
 
 
 
 
 
 
System.out.println (arrivaldate + "-" + departuredate); 
 
 
 
if (! Arrivaldate.before (departuredate)) { 
 
 
 
Seterrormessage ("The arrival date is not before the departure date"); 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
}else{ 
 
 
 
Seterrormessage (NULL); 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
((Reservationwizard) Getwizard ()). Data.arrivaldate = Arrivaldate; 
 
 
 
((Reservationwizard) Getwizard ()). Data.departuredate = Departuredate; 
 
 
 
} 
 
 
 
} 
 
 
 
} 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Java.util.Calendar; 
 
 
 
Import Java.util.Date; 
 
 
 
Import Java.util.GregorianCalendar; 
 
 
 
Import Org.eclipse.jface.wizard.WizardPage; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.layout.GridData; 
 
 
 
Import Org.eclipse.swt.layout.GridLayout; 
 
 
 
Import Org.eclipse.swt.layout.RowLayout; 
 
 
 
Import Org.eclipse.swt.widgets.Combo; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Label; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
public class FrontPage extends Wizardpage { 
 
 
 
 
 
 
 
Combo comboroomtypes; 
 
 
 
Combo comboarrivalyear; 
 
 
 
Combo Comboarrivalmonth; 
 
 
 
Combo Comboarrivalday; 
 
 
 
Combo combodepartureyear; 
 
 
 
Combo Combodeparturemonth; 
 
 
 
Combo Combodepartureday; 
 
 
 
 
 
 
 
FrontPage () { 
 
 
 
Super ("FrontPage"); 
 
 
 
Settitle ("Your Reservation Information"); 
 
 
 
SetDescription ("Select the type of room and your arrival date & departure date"); 
 
 
 
} 
 
 
 
public void CreateControl (composite parent) { 
 
 
 
 
 
 
 
Composite composite = new Composite (parent, SWT. NULL); 
 
 
 
GridLayout GridLayout = new GridLayout (2, false); 
 
 
 
Composite.setlayout (gridLayout); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Arrival date:"); 
 
 
 
Composite Compositearrival = new Composite (composite, SWT. NULL); 
 
 
 
Compositearrival.setlayout (New Rowlayout ()); 
 
 
 
months = new string[]{"string[", "Feb", "Mar", "APR", "may", "June", 
 
 
 
"June", "Aug", "Sep", "Oct", "Nov", "Dec" 
 
 
 
}; 
 
 
 
Calendar calendar = new GregorianCalendar (); 
 
 
 
((Reservationwizard) Getwizard ()). Data.arrivaldate = Calendar.gettime (); 
 
 
 
Comboarrivalmonth = new Combo (Compositearrival, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<months.length; i++) Comboarrivalmonth.add (months[i)); 
 
 
 
Comboarrivalmonth.select (Calendar.get (calendar.month)); 
 
 
 
Comboarrivalday = new Combo (Compositearrival, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<31; i++) Comboarrivalday.add ("" + (i+1)); 
 
 
 
Comboarrivalday.select (Calendar.get (Calendar.day_of_month)-1); 
 
 
 
Comboarrivalyear = new Combo (Compositearrival, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
for (int i=2004; i<2010; i++) Comboarrivalyear.add ("" + i); 
 
 
 
Comboarrivalyear.select (Calendar.get (Calendar.year)-2004); 
 
 
 
Calendar.add (calendar.date, 1); 
 
 
 
((Reservationwizard) Getwizard ()). Data.departuredate = Calendar.gettime (); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Departure date:"); 
 
 
 
Composite compositedeparture = new Composite (composite, SWT. NULL | Swt. READ_ONLY); 
 
 
 
Compositedeparture.setlayout (New Rowlayout ()); 
 
 
 
Combodeparturemonth = new Combo (Compositedeparture, SWT. NULL | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<months.length; i++) Combodeparturemonth.add (months[i)); 
 
 
 
Combodeparturemonth.select (Calendar.get (calendar.month)); 
 
 
 
Combodepartureday = new Combo (Compositedeparture, SWT. NULL | Swt. READ_ONLY); 
 
 
 
for (int i=0; i<31; i++) Combodepartureday.add ("" + (i+1)); 
 
 
 
Combodepartureday.select (Calendar.get (Calendar.day_of_month)-1); 
 
 
 
Combodepartureyear = new Combo (Compositedeparture, SWT. NULL | Swt. READ_ONLY); 
 
 
 
for (int i=2004; i<2010; i++) Combodepartureyear.add ("" + i); 
 
 
 
Combodepartureyear.select (Calendar.get (Calendar.year)-2004); 
 
 
 
Label line = new label (composite, SWT. SEPARATOR | Swt. horizontal); 
 
 
 
Griddata griddata = new Griddata (griddata.fill_horizontal); 
 
 
 
Griddata.horizontalspan = 2; 
 
 
 
Line.setlayoutdata (Griddata); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Room type:"); 
 
 
 
Comboroomtypes = new Combo (composite, SWT. BORDER | Swt. READ_ONLY); 
 
 
 
Comboroomtypes.add ("Standard Room (Rate: $198)"); 
 
 
 
Comboroomtypes.add ("Deluxe Room (Rate: $298)"); 
 
 
 
Comboroomtypes.select (0); 
 
 
 
Listener Selectionlistener = new Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
int arrivalday = Comboarrivalday.getselectionindex () + 1; 
 
 
 
int arrivalmonth = Comboarrivalmonth.getselectionindex (); 
 
 
 
int arrivalyear = Comboarrivalyear.getselectionindex () + 2004; 
 
 
 
int departureday = Combodepartureday.getselectionindex () + 1; 
 
 
 
int departuremonth = Combodeparturemonth.getselectionindex (); 
 
 
 
int departureyear = Combodepartureyear.getselectionindex () + 2004; 
 
 
 
Setdates (Arrivalday, Arrivalmonth, Arrivalyear, Departureday, Departuremonth, departureyear); 
 
 
 
} 
 
 
 
}; 
 
 
 
 
 
 
 
Comboarrivalday.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Comboarrivalmonth.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Comboarrivalyear.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Combodepartureday.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Combodeparturemonth.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Combodepartureyear.addlistener (SWT. Selection, Selectionlistener); 
 
 
 
Comboroomtypes.addlistener (SWT. Selection, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.roomtype = Comboroomtypes.getselectionindex (); 
 
 
 
} 
 
 
 
}); 
 
 
 
Setcontrol (composite); 
 
 
 
} 
 
 
 
 
 
 
 
private void setdates (int arrivalday, int arrivalmonth, int arrivalyear, int departureday, int departuremonth, int departu Reyear) { 
 
 
 
Calendar calendar = new GregorianCalendar (); 
 
 
 
Calendar.set (Calendar.day_of_month, arrivalday); 
 
 
 
Calendar.set (Calendar.month, arrivalmonth); 
 
 
 
Calendar.set (Calendar.year, arrivalyear); 
 
 
 
Date arrivaldate = Calendar.gettime (); 
 
 
 
Calendar.set (Calendar.day_of_month, departureday); 
 
 
 
Calendar.set (Calendar.month, departuremonth); 
 
 
 
Calendar.set (Calendar.year, departureyear); 
 
 
 
Date departuredate = Calendar.gettime (); 
 
 
 
 
 
 
 
System.out.println (arrivaldate + "-" + departuredate); 
 
 
 
if (! Arrivaldate.before (departuredate)) { 
 
 
 
Seterrormessage ("The arrival date is not before the departure date"); 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
}else{ 
 
 
 
Seterrormessage (NULL); 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
((Reservationwizard) Getwizard ()). Data.arrivaldate = Arrivaldate; 
 
 
 
((Reservationwizard) Getwizard ()). Data.departuredate = Departuredate; 
 
 
 
} 
 
 
 
} 
 
 
 
} 
 
 
 
 
 
 
Paymentinfopage.java 
 
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Org.eclipse.jface.wizard.WizardPage; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.layout.GridData; 
 
 
 
Import Org.eclipse.swt.layout.GridLayout; 
 
 
 
Import Org.eclipse.swt.widgets.Combo; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Label; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
Import Org.eclipse.swt.widgets.Text; 
 
 
 
public class Paymentinfopage extends Wizardpage { 
 
 
 
 
 
 
 
Combo combocreditcardtypes; 
 
 
 
Text Textcreditcardnumber; 
 
 
 
Text textcreditcardexpiration; 
 
 
 
 
 
 
 
Public Paymentinfopage () { 
 
 
 
Super ("Paymentinfo"); 
 
 
 
Settitle ("Payment information"); 
 
 
 
SetDescription ("Please enter the Your card details"); 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
public void CreateControl (composite parent) { 
 
 
 
 
 
 
 
Composite composite = new Composite (parent, SWT. NULL); 
 
 
 
Composite.setlayout (New GridLayout (2, false)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Credit card type:"); 
 
 
 
Combocreditcardtypes = new Combo (composite, SWT. Read_Only | Swt. BORDER); 
 
 
 
Combocreditcardtypes.add ("American Express"); 
 
 
 
Combocreditcardtypes.add ("Master card"); 
 
 
 
Combocreditcardtypes.add ("Visa"); 
 
 
 
Combocreditcardtypes.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Credit card number:"); 
 
 
 
Textcreditcardnumber = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textcreditcardnumber.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Expiration (MM/YY)"); 
 
 
 
Textcreditcardexpiration = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textcreditcardexpiration.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
Combocreditcardtypes.addlistener (SWT. Selection, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardtype = Combocreditcardtypes.getselectionindex (); 
 
 
 
if (((Reservationwizard) Getwizard ()). Data.creditcardnumber!= NULL && 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration!= null) 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
Else 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
}); 
 
 
 
 
 
 
 
Textcreditcardnumber.addlistener (SWT. Modify, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardnumber = Textcreditcardnumber.gettext (); 
 
 
 
if (((Reservationwizard) Getwizard ()). Data.creditcardnumber!= NULL && 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration!= null) 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
Else 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
}); 
 
 
 
 
 
 
 
Textcreditcardexpiration.addlistener (SWT. Modify, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
String text = Textcreditcardexpiration.gettext (). Trim (); 
 
 
 
if (text.length () = = 5 && text.charat (2) = = '/') { 
 
 
 
((Reservationwizard) Getwizard ()). data.creditcardexpiration = text; 
 
 
 
Seterrormessage (NULL); 
 
 
 
}else{ 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration = null; 
 
 
 
Seterrormessage ("Invalid Expiration Date:" + text); 
 
 
 
} 
 
 
 
 
 
 
 
if (((Reservationwizard) Getwizard ()). Data.creditcardnumber!= NULL && 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration!= null) 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
Else 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
}); 
 
 
 
Setcontrol (composite); 
 
 
 
} 
 
 
 
} 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import Org.eclipse.jface.wizard.WizardPage; 
 
 
 
Import Org.eclipse.swt.SWT; 
 
 
 
Import Org.eclipse.swt.layout.GridData; 
 
 
 
Import Org.eclipse.swt.layout.GridLayout; 
 
 
 
Import Org.eclipse.swt.widgets.Combo; 
 
 
 
Import Org.eclipse.swt.widgets.Composite; 
 
 
 
Import org.eclipse.swt.widgets.Event; 
 
 
 
Import Org.eclipse.swt.widgets.Label; 
 
 
 
Import Org.eclipse.swt.widgets.Listener; 
 
 
 
Import Org.eclipse.swt.widgets.Text; 
 
 
 
public class Paymentinfopage extends Wizardpage { 
 
 
 
 
 
 
 
Combo combocreditcardtypes; 
 
 
 
Text Textcreditcardnumber; 
 
 
 
Text textcreditcardexpiration; 
 
 
 
 
 
 
 
Public Paymentinfopage () { 
 
 
 
Super ("Paymentinfo"); 
 
 
 
Settitle ("Payment information"); 
 
 
 
SetDescription ("Please enter the Your card details"); 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
public void CreateControl (composite parent) { 
 
 
 
 
 
 
 
Composite composite = new Composite (parent, SWT. NULL); 
 
 
 
Composite.setlayout (New GridLayout (2, false)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Credit card type:"); 
 
 
 
Combocreditcardtypes = new Combo (composite, SWT. Read_Only | Swt. BORDER); 
 
 
 
Combocreditcardtypes.add ("American Express"); 
 
 
 
Combocreditcardtypes.add ("Master card"); 
 
 
 
Combocreditcardtypes.add ("Visa"); 
 
 
 
Combocreditcardtypes.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Credit card number:"); 
 
 
 
Textcreditcardnumber = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textcreditcardnumber.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
New Label (composite, SWT. NULL). SetText ("Expiration (MM/YY)"); 
 
 
 
Textcreditcardexpiration = new Text (composite, SWT. Single | Swt. BORDER); 
 
 
 
Textcreditcardexpiration.setlayoutdata (New Griddata (griddata.fill_horizontal)); 
 
 
 
Combocreditcardtypes.addlistener (SWT. Selection, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardtype = Combocreditcardtypes.getselectionindex (); 
 
 
 
if (((Reservationwizard) Getwizard ()). Data.creditcardnumber!= NULL && 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration!= null) 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
Else 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
}); 
 
 
 
 
 
 
 
Textcreditcardnumber.addlistener (SWT. Modify, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardnumber = Textcreditcardnumber.gettext (); 
 
 
 
if (((Reservationwizard) Getwizard ()). Data.creditcardnumber!= NULL && 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration!= null) 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
Else 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
}); 
 
 
 
 
 
 
 
Textcreditcardexpiration.addlistener (SWT. Modify, New Listener () { 
 
 
 
public void Handleevent (event event) { 
 
 
 
String text = Textcreditcardexpiration.gettext (). Trim (); 
 
 
 
if (text.length () = = 5 && text.charat (2) = = '/') { 
 
 
 
((Reservationwizard) Getwizard ()). data.creditcardexpiration = text; 
 
 
 
Seterrormessage (NULL); 
 
 
 
}else{ 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration = null; 
 
 
 
Seterrormessage ("Invalid Expiration Date:" + text); 
 
 
 
} 
 
 
 
 
 
 
 
if (((Reservationwizard) Getwizard ()). Data.creditcardnumber!= NULL && 
 
 
 
((Reservationwizard) Getwizard ()). Data.creditcardexpiration!= null) 
 
 
 
Setpagecomplete (TRUE); 
 
 
 
Else 
 
 
 
Setpagecomplete (FALSE); 
 
 
 
} 
 
 
 
}); 
 
 
 
Setcontrol (composite); 
 
 
 
} 
 
 
 
} 
 
 
 
 
 
 
Reservationwizard.java 
 
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import java.io.IOException; 
 
 
 
Import java.lang.reflect.InvocationTargetException; 
 
 
 
Import Java.util.Date; 
 
 
 
Import Org.eclipse.core.runtime.IProgressMonitor; 
 
 
 
Import org.eclipse.jface.dialogs.DialogSettings; 
 
 
 
Import Org.eclipse.jface.dialogs.MessageDialog; 
 
 
 
Import org.eclipse.jface.operation.IRunnableWithProgress; 
 
 
 
Import Org.eclipse.jface.resource.ImageDescriptor; 
 
 
 
Import Org.eclipse.jface.wizard.Wizard; 
 
 
 
Class Reservationdata { 
 
 
 
 
 
 
 
Date arrivaldate; 
 
 
 
Date departuredate; 
 
 
 
int roomtype; 
 
 
 
String CustomerName; 
 
 
 
String Customerphone; 
 
 
 
String Customeremail; 
 
 
 
String customeraddress; 
 
 
 
int creditcardtype; 
 
 
 
String Creditcardnumber; 
 
 
 
String creditcardexpiration; 
 
 
 
 
 
 
 
Public String toString () { 
 
 
 
StringBuffer sb = new StringBuffer (); 
 
 
 
Sb.append ("* HOTEL ROOM reservation DETAILS *\n"); 
 
 
 
Sb.append ("Arrival date:\t" + arrivaldate.tostring () + "\ n"); 
 
 
 
Sb.append ("departure date:\t" + departuredate.tostring () + "\ n"); 
 
 
 
Sb.append ("Room type:\t" + roomtype + "\ n"); 
 
 
 
Sb.append ("Customer name:\t" + customerName + "\ n"); 
 
 
 
Sb.append ("Customer email:\t" + customeremail + "\ n"); 
 
 
 
Sb.append ("Credit card no.:\ T "+ Creditcardnumber +" \ n "); 
 
 
 
 
 
 
 
return sb.tostring (); 
 
 
 
} 
 
 
 
} 
 
 
 
public class Reservationwizard extends Wizard { 
 
 
 
 
 
 
 
Static final String dialog_setting_file = "C:/userinfo.xml"; 
 
 
 
 
 
 
 
Static final String key_customer_name = "Customer-name"; 
 
 
 
Static final String Key_customer_email = "Customer-email"; 
 
 
 
Static final String Key_customer_phone = "Customer-phone"; 
 
 
 
Static final String key_customer_address = "customer-address"; 
 
 
 
 
 
 
 
Reservationdata data = new Reservationdata (); 
 
 
 
 
 
 
 
Public Reservationwizard () { 
 
 
 
Setwindowtitle ("Hotel Room Reservation Wizard"); 
 
 
 
Setneedsprogressmonitor (TRUE); 
 
 
 
Setdefaultpageimagedescriptor (Imagedescriptor.createfromfile (null, "C:/icons/hotel.gif")); 
 
 
 
Dialogsettings dialogsettings = new Dialogsettings ("UserInfo"); 
 
 
 
try { 
 
 
 
Dialogsettings.load (Dialog_setting_file); 
 
 
 
catch (IOException e) { 
 
 
 
E.printstacktrace (); 
 
 
 
} 
 
 
 
Setdialogsettings (dialogsettings); 
 
 
 
} 
 
 
 
public void Addpages () { 
 
 
 
AddPage (New FrontPage ()); 
 
 
 
AddPage (New Customerinfopage ()); 
 
 
 
AddPage (New Paymentinfopage ()); 
 
 
 
} 
 
 
 
public Boolean performfinish () { 
 
 
 
if (getdialogsettings ()!= null) { 
 
 
 
Getdialogsettings (). Put (Key_customer_name, data.customername); 
 
 
 
Getdialogsettings (). Put (Key_customer_phone, data.customerphone); 
 
 
 
Getdialogsettings (). Put (Key_customer_email, data.customeremail); 
 
 
 
Getdialogsettings (). Put (key_customer_address, data.customeraddress); 
 
 
 
try { 
 
 
 
Getdialogsettings (). Save (Dialog_setting_file); 
 
 
 
catch (IOException E1) { 
 
 
 
E1.printstacktrace (); 
 
 
 
} 
 
 
 
} 
 
 
 
try { 
 
 
 
GetContainer (). Run (True, True, new Irunnablewithprogress () { 
 
 
 
public void run (Iprogressmonitor monitor) 
 
 
 
Throws InvocationTargetException, Interruptedexception { 
 
 
 
Monitor.begintask ("Store data", 100); 
 
 
 
Monitor.worked (40); 
 
 
 
 
 
 
 
SYSTEM.OUT.PRINTLN (data); 
 
 
 
Thread.Sleep (2000); 
 
 
 
Monitor.done (); 
 
 
 
} 
 
 
 
}); 
 
 
 
catch (InvocationTargetException e) { 
 
 
 
E.printstacktrace (); 
 
 
 
catch (Interruptedexception e) { 
 
 
 
E.printstacktrace (); 
 
 
 
} 
 
 
 
return true; 
 
 
 
} 
 
 
 
public Boolean performcancel () { 
 
 
 
Boolean ans = messagedialog.openconfirm (Getshell (), "confirmation", "Are you sure to cancel the task?"); 
 
 
 
if (ans) 
 
 
 
return true; 
 
 
 
Else 
 
 
 
return false; 
 
 
 
} 
 
 
 
} 
 
 
 
Package swt_jface.demo12; 
 
 
 
Import java.io.IOException; 
 
 
 
Import java.lang.reflect.InvocationTargetException; 
 
 
 
Import Java.util.Date; 
 
 
 
Import Org.eclipse.core.runtime.IProgressMonitor; 
 
 
 
Import org.eclipse.jface.dialogs.DialogSettings; 
 
 
 
Import Org.eclipse.jface.dialogs.MessageDialog; 
 
 
 
Import org.eclipse.jface.operation.IRunnableWithProgress; 
 
 
 
Import Org.eclipse.jface.resource.ImageDescriptor; 
 
 
 
Import Org.eclipse.jface.wizard.Wizard; 
 
 
 
Class Reservationdata { 
 
 
 
 
 
 
 
Date arrivaldate; 
 
 
 
Date departuredate; 
 
 
 
int roomtype; 
 
 
 
String CustomerName; 
 
 
 
String Customerphone; 
 
 
 
String Customeremail; 
 
 
 
String customeraddress; 
 
 
 
int creditcardtype; 
 
 
 
String Creditcardnumber; 
 
 
 
String creditcardexpiration; 
 
 
 
 
 
 
 
Public String toString () { 
 
 
 
StringBuffer sb = new StringBuffer (); 
 
 
 
Sb.append ("* HOTEL ROOM reservation DETAILS *\n"); 
 
 
 
Sb.append ("Arrival date:\t" + arrivaldate.tostring () + "\ n"); 
 
 
 
Sb.append ("departure date:\t" + departuredate.tostring () + "\ n"); 
 
 
 
Sb.append ("Room type:\t" + roomtype + "\ n"); 
 
 
 
Sb.append ("Customer name:\t" + customerName + "\ n"); 
 
 
 
Sb.append ("Customer email:\t" + customeremail + "\ n"); 
 
 
 
Sb.append ("Credit card no.:\ T "+ Creditcardnumber +" \ n "); 
 
 
 
 
 
 
 
return sb.tostring (); 
 
 
 
} 
 
 
 
} 
 
 
 
public class Reservationwizard extends Wizard { 
 
 
 
 
 
 
 
Static final String dialog_setting_file = "C:/userinfo.xml"; 
 
 
 
 
 
 
 
Static final String key_customer_name = "Customer-name"; 
 
 
 
Static final String Key_customer_email = "Customer-email"; 
 
 
 
Static final String Key_customer_phone = "Customer-phone"; 
 
 
 
Static final String key_customer_address = "customer-address"; 
 
 
 
 
 
 
 
Reservationdata data = new Reservationdata (); 
 
 
 
 
 
 
 
Public Reservationwizard () { 
 
 
 
Setwindowtitle ("Hotel Room Reservation Wizard"); 
 
 
 
Setneedsprogressmonitor (TRUE); 
 
 
 
Setdefaultpageimagedescriptor (Imagedescriptor.createfromfile (null, "C:/icons/hotel.gif")); 
 
 
 
Dialogsettings dialogsettings = new Dialogsettings ("UserInfo"); 
 
 
 
try { 
 
 
 
Dialogsettings.load (Dialog_setting_file); 
 
 
 
catch (IOException e) { 
 
 
 
E.printstacktrace (); 
 
 
 
} 
 
 
 
Setdialogsettings (dialogsettings); 
 
 
 
} 
 
 
 
public void Addpages () { 
 
 
 
AddPage (New FrontPage ()); 
 
 
 
AddPage (New Customerinfopage ()); 
 
 
 
AddPage (New Paymentinfopage ()); 
 
 
 
} 
 
 
 
public Boolean performfinish () { 
 
 
 
if (getdialogsettings ()!= null) { 
 
 
 
Getdialogsettings (). Put (Key_customer_name, data.customername); 
 
 
 
Getdialogsettings (). Put (Key_customer_phone, data.customerphone); 
 
 
 
Getdialogsettings (). Put (Key_customer_email, data.customeremail); 
 
 
 
Getdialogsettings (). Put (key_customer_address, data.customeraddress); 
 
 
 
try { 
 
 
 
Getdialogsettings (). Save (Dialog_setting_file); 
 
 
 
catch (IOException E1) { 
 
 
 
E1.printstacktrace (); 
 
 
 
} 
 
 
 
} 
 
 
 
try { 
 
 
 
GetContainer (). Run (True, True, new Irunnablewithprogress () { 
 
 
 
public void run (Iprogressmonitor monitor) 
 
 
 
Throws InvocationTargetException, Interruptedexception { 
 
 
 
Monitor.begintask ("Store data", 100); 
 
 
 
Monitor.worked (40); 
 
 
 
 
 
 
 
SYSTEM.OUT.PRINTLN (data); 
 
 
 
Thread.Sleep (2000); 
 
 
 
Monitor.done (); 
 
 
 
} 
 
 
 
}); 
 
 
 
catch (InvocationTargetException e) { 
 
 
 
E.printstacktrace (); 
 
 
 
catch (Interruptedexception e) { 
 
 
 
E.printstacktrace (); 
 
 
 
} 
 
 
 
return true; 
 
 
 
} 
 
 
 
public Boolean performcancel () { 
 
 
 
Boolean ans = messagedialog.openconfirm (Getshell (), "confirmation", "Are you sure to cancel the task?"); 
 
 
 
if (ans) 
 
 
 
return true; 
 
 
 
Else 
 
 
 
return false; 
 
 
 
} 
 
 
 
} 
 
 
 
 
 
 
Userinfo.xml 
 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
<?xml version= "1.0" encoding= "UTF-8"?> 
  
<section name= "UserInfo" > 
  
<item value= "O ' sei early 
  
"key=" customer-address "/> 
  
<item value= "123" key= "Customer-phone"/> 
  
<item value= "123" key= "Customer-name"/> 
  
<item value= "123@sina.com" key= "Customer-email"/> 
  
</section>