001package ca.bc.webarts.javaFX.wizard.survey; 002 003import javafx.beans.property.*; 004import javafx.beans.value.*; 005import javafx.collections.*; 006import javafx.event.*; 007import javafx.scene.*; 008import javafx.scene.control.*; 009import javafx.scene.layout.*; 010import javafx.stage.Stage; 011 012import ca.bc.webarts.javaFX.wizard.WizardPage; 013 014/** 015 * This class determines if the user has complaints. 016 * If not, it jumps to the last page of the wizard. 017 */ 018public class ComplaintsPage extends WizardPage 019{ 020 private RadioButton yes; 021 private RadioButton no; 022 private ToggleGroup options = new ToggleGroup(); 023 024 ComplaintsPage() 025 { 026 super("Complaints"); 027 028 nextButton.setDisable(true); 029 finishButton.setDisable(true); 030 yes.setToggleGroup(options); 031 no.setToggleGroup(options); 032 options.selectedToggleProperty().addListener(new ChangeListener<Toggle>() 033 { 034 @Override 035 public void changed(ObservableValue<? extends Toggle> observableValue, Toggle oldToggle, Toggle newToggle) 036 { 037 nextButton.setDisable(false); 038 finishButton.setDisable(false); 039 } 040 } 041 ); 042 } 043 044 @Override 045 public Parent getContent() 046 { 047 yes = new RadioButton("Yes"); 048 no = new RadioButton("No"); 049 ((Survey)getWizard()).surveyData_.hasComplaints.bind(yes.selectedProperty()); 050 return VBoxBuilder.create().spacing(5).children (new Label("Do you have complaints?"), yes, no).build(); 051 } 052 053 054 void nextPage() 055 { 056 // If they have complaints, go to the normal next page 057 if (options.getSelectedToggle().equals(yes)) 058 { 059 super.nextPage(); 060 } 061 else 062 { 063 // No complaints? Short-circuit the rest of the pages 064 navTo("Thanks"); 065 } 066 } 067}