use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class CheckboxTemplate method create.
@Override
public FormField create() {
List<EnumItem> values = Lists.newArrayList();
values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(1)));
values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(2)));
FormField field = new FormField(ResourceId.generateFieldId(EnumType.TYPE_CLASS));
field.setLabel(I18N.CONSTANTS.defaultCheckboxFieldLabel());
field.setType(new EnumType(Cardinality.MULTIPLE, values));
return field;
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class RelevanceRow method onFieldChanged.
@UiHandler("fieldListBox")
public void onFieldChanged(ChangeEvent event) {
FormField field = getSelectedField();
if (field != null) {
updateOperators(field, getSelectedOperator());
updateOperandChoices(field, getValue());
}
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class FieldEditor method validateCode.
/**
* Returns whether code is valid.
*
* @return whether code is valid
*/
private boolean validateCode(FieldWidgetContainer fieldWidgetContainer) {
codeGroup.setShowValidationMessage(false);
String codeString = this.code.getValue();
if (Strings.isNullOrEmpty(codeString)) {
return true;
}
if (!FormField.isValidCode(codeString)) {
codeGroup.showValidationMessage(I18N.CONSTANTS.invalidCodeMessage());
return false;
} else {
// check whether code is unique
List<FormField> formFields = fieldWidgetContainer.getFormDesigner().getModel().getAllFormsFields();
formFields.remove(fieldWidgetContainer.getFormField());
for (FormField field : formFields) {
if (codeString.equals(field.getCode())) {
codeGroup.showValidationMessage(I18N.CONSTANTS.duplicateCodeMessage());
return false;
}
}
return true;
}
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class RelevancePanelPresenter method fieldList.
private List<FormField> fieldList(FieldWidgetContainer container) {
ResourceId thisFieldId = container.getFormField().getId();
FormClass formClass = container.getFormDesigner().getModel().getFormClassByElementId(thisFieldId);
List<FormField> formFields = new ArrayList<>();
for (FormField formField : formClass.getFields()) {
if (!formField.getId().equals(thisFieldId)) {
formFields.add(formField);
}
}
return formFields;
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class RadioButtonTemplate method create.
@Override
public FormField create() {
List<EnumItem> values = Lists.newArrayList();
values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(1)));
values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(2)));
FormField field = new FormField(ResourceId.generateFieldId(EnumType.TYPE_CLASS));
field.setLabel(I18N.CONSTANTS.defaultRadioFieldLabel());
field.setType(new EnumType(Cardinality.SINGLE, values));
return field;
}
Aggregations