private VisibleTradeTypeBinding(ObjectProperty<ETradeType> boundTradeType) { this.boundTradeType = boundTradeType; super.bind(boundTradeType); }
@Override protected BooleanBinding disableAcceptButton() { if (disabeAcceptBinding == null) { disabeAcceptBinding = new BooleanBinding() { { super.bind(selectedOponent); } @Override protected boolean computeValue() { return !residentOponents.isEmpty() && selectedOponent.get() == null; } }; } return disabeAcceptBinding; }
private BooleanBinding actionEnabledBinding() { return new BooleanBinding() { { super.bind(availableMap); } @Override protected boolean computeValue() { if (availableMap.isEmpty()) { return false; } for (IntegerProperty amount : availableMap.values()) { if (amount.get() > 0) { return true; } } return false; } }; }
/** * Boolean binding for the navigation enabling of the ships cataloque. * Only the ships are considered (convoys are excluded) * @param ships to be observed. * @return binding. */ public BooleanBinding enableShipCatalogueForShips(final ObservableList<IShip> ships) { return new BooleanBinding() { { super.bind(ships); } @Override protected boolean computeValue() { return ships.size() > 1; } }; }
private BooleanBinding actionEnabledBinding() { return new BooleanBinding() { { super.bind(moneyTransfer.amountProperty()); } @Override protected boolean computeValue() { return moneyTransfer.getAmount() > 0; } }; }
private BooleanBinding actionEnabledBinding() { return new BooleanBinding() { { super.bind(moneyTransfer.amountProperty()); } @Override protected boolean computeValue() { return moneyTransfer.getAmount() > 0; } }; }
@Override protected BooleanBinding disableAcceptButton() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); // todo: andi 23/12/13: should not consider ships that are automated in some way (these are the ships which's capacity may change) } @Override protected boolean computeValue() { ISmuggler smuggler = (ISmuggler) currentPerson.get(); return tavernDialogUtil.noShipWithEnoughCapacityAvailable(city, smuggler.getAmount()/10); } }; }
@Override protected BooleanBinding disableAcceptButton() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); // todo: andi 23/12/13: should not consider ships that are automated in some way (these are the ships which's capacity may change) } @Override protected boolean computeValue() { ITransportTrader trader = (ITransportTrader) currentPerson.get(); return tavernDialogUtil.noShipWithEnoughCapacityAvailable(city, trader.getNeededCapacity()); } }; }
/** * Binding indicating if there is another person in the side room. * @return boolean binding for the presence of a further person. */ private BooleanBinding hasNextPersonBinding() { return new BooleanBinding() { { super.bind(tavernState.presentPersonsInSideRoomBinding()); } @Override protected boolean computeValue() { return tavernState.presentPersonsInSideRoomBinding().get().size() > 1; } }; }
@Override protected BooleanBinding disableAcceptButton() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); // todo: andi 23/12/13: should not consider ships that are automated in some way (these are the ships which's capacity may change) } @Override protected boolean computeValue() { for (IShip ship : city.getPlayersShips()) { if (ship.getCaptian() != null) { // todo: andi 27/12/13: also check weapons and crew return false; } } return true; } }; } }
private BooleanBinding disableAcceptBinding() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); } @Override protected boolean computeValue() { Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); IShip ship = null; if (city.getActiveShip() instanceof IShip) { ship = (IShip) city.getActiveShip(); } int barrelAmountFactor = 1; if (!trader.getWare().isBarrelSizedWare()) { barrelAmountFactor = 10; } return optOffice.isPresent() && ship == null && ship.getCapacity() < trader.getAmount() * barrelAmountFactor; } }; } /**
private BooleanBinding disableAcceptBinding() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); for (IShip ship : city.getPlayersShips()) { super.bind(ship.passengerPresentProperty()); } } @Override protected boolean computeValue() { if (city.getActiveShip() != null && city.getActiveShip() instanceof IShip) { return ((IShip)city.getActiveShip()).getPassenger().isPresent(); // If passenger is on board, disable } else { return false; } } }; } /**
private BooleanBinding isOrlegCapable() { return new BooleanBinding() { { if (viewState.getCurrentCityProxy().isPresent()) { ObjectProperty<INavigableVessel> activeVessel = viewState.getCurrentCityProxy().get().activeShipProperty(); super.bind(activeVessel); } } @Override protected boolean computeValue() { INavigableVessel activeShip = viewState.getCurrentCityProxy().get().getActiveShip(); if (activeShip == null) { return false; } if (activeShip instanceof IShip) { return shipService.isOrlegCapable((IShip) activeShip, viewState.getCurrentCityProxy().get().getCity()); } return false; } }; } }
@Override protected boolean computeValue() { { super.bind(weaponStorage.getWeaponProperty(weapon)); } if (ship.getCapacity() > 0 && weaponStorage.getWeapon(weapon) > 0) { List<IWeaponSlot> slots = ship.getWeaponSlots(); if (isLargeWeapon(weapon)) { for (int i = 0; i < slots.size(); i++) { IWeaponSlot slot = slots.get(i); if (slot instanceof PrimaryLargeWeaponSlot) { SecondaryLargeWeaponSlot secondary = (SecondaryLargeWeaponSlot) slots.get(i + 1); if (!slot.getWeapon().isPresent() && !secondary.getWeapon().isPresent()) { return false; } } } } else { for (IWeaponSlot slot : slots) { if (!slot.getWeapon().isPresent()) { return false; } } } } return true; } };
@Override protected BooleanBinding disableAcceptButton() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); if (city.getActiveShip() instanceof IShip) { ((IShip)city.getActiveShip()).passengerPresentProperty(); } } @Override protected boolean computeValue() { return !(city.getActiveShip() instanceof IShip) || city.getPlayersShips().isEmpty() || ((IShip)city.getActiveShip()).passengerPresentProperty().get(); } }; }
private BooleanBinding inConvoy() { return new BooleanBinding() { { if (viewState.getCurrentCityProxy().isPresent()) { ObjectProperty<INavigableVessel> activeVessel = viewState.getCurrentCityProxy().get().activeShipProperty(); super.bind(activeVessel); if (activeVessel.get() != null) activeVessel.addListener((observable, oldValue, newValue) -> { if (oldValue instanceof IShip) { super.unbind(((IShip) oldValue).parentShipProperty()); } if (newValue instanceof IShip) { super.bind(((IShip) newValue).parentShipProperty()); } }); } } @Override protected boolean computeValue() { INavigableVessel activeShip = viewState.getCurrentCityProxy().get().getActiveShip(); if (activeShip == null) { return false; } if (activeShip instanceof IShip) { return ((IShip) activeShip).parentShipProperty().get() != null; } return false; } }; }
@Override protected BooleanBinding disableAcceptButton() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); if (city.getActiveShip() instanceof IShip) { ((IShip)city.getActiveShip()).passengerPresentProperty(); } } @Override protected boolean computeValue() { return !(city.getActiveShip() instanceof IShip) || tavernDialogUtil.noShipWithEnoughCapacityAvailable(city, AMOUNT) || ((IShip)city.getActiveShip()).passengerPresentProperty().get(); } }; }
@Override protected BooleanBinding disableAcceptButton() { return new BooleanBinding() { { super.bind(city.getPlayersShips()); if (city.getActiveShip() instanceof IShip) { ((IShip)city.getActiveShip()).passengerPresentProperty(); } } @Override protected boolean computeValue() { return !(city.getActiveShip() instanceof IShip) || city.getPlayersShips().isEmpty() || ((IShip)city.getActiveShip()).passengerPresentProperty().get(); } }; } }
canBuy = new BooleanBinding() { super.bind(required, inCity, inStorage);
capableShipPresent = new BooleanBinding() { super.bind(city.getPlayersShips());