use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.
the class ReplayVaultController method durationCellValueFactory.
@NotNull
private ObservableValue<Duration> durationCellValueFactory(TableColumn.CellDataFeatures<Replay, Duration> param) {
Replay replay = param.getValue();
Temporal startTime = replay.getStartTime();
Temporal endTime = replay.getEndTime();
if (startTime == null || endTime == null) {
return new SimpleObjectProperty<>(null);
}
return new SimpleObjectProperty<>(Duration.between(startTime, endTime));
}
use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.
the class ReplayVaultController method playersValueFactory.
private ObservableValue<String> playersValueFactory(TableColumn.CellDataFeatures<Replay, String> features) {
return new StringBinding() {
@Override
protected String computeValue() {
Replay replay = features.getValue();
ObservableMap<String, List<String>> teams = replay.getTeams();
if (teams.isEmpty()) {
return "";
}
ArrayList<String> teamsAsStrings = new ArrayList<>();
for (List<String> playerNames : teams.values()) {
Collections.sort(playerNames);
teamsAsStrings.add(Joiner.on(i18n.get("textSeparator")).join(playerNames));
}
return Joiner.on(i18n.get("vsSeparator")).join(teamsAsStrings);
}
};
}
use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.
the class AbstractChatTabControllerTest method start.
@Override
public void start(Stage stage) throws Exception {
super.start(stage);
preferences = new Preferences();
Clan clan = new Clan();
clan.setId("1234");
Vault vault = new Vault();
vault.setReplayDownloadUrlFormat(TEST_REPLAY_BASE_URL);
when(replayService.findById(any(Integer.class))).thenReturn(completedFuture(Optional.of(new Replay())));
when(clanService.getClanByTag(sampleClanTag)).thenReturn(completedFuture(Optional.of(clan)));
when(uiService.loadFxml("theme/chat/clan_tooltip.fxml")).thenReturn(mock(ClanTooltipController.class));
when(uiService.getThemeFileUrl(any())).thenReturn(getClass().getResource("/theme/chat/chat_section.html"));
when(timeService.asShortTime(any())).thenReturn("123");
when(userService.getUsername()).thenReturn("junit");
when(preferencesService.getPreferences()).thenReturn(preferences);
when(clientProperties.getVault()).thenReturn(vault);
instance = new AbstractChatTabController(clanService, webViewConfigurer, userService, chatService, platformService, preferencesService, playerService, audioService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator) {
private final Tab root = new Tab();
private final WebView webView = new WebView();
private final TextInputControl messageTextField = new TextField();
@Override
public Tab getRoot() {
return root;
}
@Override
protected TextInputControl messageTextField() {
return messageTextField;
}
@Override
protected WebView getMessagesWebView() {
return webView;
}
};
TabPane tabPane = new TabPane(instance.getRoot());
getRoot().getChildren().setAll(tabPane);
chatReadyLatch = new CountDownLatch(1);
instance.getMessagesWebView().getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
if (Worker.State.SUCCEEDED.equals(newValue)) {
chatReadyLatch.countDown();
}
});
instance.initialize();
}
use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.
the class ReplayVaultController method mapCellFactory.
private TableCell<Replay, MapBean> mapCellFactory(TableColumn<Replay, MapBean> column) {
MapPreviewTableCellController controller = uiService.loadFxml("theme/vault/map/map_preview_table_cell.fxml");
final ImageView imageView = controller.getRoot();
TableCell<Replay, MapBean> cell = new TableCell<Replay, MapBean>() {
@Override
protected void updateItem(MapBean map, boolean empty) {
super.updateItem(map, empty);
if (empty || map == null) {
setText(null);
setGraphic(null);
} else {
imageView.setImage(mapService.loadPreview(map.getFolderName(), PreviewSize.SMALL));
setGraphic(imageView);
setText(map.getDisplayName());
}
}
};
cell.setGraphic(imageView);
return cell;
}
Aggregations