Search in sources :

Example 41 with TextField

use of com.vaadin.ui.TextField in project opennms by OpenNMS.

the class MibObjFieldFactory method createField.

/* (non-Javadoc)
     * @see com.vaadin.ui.TableFieldFactory#createField(com.vaadin.data.Container, java.lang.Object, java.lang.Object, com.vaadin.ui.Component)
     */
@Override
public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) {
    if (propertyId.equals("oid")) {
        final TextField field = new TextField();
        field.setSizeFull();
        field.setRequired(true);
        field.setImmediate(true);
        field.addValidator(new RegexpValidator("^\\.[.\\d]+$", "Invalid OID {0}"));
        return field;
    }
    if (propertyId.equals("instance")) {
        final ComboBox field = new ComboBox();
        field.setSizeFull();
        field.setRequired(true);
        field.setImmediate(true);
        field.setNullSelectionAllowed(false);
        field.setNewItemsAllowed(true);
        field.setNewItemHandler(new NewItemHandler() {

            @Override
            public void addNewItem(String newItemCaption) {
                if (!field.containsId(newItemCaption)) {
                    field.addItem(newItemCaption);
                    field.setValue(newItemCaption);
                }
            }
        });
        field.addItem("0");
        field.addItem("ifIndex");
        for (String rt : resourceTypes) {
            field.addItem(rt);
        }
        return field;
    }
    if (propertyId.equals("alias")) {
        final TextField field = new TextField();
        field.setSizeFull();
        field.setRequired(true);
        field.setImmediate(true);
        field.addValidator(new StringLengthValidator("Invalid alias. It should not contain more than 19 characters.", 1, 19, false));
        return field;
    }
    if (propertyId.equals("type")) {
        final TextField field = new TextField();
        field.setSizeFull();
        field.setRequired(true);
        field.setImmediate(true);
        field.addValidator(new // Based on NumericAttributeType and StringAttributeType
        RegexpValidator(// Based on NumericAttributeType and StringAttributeType
        "^(?i)(counter|gauge|timeticks|integer|octetstring|string)?\\d*$", "Invalid type {0}. Valid types are: counter, gauge, timeticks, integer, octetstring, string"));
        return field;
    }
    return null;
}
Also used : ComboBox(com.vaadin.ui.ComboBox) StringLengthValidator(com.vaadin.data.validator.StringLengthValidator) TextField(com.vaadin.ui.TextField) NewItemHandler(com.vaadin.ui.AbstractSelect.NewItemHandler) RegexpValidator(com.vaadin.data.validator.RegexpValidator)

Example 42 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class CopyModelPopupWindow method addFields.

protected void addFields() {
    form = new Form();
    form.setCaption(i18nManager.getMessage(Messages.PROCESS_COPY_POPUP_CAPTION));
    form.getLayout().setMargin(true);
    nameTextField = new TextField(i18nManager.getMessage(Messages.TASK_NAME));
    nameTextField.setWidth(20, Sizeable.UNITS_EM);
    nameTextField.setRequired(true);
    nameTextField.setValue(modelData.getName());
    form.getLayout().addComponent(nameTextField);
    nameTextField.focus();
    descriptionTextArea = new TextArea(i18nManager.getMessage(Messages.TASK_DESCRIPTION));
    descriptionTextArea.setRows(8);
    descriptionTextArea.setWidth(20, Sizeable.UNITS_EM);
    form.getLayout().addComponent(descriptionTextArea);
    addComponent(form);
    // Some empty space
    Label emptySpace = new Label("&nbsp;", Label.CONTENT_XHTML);
    addComponent(emptySpace);
}
Also used : Form(com.vaadin.ui.Form) TextArea(com.vaadin.ui.TextArea) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField)

Example 43 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class DoubleFormPropertyRenderer method getPropertyField.

@Override
public Field getPropertyField(FormProperty formProperty) {
    final TextField textField = new TextField(getPropertyLabel(formProperty));
    textField.setRequired(formProperty.isRequired());
    textField.setEnabled(formProperty.isWritable());
    textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
    if (formProperty.getValue() != null) {
        textField.setValue(formProperty.getValue());
    }
    // Add validation of numeric value
    textField.addValidator(new DoubleValidator("Value must be a double"));
    textField.setImmediate(true);
    return textField;
}
Also used : DoubleValidator(org.activiti.explorer.ui.validator.DoubleValidator) TextField(com.vaadin.ui.TextField)

Example 44 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class LongFormPropertyRenderer method getPropertyField.

@Override
public Field getPropertyField(FormProperty formProperty) {
    final TextField textField = new TextField(getPropertyLabel(formProperty));
    textField.setRequired(formProperty.isRequired());
    textField.setEnabled(formProperty.isWritable());
    textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
    if (formProperty.getValue() != null) {
        textField.setValue(formProperty.getValue());
    }
    // Add validation of numeric value
    textField.addValidator(new LongValidator("Value must be a long"));
    textField.setImmediate(true);
    return textField;
}
Also used : TextField(com.vaadin.ui.TextField) LongValidator(org.activiti.explorer.ui.validator.LongValidator)

Example 45 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class TaskListHeader method initInputField.

protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    CssLayout csslayout = new CssLayout();
    csslayout.setHeight(24, UNITS_PIXELS);
    csslayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(csslayout);
    inputField = new TextField();
    inputField.setWidth(100, UNITS_PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW));
    inputField.focus();
    csslayout.addComponent(inputField);
    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
}
Also used : CssLayout(com.vaadin.ui.CssLayout) TextField(com.vaadin.ui.TextField)

Aggregations

TextField (com.vaadin.ui.TextField)79 Test (org.junit.Test)22 Button (com.vaadin.ui.Button)15 Label (com.vaadin.ui.Label)15 HorizontalLayout (com.vaadin.ui.HorizontalLayout)12 VerticalLayout (com.vaadin.ui.VerticalLayout)10 ClickListener (com.vaadin.ui.Button.ClickListener)7 ComboBox (com.vaadin.ui.ComboBox)7 GridLayout (com.vaadin.ui.GridLayout)7 SplitTextField (au.com.vaadinutils.crud.splitFields.SplitTextField)6 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)6 ClickEvent (com.vaadin.ui.Button.ClickEvent)6 PasswordField (com.vaadin.ui.PasswordField)6 CheckBox (com.vaadin.ui.CheckBox)4 Form (com.vaadin.ui.Form)4 TextArea (com.vaadin.ui.TextArea)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Property (com.vaadin.data.Property)3 Validator (com.vaadin.data.Validator)3