/** * 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; }
@SuppressWarnings("unchecked") public IConsumer<SInstance> getUpdateListener() { return asAtr().getAttributeValue(SPackageBasic.ATR_UPDATE_LISTENER); }
public SType<I> withInitListener(IConsumer<I> initListener) { this.asAtr().setAttributeValue(SPackageBasic.ATR_INIT_LISTENER, initListener); return this; }
/** * Run initialization code for new created instance. Recebe uma referência que * pode ser de inicialização lazy. */ @SuppressWarnings("unchecked") void init(Supplier<I> instanceRef) { IConsumer<I> initListener = asAtr().getAttributeValue(SPackageBasic.ATR_INIT_LISTENER); if (initListener != null) { initListener.accept(instanceRef.get()); } }
public static String defineLabel(WicketBuildContext ctx) { SType<?> type = ctx.getCurrentInstance().getType(); AbstractSViewListWithControls<?> view = (AbstractSViewListWithControls<?>) ctx.getView(); return view.label().orElse( Optional.ofNullable(Optional.ofNullable(type.asAtr().getItemLabel()).orElseGet(() -> type.asAtr().getLabel())) .map((x) -> { String[] parts = x.trim().split(" "); return "Adicionar " + parts[0]; }) .orElse("Adicionar item")); }
/** * Cria um novo campo com o nome informado como sendo do tipo informado e já marcado como obrigatório. */ public <T extends SType<?>> T addField(String fieldSimpleName, Class<T> type, boolean required) { T field = addField(fieldSimpleName, type); field.asAtr().required(required); return field; }
protected List<String> getAllowedTypes() { return defaultIfNull( getModelObject().getElementsType().asAtr().getAllowedFileTypes(), Collections.<String>emptyList()); }
private <T extends SType<I>, I extends SInstance, V> void adicionarDefinicaoColuna(PackageBuilder pb, AtrRef<T, I, V> atrRef, String label) { pb.createAttributeType(atrRef); pb.addAttribute(SType.class, atrRef); pb.getAttribute(atrRef) .asAtr().label(("Largura preferencial " + defaultIfNull(label, "")).trim()); }
private static void readXsdOwnAttributes(ElementReader element, SType<?> newType) { if (element.isTagAttribute()) { String value = element.getAttr("use"); if (value != null) { newType.asAtr().required("required".equals(value)); } } else { readXsdOwnAttributeMinOccurs(element, newType); readXsdOwnAttributeMaxOccurs(element, newType); } }
@SuppressWarnings("unchecked") private void addForms(BoxConfigurationData boxConfigurationMetadata) { for (Class<? extends SType<?>> formClass : singularModuleConfiguration.getFormTypes()) { String name = SFormUtil.getTypeName(formClass); Optional<SType<?>> sTypeOptional = singularFormConfig.getTypeLoader().loadType(name); if (sTypeOptional.isPresent()) { SType<?> sType = sTypeOptional.get(); String label = sType.asAtr().getLabel(); boxConfigurationMetadata.getForms().add(new FormDTO(name, sType.getNameSimple(), label)); } } }
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")); } }
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(); }
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 addImplantacaoInstituicao() { final STypeComposite<SIComposite> implantacaoInstituicao = this.addFieldComposite("implantacaoInstituicao"); implantacaoInstituicao.addFieldListOf("cursosPrevistos", STypeCurso.class) .withView(SViewListByMasterDetail::new) .asAtr().label("Cursos Previstos").itemLabel("Curso Previsto"); }
@Override protected void onConfigure() { super.onConfigure(); final FileUploadManager fileUploadManager = getFileUploadManager(); if (uploadId == null || !fileUploadManager.findUploadInfo(uploadId).isPresent()) { final AtrBasic atrAttachment = getModelObject().getElementsType().asAtr(); this.uploadId = fileUploadManager.createUpload(atrAttachment.getMaxFileSize(), null, atrAttachment.getAllowedFileTypes(), this::getTemporaryHandler); } }
@Override protected void onConfigure() { super.onConfigure(); final FileUploadManager fileUploadManager = getFileUploadManager(); if (uploadId == null || !fileUploadManager.findUploadInfoByAttachmentKey(uploadId).isPresent()) { final AtrBasic atrAttachment = getModelObject().getElementsType().asAtr(); this.uploadId = fileUploadManager.createUpload(atrAttachment.getMaxFileSize(), null, atrAttachment.getAllowedFileTypes(), this::getTemporaryHandler); } }
private void addAcondicionamentos() { acondicionamentos = addFieldListOf("acondicionamentos", STypeAcondicionamentoGAS.class); acondicionamentos.withMiniumSizeOf(1); acondicionamentos .withView(new SViewListByMasterDetail() .col(acondicionamentos.getElementsType().embalagemPrimaria, "Embalagem primária")) .asAtr().label("Acondicionamento"); }
@Override protected void onLoadType(TypeBuilder tb) { final STypeInteger exercicio = addFieldInteger(FIELD_EXERCICIO, true); exercicio.asAtr().label("Exercício"); exercicio.selection() .selfIdAndDisplay() .simpleProviderOf(2016, 2017, 2018, 2019); addFieldMonetary(FIELD_VALOR_EMPENHADO) .withRequired(true).asAtr().label("Valor Empenhado"); }
private void addInfraestruturaInstalacoesAcademicas() { final STypeComposite<SIComposite> infraestruturaInstalacoesAcademicas = this.addFieldComposite("infraestruturaInstalacoesAcademicas"); final STypeList<STypeComposite<SIComposite>, SIComposite> enderecoes = infraestruturaInstalacoesAcademicas.addFieldListOfComposite("enderecoes", "encereco"); enderecoes.withView(SViewListByMasterDetail::new) .asAtr().label("Endereços").itemLabel("Endereço"); final STypeComposite<SIComposite> endereco = enderecoes.getElementsType(); endereco.addFieldString("endereco").asAtr().required().label("Endereço"); endereco.addField("cep", STypeCEP.class); }