use of com.faforever.client.notification.PersistentNotification in project downlords-faf-client by FAForever.
the class GameServiceImpl method onCurrentGameEnded.
private void onCurrentGameEnded() {
synchronized (currentGame) {
int currentGameId = currentGame.get().getId();
notificationService.addNotification(new PersistentNotification(i18n.get("game.ended", currentGame.get().getTitle()), Severity.INFO, singletonList(new Action(i18n.get("game.rate"), actionEvent -> replayService.findById(currentGameId).thenAccept(replay -> externalReplayInfoGenerator.showExternalReplayInfo(replay, String.valueOf(currentGameId)))))));
}
}
use of com.faforever.client.notification.PersistentNotification in project downlords-faf-client by FAForever.
the class MissingGamePathNotifier method onMissingGamePathEvent.
@Subscribe
public void onMissingGamePathEvent(MissingGamePathEvent event) {
List<Action> actions = Collections.singletonList(new Action(i18n.get("missingGamePath.locate"), chooseEvent -> eventBus.post(new GameDirectoryChooseEvent())));
String notificationText = i18n.get("missingGamePath.notification");
if (event.isImmediateUserActionRequired()) {
notificationService.addNotification(new ImmediateNotification(notificationText, notificationText, Severity.WARN, actions));
} else {
notificationService.addNotification(new PersistentNotification(notificationText, Severity.WARN, actions));
}
}
use of com.faforever.client.notification.PersistentNotification in project downlords-faf-client by FAForever.
the class MainController method updateNotificationsButton.
/**
* Updates the number displayed in the notifications button and sets its CSS pseudo class based on the highest
* notification {@code Severity} of all current notifications.
*/
private void updateNotificationsButton(Collection<? extends PersistentNotification> notifications) {
JavaFxUtil.assertApplicationThread();
int size = notifications.size();
notificationsBadge.setVisible(size != 0);
notificationsBadge.setText(i18n.number(size));
Severity highestSeverity = notifications.stream().map(PersistentNotification::getSeverity).max(Enum::compareTo).orElse(null);
notificationsBadge.pseudoClassStateChanged(NOTIFICATION_INFO_PSEUDO_CLASS, highestSeverity == Severity.INFO);
notificationsBadge.pseudoClassStateChanged(NOTIFICATION_WARN_PSEUDO_CLASS, highestSeverity == Severity.WARN);
notificationsBadge.pseudoClassStateChanged(NOTIFICATION_ERROR_PSEUDO_CLASS, highestSeverity == Severity.ERROR);
}
use of com.faforever.client.notification.PersistentNotification in project downlords-faf-client by FAForever.
the class ReplayServiceImpl method moveCorruptedReplayFile.
private void moveCorruptedReplayFile(Path replayFile) {
Path corruptedReplaysDirectory = preferencesService.getCorruptedReplaysDirectory();
noCatch(() -> createDirectories(corruptedReplaysDirectory));
Path target = corruptedReplaysDirectory.resolve(replayFile.getFileName());
logger.debug("Moving corrupted replay file from {} to {}", replayFile, target);
noCatch(() -> move(replayFile, target));
notificationService.addNotification(new PersistentNotification(i18n.get("corruptedReplayFiles.notification"), WARN, singletonList(new Action(i18n.get("corruptedReplayFiles.show"), event -> platformService.reveal(replayFile)))));
}
use of com.faforever.client.notification.PersistentNotification 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;
});
}
Aggregations