Search in sources :

Example 1 with PersistentNotification

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)))))));
    }
}
Also used : Arrays(java.util.Arrays) RehostRequestEvent(com.faforever.client.fa.relay.event.RehostRequestEvent) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) LoggerFactory(org.slf4j.LoggerFactory) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) ReportingService(com.faforever.client.reporting.ReportingService) ConnectionState(com.faforever.client.net.ConnectionState) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Collections.singletonList(java.util.Collections.singletonList) ListChangeListener(javafx.collections.ListChangeListener) Map(java.util.Map) GameStatus(com.faforever.client.remote.domain.GameStatus) URI(java.net.URI) PlayerService(com.faforever.client.player.PlayerService) Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) CancellationException(java.util.concurrent.CancellationException) MethodHandles(java.lang.invoke.MethodHandles) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ObservableMap(javafx.collections.ObservableMap) Observable(javafx.beans.Observable) DismissAction(com.faforever.client.notification.DismissAction) FeaturedMod(com.faforever.client.mod.FeaturedMod) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) Nullable(org.jetbrains.annotations.Nullable) RatingMode(com.faforever.client.fa.RatingMode) BooleanProperty(javafx.beans.property.BooleanProperty) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ForgedAllianceService(com.faforever.client.fa.ForgedAllianceService) PostConstruct(javax.annotation.PostConstruct) ModService(com.faforever.client.mod.ModService) Lazy(org.springframework.context.annotation.Lazy) ObservableList(javafx.collections.ObservableList) NotNull(org.jetbrains.annotations.NotNull) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) LoginMessage(com.faforever.client.remote.domain.LoginMessage) FXCollections(javafx.collections.FXCollections) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) IceAdapter(com.faforever.client.fa.relay.ice.IceAdapter) PlatformService(com.faforever.client.fx.PlatformService) GameUpdater(com.faforever.client.patch.GameUpdater) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) HashSet(java.util.HashSet) NotificationService(com.faforever.client.notification.NotificationService) Service(org.springframework.stereotype.Service) ERROR(com.faforever.client.notification.Severity.ERROR) Subscribe(com.google.common.eventbus.Subscribe) ReportAction(com.faforever.client.notification.ReportAction) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Executor(java.util.concurrent.Executor) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Action(com.faforever.client.notification.Action) ReplayService(com.faforever.client.replay.ReplayService) IOException(java.io.IOException) MatchmakerMessage(com.faforever.client.rankedmatch.MatchmakerMessage) PersistentNotification(com.faforever.client.notification.PersistentNotification) FafService(com.faforever.client.remote.FafService) Consumer(java.util.function.Consumer) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Severity(com.faforever.client.notification.Severity) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LADDER_1V1(com.faforever.client.game.KnownFeaturedMod.LADDER_1V1) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) NONE(com.faforever.client.fa.RatingMode.NONE) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) Collections(java.util.Collections) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Example 2 with PersistentNotification

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));
    }
}
Also used : Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification) MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) Component(org.springframework.stereotype.Component) List(java.util.List) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) PostConstruct(javax.annotation.PostConstruct) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) Collections(java.util.Collections) Action(com.faforever.client.notification.Action) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) PersistentNotification(com.faforever.client.notification.PersistentNotification) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with PersistentNotification

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);
}
Also used : Severity(com.faforever.client.notification.Severity) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Example 4 with PersistentNotification

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)))));
}
Also used : Path(java.nio.file.Path) GameService(com.faforever.client.game.GameService) SneakyThrows(lombok.SneakyThrows) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) Collections.singletonList(java.util.Collections.singletonList) DirectoryStream(java.nio.file.DirectoryStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) URI(java.net.URI) Splitter(com.google.common.base.Splitter) Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) URIBuilder(org.apache.http.client.utils.URIBuilder) UrlEscapers(com.google.common.net.UrlEscapers) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) Set(java.util.Set) Files.createDirectories(java.nio.file.Files.createDirectories) DismissAction(com.faforever.client.notification.DismissAction) Collectors(java.util.stream.Collectors) Bytes(com.google.common.primitives.Bytes) FeaturedMod(com.faforever.client.mod.FeaturedMod) List(java.util.List) Optional(java.util.Optional) ModService(com.faforever.client.mod.ModService) Lazy(org.springframework.context.annotation.Lazy) TaskService(com.faforever.client.task.TaskService) PreferencesService(com.faforever.client.preferences.PreferencesService) Files.move(java.nio.file.Files.move) GameOption(com.faforever.client.replay.Replay.GameOption) CompletableFuture(java.util.concurrent.CompletableFuture) ChatMessage(com.faforever.client.replay.Replay.ChatMessage) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) PlatformService(com.faforever.client.fx.PlatformService) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) Service(org.springframework.stereotype.Service) WARN(com.faforever.client.notification.Severity.WARN) ReplayData(com.faforever.commons.replay.ReplayData) SortConfig(com.faforever.client.vault.search.SearchController.SortConfig) ReportAction(com.faforever.client.notification.ReportAction) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Action(com.faforever.client.notification.Action) IOException(java.io.IOException) ApplicationContext(org.springframework.context.ApplicationContext) PersistentNotification(com.faforever.client.notification.PersistentNotification) URLDecoder.decode(java.net.URLDecoder.decode) FafService(com.faforever.client.remote.FafService) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) Game(com.faforever.client.game.Game) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Example 5 with PersistentNotification

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;
    });
}
Also used : LoadLocalReplaysTask(com.faforever.client.replay.LoadLocalReplaysTask) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Aggregations

PersistentNotification (com.faforever.client.notification.PersistentNotification)10 I18n (com.faforever.client.i18n.I18n)7 Action (com.faforever.client.notification.Action)7 NotificationService (com.faforever.client.notification.NotificationService)7 Severity (com.faforever.client.notification.Severity)7 Inject (javax.inject.Inject)7 Collections (java.util.Collections)5 Lazy (org.springframework.context.annotation.Lazy)5 EventBus (com.google.common.eventbus.EventBus)4 IOException (java.io.IOException)4 MethodHandles (java.lang.invoke.MethodHandles)4 Collections.singletonList (java.util.Collections.singletonList)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 ClientProperties (com.faforever.client.config.ClientProperties)3 PlatformService (com.faforever.client.fx.PlatformService)3 DismissAction (com.faforever.client.notification.DismissAction)3 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)3 ReportAction (com.faforever.client.notification.ReportAction)3