use of com.faforever.client.fx.StringCell 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.StringCell 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);
}
use of com.faforever.client.fx.StringCell in project downlords-faf-client by FAForever.
the class GamesTableController method initializeGameTable.
public void initializeGameTable(ObservableList<Game> games) {
SortedList<Game> sortedList = new SortedList<>(games);
sortedList.comparatorProperty().bind(gamesTable.comparatorProperty());
gamesTable.setPlaceholder(new Label(i18n.get("games.noGamesAvailable")));
gamesTable.setRowFactory(param1 -> gamesRowFactory());
gamesTable.setItems(sortedList);
applyLastSorting(gamesTable);
gamesTable.setOnSort(this::onColumnSorted);
sortedList.addListener((Observable observable) -> selectFirstGame());
selectFirstGame();
passwordProtectionColumn.setCellValueFactory(param -> param.getValue().passwordProtectedProperty());
passwordProtectionColumn.setCellFactory(param -> passwordIndicatorColumn());
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 -> Bindings.createObjectBinding(() -> new PlayerFill(param.getValue().getNumPlayers(), param.getValue().getMaxPlayers()), param.getValue().numPlayersProperty(), param.getValue().maxPlayersProperty()));
playersColumn.setCellFactory(param -> playersCell());
ratingColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(new RatingRange(param.getValue().getMinRating(), param.getValue().getMaxRating())));
ratingColumn.setCellFactory(param -> ratingTableCell());
hostColumn.setCellValueFactory(param -> param.getValue().hostProperty());
hostColumn.setCellFactory(param -> new StringCell<>(String::toString));
modsColumn.setCellValueFactory(this::modCell);
modsColumn.setCellFactory(param -> new StringCell<>(String::toString));
gamesTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> selectedGame.set(newValue)));
}
use of com.faforever.client.fx.StringCell in project downlords-faf-client by FAForever.
the class LeaderboardController method initialize.
@Override
public void initialize() {
super.initialize();
rankColumn.setCellValueFactory(param -> param.getValue().rankProperty());
rankColumn.setCellFactory(param -> new StringCell<>(rank -> i18n.number(rank.intValue())));
nameColumn.setCellValueFactory(param -> param.getValue().usernameProperty());
nameColumn.setCellFactory(param -> new StringCell<>(name -> name));
winLossColumn.setCellValueFactory(param -> new SimpleFloatProperty(param.getValue().getWinLossRatio()));
winLossColumn.setCellFactory(param -> new StringCell<>(number -> i18n.get("percentage", number.floatValue() * 100)));
gamesPlayedColumn.setCellValueFactory(param -> param.getValue().gamesPlayedProperty());
gamesPlayedColumn.setCellFactory(param -> new StringCell<>(count -> i18n.number(count.intValue())));
ratingColumn.setCellValueFactory(param -> param.getValue().ratingProperty());
ratingColumn.setCellFactory(param -> new StringCell<>(rating -> i18n.number(rating.intValue())));
contentPane.managedProperty().bind(contentPane.visibleProperty());
connectionProgressPane.managedProperty().bind(connectionProgressPane.visibleProperty());
connectionProgressPane.visibleProperty().bind(contentPane.visibleProperty().not());
searchTextField.textProperty().addListener((observable, oldValue, newValue) -> {
if (Validator.isInt(newValue)) {
ratingTable.scrollTo(Integer.parseInt(newValue) - 1);
} else {
LeaderboardEntry foundPlayer = null;
for (LeaderboardEntry leaderboardEntry : ratingTable.getItems()) {
if (leaderboardEntry.getUsername().toLowerCase().startsWith(newValue.toLowerCase())) {
foundPlayer = leaderboardEntry;
break;
}
}
if (foundPlayer == null) {
for (LeaderboardEntry leaderboardEntry : ratingTable.getItems()) {
if (leaderboardEntry.getUsername().toLowerCase().contains(newValue.toLowerCase())) {
foundPlayer = leaderboardEntry;
break;
}
}
}
if (foundPlayer != null) {
ratingTable.scrollTo(foundPlayer);
ratingTable.getSelectionModel().select(foundPlayer);
} else {
ratingTable.getSelectionModel().select(null);
}
}
});
}
Aggregations