Java Code Examples for com.smartgwt.client.widgets.form.fields.FormItem#setRequired()

The following examples show how to use com.smartgwt.client.widgets.form.fields.FormItem#setRequired() . 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: 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 2
Source File: NsesssV2Form.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
/** Resets nested Identifier members. */
private void resetIdentifierField(FormItem fi, boolean clear, boolean visible, boolean required) {
    Canvas canvas = ((RepeatableFormItem) fi).getCanvas();
    RepeatableForm rf = (RepeatableForm) canvas;
    for (Row row : rf.getRows()) {
        ValuesManager vm = row.getForm();
        DynamicForm[] nestedForms = vm.getMembers();
        for (DynamicForm nf : nestedForms) {
            for (FormItem formItem : nf.getFields()) {
                formItem.setRequired(required);
            }
        }
    }
    resetField(fi, clear, visible, required);
}
 
Example 3
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 4
Source File: ExtendedPropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private FormItem prepareAttributeItem(GUIAttribute att) {
	List<FormItemIcon> multiValIcons = prepareMultiValueIcons(att);

	FormItem item;
	if (att.getType() == GUIAttribute.TYPE_STRING) {
		att.setStringValue(object.getValue(att.getName()) != null ? (String) object.getValue(att.getName()) : null);
		item = ItemFactory.newStringItemForAttribute(att);
	} else if (att.getType() == GUIAttribute.TYPE_INT) {
		item = ItemFactory.newIntegerItemForAttribute(att.getName(), att.getLabel(), null);
		if (object.getValue(att.getName()) != null)
			item.setValue((Long) object.getValue(att.getName()));
	} else if (att.getType() == GUIAttribute.TYPE_BOOLEAN) {
		item = ItemFactory.newBooleanSelectorForAttribute(att.getName(), att.getLabel(),
				checkMandatory ? !att.isMandatory() : true);
		if (object.getValue(att.getName()) != null)
			item.setValue(((Boolean) object.getValue(att.getName())).booleanValue() ? "1" : "0");
	} else if (att.getType() == GUIAttribute.TYPE_DOUBLE) {
		item = ItemFactory.newFloatItemForAttribute(att.getName(), att.getLabel(), null);
		item.setValue((Double) object.getValue(att.getName()));
	} else if (att.getType() == GUIAttribute.TYPE_DATE) {
		item = ItemFactory.newDateItemForAttribute(att.getName(), att.getLabel());
		if (object.getValue(att.getName()) != null)
			item.setValue((Date) object.getValue(att.getName()));
		item.addKeyPressHandler(new KeyPressHandler() {
			@Override
			public void onKeyPress(KeyPressEvent event) {
				if ("backspace".equals(event.getKeyName().toLowerCase())
						|| "delete".equals(event.getKeyName().toLowerCase())) {
					item.clearValue();
					item.setValue((Date) null);
					changedHandler.onChanged(null);
				} else {
					changedHandler.onChanged(null);
				}
			}
		});
	} else if (att.getType() == GUIAttribute.TYPE_USER) {
		item = ItemFactory.newUserSelectorForAttribute(att.getName(), att.getLabel(),
				(att.getOptions() != null && att.getOptions().length > 0) ? att.getOptions()[0] : null,
				multiValIcons);
		if (object.getValue(att.getName()) != null)
			item.setValue((object.getValue(att.getName()).toString()));
	} else if (att.getType() == GUIAttribute.TYPE_FOLDER) {
		item = ItemFactory.newFolderSelectorForAttribute(att.getName(), att.getLabel(),
				checkMandatory ? !att.isMandatory() : true, multiValIcons);
		FolderSelector selector = (FolderSelector) item;
		if (object.getValue(att.getName()) != null) {
			selector.setFolder(att.getIntValue(), att.getStringValue());
			item.setValue(att.getStringValue());
		}
		selector.addFolderChangeListener(new FolderChangeListener() {

			@Override
			public void onChanged(GUIFolder folder) {
				if (changedHandler != null)
					changedHandler.onChanged(null);
			}
		});
	} else {
		item = null;
	}

	if (item != null) {
		if (att.isMultiple() && att.getType() != GUIAttribute.TYPE_USER
				&& att.getType() != GUIAttribute.TYPE_FOLDER)
			item.setIcons(multiValIcons.toArray(new FormItemIcon[0]));
		item.setRequired(checkMandatory ? att.isMandatory() : false);
	}

	return item;
}
 
Example 5
Source File: NsesssV2Form.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private void resetField(FormItem fi, boolean clear, boolean visible, boolean required) {
    fi.setVisible(visible);
    fi.setRequired(required);
    clearIfTrue(clear, fi);
}
 
Example 6
Source File: SubscriptionTemplate.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
protected void declareAsRequired(FormItem formItem) {
    formItem.setErrorFormatter(createErrorFormatter("invalid", i18n.invalidInputs()));
    formItem.setRequired(true);
}