Search in sources :

Example 1 with UiService

use of com.faforever.client.theme.UiService 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);
}
Also used : GameService(com.faforever.client.game.GameService) UiService(com.faforever.client.theme.UiService) MapPreviewTableCell(com.faforever.client.game.MapPreviewTableCell) PreviewSize(com.faforever.client.map.MapServiceImpl.PreviewSize) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Bindings(javafx.beans.binding.Bindings) Scope(org.springframework.context.annotation.Scope) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) GameStatus(com.faforever.client.remote.domain.GameStatus) TableView(javafx.scene.control.TableView) SortedList(javafx.collections.transformation.SortedList) StringCell(com.faforever.client.fx.StringCell) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) AbstractViewController(com.faforever.client.fx.AbstractViewController) ObservableMap(javafx.collections.ObservableMap) Collectors(java.util.stream.Collectors) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) Platform(javafx.application.Platform) Component(org.springframework.stereotype.Component) List(java.util.List) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Entry(java.util.Map.Entry) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) NotNull(org.jetbrains.annotations.NotNull) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Image(javafx.scene.image.Image) Game(com.faforever.client.game.Game) NodeTableCell(com.faforever.client.fx.NodeTableCell) Joiner(com.google.common.base.Joiner) MapPreviewTableCell(com.faforever.client.game.MapPreviewTableCell) Game(com.faforever.client.game.Game) SortedList(javafx.collections.transformation.SortedList)

Example 2 with UiService

use of com.faforever.client.theme.UiService 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)));
}
Also used : PreferencesService(com.faforever.client.preferences.PreferencesService) Pos(javafx.geometry.Pos) UiService(com.faforever.client.theme.UiService) PreviewSize(com.faforever.client.map.MapServiceImpl.PreviewSize) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) HashMap(java.util.HashMap) Bindings(javafx.beans.binding.Bindings) Scope(org.springframework.context.annotation.Scope) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Map(java.util.Map) TableView(javafx.scene.control.TableView) SortedList(javafx.collections.transformation.SortedList) StringCell(com.faforever.client.fx.StringCell) ObjectProperty(javafx.beans.property.ObjectProperty) Pair(javafx.util.Pair) Label(javafx.scene.control.Label) Controller(com.faforever.client.fx.Controller) Node(javafx.scene.Node) TableRow(javafx.scene.control.TableRow) Observable(javafx.beans.Observable) Collectors(java.util.stream.Collectors) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) Platform(javafx.application.Platform) SortType(javafx.scene.control.TableColumn.SortType) Component(org.springframework.stereotype.Component) List(java.util.List) SortEvent(javafx.scene.control.SortEvent) RatingRange(com.faforever.client.remote.domain.RatingRange) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Entry(java.util.Map.Entry) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) NotNull(org.jetbrains.annotations.NotNull) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Image(javafx.scene.image.Image) Joiner(com.google.common.base.Joiner) RatingRange(com.faforever.client.remote.domain.RatingRange) SortedList(javafx.collections.transformation.SortedList) Label(javafx.scene.control.Label) Observable(javafx.beans.Observable)

Aggregations

StringCell (com.faforever.client.fx.StringCell)2 I18n (com.faforever.client.i18n.I18n)2 MapService (com.faforever.client.map.MapService)2 PreviewSize (com.faforever.client.map.MapServiceImpl.PreviewSize)2 UiService (com.faforever.client.theme.UiService)2 Joiner (com.google.common.base.Joiner)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Collectors (java.util.stream.Collectors)2 Platform (javafx.application.Platform)2 Bindings (javafx.beans.binding.Bindings)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)2 ObservableValue (javafx.beans.value.ObservableValue)2 ObservableList (javafx.collections.ObservableList)2 SortedList (javafx.collections.transformation.SortedList)2 Node (javafx.scene.Node)2 TableColumn (javafx.scene.control.TableColumn)2 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)2