use of com.faforever.client.util.TimeService in project downlords-faf-client by FAForever.
the class CoopController method initialize.
public void initialize() {
missionComboBox.setCellFactory(param -> missionListCell());
missionComboBox.setButtonCell(missionListCell());
missionComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> setSelectedMission(newValue));
playButton.disableProperty().bind(titleTextField.textProperty().isEmpty());
numberOfPlayersComboBox.setButtonCell(numberOfPlayersCell());
numberOfPlayersComboBox.setCellFactory(param -> numberOfPlayersCell());
numberOfPlayersComboBox.getSelectionModel().select(2);
numberOfPlayersComboBox.getSelectionModel().selectedItemProperty().addListener(observable -> loadLeaderboard());
// TODO don't use API object but bean instead
rankColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getRanking()));
rankColumn.setCellFactory(param -> new StringCell<>(String::valueOf));
playerCountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getPlayerCount()));
playerCountColumn.setCellFactory(param -> new StringCell<>(String::valueOf));
playerNamesColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPlayerNames()));
playerNamesColumn.setCellFactory(param -> new StringCell<>(String::valueOf));
secondaryObjectivesColumn.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue().isSecondaryObjectives()));
secondaryObjectivesColumn.setCellFactory(param -> new StringCell<>(aBoolean -> aBoolean ? i18n.get("yes") : i18n.get("no")));
timeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDuration()));
timeColumn.setCellFactory(param -> new StringCell<>(timeService::shortDuration));
replayColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getId()));
replayColumn.setCellFactory(param -> new NodeTableCell<>((replayId) -> {
ReplayButtonController button = uiService.loadFxml("theme/play/coop/replay_button.fxml");
button.setReplayId(replayId);
button.setOnClickedAction(this::onReplayButtonClicked);
return button.getRoot();
}));
webViewConfigurer.configureWebView(descriptionWebView);
ObservableList<Game> games = gameService.getGames();
FilteredList<Game> filteredItems = new FilteredList<>(games);
filteredItems.setPredicate(OPEN_COOP_GAMES_PREDICATE);
GamesTableController gamesTableController = uiService.loadFxml("theme/play/games_table.fxml");
gamesTableController.initializeGameTable(filteredItems);
Node root = gamesTableController.getRoot();
populateContainer(root);
coopService.getMissions().thenAccept(coopMaps -> {
Platform.runLater(() -> missionComboBox.setItems(observableList(coopMaps)));
SingleSelectionModel<CoopMission> selectionModel = missionComboBox.getSelectionModel();
if (selectionModel.isEmpty()) {
Platform.runLater(selectionModel::selectFirst);
}
}).exceptionally(throwable -> {
notificationService.addPersistentErrorNotification(throwable, "coop.couldNotLoad", throwable.getLocalizedMessage());
return null;
});
}
Aggregations