Search in sources :

Example 16 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification 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;
        });
    }
}
Also used : Path(java.nio.file.Path) PreferencesService(com.faforever.client.preferences.PreferencesService) UiService(com.faforever.client.theme.UiService) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) ReportingService(com.faforever.client.reporting.ReportingService) Scope(org.springframework.context.annotation.Scope) EventBus(com.google.common.eventbus.EventBus) NotificationService(com.faforever.client.notification.NotificationService) Arrays.asList(java.util.Arrays.asList) ERROR(com.faforever.client.notification.Severity.ERROR) PlayerService(com.faforever.client.player.PlayerService) Path(java.nio.file.Path) ReportAction(com.faforever.client.notification.ReportAction) RatingUtil(com.faforever.client.util.RatingUtil) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) Action(com.faforever.client.notification.Action) DismissAction(com.faforever.client.notification.DismissAction) Player(com.faforever.client.player.Player) StageHolder(com.faforever.client.ui.StageHolder) Component(org.springframework.stereotype.Component) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) Optional(java.util.Optional) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) I18n(com.faforever.client.i18n.I18n) Player(com.faforever.client.player.Player) CompletableFuture(java.util.concurrent.CompletableFuture) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent)

Example 17 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class ModDetailController method onInstallButtonClicked.

public void onInstallButtonClicked() {
    installButton.setVisible(false);
    modService.downloadAndInstallMod(modVersion, progressBar.progressProperty(), progressLabel.textProperty()).thenRun(() -> uninstallButton.setVisible(true)).exceptionally(throwable -> {
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("modVault.installationFailed", modVersion.getDisplayName(), throwable.getLocalizedMessage()), Severity.ERROR, throwable, singletonList(new ReportAction(i18n, reportingService, throwable))));
        return null;
    });
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction)

Example 18 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class MapDetailController method onInstallButtonClicked.

public void onInstallButtonClicked() {
    installButton.setVisible(false);
    mapService.downloadAndInstallMap(map, progressBar.progressProperty(), progressLabel.textProperty()).thenRun(() -> setInstalled(true)).exceptionally(throwable -> {
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("mapVault.installationFailed", map.getDisplayName(), throwable.getLocalizedMessage()), Severity.ERROR, throwable, singletonList(new ReportAction(i18n, reportingService, throwable))));
        setInstalled(false);
        return null;
    });
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction)

Example 19 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification 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;
    });
}
Also used : Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) Scope(org.springframework.context.annotation.Scope) TableColumn(javafx.scene.control.TableColumn) NavigateEvent(com.faforever.client.main.event.NavigateEvent) Inject(javax.inject.Inject) FXCollections.observableList(javafx.collections.FXCollections.observableList) NotificationService(com.faforever.client.notification.NotificationService) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) TableView(javafx.scene.control.TableView) Pane(javafx.scene.layout.Pane) ReportAction(com.faforever.client.notification.ReportAction) SimpleFloatProperty(javafx.beans.property.SimpleFloatProperty) StringCell(com.faforever.client.fx.StringCell) TextField(javafx.scene.control.TextField) Logger(org.slf4j.Logger) Node(javafx.scene.Node) MethodHandles(java.lang.invoke.MethodHandles) AbstractViewController(com.faforever.client.fx.AbstractViewController) DismissAction(com.faforever.client.notification.DismissAction) Assert(com.faforever.client.util.Assert) Component(org.springframework.stereotype.Component) Severity(com.faforever.client.notification.Severity) Validator(com.faforever.client.util.Validator) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) I18n(com.faforever.client.i18n.I18n) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction)

Example 20 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification 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;
    });
}
Also used : TextInputControl(javafx.scene.control.TextInputControl) EventHandler(javafx.event.EventHandler) Arrays(java.util.Arrays) CHAT_TEXT(com.faforever.client.theme.UiService.CHAT_TEXT) UiService(com.faforever.client.theme.UiService) TextInputControl(javafx.scene.control.TextInputControl) PseudoClass(javafx.css.PseudoClass) URL(java.net.URL) ImageUploadService(com.faforever.client.uploader.ImageUploadService) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) StringUtils(org.apache.commons.lang3.StringUtils) CHAT_CONTAINER(com.faforever.client.theme.UiService.CHAT_CONTAINER) CASE_INSENSITIVE(java.util.regex.Pattern.CASE_INSENSITIVE) NavigateEvent(com.faforever.client.main.event.NavigateEvent) AudioService(com.faforever.client.audio.AudioService) TimeService(com.faforever.client.util.TimeService) TabPane(javafx.scene.control.TabPane) Matcher(java.util.regex.Matcher) CharStreams(com.google.common.io.CharStreams) MINUTES(java.time.temporal.ChronoUnit.MINUTES) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ITEM_AT_INDEX(javafx.scene.AccessibleAttribute.ITEM_AT_INDEX) ChatPrefs(com.faforever.client.preferences.ChatPrefs) SELF(com.faforever.client.chat.SocialStatus.SELF) PlayerService(com.faforever.client.player.PlayerService) HtmlEscapers.htmlEscaper(com.google.common.html.HtmlEscapers.htmlEscaper) ClientProperties(com.faforever.client.config.ClientProperties) JSObject(netscape.javascript.JSObject) RatingUtil.getLeaderboardRating(com.faforever.client.util.RatingUtil.getLeaderboardRating) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) KeyEvent(javafx.scene.input.KeyEvent) Reader(java.io.Reader) NavigationItem(com.faforever.client.main.event.NavigationItem) DismissAction(com.faforever.client.notification.DismissAction) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) StageHolder(com.faforever.client.ui.StageHolder) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) FRIEND(com.faforever.client.chat.SocialStatus.FRIEND) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner) CHAT_ENTRY(com.faforever.client.theme.UiService.CHAT_ENTRY) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) Worker(javafx.concurrent.Worker) RatingUtil.getGlobalRating(com.faforever.client.util.RatingUtil.getGlobalRating) WebEngine(javafx.scene.web.WebEngine) AnchorLocation(javafx.stage.PopupWindow.AnchorLocation) MouseEvent(javafx.scene.input.MouseEvent) ClassPathResource(org.springframework.core.io.ClassPathResource) UserService(com.faforever.client.user.UserService) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) PlatformService(com.faforever.client.fx.PlatformService) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) TabPaneSkin(com.sun.javafx.scene.control.skin.TabPaneSkin) Tooltip(javafx.scene.control.Tooltip) ReportAction(com.faforever.client.notification.ReportAction) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) PopupWindow(javafx.stage.PopupWindow) Logger(org.slf4j.Logger) ClanService(com.faforever.client.clan.ClanService) IdenticonUtil(com.faforever.client.util.IdenticonUtil) Controller(com.faforever.client.fx.Controller) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Node(javafx.scene.Node) ReplayService(com.faforever.client.replay.ReplayService) FOE(com.faforever.client.chat.SocialStatus.FOE) IOException(java.io.IOException) WebViewConfigurer(com.faforever.client.fx.WebViewConfigurer) InputStreamReader(java.io.InputStreamReader) Popup(javafx.stage.Popup) ClanTooltipController(com.faforever.client.clan.ClanTooltipController) Preview(com.faforever.client.chat.UrlPreviewResolver.Preview) Stage(javafx.stage.Stage) Severity(com.faforever.client.notification.Severity) Tab(javafx.scene.control.Tab) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) ContentDisplay(javafx.scene.control.ContentDisplay) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction)

Aggregations

ImmediateNotification (com.faforever.client.notification.ImmediateNotification)22 DismissAction (com.faforever.client.notification.DismissAction)12 ReportAction (com.faforever.client.notification.ReportAction)12 I18n (com.faforever.client.i18n.I18n)7 NotificationService (com.faforever.client.notification.NotificationService)7 Severity (com.faforever.client.notification.Severity)7 EventBus (com.google.common.eventbus.EventBus)6 MethodHandles (java.lang.invoke.MethodHandles)6 Path (java.nio.file.Path)6 Inject (javax.inject.Inject)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 PreferencesService (com.faforever.client.preferences.PreferencesService)5 List (java.util.List)5 Component (org.springframework.stereotype.Component)5 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)4 NavigateEvent (com.faforever.client.main.event.NavigateEvent)4 Action (com.faforever.client.notification.Action)4 Subscribe (com.google.common.eventbus.Subscribe)4 IOException (java.io.IOException)4