Search in sources :

Example 1 with NavigateEvent

use of com.faforever.client.main.event.NavigateEvent in project downlords-faf-client by FAForever.

the class MainController method restoreLastView.

private void restoreLastView() {
    final NavigationItem navigationItem;
    if (preferencesService.getPreferences().getRememberLastTab()) {
        final WindowPrefs mainWindowPrefs = preferencesService.getPreferences().getMainWindow();
        navigationItem = Optional.ofNullable(NavigationItem.fromString(mainWindowPrefs.getLastView())).orElse(NavigationItem.NEWS);
    } else {
        navigationItem = NavigationItem.NEWS;
    }
    eventBus.post(new NavigateEvent(navigationItem));
}
Also used : NavigationItem(com.faforever.client.main.event.NavigationItem) WindowPrefs(com.faforever.client.preferences.WindowPrefs) NavigateEvent(com.faforever.client.main.event.NavigateEvent)

Example 2 with NavigateEvent

use of com.faforever.client.main.event.NavigateEvent 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 3 with NavigateEvent

use of com.faforever.client.main.event.NavigateEvent in project downlords-faf-client by FAForever.

the class AbstractChatTabController method showNotificationIfNecessary.

protected void showNotificationIfNecessary(ChatMessage chatMessage) {
    Stage stage = StageHolder.getStage();
    if (stage.isFocused() && stage.isShowing()) {
        return;
    }
    Player player = playerService.getPlayerForUsername(chatMessage.getUsername());
    String identiconSource = player != null ? String.valueOf(player.getId()) : chatMessage.getUsername();
    notificationService.addNotification(new TransientNotification(chatMessage.getUsername(), chatMessage.getMessage(), IdenticonUtil.createIdenticon(identiconSource), event -> {
        eventBus.post(new NavigateEvent(NavigationItem.CHAT));
        stage.toFront();
        getRoot().getTabPane().getSelectionModel().select(getRoot());
    }));
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) 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) Player(com.faforever.client.player.Player) NavigateEvent(com.faforever.client.main.event.NavigateEvent) Stage(javafx.stage.Stage)

Example 4 with NavigateEvent

use of com.faforever.client.main.event.NavigateEvent in project downlords-faf-client by FAForever.

the class FriendOnlineNotifier method onUserOnline.

@Subscribe
public void onUserOnline(UserOnlineEvent event) {
    String username = event.getUsername();
    Player player = playerService.getPlayerForUsername(username);
    if (player != null && player.getSocialStatus() == SocialStatus.FRIEND) {
        audioService.playFriendOnlineSound();
        notificationService.addNotification(new TransientNotification(i18n.get("friend.nowOnlineNotification.title", username), i18n.get("friend.nowOnlineNotification.action"), IdenticonUtil.createIdenticon(player.getId()), actionEvent -> {
            eventBus.post(new NavigateEvent(NavigationItem.CHAT));
            eventBus.post(new InitiatePrivateChatEvent(username));
        }));
    }
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) IdenticonUtil(com.faforever.client.util.IdenticonUtil) SocialStatus(com.faforever.client.chat.SocialStatus) InitiatePrivateChatEvent(com.faforever.client.chat.InitiatePrivateChatEvent) NavigationItem(com.faforever.client.main.event.NavigationItem) NavigateEvent(com.faforever.client.main.event.NavigateEvent) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) AudioService(com.faforever.client.audio.AudioService) Component(org.springframework.stereotype.Component) PostConstruct(javax.annotation.PostConstruct) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) NavigateEvent(com.faforever.client.main.event.NavigateEvent) InitiatePrivateChatEvent(com.faforever.client.chat.InitiatePrivateChatEvent) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

NavigateEvent (com.faforever.client.main.event.NavigateEvent)4 I18n (com.faforever.client.i18n.I18n)3 NavigationItem (com.faforever.client.main.event.NavigationItem)3 NotificationService (com.faforever.client.notification.NotificationService)3 Inject (javax.inject.Inject)3 AudioService (com.faforever.client.audio.AudioService)2 DismissAction (com.faforever.client.notification.DismissAction)2 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)2 ReportAction (com.faforever.client.notification.ReportAction)2 Severity (com.faforever.client.notification.Severity)2 TransientNotification (com.faforever.client.notification.TransientNotification)2 ReportingService (com.faforever.client.reporting.ReportingService)2 IdenticonUtil (com.faforever.client.util.IdenticonUtil)2 EventBus (com.google.common.eventbus.EventBus)2 MethodHandles (java.lang.invoke.MethodHandles)2 Arrays (java.util.Arrays)2 Node (javafx.scene.Node)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Component (org.springframework.stereotype.Component)2