use of com.faforever.client.fx.NodeTableCell 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;
});
}
use of com.faforever.client.fx.NodeTableCell in project downlords-faf-client by FAForever.
the class LiveReplayController method initializeGameTable.
private void initializeGameTable(ObservableList<Game> games) {
SortedList<Game> sortedList = new SortedList<>(games);
sortedList.comparatorProperty().bind(liveReplayControllerRoot.comparatorProperty());
mapPreviewColumn.setCellFactory(param -> new MapPreviewTableCell(uiService));
mapPreviewColumn.setCellValueFactory(param -> Bindings.createObjectBinding(() -> mapService.loadPreview(param.getValue().getMapFolderName(), PreviewSize.SMALL), param.getValue().mapFolderNameProperty()));
gameTitleColumn.setCellValueFactory(param -> param.getValue().titleProperty());
gameTitleColumn.setCellFactory(param -> new StringCell<>(title -> title));
playersColumn.setCellValueFactory(param -> param.getValue().numPlayersProperty());
playersColumn.setCellFactory(param -> new StringCell<>(number -> i18n.number(number.intValue())));
hostColumn.setCellValueFactory(param -> param.getValue().hostProperty());
hostColumn.setCellFactory(param -> new StringCell<>(String::toString));
modsColumn.setCellValueFactory(this::modCell);
modsColumn.setCellFactory(param -> new StringCell<>(String::toString));
watchColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue()));
watchColumn.setCellFactory(param -> new NodeTableCell<>(this::watchReplayButton));
liveReplayControllerRoot.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> selectedGame.set(newValue)));
liveReplayControllerRoot.setItems(games);
}
Aggregations