@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageOne.title", new Object[]{informant.getName()}, locale.getCurrentLocal())); StringBuilder template = new StringBuilder(); HashMap<String, Object> parameters = new HashMap<>(); if (informant.getWareNeeded().isPresent()) { GenericPair<ICity, IWare> needed = informant.getWareNeeded().get(); template.append(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageTwo.dialog1", new Object[]{needed.getFirst().getName(), translator.getLocalDisplayName((EWare) needed.getSecond())}, locale.getCurrentLocal())); } if (informant.getWareSurplus().isPresent()) { GenericPair<ICity, IWare> surplus = informant.getWareSurplus().get(); template.append(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageTwo.dialog2", new Object[]{surplus.getFirst().getName(), translator.getLocalDisplayName((EWare) surplus.getSecond())}, locale.getCurrentLocal())); } final Optional<MapSegmentedImage> mapSectionPart = informant.getMapSectionPart(city.getPlayer()); mapSectionPart.ifPresent(mapSegmentedImage -> { List<Integer> visibleSegs = new ArrayList<>(mapSegmentedImage.getSegmentIndices()); parameters.put("visibleSegments", visibleSegs); template.append(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageTwo.dialog4", new Object[]{mapSegmentedImage.getImageName()}, locale.getCurrentLocal())); }); if (informant.getPirateLocation().isPresent()) { GenericPair<String, ICity> pirate = informant.getPirateLocation().get(); template.append(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageTwo.dialog3", new Object[]{pirate.getFirst(), pirate.getSecond().getName()}, locale.getCurrentLocal())); } DecoratedText dt = decoratedTextFactory.createDecoratedText(template.toString(), parameters); getContent().addAll(dt); }