/** * Listener é invocado quando o campo do qual o tipo depende * é atualizado ( a dependencia é expressa via depends on) */ public SType<I> withUpdateListener(IConsumer<I> consumer) { asAtr().setAttributeValue(SPackageBasic.ATR_UPDATE_LISTENER, consumer); return this; }
private void debugAttributesDefined(Appendable appendable, int level) { attributesDefined.getAttributes().stream().filter(att -> !getLocalTypeOptional(att.getNameSimple()) .isPresent()).forEach(att -> { try { pad(appendable, level + 1).append("att ").append(suppressPackage(att.getName())) .append(':').append(suppressPackage(att.getSuperType().getName())).append( att.isSelfReference() ? " SELF" : "").append('\n'); } catch (IOException ex) { LOGGER.log(Level.SEVERE, ex.getMessage(), ex); } }); }
public Object getAttributeValueOrDefaultValueIfNull() { if (Objects.equals(nameSimple, SPackageBasic.ATR_DEFAULT_IF_NULL.getNameSimple())) { return null; } return getAttributeValue(SPackageBasic.ATR_DEFAULT_IF_NULL); }
public boolean hasValidation() { return isRequired() || getAttributeValue(SPackageBasic.ATR_REQUIRED_FUNCTION) != null || hasValidationInternal(); }
public String translateImport(SType<?> superType) { String nameFull = superType.getName(); return imports.contains(nameFull) ? superType.getNameSimple() : nameFull; } }
public static <V> Optional<V> getAttribute(SType<?> type, AtrRef<?, ?, V> ref) { if (type.hasAttributeDefinedInHierarchy(ref)) { return Optional.ofNullable(type.getAttributeValue(ref)); } return Optional.empty(); }
DiffInfo(SInstance original, SInstance newer, DiffType type) { this.original = original; this.newer = newer; this.type = type; //Copia dados básicos para o caso do diff ser serializado SInstance instance = newer == null ? original : newer; this.simpleName = instance.getType().getNameSimple(); this.simpleLabel = instance.getType().asAtr().getLabel(); }
private void prepareDefaultImports(SDictionary dictionary) { for (SType<?> type : dictionary.getType(SType.class).getPackage().getLocalTypes()) { imports.put(type.getNameSimple(), type.getName()); } }
@SuppressWarnings("unchecked") private static void realMapToSInstance(Map<Integer, Map<String, Object>> pojoReferenceDataMap, Object pojoDataMap, SInstance rootInstance, boolean strictMode) { SType<?> type = rootInstance.getType(); if (type.isComposite()) { mapToSIComposite(pojoReferenceDataMap, (Map<String, Object>) pojoDataMap, (SIComposite) rootInstance, strictMode); } else if (type.isList()) { mapToSIList(pojoReferenceDataMap, (Map<String, Object>) pojoDataMap, (SIList<SInstance>) rootInstance, strictMode, type); } else { rootInstance.setValue(((Map<String, Object>) pojoDataMap).get(type.getNameSimple())); } }
@Override protected void onLoadType(@Nonnull TypeBuilder tb) { endpoint = this.addFieldString("endpoint"); htmlToExport = this.addField("htmlToExport", STypeHTML.class); endpoint.setInitialValue(RestfulHtmlToPdfConverter.getEndpointDefault()); endpoint.asAtr() .label("Endpoint:") .maxLength(155) .enabled(true); htmlToExport .withInitListener(s -> s.setValue(" teste ")) .withView(SViewByRichText::new) .asAtr() .label("HTML Exportação"); } }
if (elementsType.isComposite()) { int sumWidthPref = compositeElementsType.getFields().stream().mapToInt((x) -> x.asAtrBootstrap().getColPreference(1)).sum(); final Integer preferentialWidth = tCampo.asAtrBootstrap().getColPreference(1); final IModel<String> headerModel = $m.ofValue(tCampo.asAtr().getLabel()); final BSTDataCell cell = row.newTHeaderCell(headerModel); final String width = String.format("width:%.0f%%;", (100.0 * preferentialWidth) / sumWidthPref); final boolean isCampoObrigatorio = tCampo.asAtr().isRequired();
@SuppressWarnings("unchecked") private List<String> initEnumSelectDomain(SType<?> type) { if (selection && type.asAtrProvider().getConverter() instanceof EnumSInstanceConverter) { return (List<String>) type .asAtrProvider() .getProvider() .load(new ProviderContext()) .stream() .map(e -> type.asAtrProvider().getDisplayFunction().apply((Serializable) e)) .collect(Collectors.toList()); } return Collections.emptyList(); }
/** * * @param header * a subtype of element type of the list. * it can not be the very element type of the list * in order to use de element type as header it is necessary to define a displayString and call {@link #SViewListByForm()} */ public SViewListByForm(SType header) { this.headerPath = header.getNameSimple(); }
private String mapName(String originalName) { if (originalName.indexOf('.') == -1) { return getName() + '.' + originalName; } return originalName; }
final STypeString acao = this.addFieldString("acao", true); acao.selectionOfEnum(AcaoGestaoObras.class) .asAtr().label("Ação").asAtrBootstrap().colPreference(3); .asAtrBootstrap().colPreference(12) .asAtr().label("Todos os dados informados estão corretos");
private static void writeType(ContextArchive ctx, SIPersistenceType pType, SType<?> type) { pType.setSuperType(ctx.translateImport(type.getSuperType())); ensureType(ctx, type.getSuperType()); if (type.isComposite()) { //TODO (por Daniel Bordin) O código abaixo ainda precisa resolver a questão de field que foram extendido // e tiveram apenas uma atributo alterado for (SType<?> localField : ((STypeComposite<?>) type).getFieldsLocal()) { SIPersistenceType pMember = pType.addMember(localField.getNameSimple()); writeType(ctx, pMember, localField); } } }
/** * Checks if the SType is a list or a composite and calls the right method to include the complex element on XSD * @param sType The SType that will be inserted on the XSD * @param element The parent element */ private static void toXsdFromSType(SType<?> sType, MElement element) { if (sType.isList()) { toXsdFromList((STypeList<?, ?>) sType, element); } else if (sType.isComposite()) { toXsdFromComposite((STypeComposite<?>) sType, element); } }
/** Se aplica somene se o tipo for da classe {@link STypeList} */ @Override public boolean isApplicableFor(SType<?> type) { return type.isList(); } }
@Nonnull final static SType<?> getAttributeDefinedHierarchy(@Nonnull SType<?> type, @Nonnull AttrInternalRef ref) { Objects.requireNonNull(type); Objects.requireNonNull(ref); for (SType<?> current = type; current != null; current = current.getSuperType()) { SType<?> att = current.getAttributeDefinedLocally(ref); if (att != null) { return att; } } throw new SingularFormException("Não existe atributo '" + ref.getName() + "' em " + type.getName(), type); }
private void buildHeader(BSContainer<?> header, Form<?> form, IModel<SIList<SInstance>> list, WicketBuildContext ctx, SViewListByTable view, boolean isEdition) { final IModel<String> label = $m.ofValue(ctx.getCurrentInstance().getType().asAtr().getLabel()); final Label title = new Label("_title", label); ctx.configureContainer(label); header.appendTag("span", title); // header.add($b.visibleIf($m.get(() -> !Strings.isNullOrEmpty(label.getObject())))); final SType<SInstance> elementsType = list.getObject().getElementsType(); if (!elementsType.isComposite() && elementsType.asAtr().isRequired()) { title.add($b.classAppender("singular-form-required")); } }