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());
});
}
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);
}
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();
}
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());
}
Aggregations