/** * Retorna true sea instância ou algums de seus filhos é capaz de receber anotação. Ou seja, se foi marcado como * anotável. */ public boolean hasAnyAnnotable(SInstance instance) { return SInstances.hasAny(instance, i -> i.asAtrAnnotation().isAnnotated()); } }
/** * Retorna true sea instância ou algums de seus filhos é capaz de receber anotação. Ou seja, se foi marcado como * anotável. */ public boolean hasAnyAnnotable(SInstance instance) { return SInstances.hasAny(instance, i -> i.asAtrAnnotation().isAnnotated()); } }
private static boolean isRejected(SInstance instance) { return isFalse(instance.asAtrAnnotation().approved()); }
private static boolean isApproved(SInstance instance) { return isTrue(instance.asAtrAnnotation().approved()); }
/** * Verifica se a anotação existe e possui o texto experado. Se o caminho for null, então faz o teste para a * instância atual. */ public AssertionsSInstance isAnnotationTextEquals(String fieldPath, String expectedText) { AssertionsSInstance field = field(fieldPath); String currentText = field.getTarget().asAtrAnnotation().text(); if(! Objects.equals(expectedText, currentText)) { throw new AssertionError(field.errorMsg("Texto da anotação incorreto", expectedText, currentText)); } return this; }
protected static String getTitle(ISInstanceAwareModel<SIComposite> referenced) { final String annotationLabel = referenced.getMInstancia().asAtrAnnotation().label(); if (isNotBlank(annotationLabel)) return annotationLabel; final String referencedLabel = referenced.getMInstancia().asAtr().getLabel(); if (isNotBlank(referencedLabel)) return String.format("Comentários sobre %s", referencedLabel); return "Comentários"; }
/** Retorna true se a instância ou algum de seus filhos tiver uma anotação marcadada como não aprovada. */ public boolean hasAnyRefusal(SInstance instance) { return SInstances.hasAny(instance, i -> hasAnnotation(i) && !i.asAtrAnnotation().annotation().getApproved()); }
/** Retorna true se a instância ou algum de seus filhos tiver uma anotação marcadada como não aprovada. */ public boolean hasAnyRefusal(SInstance instance) { return SInstances.hasAny(instance, i -> hasAnnotation(i) && BooleanUtils.isFalse(i.asAtrAnnotation().annotation().getApproved())); }
/** * Returns true if the given instance or any of its children is annotated with an refusal * @param instance * @return */ public boolean hasAnyRefusalOnTree(SInstance instance) { return SInstances.hasAny(instance, i -> hasAnnotation(i) && BooleanUtils.isFalse(i.asAtrAnnotation().annotation().getApproved())); }
@Override public void onAction(SInstanceAction action, ISupplier<SInstance> actionInstanceSupplier, Delegate delegate) { final SInstance formInstance = formDelegate.getFormInstance(); final SInstance fieldInstance = delegate.getInstanceRef().get(); final SIAnnotation annotationInstance = fieldInstance.asAtrAnnotation().annotation(); annotationInstance.setApproved(formInstance.getValue(EditAnotacaoRefType.APPROVED)); annotationInstance.setText(formInstance.getValue(EditAnotacaoRefType.JUSTIFICATION)); delegate.refreshFieldForInstance(fieldInstance); formDelegate.close(); } }
private void checkSubtree(String name) { SInstance field = instance.getField(name); if (field != null) { AtrAnnotation annotatedField = field.asAtrAnnotation(); if (annotatedField.hasAnyAnnotationOnTree()) { checkAnnotation(annotatedField); } else if (ctx.getRootContext().getAnnotationMode().editable() && annotatedField.hasAnyAnnotable()) { isAnnotated = true; } } }
private BSActionPanel.ActionConfig<SInstance> buildShowAnnotationsActionConfig() { IPredicate<SInstance> hasAnyRefusal = it -> it.asAtrAnnotation().hasAnyRefusal(); IPredicate<SInstance> hasAnyAnnotable = it -> it.asAtrAnnotation().hasAnyAnnotable(); IPredicate<SInstance> hasAnyAnnotation = it -> it.asAtrAnnotation().hasAnyAnnotationOnTree(); //@formatter:off IFunction<SInstance, String> titleFunc = it -> hasAnyRefusal.test(it) ? "Possui anotação rejeitada" : hasAnyAnnotation.test(it) ? "Possui anotação" : hasAnyAnnotable.test(it) ? "Possui anotável" : null; IFunction<SInstance, IModel<Icon>> iconFunc = it -> $m.ofValue( hasAnyRefusal.test(it) ? Icon.of("annotation-icon annotation-icon-rejected") : hasAnyAnnotation.test(it) ? Icon.of("annotation-icon annotation-icon-approved") : hasAnyAnnotable.test(it) ? Icon.of("annotation-icon annotation-icon-empty") : null ); //@formatter:on return new BSActionPanel.ActionConfig<SInstance>() .iconFunction(rowModel -> iconFunc.apply(rowModel.getObject())) .titleFunction(rowModel -> titleFunc.apply(rowModel.getObject())) .style($m.ofValue("line-height:1em; font-size: 1em;")); }
private void checkSubtree(String name) { SInstance field = instance.getField(name); if (field != null) { AtrAnnotation annotatedField = field.asAtrAnnotation(); if (annotatedField.hasAnyAnnotationOnTree()) { checkAnnotation(annotatedField); } else if (ctx.getRootContext().getAnnotationMode().editable() && annotatedField.hasAnyAnnotable()) { isAnnotated = true; } } }
@Override public Iterable<SInstanceAction> getActions(ISInstanceActionCapable target, SInstance instance) { final boolean annotatable = instance.asAtrAnnotation().isAnnotated(); if (!annotatable || !annotationsVisible.test(instance)) return Collections.emptyList(); final boolean editable = annotationsEditable.test(instance); SInstanceAction editAction = new SInstanceAction(SInstanceAction.ActionType.NORMAL) .setIcon(resolveIcon(instance)) .setText(getEditActionTitle(instance)) .setPosition(Integer.MAX_VALUE) .setPreview(resolvePreview(instance, editable)) .setActionHandler(new EditAnnotationHandler()); return Collections.singletonList(editAction); }
@Override public void onAction(SInstanceAction action, ISupplier<SInstance> fieldInstance, Delegate delegate) { Out<FormDelegate> formDelegate = new Out<>(); delegate.openForm(formDelegate, "Você está prestes a remover este comentário", "Deseja realmente prosseguir e apagá-lo?", () -> null, fd -> Arrays.asList( new SInstanceAction(ActionType.CONFIRM) .setText("Apagar") .setActionHandler((a, i, d) -> { d.getInstanceRef().get().asAtrAnnotation().clear(); d.refreshFieldForInstance(d.getInstanceRef().get()); fd.close(); }), new SInstanceAction(ActionType.CANCEL) .setText("Cancelar") .setActionHandler((a, i, d) -> fd.close())// )); } }
+ "%s" + "</div>", HTMLUtil.escapeHtml(Objects.toString(instance.asAtrAnnotation().text(), "")), isTrue(instance.asAtrAnnotation().approved()) ? "<div class='annotation-status annotation-status-approved'>Aprovado</div>" : isFalse(instance.asAtrAnnotation().approved()) ? "<div class='annotation-status annotation-status-rejected'>Rejeitado</div>" : ""))
@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)) // )); } }