Search in sources :

Example 1 with EnumItem

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));
}
Also used : ListStore(com.sencha.gxt.data.shared.ListStore) ListFilter(com.sencha.gxt.widget.core.client.grid.filters.ListFilter) EnumItem(org.activityinfo.model.type.enumerated.EnumItem)

Example 2 with EnumItem

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));
    }
}
Also used : EnumItem(org.activityinfo.model.type.enumerated.EnumItem)

Example 3 with EnumItem

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;
}
Also used : EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem) FormField(org.activityinfo.model.form.FormField)

Example 4 with EnumItem

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;
}
Also used : EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem) FormField(org.activityinfo.model.form.FormField)

Example 5 with EnumItem

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;
}
Also used : EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem)

Aggregations

EnumItem (org.activityinfo.model.type.enumerated.EnumItem)44 EnumType (org.activityinfo.model.type.enumerated.EnumType)30 FormField (org.activityinfo.model.form.FormField)11 FormClass (org.activityinfo.model.form.FormClass)9 ResourceId (org.activityinfo.model.resource.ResourceId)9 Test (org.junit.Test)7 QuantityType (org.activityinfo.model.type.number.QuantityType)6 EnumValue (org.activityinfo.model.type.enumerated.EnumValue)5 CuidAdapter.activityFormClass (org.activityinfo.model.legacy.CuidAdapter.activityFormClass)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)3 CompoundExpr (org.activityinfo.model.formula.CompoundExpr)2 SymbolNode (org.activityinfo.model.formula.SymbolNode)2 ColumnModel (org.activityinfo.model.query.ColumnModel)2 ColumnView (org.activityinfo.model.query.ColumnView)2 Cardinality (org.activityinfo.model.type.Cardinality)2 FieldValue (org.activityinfo.model.type.FieldValue)2 CalculatedFieldType (org.activityinfo.model.type.expr.CalculatedFieldType)2 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)2 ActivityField (org.activityinfo.store.mysql.metadata.ActivityField)2 Optional (com.google.common.base.Optional)1