public ObservableValue<?> getValueProperty(String id) { try { if (getData() == null) return new SimpleObjectProperty<>(getData(), id); PropertyDescriptor pds = getPropertyDescriptor(id); if (pds == null) throw new IllegalArgumentException("Property " + id + " does not exist on " + beanInfo.getBeanDescriptor().getDisplayName()); if (List.class.isAssignableFrom(pds.getPropertyType())) { @SuppressWarnings("unchecked") Property<java.util.List<?>> p = JavaBeanObjectPropertyBuilder.create().bean(getData()).name(id).build(); return MBindings.get(p, FXCollections::observableList); } if (pds.getWriteMethod() == null) { return ReadOnlyJavaBeanObjectPropertyBuilder.create().bean(getData()).name(id).build(); } else { ObservableValue<?> value = JavaBeanObjectPropertyBuilder.create().bean(getData()).name(id).build(); value.addListener(editor.watchForChanges); return value; } } catch (NoSuchMethodException e) { log.log(Level.SEVERE, "While generating property " + id , e); throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") public ServerPane(final ServerData serverData) { this.serverData = assertNotNull(serverData, "serverData"); this.server = assertNotNull(serverData.getServer(), "serverData.server"); loadDynamicComponentFxml(ServerPane.class, this); try { url = JavaBeanObjectPropertyBuilder.create().bean(server).name(Server.PropertyEnum.url.name()).build(); name = JavaBeanStringPropertyBuilder.create().bean(server).name(Server.PropertyEnum.name.name()).build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } urlTextField.textProperty().bindBidirectional(url, new UrlStringConverter()); nameTextField.textProperty().bindBidirectional(name); acceptInvitationCheckBox.selectedProperty().bindBidirectional(serverData.acceptInvitationProperty()); nameLabel.disableProperty().bind(acceptInvitationCheckBox.selectedProperty()); nameTextField.disableProperty().bind(acceptInvitationCheckBox.selectedProperty()); urlLabel.disableProperty().bind(acceptInvitationCheckBox.selectedProperty()); urlTextField.disableProperty().bind(acceptInvitationCheckBox.selectedProperty()); addWeakPropertyChangeListener(server, Server.PropertyEnum.url, updateCompletePropertyChangeListener); serverData.acceptInvitationProperty().addListener(new WeakInvalidationListener(updateCompleteInvalidationListener)); updateComplete(); }
@SuppressWarnings("unchecked") public ServerListItem(final Server server) { this.server = assertNotNull(server, "server"); try { name = JavaBeanStringPropertyBuilder.create() .bean(server) .name(Server.PropertyEnum.name.name()).build(); url = JavaBeanObjectPropertyBuilder.create() .bean(server) .name(Server.PropertyEnum.url.name()).build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } updateSeverity(); }
@SuppressWarnings("unchecked") private void bind() { try { name = JavaBeanStringPropertyBuilder.create() .bean(localRepo) .name(LocalRepo.PropertyEnum.name.name()).build(); localRoot = JavaBeanObjectPropertyBuilder.create() .bean(localRepo) .name(LocalRepo.PropertyEnum.localRoot.name()).build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } name.addListener((InvalidationListener) observable -> updateNameShown()); localRootAsString.bind(localRoot.asString()); }
@SuppressWarnings("unchecked") @Override public ObjectProperty<ToggleGroup> toggleGroupProperty() { JavaBeanObjectPropertyBuilder<ToggleGroup> builder = new JavaBeanObjectPropertyBuilder<ToggleGroup>(); try { return builder.bean(toggleGroup).build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }
/** * @param bean * @param propertyName * @return {@link JavaBeanObjectProperty} */ protected static JavaBeanObjectProperty<Object> objectProperty(Object bean, String propertyName) { Object key = key(bean, propertyName); if (OBJECT_PROPERTIES.containsKey(key)) { return OBJECT_PROPERTIES.get(key); } try { @SuppressWarnings("unchecked") JavaBeanObjectProperty<Object> property = JavaBeanObjectPropertyBuilder.create().bean(bean).name(propertyName).build(); OBJECT_PROPERTIES.put(key, property); return property; } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } }
@SuppressWarnings("unchecked") private void bind() { try { // nameProperty must be kept as field to prevent garbage-collection! nameProperty = JavaBeanStringPropertyBuilder.create() .bean(localRepo) .name(LocalRepo.PropertyEnum.name.name()) .build(); nameTextField.textProperty().bindBidirectional(nameProperty); localRootProperty = JavaBeanObjectPropertyBuilder.create() .bean(localRepo) .name(LocalRepo.PropertyEnum.localRoot.name()) .build(); Bindings.bindBidirectional(localRootTextField.textProperty(), localRootProperty, new FileStringConverter()); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } syncPeriodCheckBox.selectedProperty().addListener((InvalidationListener) observable -> updateSyncPeriodInConfig()); syncPeriodTimePeriodTextField.timePeriodProperty().addListener((InvalidationListener) observable -> updateSyncPeriodInConfig()); addWeakPropertyChangeListener(repoSyncDaemon, RepoSyncDaemon.PropertyEnum.activities, activityPropertyChangeListener); addWeakPropertyChangeListener(repoSyncDaemon, RepoSyncDaemon.PropertyEnum.states, statePropertyChangeListener); addWeakPropertyChangeListener(repoSyncTimer, RepoSyncTimer.PropertyEnum.nextSyncTimestamps, nextSyncPropertyChangeListener); }
public ServerListItem(final Server server) { this.server = assertNotNull(server, "server"); try { name = JavaBeanStringPropertyBuilder.create() .bean(server) .name(Server.PropertyEnum.name.name()).build(); url = JavaBeanObjectPropertyBuilder.create() .bean(server) .name(Server.PropertyEnum.url.name()).build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") private JavaBeanObjectProperty<char[]> createPassphraseProperty() { try { return JavaBeanObjectPropertyBuilder.create() .bean(createPgpKeyParam) .name(CreatePgpKeyParam.PropertyEnum.passphrase.name()) .build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") private JavaBeanObjectProperty<CreatePgpKeyParam.Algorithm> createAlgorithmProperty() { try { return JavaBeanObjectPropertyBuilder.create() .bean(createPgpKeyParam) .name(CreatePgpKeyParam.PropertyEnum.algorithm.name()) .build(); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }
public ItemCompraEntityWrapper(ItemCompra itemCompra) { _itemCompra = itemCompra; try { JavaBeanStringPropertyBuilder builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemCompra); builder.name("codigo"); codigo = builder.build(); builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemCompra); builder.name("nombre"); nombre = builder.build(); JavaBeanObjectPropertyBuilder<BigDecimal> builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemCompra); builder1.name("cantidad"); cantidad = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemCompra); builder1.name("costoUnitario"); costoUnitario = builder1.build(); importe = new SimpleObjectProperty<BigDecimal>(); importe.set( new BigDecimal(0) ); JavaBeanObjectPropertyBuilder<Articulo> builder2 = JavaBeanObjectPropertyBuilder.create(); builder2.bean(itemCompra); builder2.name("articulo"); articulo = builder2.build(); } catch (NoSuchMethodException e) { logger.error("Invalid method to wrap", e); } }
public ItemTraspasoPropWrapper(ItemTraspasoSaliente itemConteo) { _itemConteo = itemConteo; try { JavaBeanStringPropertyBuilder builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemConteo); builder.name("codigo"); codigo = builder.build(); builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemConteo); builder.name("nombre"); nombre = builder.build(); JavaBeanObjectPropertyBuilder<BigDecimal> builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("cantidad"); cantidad = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("stockDB"); stockDB = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("costoUnitario"); costoUnitario = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("precioPublico"); precioPublico = builder1.build(); JavaBeanObjectPropertyBuilder<Articulo> builder2 = JavaBeanObjectPropertyBuilder.create(); builder2.bean(itemConteo); builder2.name("articulo"); articulo = builder2.build(); } catch (NoSuchMethodException e) { logger.error("Invalid method to wrap", e); } }
public ItemConteoPropWrapper(ItemConteoInventario itemConteo) { _itemConteo = itemConteo; try { JavaBeanStringPropertyBuilder builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemConteo); builder.name("codigo"); codigo = builder.build(); builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemConteo); builder.name("nombre"); nombre = builder.build(); JavaBeanObjectPropertyBuilder<BigDecimal> builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("conteo"); conteo = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("stockDB"); stockDB = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("costoUnitario"); costoUnitario = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("diferencia"); diferencia = builder1.build(); JavaBeanObjectPropertyBuilder<Articulo> builder2 = JavaBeanObjectPropertyBuilder.create(); builder2.bean(itemConteo); builder2.name("articulo"); articulo = builder2.build(); } catch (NoSuchMethodException e) { logger.error("Invalid method to wrap", e); } }
public ItemTraspasoPropWrapper(ItemTraspasoEntrante itemConteo) { _itemConteo = itemConteo; try { JavaBeanStringPropertyBuilder builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemConteo); builder.name("codigo"); codigo = builder.build(); builder = JavaBeanStringPropertyBuilder.create(); builder.bean(itemConteo); builder.name("nombre"); nombre = builder.build(); JavaBeanObjectPropertyBuilder<BigDecimal> builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("cantidad"); cantidad = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("stockDB"); stockDB = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("costoUnitario"); costoUnitario = builder1.build(); builder1 = JavaBeanObjectPropertyBuilder.create(); builder1.bean(itemConteo); builder1.name("precioPublico"); precioPublico = builder1.build(); JavaBeanObjectPropertyBuilder<Articulo> builder2 = JavaBeanObjectPropertyBuilder.create(); builder2.bean(itemConteo); builder2.name("articulo"); articulo = builder2.build(); } catch (NoSuchMethodException e) { logger.error("Invalid method to wrap", e); } }