use of com.faforever.client.notification.DismissAction in project downlords-faf-client by FAForever.
the class ReplayVaultController method loadLocalReplaysInBackground.
public CompletableFuture<Void> loadLocalReplaysInBackground() {
// TODO use replay service
LoadLocalReplaysTask task = applicationContext.getBean(LoadLocalReplaysTask.class);
replayVaultRoot.getItems().clear();
return taskService.submitTask(task).getFuture().thenAccept(this::addLocalReplays).exceptionally(throwable -> {
logger.warn("Error while loading local replays", throwable);
notificationService.addNotification(new PersistentNotification(i18n.get("replays.loadingLocalTask.failed"), Severity.ERROR, asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
return null;
});
}
use of com.faforever.client.notification.DismissAction in project downlords-faf-client by FAForever.
the class ReplayServiceImpl method runLiveReplay.
@Override
public void runLiveReplay(URI uri) {
logger.debug("Running replay from URL: {}", uri);
if (!uri.getScheme().equals(FAF_LIFE_PROTOCOL)) {
throw new IllegalArgumentException("Invalid protocol: " + uri.getScheme());
}
Map<String, String> queryParams = Splitter.on('&').trimResults().withKeyValueSeparator("=").split(uri.getQuery());
String gameType = queryParams.get("mod");
String mapName = noCatch(() -> decode(queryParams.get("map"), UTF_8.name()));
Integer gameId = Integer.parseInt(uri.getPath().split("/")[1]);
try {
URI replayUri = new URI(GPGNET_SCHEME, null, uri.getHost(), uri.getPort(), uri.getPath(), null, null);
gameService.runWithLiveReplay(replayUri, gameId, gameType, mapName).exceptionally(throwable -> {
notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("liveReplayCouldNotBeStarted"), Severity.ERROR, throwable, asList(new DismissAction(i18n), new ReportAction(i18n, reportingService, throwable))));
return null;
});
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
use of com.faforever.client.notification.DismissAction in project downlords-faf-client by FAForever.
the class JoinGameHelper method join.
public void join(Game game, String password, boolean ignoreRating) {
Player currentPlayer = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("Player has not been set"));
int playerRating = RatingUtil.getRoundedGlobalRating(currentPlayer);
if (!preferencesService.isGamePathValid()) {
CompletableFuture<Path> gameDirectoryFuture = new CompletableFuture<>();
eventBus.post(new GameDirectoryChooseEvent(gameDirectoryFuture));
gameDirectoryFuture.thenAccept(path -> Optional.ofNullable(path).ifPresent(path1 -> join(game, password, ignoreRating)));
return;
}
if (!ignoreRating && (playerRating < game.getMinRating() || playerRating > game.getMaxRating())) {
showRatingOutOfBoundsConfirmation(playerRating, game, password);
return;
}
if (game.getPasswordProtected() && password == null) {
EnterPasswordController enterPasswordController = uiService.loadFxml("theme/enter_password.fxml");
enterPasswordController.setOnPasswordEnteredListener(this::join);
enterPasswordController.setGame(game);
enterPasswordController.setIgnoreRating(ignoreRating);
enterPasswordController.showPasswordDialog(StageHolder.getStage());
} else {
gameService.joinGame(game, password).exceptionally(throwable -> {
logger.warn("Game could not be joined", throwable);
notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("games.couldNotJoin"), ERROR, throwable, asList(new DismissAction(i18n), new ReportAction(i18n, reportingService, throwable))));
return null;
});
}
}
use of com.faforever.client.notification.DismissAction in project downlords-faf-client by FAForever.
the class LeaderboardController method onDisplay.
@Override
public void onDisplay(NavigateEvent navigateEvent) {
Assert.checkNullIllegalState(ratingType, "ratingType must not be null");
contentPane.setVisible(false);
leaderboardService.getEntries(ratingType).thenAccept(leaderboardEntryBeans -> {
ratingTable.setItems(observableList(leaderboardEntryBeans));
contentPane.setVisible(true);
}).exceptionally(throwable -> {
contentPane.setVisible(false);
logger.warn("Error while loading leaderboard entries", throwable);
notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("leaderboard.failedToLoad"), Severity.ERROR, throwable, Arrays.asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
return null;
});
}
use of com.faforever.client.notification.DismissAction in project downlords-faf-client by FAForever.
the class AbstractChatTabController method sendMessage.
private void sendMessage() {
TextInputControl messageTextField = messageTextField();
messageTextField.setDisable(true);
final String text = messageTextField.getText();
chatService.sendMessageInBackground(receiver, text).thenAccept(message -> {
messageTextField.clear();
messageTextField.setDisable(false);
messageTextField.requestFocus();
}).exceptionally(throwable -> {
logger.warn("Message could not be sent: {}", text, throwable);
notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("chat.sendFailed"), Severity.ERROR, throwable, Arrays.asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
messageTextField.setDisable(false);
messageTextField.requestFocus();
return null;
});
}
Aggregations