@Override public long size() { return lista.getObject().size(); }
@Override public long size() { return list.getObject().size(); }
@Override public int size() throws TemplateModelException { return getInstance().size(); }
@Override public int size() throws TemplateModelException { return getInstance().size(); }
@Override public boolean hasSlot(int index) { return getInstance().size() > index; }
@Override public boolean hasSlot(int index) { return getInstance().size() > index; }
private E getChecking(int index, PathReader pathReader) { if (index < 0 || index + 1 > size()) { String msg = "índice inválido: " + index + ((index < 0) ? " < 0" : " > que a lista (size= " + size() + ")"); if (pathReader == null) { throw new SingularFormException(msg, this); } throw new SingularFormException(pathReader.getErrorMsg(this, msg)); } return values.get(index); }
private E getChecking(int index, PathReader pathReader) { if (index < 0 || index + 1 > size()) { String msg = "índice inválido: " + index + ((index < 0) ? " < 0" : " > que a lista (size= " + size() + ")"); if (pathReader == null) { throw new SingularFormException(msg, this); } throw new SingularFormException(pathReader.getErrorMsg(this, msg), this); } return values.get(index); }
/** * Verifica se a instancia atual é uma lista e se contêm a quantidade de elementos indicados. */ public AssertionsSInstance isList(int expectedSize) { int current = getTarget(SIList.class).size(); if (expectedSize != current) { throw new AssertionError(errorMsg("Tamanho da lista errado", expectedSize, current)); } return this; }
@Override protected Iterator<IModel<SInstance>> getItemModels() { List<IModel<SInstance>> list = new ArrayList<>(); SIList<SInstance> sList = getModelObject(); for (int i = 0; i < sList.size(); i++) { list.add(new SInstanceListItemModel<>(getDefaultModel(), i)); } return list.iterator(); }
@Override protected Iterator<IModel<SInstance>> getItemModels() { List<IModel<SInstance>> list = new ArrayList<>(); SIList<SInstance> sList = getModelObject(); for (int i = 0; i < sList.size(); i++) list.add(new SInstanceListItemModel<>(getDefaultModel(), i)); return list.iterator(); }
@Override protected Iterator<IModel<SIAttachment>> getItemModels() { final SIList<SIAttachment> objList = this.getAttackmentList(); final List<IModel<SIAttachment>> modelList = new ArrayList<>(); for (int i = 0; i < objList.size(); i++) modelList.add(new SInstanceListItemModel<>(this.getAttackmentListModel(), i)); return modelList.iterator(); }
/** * Get the serializable values from the SIlist. Will always create the item models to avoid desynchronization. * @return the serializable values */ @Override public List<Serializable> getObject() { ArrayList<SelectSInstanceAwareModel> selects = new ArrayList<>(); for (int i = 0; i < listModel.getObject().size(); i += 1) { selects.add(new SelectSInstanceAwareModel(new SInstanceListItemModel<>(listModel, i), new RetrieveFromParentSelectConverterResolver())); } return selects.stream().map(IModel::getObject).collect(Collectors.toList()); }
@Override protected Iterator<IModel<SIAttachment>> getItemModels() { final SIList<SIAttachment> objList = this.getAttachmentList(); final List<IModel<SIAttachment>> modelList = new ArrayList<>(); for (int i = 0; i < objList.size(); i++) modelList.add(new SInstanceListItemModel<>(this.getAttachmentListModel(), i)); return modelList.iterator(); }
private void revert() { SIList<SInstance> list = getModelObject(); list.remove(list.size() - 1); }
private void revert(AjaxRequestTarget target) { SIList<SInstance> list = getModelObject(); list.remove(list.size() - 1); }
public MultipleSelectSInstanceAwareModel(IModel<? extends SInstance> model) { this.model = model; this.selects = new ArrayList<>(); if (model.getObject() instanceof SIList) { final SIList<?> list = (SIList<?>) model.getObject(); for (int i = 0; i < list.size(); i += 1) { selects.add(new SelectSInstanceAwareModel(new SInstanceListItemModel<>(model, i), getCustomSelectConverterResolver())); } } else { throw new SingularFormException("Este model somente deve ser utilizado para tipo lista"); } }
@Override public I getObject() { SIList<I> iLista = getRootTarget(); if (iLista == null || getIndex() >= iLista.size()) return null; return (I) iLista.get(getIndex()); }
@Override public I getObject() { SIList<I> iList = getRootTarget(); if (iList == null || getIndex() < 0 || getIndex() >= iList.size()) { return null; } return (I) iList.get(getIndex()); }
@Override protected void onAction(AjaxRequestTarget target, Form<?> form) { final SIList<SInstance> lista = modelLista.getObject(); if (lista.getType().getMaximumSize() != null && lista.getType().getMaximumSize() == lista.size()) { target.appendJavaScript(";bootbox.alert('A Quantidade máxima de valores foi atingida.');"); target.appendJavaScript(Scripts.multipleModalBackDrop()); } else { lista.addNew(); target.add(form); target.focusComponent(this); } }