changes
This commit is contained in:
75
src/main/java/lodge/TestMainFxCommandDialog.java
Normal file
75
src/main/java/lodge/TestMainFxCommandDialog.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package lodge;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.util.Callback;
|
||||
import lodge.datamodel.Address;
|
||||
|
||||
public class TestMainFxCommandDialog extends Dialog<Address> {
|
||||
|
||||
@FXML
|
||||
private TextField tfStreet;
|
||||
@FXML
|
||||
private TextField tfCity;
|
||||
@FXML
|
||||
private TextField tfState;
|
||||
@FXML
|
||||
private TextField tfZip;
|
||||
|
||||
public TestMainFxCommandDialog() {
|
||||
super();
|
||||
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("dialogCommandAddress.fxml"));
|
||||
fxmlLoader.setController(this);
|
||||
try {
|
||||
fxmlLoader.load();
|
||||
} catch (IOException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
getDialogPane().setContent(fxmlLoader.getRoot());
|
||||
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
|
||||
setTitle("AccomodationAddress Dialog");
|
||||
setHeaderText("Enter Inventory Details");
|
||||
setPropertyBindings();
|
||||
setResultConverter();
|
||||
}
|
||||
|
||||
private void setPropertyBindings() {
|
||||
System.out.println("setPropertyBindings called.");
|
||||
}
|
||||
|
||||
private void setResultConverter() {
|
||||
System.out.println("setResultConverter called.");
|
||||
Callback<ButtonType, Address> aRC = (buttonType) -> {
|
||||
if (buttonType == ButtonType.OK) {
|
||||
if(getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty() || getZip().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new Address(getStreet(), getCity(), getState(), getZip());
|
||||
}
|
||||
return null;
|
||||
};
|
||||
setResultConverter(aRC);
|
||||
}
|
||||
|
||||
private String getZip() {
|
||||
return tfZip.getText();
|
||||
}
|
||||
|
||||
private String getState() {
|
||||
return tfState.getText();
|
||||
}
|
||||
|
||||
private String getCity() {
|
||||
return tfCity.getText();
|
||||
}
|
||||
|
||||
private String getStreet() {
|
||||
return tfStreet.getText();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user