public void setLabel(DecoratedText label) { this.label = label; this.label.setLayoutX(inset); label.setOnMouseReleased(evt -> { if (!getDisabled()) { menu.deselctAll(); selected.setValue(true); if (onMouseSelect != null) { // There might be simple messages that have no handle defined. onMouseSelect.handle(evt); } } }); } }
private void addConvoyList(VBox box, List<IConvoy> presentConvoys, IShip ship) { VBox innerBox = new VBox(); int i = 0; for (IConvoy convoy : presentConvoys) { final String key = "ch.sahits.game.javafx.service.NoticeBoardShipSelectionMenuProvider.ship"; String loadedText = messageSource.getMessage(key, new Object[]{convoy.getName(), convoy.getCapacity()}, locale.getCurrentLocal()); DecoratedText dt = textFactory.createDecoratedText(loadedText, new HashMap<>()); dt.setId("convoy"+i); innerBox.getChildren().add(dt); dt.setOnMouseReleased(evt -> { convoy.addShip(ship); ship.parentShipProperty().setValue(convoy.getOrlegShip()); final ICityPlayerProxyJFX proxy = viewState.getCurrentCityProxy().get(); proxy.leave(ship); proxy.getPlayer().removeSelectableVessel(ship); executeOnCloseButtonClicked(); }); i++; } innerBox.setLayoutX(50); box.getChildren().add(innerBox); }
opponent.setOnMouseReleased(mouseEvent -> { selectedOponent.set((IPlayer) opponent.getUserData()); disableAcceptButton().invalidate();
text = textFactory.createDecoratedText(template, new HashMap<>()); text.setId("noPunishment"); text.setOnMouseReleased((evt) -> { office.setViolation(Optional.empty()); taskFactory.getPostponedDisplayMessage(violation.getDate(), "ch.sahits.game.openpatrician.display.dialog.cityhall.AldermanOfficeDialog.displeasure", violation.getCity().getName()); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setId("smallFine"); text.setOnMouseReleased((evt) -> { ((CityViolation) violation).setPunishment(ECityViolationPunishment.SMALL_FINE); LocalDateTime when = date.getCurrentDate().plusMonths(2); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setId("mediumFine"); text.setOnMouseReleased((evt) -> { ((CityViolation) violation).setPunishment(ECityViolationPunishment.MEDIUM_FINE); LocalDateTime when = date.getCurrentDate().plusMonths(2); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setId("largeFine"); text.setOnMouseReleased((evt) -> { ((CityViolation) violation).setPunishment(ECityViolationPunishment.LARGE_FINE); LocalDateTime when = date.getCurrentDate().plusMonths(2); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setId("boycott"); text.setOnMouseReleased((evt) -> { ((CityViolation) violation).setPunishment(ECityViolationPunishment.BLOCKADE); LocalDateTime when = date.getCurrentDate().plusMonths(2);
@PostConstruct private void initializeDialog() { loaner = (LoanerState) loanerService.findLoaner(city.getCity()); setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.notice.NoticeBoardFactory.takeLoan", new Object[]{}, locale.getCurrentLocal())); addDecoratedText("ch.sahits.game.openpatrician.display.dialog.LoanerTakeLoanDialog.dialogSubheading", "introText"); for (final ILoanProposal proposal : loaner.getLoanProposals()) { int amount = proposal.getAmount(); int payback = (int) (amount * proposal.getInterest()); int duration = proposal.getDurationInWeeks(); String interest = String.format("%.1f", (proposal.getInterest() - 1) * 100); final DecoratedText entry = addDecoratedText("ch.sahits.game.openpatrician.display.dialog.LoanerTakeLoanDialog.loanProposal", "proposal", amount, duration, payback, interest); loans.add(entry); entry.setOnMouseReleased(mouseEvent -> { selectedProposal.setValue(proposal); deactivateAll(); entry.applyStyle(SELECTED_STYLE); }); entry.applyStyle(DEFAULT_NON_SELECTED_STYLE); } final OpenPatricianLargeWaxButton acceptBtn = addActionButton("ch.sahits.game.openpatrician.display.dialog.LoanerTakeLoanDialog.btnLabel", "actionBtn"); acceptBtn.setDisable(true); selectedProposal.addListener((observableValue, oldProposal, newProposal) -> { if (newProposal != null) { acceptBtn.setDisable(false); } }); acceptBtn.setOnAction(createAcceptHandler()); } private void deactivateAll() {
private DecoratedText getCandidateRow(ICitizen candidate, IElectionResult result) { Object[] args; String template; DecoratedText text; if (candidate instanceof IHumanPlayer) { IPlayer p = (IPlayer) candidate; args = new Object[]{modelTranslator.getLocalDisplayDistinctArticle(p.getPersonalData().isMale(), true), modelTranslator.getLocalDisplayName(p.getCareerLevel()), modelTranslator.getLocalDisplayName(p.getRank()), p.getName()+" "+p.getLastName()}; } else { args = new Object[]{modelTranslator.getLocalDisplayDistinctArticle(true, true), modelTranslator.getLocalDisplayName(EEconomicCareer.SMART), modelTranslator.getLocalDisplayName(candidate.getRank()), candidate.getName()+" "+candidate.getLastName()}; } template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.cityhall.TownInfoNotice.candidate", args, locale.getCurrentLocal()); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setOnMouseReleased((evt) -> { result.vote(candidate); executeOnCloseButtonClicked(); }); return text; }
String dueDate = modelTranslations.toDisplayString(dueDate1); final DecoratedText entry = addDecoratedText("ch.sahits.game.openpatrician.display.dialog.LoanerPaybackDialog.payback", "payback", payback, cityName, dueDate); entry.setOnMouseReleased(mouseEvent -> { selectedDebt.setValue(debt); deactivateAll();
final DecoratedText entry = addDecoratedText("ch.sahits.game.openpatrician.display.dialog.LoanerGiveLoanDialog.request", "request"+index, rank, citizen.getName(), citizen.getLastName(), request.getSum(), request.getDurationInWeeks()); loans.add(entry); entry.setOnMouseReleased(mouseEvent -> { selectedRequest.setValue(request); deactivateAll();