/** * Retorna o campo cujo o nome seja igual ao do tipo informado e verifica se o campo encontrado é do mesmo tipo * informado. Caso não seja do mesmo tipo, dispara uma exception. */ public <II extends SISimple<T>, T extends Serializable> T getFieldValue(STypeSimple<II, T> type) { return getField(type).getValue(); }
public SInstance getField(String path) { return getField(new PathReader(path)); }
/** * Resolves a field instance and sets its value. * * @param value new value * @param rootTypeClass root type class * @param targetTypeFunction function that receives the root type and returns the field type * @param <RT> root type * @param <RI> root instance * @param <TT> target type * @param <TI> target instance * @param <VAL> value * @throws ClassCastException if this instance type doesn't match rootTypeClass * @throws NoSuchElementException if type returned by the function doesn't match a descendant type */ public <RT extends SType<RI>, RI extends SInstance, TT extends STypeSimple<TI, VAL>, TI extends SISimple<VAL>, VAL extends Serializable> void setValue( VAL value, Class<RT> rootTypeClass, IFunction<RT, TT> targetTypeFunction) { getField(rootTypeClass, targetTypeFunction).setValue(value); }
/** * Retorna o campo cujo o nome seja igual ao do tipo informado e verifica se o campo encontrado é do mesmo tipo * informado. Caso não seja do mesmo tipo, dispara uma exception. */ @SuppressWarnings("unchecked") public <II extends SInstance> II getField(SType<II> type) { SInstance instance = getField(type.getNameSimple()); type.checkIfIsInstanceOf(instance); return (II) instance; }
public FieldRefSelectionBuilder<STL, ST, SI> display(SType<?> field) { return display(it -> defaultString(it.getField(field).toStringDisplay())); }
public <V> void setAttributeCalculation(@Nonnull AttrInternalRef ref, @Nullable String subPath, @Nullable SimpleValueCalculation<V> valueCalculation) { SInstance instanceAtr = getCreating(ref); if (subPath != null) { instanceAtr = instanceAtr.getField(new PathReader(subPath)); } if (!(instanceAtr instanceof SISimple)) { throw new SingularFormException( "O atributo " + instanceAtr.getPathFull() + " não é do tipo " + SISimple.class.getName(), instanceAtr); } ((SISimple) instanceAtr).setValueCalculation(valueCalculation); }
static <V> void setValueCalculation(SInstance instance, String subPath, SimpleValueCalculation<V> valueCalculation) { if (subPath != null) { instance = instance.getField(new PathReader(subPath)); } if (!(instance instanceof SISimple)) { throw new SingularFormException("O atributo " + instance.getPathFull() + " não é do tipo " + SISimple.class.getName(), instance); } ((SISimple) instance).setValueCalculation(valueCalculation); }
private boolean isAnyChildrenVisible(String tabId) { BSTab bsTab = tabMap.get(tabId); SInstance instance = bsTab.getModelObject(); if ((instance instanceof SIComposite) && instance.asAtr().exists() && instance.asAtr().isVisible()) { for (String typeName : bsTab.getSubtree()) { SInstance field = instance.getField(typeName); if (field.asAtr().exists() && field.asAtr().isVisible()) { return true; } } } return false; }
private boolean isAnyChildrenVisible() { SInstance instance = ctx.getCurrentInstance(); if ((instance instanceof SIComposite) && instance.asAtr().exists() && instance.asAtr().isVisible()) { for (String typeName : block.getTypes()) { SInstance field = instance.getField(typeName); if (field.asAtr().exists() && field.asAtr().isVisible()) { return true; } } } return false; }
@Override public void onAction(SInstanceAction action, ISupplier<SInstance> fieldInstance, Delegate delegate) { ISupplier<SInstance> formSupplier = () -> { SInstance ins = SDocumentFactory.empty().createInstance(new EditAnotacaoRefType()); ins.getField(EditAnotacaoRefType.APPROVED) .setValue(fieldInstance.get().asAtrAnnotation().approved()); ins.getField(EditAnotacaoRefType.JUSTIFICATION) .setValue(fieldInstance.get().asAtrAnnotation().text()); return ins; }; Out<SInstanceAction.FormDelegate> formDelegate = new Out<>(); delegate.openForm(formDelegate, getEditActionTitle(fieldInstance.get()), null, formSupplier, fd -> Arrays.asList( new SInstanceAction(SInstanceAction.ActionType.CONFIRM) .setText("Confirmar") .setActionHandler(new ConfirmarEdicaoHandler(fd)), // new SInstanceAction(SInstanceAction.ActionType.CANCEL) .setText("Cancelar") .setActionHandler(new CloseFormHandler(fd)) // )); } }
} else { tab.getTypesNames() .forEach(tp -> ctx.getModel().getObject().getField(tp).asAtr().visible(false));
configuredStudioTable .getColumns() .forEach((name, path) -> tableBuilder.appendPropertyColumn(Model.of(name), path, ins -> ins.getField(path).toStringDisplay()));