Search in sources :

Example 1 with Clan

use of com.faforever.client.clan.Clan in project downlords-faf-client by FAForever.

the class ChatUserItemController method onMouseEnteredClanTag.

public void onMouseEnteredClanTag() {
    clanService.getClanByTag(player.getClan()).thenAccept(optionalClan -> {
        if (!optionalClan.isPresent()) {
            return;
        }
        clanMenu.getItems().clear();
        Clan clan = optionalClan.get();
        if (playerService.isOnline(clan.getLeader().getId())) {
            MenuItem messageLeaderItem = new MenuItem(i18n.get("clan.messageLeader"));
            messageLeaderItem.setOnAction(event -> eventBus.post(new InitiatePrivateChatEvent(clan.getLeader().getUsername())));
            clanMenu.getItems().add(messageLeaderItem);
        }
        MenuItem visitClanPageAction = new MenuItem(i18n.get("clan.visitPage"));
        visitClanPageAction.setOnAction(event -> {
            platformService.showDocument(clan.getWebsiteUrl());
        // TODO: Could be viewed in clan section (if implemented)
        });
        clanMenu.getItems().add(visitClanPageAction);
        if (clanMenu.getTooltip() != null) {
            clanTooltipController.setClan(clan);
            return;
        }
        Tooltip clanTooltip = new Tooltip();
        clanTooltipController = uiService.loadFxml("theme/chat/clan_tooltip.fxml");
        clanTooltip.setMaxHeight(clanTooltipController.getRoot().getHeight());
        clanTooltip.setGraphic(clanTooltipController.getRoot());
        clanTooltipController.setClan(clan);
        clanMenu.setTooltip(clanTooltip);
        clanTooltip.show(StageHolder.getStage());
    });
}
Also used : Clan(com.faforever.client.clan.Clan) Tooltip(javafx.scene.control.Tooltip) MenuItem(javafx.scene.control.MenuItem)

Example 2 with Clan

use of com.faforever.client.clan.Clan in project downlords-faf-client by FAForever.

the class ChatUserItemControllerTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new ChatUserItemController(preferencesService, avatarService, countryFlagService, chatService, i18n, uiService, joinGameHelper, eventBus, clanService, playerService, platformService);
    Preferences preferences = new Preferences();
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(chatService.getOrCreateChatUser("junit")).thenReturn(new ChatUser("junit", null));
    when(i18n.get(eq("user.status.hosting"), anyString())).thenReturn("Hosting");
    when(i18n.get(eq("user.status.waiting"), anyString())).thenReturn("Waiting");
    when(i18n.get(eq("user.status.playing"), anyString())).thenReturn("Playing");
    when(clanService.getClanByTag(anyString())).thenReturn(CompletableFuture.completedFuture(Optional.of(new Clan())));
    loadFxml("theme/chat/chat_user_item.fxml", param -> instance);
}
Also used : Clan(com.faforever.client.clan.Clan) Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Example 3 with Clan

use of com.faforever.client.clan.Clan in project downlords-faf-client by FAForever.

the class AbstractChatTabControllerTest method start.

@Override
public void start(Stage stage) throws Exception {
    super.start(stage);
    preferences = new Preferences();
    Clan clan = new Clan();
    clan.setId("1234");
    Vault vault = new Vault();
    vault.setReplayDownloadUrlFormat(TEST_REPLAY_BASE_URL);
    when(replayService.findById(any(Integer.class))).thenReturn(completedFuture(Optional.of(new Replay())));
    when(clanService.getClanByTag(sampleClanTag)).thenReturn(completedFuture(Optional.of(clan)));
    when(uiService.loadFxml("theme/chat/clan_tooltip.fxml")).thenReturn(mock(ClanTooltipController.class));
    when(uiService.getThemeFileUrl(any())).thenReturn(getClass().getResource("/theme/chat/chat_section.html"));
    when(timeService.asShortTime(any())).thenReturn("123");
    when(userService.getUsername()).thenReturn("junit");
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(clientProperties.getVault()).thenReturn(vault);
    instance = new AbstractChatTabController(clanService, webViewConfigurer, userService, chatService, platformService, preferencesService, playerService, audioService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator) {

        private final Tab root = new Tab();

        private final WebView webView = new WebView();

        private final TextInputControl messageTextField = new TextField();

        @Override
        public Tab getRoot() {
            return root;
        }

        @Override
        protected TextInputControl messageTextField() {
            return messageTextField;
        }

        @Override
        protected WebView getMessagesWebView() {
            return webView;
        }
    };
    TabPane tabPane = new TabPane(instance.getRoot());
    getRoot().getChildren().setAll(tabPane);
    chatReadyLatch = new CountDownLatch(1);
    instance.getMessagesWebView().getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
        if (Worker.State.SUCCEEDED.equals(newValue)) {
            chatReadyLatch.countDown();
        }
    });
    instance.initialize();
}
Also used : TabPane(javafx.scene.control.TabPane) CountDownLatch(java.util.concurrent.CountDownLatch) TextInputControl(javafx.scene.control.TextInputControl) Tab(javafx.scene.control.Tab) Clan(com.faforever.client.clan.Clan) Replay(com.faforever.client.replay.Replay) TextField(javafx.scene.control.TextField) Vault(com.faforever.client.config.ClientProperties.Vault) Preferences(com.faforever.client.preferences.Preferences) WebView(javafx.scene.web.WebView) ClanTooltipController(com.faforever.client.clan.ClanTooltipController)

Example 4 with Clan

use of com.faforever.client.clan.Clan in project downlords-faf-client by FAForever.

the class AbstractChatTabControllerTest method testShowClanWebsite.

@Test
public void testShowClanWebsite() throws Exception {
    Clan clan = new Clan();
    clan.setId("1234");
    clan.setWebsiteUrl("http://example.com");
    instance.showClanWebsite(sampleClanTag);
    WaitForAsyncUtils.waitForFxEvents();
    verify(platformService).showDocument(any());
}
Also used : Clan(com.faforever.client.clan.Clan) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

Clan (com.faforever.client.clan.Clan)4 Preferences (com.faforever.client.preferences.Preferences)2 ClanTooltipController (com.faforever.client.clan.ClanTooltipController)1 Vault (com.faforever.client.config.ClientProperties.Vault)1 Replay (com.faforever.client.replay.Replay)1 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 MenuItem (javafx.scene.control.MenuItem)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 TextField (javafx.scene.control.TextField)1 TextInputControl (javafx.scene.control.TextInputControl)1 Tooltip (javafx.scene.control.Tooltip)1 WebView (javafx.scene.web.WebView)1 Before (org.junit.Before)1 Test (org.junit.Test)1