com.smartgwt.client.widgets.form.fields.FormItem Java Examples

The following examples show how to use com.smartgwt.client.widgets.form.fields.FormItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StationSelector.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
FormItem createFilterCategorySelectionGroup(String serviceUrl) {
	if (stationFilterGroups.containsKey(serviceUrl)) {
		RadioGroupItem selector = stationFilterGroups.get(serviceUrl);
		return selector;
	}
	RadioGroupItem radioGroup = new RadioGroupItem("sosDataSource");
	radioGroup.setShowTitle(false);
	radioGroup.addChangedHandler(new ChangedHandler() {
		@Override
		public void onChanged(ChangedEvent event) {
			Object value = event.getValue();
			if (value != null) {
				hideInfoWindow();
				controller.setStationFilter(value.toString());
				controller.updateContentUponStationFilter();
			}
		}
	});

	stationFilterGroups.put(serviceUrl, radioGroup);
	return radioGroup;
}
 
Example #2
Source File: ExtendedPropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void displayAttributeItems() {
	extendedItems.clear();

	for (GUIAttribute att : object.getAttributes()) {
		if (att.isHidden())
			continue;

		FormItem item = prepareAttributeItem(att);
		if (item != null) {
			item.setDisabled(!updateEnabled);
			if (changedHandler != null)
				item.addChangedHandler(changedHandler);
			extendedItems.add(item);
		}
	}

	refreshAttributesForm();
}
 
Example #3
Source File: ExportAction.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private final DynamicForm createOptionsForm() {
    DynamicForm f = new DynamicForm();
    f.setAutoHeight();
    f.setLayoutAlign(Alignment.CENTER);
    f.setWidth(350);

    formItems = createExportFormOptions();

    if (formItems == null || formItems.isEmpty()) {
        return null;
    }

    FormItem fields[] = new FormItem[formItems.size()];

    for (int i = 0; i < formItems.size(); i++) {
        fields[i] = formItems.get(i);
        formItems.get(i);
    }

    f.setFields(fields);

    return f;
}
 
Example #4
Source File: KrameriusExportAction.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<FormItem> createExportFormOptions() {
    List<FormItem> formItems = new ArrayList<>();

    //RadioGroupItem requires specifically LinkedHashMap
    LinkedHashMap<String, String> radioButtonMap = new LinkedHashMap<>();
    radioButtonMap.put(K4_POLICY_PUBLIC, i18n.ExportAction_Request_K4_Policy_Public());
    radioButtonMap.put(K4_POLICY_PRVIATE, i18n.ExportAction_Request_K4_Policy_Private());

    rgi = new RadioGroupItem();
    rgi.setTitle(i18n.ExportAction_Request_K4_Policy_Msg());
    rgi.setValueMap(radioButtonMap);
    rgi.setDefaultValue(K4_POLICY_PUBLIC);
    rgi.setVertical(false);
    formItems.add(rgi);

    return formItems;
}
 
Example #5
Source File: MAMFieldValidator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected boolean condition(Object o) {
    if (o == null || o.toString().equals("")) {
        //empty M field, check if other items are empty

        if (ignoredTitles != null) {
            String ignoredRadioVal = ignoredTitles.get(field.getName());

            if (rdaRadioItem != null && rdaRadioItem.getValueAsString() != null && rdaRadioItem.getValueAsString().equals(ignoredRadioVal)) {
                return true;
            }
        }

        for (FormItem item : itemsToCheck) {
            Object itemValue = item.getValue();

            if (itemValue != null && !"".equals(itemValue.toString())) {
                return false;
            }
        }
    }

    return true;
}
 
Example #6
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Builds the SmartGWT form.
 * @return the form
 */
public final DynamicForm generateForm() {
    List<Field> fields = formDeclaration.getFields();
    ArrayList<FormItem> formItems = new ArrayList<FormItem>(fields.size());


    for (Field child : fields) {
        FormItem formItem = createItem(child, activeLocale);
        if (formItem != null) {
            formItems.add(formItem);
        }
    }
    DynamicForm df = createDefaultForm();
    addFormItems(df, formItems);
    return df;
}
 
Example #7
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public DynamicForm createNestedForm(Field f, String lang, List<FormItem> itemsToCheck) {

        if (itemsToCheck == null && f.getTitle(lang) != null && f.getTitle(lang).endsWith("MA")) {
            itemsToCheck = new ArrayList<>();
        }

        List<Field> fields = f.getFields();
        ArrayList<FormItem> formItems = new ArrayList<FormItem>(fields.size());
        for (Field child : fields) {
            FormItem formItem = createItem(child, lang, itemsToCheck);

            if (formItem != null) {
                formItems.add(formItem);
            }
        }
        DynamicForm df = createDefaultForm();
        addFormItems(df, formItems);
        return df;
    }
 
Example #8
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void setOptionDataSource(FormItem item, Field f, String lang) {
    Field optionField = f.getOptionDataSource();
    DataSource ds = ValueMapDataSource.getInstance().getOptionDataSource(optionField.getName());
    item.setValueField(f.getOptionValueField()[0]);
    item.setOptionDataSource(ds);

    setPickListValueMapping(item, f);

    Integer pickListWidth = getWidthAsInteger(optionField.getWidth());
    if (item instanceof SelectItem) {
        SelectItem selectItem = (SelectItem) item;
        selectItem.setPickListFields(getPickListFields(optionField, lang));
        if (pickListWidth != null) {
            selectItem.setPickListWidth(pickListWidth);
        }
    } else if (item instanceof ComboBoxItem) {
        ComboBoxItem cbi = (ComboBoxItem) item;
        cbi.setPickListFields(getPickListFields(optionField, lang));
        if (pickListWidth != null) {
            cbi.setPickListWidth(pickListWidth);
        }
    }
}
 
Example #9
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds common properties to simple {@link #getFormItem items}.
 */
public FormItem customizeFormItem(FormItem item, Field f) {
    if (item.getTitle() == null) {
        item.setShowTitle(false);
    }
    item.setRequired(f.getRequired());
    item.setPrompt(f.getHint(activeLocale));
    item.setHoverWidth(defaultHoverWidth);
    if (f.getHidden() != null && f.getHidden()) {
        item.setVisible(false);
    }
    String width = f.getWidth();
    if (width != null) {
        item.setWidth(width);
    }
    if (f.getHeight() != null) {
        item.setHeight(f.getHeight());
    }
    if (f.getReadOnly() != null && f.getReadOnly()) {
        item.setCanEdit(!f.getReadOnly());
    }
    return item;
}
 
Example #10
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public FormItem getFormItem(Field f, String lang) {
    FormItem formItem;
    String type = f.getType();
    if (Field.TEXT.equals(type)) {
        formItem = getTextFormItem(f, lang);
    } else if (Field.TEXTAREA.equals(type)) {
        formItem = getTextAreaFormItem(f, lang);
    } else if (Field.G_YEAR.equals(type)) {
        formItem = getDateYearFormItem(f, lang);
    } else if (Field.DATE.equals(type)) {
        formItem = getDateFormItem(f, lang);
    } else if (Field.COMBO.equals(type)) {
        formItem = getComboBoxItem(f, lang);
    } else if (Field.SELECT.equals(type)) {
        formItem = getSelectItem(f, lang);
    } else if (Field.RADIOGROUP.equals(type)) {
        formItem = getRadioGroupItem(f, lang);
    } else { // fallback
        formItem = getTextFormItem(f, lang);
    }
    return formItem;
}
 
Example #11
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
        public Object parseValue(String value, DynamicForm form, FormItem item) {
//            ClientUtils.severe(LOG, "parse: value: %s", value);
            Object result = null;
            if (value != null && !value.isEmpty()) {
                try {
                    Date date = displayFormat.parse(value);
                    result = ISO_FORMAT.format(date);
                } catch (IllegalArgumentException ex) {
                    String toString = String.valueOf(value);
                    LOG.log(Level.WARNING, toString, ex);
                    result = null;
                }
            }
            return result;
        }
 
Example #12
Source File: DcEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private LinkedHashMap<String, FormItem> creatFormItems() {
    return new FormItemBuilder().addItem(DcConstants.TITLE, i18n.DCEditor_Titles_Title())
            .addItem(DcConstants.IDENTIFIER, i18n.DCEditor_Identifiers_Title())
            .addItem(DcConstants.CREATOR, i18n.DCEditor_Creators_Title())
            .addItem(DcConstants.CONTRIBUTOR, i18n.DCEditor_Contributors_Title())
            .addItem(DcConstants.COVERAGE, i18n.DCEditor_Coverage_Title())
            .addItem(DcConstants.DATE, i18n.DCEditor_Dates_Title())
            .addItem(DcConstants.FORMAT, i18n.DCEditor_Formats_Title())
            .addItem(DcConstants.LANGUAGE, i18n.DCEditor_Language_Title())
            .addItem(DcConstants.PUBLISHER, i18n.DCEditor_Publishers_Title())
            .addItem(DcConstants.RELATION, i18n.DCEditor_Relations_Title())
            .addItem(DcConstants.RIGHTS, i18n.DCEditor_Rights_Title())
            .addItem(DcConstants.SOURCE, i18n.DCEditor_Sources_Title())
            .addItem(DcConstants.SUBJECT, i18n.DCEditor_Subjects_Title())
            .addItem(DcConstants.TYPE, i18n.DCEditor_Types_Title())
            .addItem(DcConstants.DESCRIPTION, i18n.DCEditor_Descriptions_Title())
            .getItems();
}
 
Example #13
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private FormItem createFormItem(Record editedRecord, ValueType valueType, DisplayType displayType) {
    FormItem fi = createFormItem(displayType, editedRecord);

    Boolean required = editedRecord.getAttributeAsBoolean(WorkflowModelConsts.PARAMETER_REQUIRED);
    ArrayList<Validator> validators = new ArrayList<Validator>();
    if (required != null && required) {
        validators.add(new RequiredIfValidator(requiredFunc));
    }
    if (valueType == ValueType.NUMBER && displayType != DisplayType.CHECKBOX) {
        validators.add(new IsFloatValidator());
    }
    if (!validators.isEmpty()) {
        fi.setValidators(validators.toArray(new Validator[validators.size()]));
    }
    return fi;
}
 
Example #14
Source File: RepeatableFormItem.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
     * Replace string values of record attributes with types declared by item children.
     * This is necessary as declarative forms do not use DataSource stuff.
     * @param record record to scan for attributes
     * @param item item with possible profile
     * @return resolved record
     */
    private static Record resolveRecordValues(Record record, FormItem item) {
        Field f = getProfile(item);
        if (f != null) {
            for (Field field : f.getFields()) {
                String fType = field.getType();
                if ("date".equals(fType) || "datetime".equals(fType)) {
                    // parses ISO dateTime to Date; otherwise DateItem cannot recognize the value!
                    Object value = record.getAttributeAsObject(field.getName());
                    if (!(value instanceof String)) {
                        continue;
                    }
                    String sd = (String) value;
//                    ClientUtils.severe(LOG, "name: %s, is date, %s", field.getName(), sd);
//                    Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse("1994-11-05T13:15:30Z");
                    try {
                        Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(sd);
                        record.setAttribute(field.getName(), d);
                    } catch (IllegalArgumentException ex) {
                        LOG.log(Level.WARNING, sd, ex);
                    }
                }
            }
        }
        return record;
    }
 
Example #15
Source File: OverUndershootRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createEntryConditionEditCanvas() {
    StaticTextItem labelItem = createLabelItem(i18n.enterCondition());
    
    OverUndershootSelectionData data = controller.getOverUndershootEntryConditions();
    SelectItem entryOperatorItem = createOperatorItem(data, GREATER_THAN_INT);
    entryOperatorItem.addChangedHandler(createEntryOperatorChangedHandler());
    entryOperatorItem.setWidth(EDIT_ITEMS_WIDTH);

    TextItem entryValueItem = createValueItem();
    entryValueItem.addChangedHandler(createEntryValueChangedHandler());
    entryValueItem.setWidth(EDIT_ITEMS_WIDTH);
    declareAsRequired(entryValueItem);
    
    StaticTextItem entryUnitItem = createStaticUnitItem(data);
    entryUnitItem.setWidth(EDIT_ITEMS_WIDTH);
    
    FormItem[] items = new FormItem[] { labelItem, entryOperatorItem, entryValueItem, entryUnitItem };
    entryConditionForm = assembleEditConditionForm(items);
    return alignVerticalCenter(entryConditionForm);
}
 
Example #16
Source File: OverUndershootRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createExitConditionEditCanvas() {
    StaticTextItem labelItem = createLabelItem(i18n.exitCondition());

    OverUndershootSelectionData data = controller.getOverUndershootExitConditions();
    exitOperatorItem = createOperatorItem(data, LESS_THAN_OR_EQUAL_TO_INT);
    exitOperatorItem.addChangedHandler(createExitOperatorChangedHandler());
    exitOperatorItem.setWidth(EDIT_ITEMS_WIDTH);

    exitValueItem = createValueItem();
    exitValueItem.addChangedHandler(createExitValueChangedHandler());
    exitValueItem.setWidth(EDIT_ITEMS_WIDTH);
    declareAsRequired(exitValueItem);

    StaticTextItem exitUnitItem = createStaticUnitItem(data);
    exitUnitItem.setWidth(EDIT_ITEMS_WIDTH);
    
    FormItem[] items = new FormItem[] { labelItem, exitOperatorItem, exitValueItem, exitUnitItem };
    exitConditionForm = assembleEditConditionForm(items);
    return alignVerticalCenter(exitConditionForm);
}
 
Example #17
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
        public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
//            ClientUtils.severe(LOG, "format: class: %s, value: %s", ClientUtils.safeGetClass(value), value);
            if (value == null) {
                return null;
            }
            try {
                Date date = value instanceof Date
                        ? (Date) value : ISO_FORMAT.parse((String) value);
                return displayFormat.format(date);
            } catch (IllegalArgumentException ex) {
                String toString = String.valueOf(value);
                LOG.log(Level.WARNING, toString, ex);
                return toString;
            }
        }
 
Example #18
Source File: DcEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private DynamicForm createFullForm() {
    DynamicForm f = new DynamicForm();
    f.setWidth100();
    f.setNumCols(2);
    f.setBrowserSpellCheck(false);
    f.setWrapItemTitles(false);
    f.setTitleOrientation(TitleOrientation.TOP);
    ArrayList<FormItem> items = new ArrayList<FormItem>();
    addElement(items, DcConstants.CONTRIBUTOR, null, true);
    addElement(items, DcConstants.COVERAGE, null, true);
    addElement(items, DcConstants.CREATOR, null, true);
    addElement(items, DcConstants.DATE, null, true);
    addElement(items, DcConstants.DESCRIPTION, null, true);
    addElement(items, DcConstants.FORMAT, null, true);
    addElement(items, DcConstants.IDENTIFIER, null, true);
    addElement(items, DcConstants.LANGUAGE, null, true);
    addElement(items, DcConstants.PUBLISHER, null, true);
    addElement(items, DcConstants.RELATION, null, true);
    addElement(items, DcConstants.RIGHTS, null, true);
    addElement(items, DcConstants.SOURCE, null, true);
    addElement(items, DcConstants.SUBJECT, null, true);
    addElement(items, DcConstants.TITLE, null, true);
    addElement(items, DcConstants.TYPE, null, true);
    f.setFields(items.toArray(new FormItem[items.size()]));
    return f;
}
 
Example #19
Source File: SensorLossRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createEditConditionCanvas() {
        StaticTextItem label = createLabelItem(i18n.sensorFailure());

        SelectItem unitItem = createUnitsItem();
        unitItem.addChangedHandler(createEntryUnitChangedHandler());
        unitItem.setValueMap(createTimeunitsMap());
        unitItem.setWidth(2 * EDIT_ITEMS_WIDTH);
        
        TextItem valueItem = createValueItem();
        valueItem.addChangedHandler(createValueChangedHandler());
        valueItem.setWidth(EDIT_ITEMS_WIDTH);
        valueItem.setRequired(true);
//        valueItem.setKeyPressFilter("[0-9]+(\\.|,)[0-9]+");
        
        FormItem[] formItems = new FormItem[] { label, unitItem, valueItem };
        conditionForm = assembleEditConditionForm(formItems);
        return alignVerticalCenter(conditionForm);
    }
 
Example #20
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void setOptions(FormItem item, Record profile) {
    String dataSourceId = profile.getAttribute(WorkflowModelConsts.PARAMETER_VALUEMAPID);
    if (dataSourceId != null) {
        DataSource ds = ValueMapDataSource.getInstance().getOptionDataSource(dataSourceId);
        item.setValueField(profile.getAttribute(WorkflowModelConsts.PARAMETER_OPTION_VALUE_FIELD));
        item.setOptionDataSource(ds);
        item.setDisplayField(profile.getAttribute(WorkflowModelConsts.PARAMETER_OPTION_DISPLAY_FIELD));
    }
}
 
Example #21
Source File: NdkFormGenerator.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Override
    protected FormWidget customizeNestedForm(final FormWidget fw, final Field f) {
        fw.addFormWidgetListener(new FormWidgetListener() {

            @Override
            public void onDataLoad() {
                ValuesManager vm = fw.getValues();
                Map<?, ?> values = vm.getValues();
                StringBuilder sb = new StringBuilder();
                for (Entry<?, ?> entry : values.entrySet()) {
                    if (HIDDEN_FIELDS_NAME.equals(entry.getKey())) {
                        continue;
                    }
                    Field member = f.getMember(String.valueOf(entry.getKey()));
                    if (member == null) {
                        sb.append(entry.getKey()).append('=').append(entry.getValue());
                        sb.append(", ");
                    }
                }
//                vm.setValue("_hiddenFields", sb.toString());
                DynamicForm memberForField = (DynamicForm) vm.getMemberForField(HIDDEN_FIELDS_NAME);
                FormItem field = memberForField.getField(HIDDEN_FIELDS_NAME);
                field.setVisible(sb.toString().trim().length() != 0);
                field.setValue(sb.toString());
            }
        });
        return fw;
    }
 
Example #22
Source File: DigitalObjectSearchView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private FormItem createSortItem(String title, FormItemIfFunction showIf) {
    SelectItem item = new SelectItem(DigitalObjectResourceApi.SEARCH_SORT_PARAM, title);
    item.setWidth(300);
    item.setAllowEmptyValue(false);
    LinkedHashMap<String, String> valueMap = new LinkedHashMap();
    valueMap.put("asc", i18n.DigitalObjectSearchView_FilterAsc_Title());
    valueMap.put("desc", i18n.DigitalObjectSearchView_FilterDesc_Title());
    item.setDefaultValue("desc");
    item.setValueMap(valueMap);
    if (showIf != null) {
        item.setShowIfCondition(showIf);
    }
    return item;
}
 
Example #23
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public WorkflowTaskFormView(ClientMessages i18n, WorkflowTasksEditor handler) {
    this.i18n = i18n;
    this.handler = handler;
    // params are required just in case of the finished state of the task
    this.requiredFunc = new RequiredIfFunction() {

        @Override
        public boolean execute(FormItem formItem, Object value) {
            return State.FINISHED.name().equals(
                    taskForm.getValueAsString(WorkflowTaskDataSource.FIELD_STATE));
        }
    };
    this.widget = createMainLayout();
    setItemChangedHandler();
}
 
Example #24
Source File: NewDigObject.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public MetaModelRecord getModel() {
        FormItem field = optionsForm.getField(DigitalObjectDataSource.FIELD_MODEL);
        ListGridRecord selectedRecord = field.getSelectedRecord();
//        Map<?, ?> values = selectedRecord.toMap();
//        ClientUtils.info(LOG, "getModel: %s", values);
        return MetaModelRecord.get(selectedRecord);
    }
 
Example #25
Source File: DcEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void updateProfile(DynamicForm form, FormItem item, Field profile) {
            if (profile != null) {
                Boolean hidden = profile.getHidden();
                form.setVisible(hidden == null || !hidden);
                String title = profile.getTitle(null);
                if (title != null) {
                    if (title.isEmpty()) {
                        item.setShowTitle(false);
                    }
                    item.setTitle(title);
                }
                String hint = profile.getHint(null);
                if (hint != null) {
                    item.setPrompt(hint);
                }
                item.setRequired(profile.getRequired());
                String width = profile.getWidth();
                if (width != null) {
                    item.setWidth(width);
                }
                Integer length = profile.getLength();
                if (length != null && item instanceof TextItem) {
                    ((TextItem) item).setLength(length);
                }
                LinkedHashMap<String, String> valueMap = profile.getValueMap();
                if (valueMap != null) {
//                    System.out.println("DCE.updateProfile.valueMap: " + valueMap);
                    item.setValueMap(valueMap);
                }
            }
        }
 
Example #26
Source File: DcEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public FormItemBuilder addItem(String name, String title) {
    FormItem item;
    item = new RepeatableFormItem(name, title, new ElementFormFactory());
    if (items.put(name, item) != null) {
        throw new IllegalStateException("duplicate: " + name);
    }
    return this;
}
 
Example #27
Source File: RepeatableFormItem.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public static void clearErrors(DynamicForm repeateableItemContainer, boolean show) {
    // It should help to draw inner form errors properly.
    for (FormItem formItem : repeateableItemContainer.getFields()) {
        if (formItem instanceof RepeatableFormItem) {
            ((RepeatableFormItem) formItem).clearErrors(show);
        }
    }
}
 
Example #28
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new IntegerItem for the Extended AttributesDS.
 * 
 * @param name The item name (mandatory)
 * @param label The item label
 * @param value The item value (optional)
 * 
 * @return the new item
 */
public static FormItem newIntegerItemForAttribute(String name, String label, Integer value) {
	// We cannot use spaces in items name
	String itemName = "_" + name.replaceAll(" ", Constants.BLANK_PLACEHOLDER);
	FormItem item = newIntegerItem(itemName, label, value);
	if (!InputValues.getInputs(item.getName()).isEmpty()) {
		item = formItemWithSuggestions(item);
		IsIntegerValidator iv = new IsIntegerValidator();
		iv.setErrorMessage(I18N.message("wholenumber"));
		item.setValidators(iv);
	}
	return item;
}
 
Example #29
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new FloatItem for the Extended AttributesDS.
 * 
 * @param name The item name (mandatory)
 * @param label The item label (optional)
 * @param value The item value (optional)
 * 
 * @return the new item
 */
public static FormItem newFloatItemForAttribute(String name, String label, Float value) {
	// We cannot use spaces in items name
	String itemName = "_" + name.replaceAll(" ", Constants.BLANK_PLACEHOLDER);
	FormItem item = newFloatItem(itemName, label, value);
	if (!InputValues.getInputs(item.getName()).isEmpty()) {
		item = formItemWithSuggestions(item);
		IsFloatValidator iv = new IsFloatValidator();
		iv.setErrorMessage(I18N.message("wholenumber"));
		item.setValidators(iv);
	}
	return item;
}
 
Example #30
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private DynamicForm createParameterForm(Record[] records) {
    if (records == null || records.length == 0) {
        return createDefaultParameterForm();
    }
    DynamicForm df = new DynamicForm();
    df.setUseFlatFields(true);
    df.setWrapItemTitles(false);
    df.setTitleOrientation(TitleOrientation.TOP);
    df.setNumCols(3);
    df.setColWidths("*", "*", "*");
    df.setItemHoverWidth(300);
    FormItem[] items = new FormItem[records.length];
    Record values = new Record();
    for (int i = 0; i < records.length; i++) {
        Record record = records[i];
        ValueType valueType = ValueType.fromString(
                record.getAttribute(WorkflowModelConsts.PARAMETER_VALUETYPE));
        DisplayType displayType = DisplayType.fromString(
                record.getAttribute(WorkflowModelConsts.PARAMETER_DISPLAYTYPE));
        displayType = valueType == ValueType.DATETIME ? DisplayType.DATETIME : displayType;

        String paramName = record.getAttribute(WorkflowParameterDataSource.FIELD_NAME);
        String fieldName = "f" + i;
        items[i] = createFormItem(record, valueType, displayType);
        items[i].setName(fieldName);
        // use dataPath to solve cases where the valid JSON name is not a valid javascript ID (param.id).
        items[i].setDataPath("/" + paramName);
        items[i].setTitle(record.getAttribute(WorkflowModelConsts.PARAMETER_PROFILELABEL));
        items[i].setTooltip(record.getAttribute(WorkflowModelConsts.PARAMETER_PROFILEHINT));
        Object val = getParameterValue(record, valueType, displayType);
        if (val != null) {
            values.setAttribute(paramName, val);
        }
    }
    df.setItems(items);
    df.editRecord(values);
    df.addItemChangedHandler(itemChangedHandler);
    return df;
}