use of org.activityinfo.model.type.enumerated.EnumItem in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addEnumFilter.
private void addEnumFilter(String path, EffectiveTableColumn columnModel, EnumType enumType) {
ListStore<EnumItemViewModel> store = new ListStore<>(x -> x.getId());
for (EnumItem enumItem : enumType.getValues()) {
store.add(new EnumItemViewModel(enumItem));
}
ListFilter<Integer, EnumItemViewModel> filter = new ListFilter<>(new NullValueProvider<>(path), store);
filter.setUseStoreKeys(true);
filters.add(new ColumnView(columnModel.getFormula(), filter));
}
use of org.activityinfo.model.type.enumerated.EnumItem in project activityinfo by bedatadriven.
the class EnumCheckboxWidget method addOption.
private void addOption() {
String newLabel = Window.prompt(I18N.CONSTANTS.enterNameForOption(), "");
if (!Strings.isNullOrEmpty(newLabel)) {
EnumItem newValue = new EnumItem(EnumItem.generateId(), newLabel);
enumType.getValues().add(newValue);
boxPanel.add(createControl(newValue));
}
}
use of org.activityinfo.model.type.enumerated.EnumItem 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.type.enumerated.EnumItem 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;
}
use of org.activityinfo.model.type.enumerated.EnumItem in project activityinfo by bedatadriven.
the class EnumImportStrategy method getImportSites.
@Override
public List<ImportTarget> getImportSites(FormTree.Node node) {
EnumType type = (EnumType) node.getType();
List<ImportTarget> result = Lists.newArrayList();
if (type.getCardinality() == Cardinality.SINGLE) {
result.add(new ImportTarget(node.getField(), VALUE, node.getField().getLabel(), node.getDefiningFormClass().getId()));
} else {
for (EnumItem item : type.getValues()) {
result.add(new ImportTarget(node.getField(), new TargetSiteId(item.getId().asString()), label(item.getLabel(), node.getField().getLabel()), node.getDefiningFormClass().getId()));
}
}
return result;
}
Aggregations