use of utils.alerts.AlertWindow in project on-track by michaelplazek.
the class CentralTrafficControlController method connectTables.
private void connectTables() {
stopColumn.setCellValueFactory(new PropertyValueFactory<ScheduleRow, String>("stop"));
dwellColumn.setCellValueFactory(new PropertyValueFactory<ScheduleRow, String>("dwell"));
selectedDwellColumn.setCellValueFactory(new PropertyValueFactory<ScheduleRow, String>("dwell"));
selectedStopColumn.setCellValueFactory(new PropertyValueFactory<ScheduleRow, String>("stop"));
selectedTimeColumn.setCellValueFactory(new PropertyValueFactory<ScheduleRow, String>("time"));
trainColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("id"));
departureColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("departure"));
dispatchTrainColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("id"));
dispatchLocationColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("locationId"));
dispatchAuthorityColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("authority"));
dispatchSpeedColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("speed"));
dispatchPassengersColumn.setCellValueFactory(new PropertyValueFactory<TrainTracker, String>("passengers"));
// set dropdown menu for stations
stopColumn.setCellFactory(ComboBoxTableCell.forTableColumn(new DefaultStringConverter(), ctc.getStationList()));
stopColumn.setOnEditCommit((TableColumn.CellEditEvent<ScheduleRow, String> t) -> {
((ScheduleRow) t.getTableView().getItems().get(t.getTablePosition().getRow())).setStop(t.getNewValue());
});
dwellColumn.setCellFactory(TextFieldTableCell.<ScheduleRow>forTableColumn());
dwellColumn.setOnEditCommit((TableColumn.CellEditEvent<ScheduleRow, String> t) -> {
String input = t.getNewValue();
if (checkTimeFormat(input) || input.equals("")) {
((ScheduleRow) t.getTableView().getItems().get(t.getTablePosition().getRow())).setDwell(input);
} else {
AlertWindow alert = new AlertWindow();
alert.setTitle("Error Submitting");
alert.setHeader("Please Use Correct Format");
alert.setContent("Please enter the time in the following format: " + "XX:XX:XX");
alert.show();
}
});
addScheduleTable.setItems(FXCollections.observableArrayList(new ScheduleRow("", "", ""), new ScheduleRow("", "", ""), new ScheduleRow("", "", ""), new ScheduleRow("", "", ""), new ScheduleRow("", "", ""), new ScheduleRow("", "", "")));
}
use of utils.alerts.AlertWindow in project on-track by michaelplazek.
the class CentralTrafficControlController method addTrainToQueue.
private void addTrainToQueue() {
if (trackSelect.getSelectionModel().getSelectedItem().equals("Select track")) {
AlertWindow alert = new AlertWindow();
alert.setTitle("Error Submitting");
alert.setHeader("No Track Selected");
alert.setContent("Please select a track from the " + "Select Track dropdown menu before submitting.");
alert.show();
} else {
// get train stop info
List<String> stopData = new ArrayList<>();
for (ScheduleRow item : addScheduleTable.getItems()) {
stopData.add(stopColumn.getCellData(item));
}
// get train dwell info
List<String> dwellData = new ArrayList<>();
for (ScheduleRow item : addScheduleTable.getItems()) {
dwellData.add(dwellColumn.getCellObservableValue(item).getValue());
}
// get line
String line = trackSelect.getSelectionModel().getSelectedItem();
// create schedule
Schedule schedule = new Schedule(line);
for (int i = 0; i < addScheduleTable.getItems().size(); i++) {
schedule.addStop(new ScheduleRow(stopData.get(i), dwellData.get(i), ""));
}
String name = trainNameField.getText();
String departingTime = departingTimeField.getText();
if (!name.equals("") && departingTime.length() == 8) {
TrainTracker train = new TrainTracker(name, departingTime, line, schedule);
// set the track that is current set
train.setLine(ctc.getLine());
// create item in queue
trainQueueTable.setItems(ctc.getTrainQueueTable());
resetSchedule();
// create train
ctc.addTrain(train);
}
}
}
Aggregations