public ItemNavigator(List<IItemNavigatorLabelWrapper<T>> list) { this.list.setAll(list); initializeControl(); }
private void initializeControl() { if (!list.isEmpty()) { final Text label = new Text(list.get(getCurrentPosition()).getLabel()); StringBinding labelBinding = new StringBinding() { label.getStyleClass().add("dialogText"); label.setId("navigation-label"); setCenter(label); previous.setId("previous"); previous.getStyleClass().add("actionButton"); previous.setOnAction(event -> previous()); previous.visibleProperty().bind(visibleNavigation); setLeft(previous); final OpenPatricianSmallWaxButton next = new OpenPatricianSmallWaxButton(">"); next.setId("next"); next.getStyleClass().add("actionButton"); next.setOnAction(event -> next()); next.visibleProperty().bind(visibleNavigation); setRight(next);
private void initializeContent(final ItemNavigator<IPlayer> itemNavigator) { IntegerProperty currentPos = itemNavigator.currentPositionProperty(); currentPos.addListener((observable, oldValue, newValue) -> { getContent().removeIf(node -> node instanceof VBox); initializeContent(itemNavigator); }); IPlayer member = itemNavigator.getCurrent();
ItemNavigator<IShip> itemNavigator = new ItemNavigator<>(wrappedList); Group centerPane = dialogHelper.center(itemNavigator);
private EventHandler<MouseEvent> createAuctionShipAction(final VBox container, IGuild guild, DecoratedText text, ItemNavigator<IShip> itemNavigator, Group centerPane, Pane action) { return event -> { try { // The elements are split up on two components, make sure they are gone from both. container.getChildren().removeAll(text, centerPane, action); getContent().removeAll(text, centerPane, action); LocalDateTime auctionDate = date.getCurrentDate().plusDays(10); auctionDate = guildService.cleanUpAuctionAndDetermineAuctionDate(auctionDate, guild); IShip ship = itemNavigator.getCurrent(); IShipAuction auction = modelFactory.createShipAuction(auctionDate, ship.getValue(), city.getPlayer(), ship); city.getPlayer().removeShip(ship); guild.getAuctions().add(auction); } catch (RuntimeException e) { logger.error("Failed to set ship for auctioning", e); } }; }
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.GuildMembersDialog.title", new Object[]{}, locale.getCurrentLocal())); ICity city = this.city.getCity(); IGuild guild = guildList.findGuild(city).get(); if (guild.getMembers().isEmpty()) { String template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.GuildMembersDialog.noMembers", new Object[]{city.getName()}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(template, new HashMap<>()); text.setId("noMembers"); box = new VBox(text); box.setLayoutY(CLOSE_BTN_Y_POS - 500); getContent().addAll(box); } else { List<IPlayer> members = guild.getMembers(); List<IItemNavigatorLabelWrapper<IPlayer>> wrappedList = itemWrapperFactory.createNonLabeledListForPlayer(members); ItemNavigator<IPlayer> itemNavigator = new ItemNavigator<>(wrappedList); initializeContent(itemNavigator); if (members.size() > 1) { Group centerPane = dialogHelper.center(itemNavigator); box.getChildren().addAll(dialogHelper.createVerticalSpacer(50), centerPane); } } }