/** * Set the given property on the target from the value readen from source * * @param source * @param target * @param propertyName */ public static void setPropertyValue(Object source, Object target, String propertyName) { Object val = invokeGetterOn(source, propertyName); invokeSetterOn(target, propertyName, val); }
/** * Set the given property on the target from the value readen from source. Source and target have * the same data type for the property but different names. * * @param source * @param target * @param spropertyName * @param tpropertyName */ public static void setPropertyValue(Object source, Object target, String spropertyName, String tpropertyName) { try { Object val = invokeGetterOn(source, spropertyName); invokeSetterOn(target, tpropertyName, val); } catch (IllegalArgumentException e) { // TODO: handle exception } }
/** * Object source holds date in string value. Cibling object holds LocalDateTime. * * @param source * @param target * @param spropertyName * @param tpropertyName * @param sDatformat */ public static void setDateFromStringPropertyValue(Object source, Object target, String spropertyName, String tpropertyName, String sDatformat) { Object val = invokeGetterOn(source, spropertyName); LocalDateTime ldt = DateUtils.fromString_3((String) val, sDatformat); invokeSetterOn(target, tpropertyName, ldt); }
/** * Commit/cancel modifications. Commit: Set initial value to current value Cancel: Set current value * to initial value */ @Override public void cancelModification() { currentInternalValue.set(initialInternalValue.get()); ReflectionUIUtils.invokeSetterOn(controller.getModel(), getAttributePath(), getInitialInternalValue()); }
public void commitModification(boolean introspect) { final String valToCommit = StringUtils.isEmpty(currentInternalValue.get()) ? defaultInternalValueProperty().get() : currentInternalValue.get(); initialInternalValue.set(valToCommit); if (introspect) { ReflectionUIUtils.invokeSetterOn(controller.getModel(), getAttributePath(), getInitialInternalValue()); } } // @formatter:on
public void onCommitSuccess(IOperationResult result) { // commit all modifications for(IInputComponentWrapper r: row.getEntries()) { r.commitModification(); } row.endInlineEdit(); NotificationsUtils.sendObjectUpdateSuccessNotif(controller); // update version Integer newVersion = (Integer) ReflectionUIUtils.invokeGetterOn(result, "data.attributes.version"); ReflectionUIUtils.invokeSetterOn(row.getController().getModel(), "data.attributes.version", newVersion); // inform other object that this object have been updated ModelUpdatedEvent event = new ModelUpdatedEvent.Builder().model(result).build(); controller.dispatchEvent(event); } }
@Override public void onCommitSuccess(IOperationResult result) { // commit all modifications for(IInputComponentWrapper entry: row.getEntries()) { entry.commitModification(); } row.endInlineEdit(); NotificationsUtils.sendObjectUpdateSuccessNotif(controller); // update version Integer newVersion = (Integer) ReflectionUIUtils.invokeGetterOn(result, "data.attributes.version"); ReflectionUIUtils.invokeSetterOn(row.getController().getModel(), "data.attributes.version", newVersion); // inform other object that this object have been updated ModelUpdatedEvent event = new ModelUpdatedEvent.Builder().model(result).build(); controller.dispatchEvent(event); } }
private void onCommitSuccess(IOperationResult result) { Platform.runLater(() -> { layout.getChildren().clear(); row.endEdition(); }); // go back // tell the header nav bar to go back HeaderNavbarFireBackButton ev = new HeaderNavbarFireBackButton.Builder().build(); // attach commit result may be some warning to display ev.setModel(ActionResult.success()); dispatchEvent(ev); NotificationsUtils.sendObjectUpdateSuccessNotif(this); // update version Integer newVersion = (Integer) ReflectionUIUtils.invokeGetterOn(result, "data.attributes.version"); ReflectionUIUtils.invokeSetterOn(row.getController().getModel(), "data.attributes.version", newVersion); // inform other object that this object have been updated ModelUpdatedEvent event = new ModelUpdatedEvent.Builder().model(result).build(); dispatchEvent(event); }