Java 类com.vaadin.ui.AbstractTextField 实例源码

项目:esup-ecandidat    文件:CustomBeanFieldGroup.java   
/**  construit un champs avec un type
 * @param caption
 * @param propertyId
 * @param fieldType
 * @return le champs
 * @throws BindException
 */
@SuppressWarnings({ "rawtypes", "hiding" })
public <T extends Field> T buildAndBind(String caption, String propertyId,
           Class<T> fieldType) throws BindException {
       T field = super.buildAndBind(caption, propertyId, fieldType);
       if (MethodUtils.getIsNotNull(this.beanType,propertyId)){
        field.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
        field.setRequired(true);
    }
       if (field instanceof AbstractTextField) {
        ((AbstractTextField) field).setNullRepresentation("");
        ((AbstractTextField) field).setNullSettingAllowed(true);
    }
    IRequiredField requiredField = (IRequiredField) field;
    requiredField.initField(true);
       return field;
   }
项目:dungeonstory-java    文件:AbstractForm.java   
private boolean findFieldAndFocus(Component compositionRoot) {
    if (compositionRoot instanceof AbstractComponentContainer) {
        AbstractComponentContainer cc = (AbstractComponentContainer) compositionRoot;

        for (Component component : cc) {
            if (component instanceof AbstractTextField) {
                AbstractTextField abstractTextField = (AbstractTextField) component;
                abstractTextField.selectAll();
                return true;
            }
            if (component instanceof AbstractField) {
                AbstractField<?> abstractField = (AbstractField<?>) component;
                abstractField.focus();
                return true;
            }
            if (component instanceof AbstractComponentContainer) {
                if (findFieldAndFocus(component)) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:cuba    文件:CubaSourceCodeEditor.java   
public CubaSourceCodeEditor() {
    String aceLocation = "VAADIN/resources/ace";

    setBasePath(aceLocation);
    setThemePath(aceLocation);
    setWorkerPath(aceLocation);
    setModePath(aceLocation);

    setUseWorker(false);

    setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY);
    setTextChangeTimeout(200);

    setValidationVisible(false);
    setShowBufferedSourceException(false);
    setShowErrorForDisabledState(false);

    setHandleTabKey(false);
    setFontSize("auto");
}
项目:cuba    文件:WebWrapperUtils.java   
public static TextInputField.TextChangeEventMode toTextChangeEventMode(AbstractTextField.TextChangeEventMode mode) {
    if (mode == null) {
        return null;
    }

    switch (mode) {
        case EAGER:
            return TextInputField.TextChangeEventMode.EAGER;
        case LAZY:
            return TextInputField.TextChangeEventMode.LAZY;
        case TIMEOUT:
            return TextInputField.TextChangeEventMode.TIMEOUT;
        default:
            throw new UnsupportedOperationException("Unsupported Vaadin TextChangeEventMode");
    }
}
项目:cuba    文件:WebWrapperUtils.java   
public static AbstractTextField.TextChangeEventMode toVaadinTextChangeEventMode(TextInputField.TextChangeEventMode mode) {
    if (mode == null) {
        return null;
    }

    AbstractTextField.TextChangeEventMode vMode;
    switch (mode) {
        case EAGER:
            vMode = AbstractTextField.TextChangeEventMode.EAGER;
            break;
        case LAZY:
            vMode = AbstractTextField.TextChangeEventMode.LAZY;
            break;
        case TIMEOUT:
            vMode = AbstractTextField.TextChangeEventMode.TIMEOUT;
            break;
        default:
            throw new UnsupportedOperationException("Unsupported TextChangeEventMode");
    }

    return vMode;
}
项目:esup-ecandidat    文件:CustomBeanFieldGroup.java   
/** ajoute le champs ainsi que le validateur, le required, et initialise le field
 * @param caption
 * @param propertyId
 * @return le field
 */
public Field<?> buildAndBind(String caption, String propertyId) {
    Field<?> field = super.buildAndBind(caption, propertyId);
    if (MethodUtils.getIsNotNull(this.beanType,propertyId)){
        field.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
        field.setRequired(true);            
    }

    if (field instanceof AbstractTextField) {
        ((AbstractTextField) field).setNullRepresentation("");
        ((AbstractTextField) field).setNullSettingAllowed(true);
    }

    if (field instanceof DateField) {
        ((DateField)field).setParseErrorMessage(applicationContext.getMessage("validation.parse.date", null, UI.getCurrent().getLocale()));
    }
    if (field instanceof RequiredIntegerField) {
        ((RequiredIntegerField)field).setConversionError(applicationContext.getMessage("validation.parse.int", null, UI.getCurrent().getLocale()));
    }
    if (field instanceof I18nField) {
        if (cacheController.getLangueEnServiceWithoutDefault().size()!=0){
            field.setRequiredError(applicationContext.getMessage("validation.i18n.obigatoire", null, UI.getCurrent().getLocale()));
        }           
        field.addValidator(new I18nValidator(applicationContext.getMessage("validation.i18n.one.missing", null, UI.getCurrent().getLocale()),
                applicationContext.getMessage("validation.i18n.same.lang", null, UI.getCurrent().getLocale())));

    }       

    IRequiredField requiredField = (IRequiredField) field;
    requiredField.initField(true);
    return field;
}
项目:textfieldformatter    文件:IBANFormatter.java   
public static IBANFormatter fromIBANLength(AbstractTextField field, int length) {
    int num4s = length / 4;
    int lastBlock = length % 4;
    int[] blocks = null;
    if (lastBlock != 0) {
        blocks = new int[num4s + 1];
        Arrays.fill(blocks, 4);
        blocks[blocks.length - 1] = lastBlock;
    } else {
        blocks = new int[num4s];
        Arrays.fill(blocks, 4);
    }
    return new IBANFormatter(field, blocks) ;
}
项目:textfieldformatter    文件:CustomStringBlockFormatter.java   
public CustomStringBlockFormatter(AbstractTextField field, int[] blocks, String[] delimiters, ForceCase forceCase) {
    super(field);
    getState().formatBlocks = blocks;
    getState().delimiters = delimiters;
    if (forceCase == ForceCase.UPPER) {
        getState().lowercase = false;
        getState().uppercase = true;            
    } else if (forceCase == ForceCase.LOWER) {
        getState().lowercase = true;
        getState().uppercase = false;
    }
}
项目:bookery    文件:ServerSettingsLayout.java   
private AbstractTextField[] generateFields() {
    fields = new ArrayList<>();
    for(SettingKey key : SettingKey.values()) {
        AbstractTextField field = new TextField(key.getName());
        field.setColumns(25);
        field.setId(key.getKey());
        field.addBlurListener(this);
        fields.add(field);
    }
    AbstractTextField[] result = new AbstractTextField[fields.size()];
    return fields.toArray(result);
}
项目:bookery    文件:ServerSettingsLayout.java   
public void loadData() {
    for(AbstractTextField field : fields) {
        SettingKey key = SettingKey.getEnumByKey(field.getId());
        AppSetting setting = presenter.loadSetting(key);
        field.setValue(setting.getConfigurationValue());
    }
    checkSolr();
}
项目:bookery    文件:ServerSettingsLayout.java   
@Override
public void blur(FieldEvents.BlurEvent event) {
    SettingKey key = SettingKey.getEnumByKey(event.getComponent().getId());
    for(AbstractTextField field : fields) {
        if(field.getId().equals(key.getKey())) {
            presenter.updateSetting(key, field.getValue());
            break;
        }
    }
}
项目:Vaadin-AutocompleteTextField    文件:AutocompleteTextFieldExtension.java   
/**
 * Construct a new {@link AutocompleteTextFieldExtension} and extends the
 * given {@link AbstractTextField}.
 *
 * @param target The textfield to extend.
 */
public AutocompleteTextFieldExtension(AbstractTextField target) {
    addFunctions();
    if (target != null) {
        extend(target);
    }
}
项目:Vaadin-Prime-Count    文件:OutcomeOfUserStory.java   
private void resetAbstractField(final AbstractField<?> next)
{
    if (next instanceof AbstractTextField)
    {
        ((AbstractTextField) next).setValue(Constants.EMPTY);
    }
    else
    {
        next.setValue(null);
    }
}
项目:minimal-j    文件:VaadinTextField.java   
@Override
public void handleAction(Object sender, Object target) {
    if (target instanceof AbstractTextField) {
        VaadinDialog dialog = findDialog((AbstractTextField) target);
        if (dialog != null) {
            Action saveAction = dialog.getSaveAction();
            if (saveAction.isEnabled()) {
                saveAction.action();
            }                       
        }
    }
}
项目:jain-I18n    文件:I18NComponentHandlerFactory.java   
/**
 * Method to find I18NHandler for the component
 * @param component
 * @return {@link I18NComponentHandler}
 */
public static I18NComponentHandler getHandler (Component component) {
    if (componentHandler != null && component != null) {
        I18NComponentHandler handler = componentHandler.get(component.getClass());
        if (handler != null)
            return handler;
    }
    if (component instanceof Label)
        return new I18NLableHandler((Label)component);
    if (component instanceof AbstractTextField)
        return new I18NFieldHandler((AbstractTextField)component);
    if (component instanceof PopupDateField)
        return new I18NFieldHandler((PopupDateField)component);
    if (component instanceof Table)
        return new I18NTableHandler((Table)component);
    if (component instanceof AbstractSelect)
        return new I18NAbstractSelectHandler((AbstractSelect)component);
    if (component instanceof TabSheet || component.getParent() instanceof TabSheet)
        return new I18NTabSheetHandler(component);
    if  (component instanceof JUploader) 
        return new I18NJUploadHandler((JUploader) component);
    if (component instanceof MenuBar) 
        return new I18NMenuBarHandler((MenuBar) component);
    if (component instanceof AbstractComponent)
        return new I18NAbstractComponentHandler ((AbstractComponent)component);
    return  new I18NComponentHandler(component);
}
项目:jain-I18n    文件:I18NFieldHandler.java   
public void applyI18N(Component component, Locale locale) {
    super.applyI18N(component, locale);

    if (component instanceof AbstractTextField) {
        ((AbstractTextField) component).setInputPrompt(getInputPrompt(locale));
        ((AbstractTextField) component).setRequiredError(getRequiredError(locale));
    } else if (component instanceof ComboBox) {
        ((ComboBox) component).setInputPrompt(getInputPrompt(locale));
        ((ComboBox) component).setRequiredError(getRequiredError(locale));
    } else if (component instanceof PopupDateField) {
        ((PopupDateField) component).setInputPrompt(getInputPrompt(locale));
        ((PopupDateField) component).setRequiredError(getRequiredError(locale));
    }
}
项目:root    文件:NumericButtonField.java   
public NumericButtonField(AbstractTextField field) {
    super(3, 4);

    setStyleName("numericButtonField");
    setSpacing(true);

    this.textField = field;

    addNumericButtons();
    addClearButton();
    addEnterButton();
}
项目:viritin    文件:AbstractForm.java   
private boolean findFieldAndFocus(Component compositionRoot) {
    if (compositionRoot instanceof AbstractComponentContainer) {
        AbstractComponentContainer cc = (AbstractComponentContainer) compositionRoot;

        for (Component component : cc) {
            if (component instanceof AbstractTextField) {
                AbstractTextField abstractTextField = (AbstractTextField) component;
                if (!abstractTextField.isReadOnly()) {
                    abstractTextField.selectAll();
                    return true;
                }
            }
            if (component instanceof AbstractField) {
                AbstractField abstractField = (AbstractField) component;
                if (!abstractField.isReadOnly()) {
                    abstractField.focus();
                    return true;
                }
            }
            if (component instanceof AbstractComponentContainer) {
                if (findFieldAndFocus(component)) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:mycollab    文件:GridCellWrapper.java   
public void addComponent(Component component) {
    if (!(component instanceof Button))
        component.setCaption(null);

    if (component instanceof MultiSelectComp) {
        component.setWidth("200px");
    } else if (component instanceof AbstractTextField || component instanceof RichTextArea) {
        component.setWidth("100%");
    }
    super.addComponent(component);
}
项目:enterprise-app    文件:DefaultCrudFieldFactory.java   
/**
 * If the Column annotation has a "length" attribute, adds a validator to check for the maximum allowed length.
 * @param field
 * @param columnAnnotation
 */
public void checkLength(Field field, Column columnAnnotation, Type typeAnnotation) {
    if(typeAnnotation != null && !"text".equals(typeAnnotation.type()))
    if(AbstractTextField.class.isAssignableFrom(field.getClass())) {
        if(columnAnnotation != null) {
            field.addValidator(new StringLengthValidator(Constants.uiMaxLengthExceeded(columnAnnotation.length()), 0, columnAnnotation.length(), true));
        }
    }
}
项目:enterprise-app    文件:DefaultCrudFieldFactory.java   
/**
 * Configures the null representation for the field, if necessary.
 * @param field field to configure.
 */
public void checkNullRepresentation(Field field) {
    if(AbstractTextField.class.isAssignableFrom(field.getClass())) {
        ((AbstractTextField) field).setNullRepresentation("");
        ((AbstractTextField) field).setNullSettingAllowed(true);
        ((AbstractTextField) field).setImmediate(true);
    }
}
项目:hypothesis    文件:ComponentDataFactoryImpl.java   
private void writeValue(Element element, AbstractComponent field) {
    final Element valueElement = element.createChild(DocumentConstants.VALUE);

    if (field instanceof ComboBox) {
        ComboBox comboBox = (ComboBox) field;

        if (comboBox.getValue() != null) {
            valueElement.setAttribute(DocumentConstants.ID, (String) comboBox.getValue());
            valueElement.setText(comboBox.getItemCaption(comboBox.getValue()));
        }
    } else if (field instanceof DateField) {
        DateField dateField = (DateField) field;

        if (dateField.getValue() != null) {
            Date date = dateField.getValue();
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            valueElement.setText(format.format(date));
        }
    } else if (field instanceof SelectPanel) {
        SelectPanel selectPanel = (SelectPanel) field;

        selectPanel.getSelectedButtons().forEach(e -> {
            Element currentElement = valueElement != null ? valueElement
                    : element.createChild(DocumentConstants.VALUE);
            currentElement.setAttribute(DocumentConstants.ID, selectPanel.getChildIndex(e) + 1);
            currentElement.setText(e.getCaption());
        });
    } else if (field instanceof AbstractTextField) {
        valueElement.setText(((AbstractTextField) field).getValue());
    }
}
项目:scoutmaster    文件:SimpleFormLayout.java   
private void addDynamicValidation(AbstractField<?> field)
{
    if (field instanceof AbstractTextField)
    {
        ((AbstractTextField) field).addTextChangeListener(listener -> {
            validate(field);
        });

        ((AbstractTextField) field).addBlurListener(listener -> {
            validate(field);
        });
    }
    else if (field instanceof ComboBox)
    {
        ((ComboBox) field).addBlurListener(listener -> {
            validate(field);
        });
        field.addValueChangeListener(listener -> {
            validate(field);
        });
    }
    else
    {
        field.addValueChangeListener(listener -> {
            validate(field);
        });
    }

}
项目:textfieldformatter    文件:IBANFormatter.java   
public IBANFormatter(AbstractTextField field, int[] blocks) {
    super(field, blocks, ForceCase.UPPER);
}
项目:textfieldformatter    文件:AbstractTextFieldFormatterExtension.java   
public AbstractTextFieldFormatterExtension(AbstractTextField field) {
    extend(field);
}
项目:textfieldformatter    文件:NumeralFieldFormatter.java   
public NumeralFieldFormatter(AbstractTextField field, String delimiter, String decimalMark, int decimalScale) {
    this(field, delimiter, decimalMark, UNDEFINED_INTEGER_SCALE, decimalScale, false);
}
项目:textfieldformatter    文件:CreditCardFieldFormatter.java   
public CreditCardFieldFormatter(AbstractTextField field) {
    super(field);
    getState().formatCreditCard = true;
}
项目:textfieldformatter    文件:CustomStringBlockFormatter.java   
public CustomStringBlockFormatter(AbstractTextField field, int[] blocks, ForceCase forceCase) {
    this(field, blocks, null, forceCase);
}
项目:textfieldformatter    文件:CustomStringBlockFormatter.java   
public CustomStringBlockFormatter(AbstractTextField field, int[] blocks) {
    this(field, blocks, null, ForceCase.NONE);
}
项目:textfieldformatter    文件:PhoneFieldFormatter.java   
public PhoneFieldFormatter(AbstractTextField field, String phoneRegionCode) {
    super(field);
    getState().formatPhone = true;
    getState().phoneRegionCode = phoneRegionCode;
}
项目:Vaadin-AutocompleteTextField    文件:AutocompleteEvents.java   
public SelectEvent(AbstractTextField source, AutocompleteSuggestion suggestion) {
    super(source);
    this.suggestion = suggestion;
}
项目:Vaadin-AutocompleteTextField    文件:AutocompleteEvents.java   
@Override
public AbstractTextField getComponent() {
    return (AbstractTextField) super.getComponent();
}
项目:Vaadin-AutocompleteTextField    文件:AutocompleteTextFieldExtension.java   
@Override
public AbstractTextField getParent() {
    return (AbstractTextField) super.getParent();
}
项目:Vaadin-AutocompleteTextField    文件:AutocompleteTextFieldExtension.java   
@Override
protected Class<? extends AbstractTextField> getSupportedParentType() {
    return AbstractTextField.class;
}
项目:jain-I18n    文件:I18NFieldHandler.java   
public I18NFieldHandler(final AbstractTextField component) {
    super(component);
    this.i18NInputPrompt = component.getInputPrompt(); 
    this.i18NRequiredError = component.getRequiredError();
}
项目:Plugins    文件:DistributionMetadataVaadinDialog.java   
@Override
protected void buildDialogLayout() {
    // common part: create layout
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");
    binder = new BeanFieldGroup<DistributionMetadataConfig_V1>(DistributionMetadataConfig_V1.class);
    DistributionMetadataConfig_V1 config = new DistributionMetadataConfig_V1();
    binder.setItemDataSource(config);
    for (Field f : DistributionMetadataConfig_V1.class.getDeclaredFields()) {
        Component component = null;
        if ("description".equals(f.getName())) {
            component = binder.buildAndBind(ctx.tr(this.getClass().getSimpleName() + "." + f.getName() + ".caption"), f.getName(), TextArea.class);
        } else {
            component = binder.buildAndBind(ctx.tr(this.getClass().getSimpleName() + "." + f.getName() + ".caption"), f.getName());
        }
        component.setSizeFull();
        if (AbstractTextField.class.isAssignableFrom(component.getClass())) {
            ((AbstractTextField) component).setInputPrompt(ctx.tr(this.getClass().getSimpleName() + "." + f.getName() + ".inputPrompt"));
            ((AbstractTextField) component).setNullRepresentation("");
            if (URI.class.isAssignableFrom(f.getType())) {
                ((AbstractTextField) component).setConverter(new StringToUriConverter());
                ((AbstractTextField) component).setConversionError(ctx.tr("DistributionMetadataVaadinDialog.exception.uri.conversion"));
            }
        }

        if (Validatable.class.isAssignableFrom(component.getClass())) {
            if (URI.class.isAssignableFrom(f.getType())) {
                ((Validatable) component).addValidator(new UrlValidator(true, ctx.getDialogMasterContext().getDialogContext().getLocale()));
            }
        }
        if (AbstractComponent.class.isAssignableFrom(component.getClass())) {
            ((AbstractComponent) component).setImmediate(true);
            ((AbstractComponent) component).setLocale(ctx.getDialogMasterContext().getDialogContext().getLocale());
        }
        if (DateField.class.isAssignableFrom(component.getClass())) {
            ((DateField) component).setParseErrorMessage(ctx.tr("DistributionMetadataVaadinDialog.exception.date.conversion"));
        }
        mainLayout.addComponent(component);
    }
    setCompositionRoot(mainLayout);
}
项目:viritin    文件:FluentTextField.java   
public default S addTextChangeListener(HasValue.ValueChangeListener<String> l) {
    ((AbstractTextField) this).addValueChangeListener(l);
    ((AbstractTextField) this).setValueChangeMode(ValueChangeMode.LAZY);
    return (S) this;
}
项目:abstractform    文件:VaadinBindingFormInstanceImpl.java   
@Override
public void refreshValidationSummary() {
    validationSummaryComponent.removeAllComponents();
    for (ValidationError error : validationErrosSummaryList) {
        if (error != null) {
            Component errorComponent = null;
            if (error.getFieldId() != null) {
                errorComponent = getComponentById(error.getFieldId());
            }
            if (errorComponent != null) {
                HorizontalLayout layout = new HorizontalLayout();
                if (errorComponent instanceof AbstractField) {
                    final AbstractField component = (AbstractField) errorComponent;
                    Button but = new Button(errorComponent.getCaption());
                    but.setStyleName(BaseTheme.BUTTON_LINK);

                    but.addListener(new Button.ClickListener() {

                        private static final long serialVersionUID = -635674369175495232L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            component.focus();
                            if (component instanceof AbstractField) {
                                AbstractTextField field = (AbstractTextField) component;
                                field.selectAll();
                            }
                        }
                    });
                    layout.addComponent(but);
                } else {
                    layout.addComponent(new Label(errorComponent.getCaption()));
                }
                layout.addComponent(new Label(" : " + error.getMessage()));
                validationSummaryComponent.addComponent(layout);

            } else {
                validationSummaryComponent.addComponent(new Label(error.getMessage()));
            }
        }
    }

}
项目:textfieldformatter    文件:NumeralFieldFormatter.java   
/**
 * Creates a field formatter for numeral fields.
 *
 * @param field
 *            TextField to be extended
 * @param delimiter
 *            Delimiter for integer groups
 * @param decimalMark
 *            Delimiter for decimal
 * @param integerScale
 *            Limit the scale of integer
 * @param decimalScale
 *            Number of decimals
 * @param nonNegativeOnly
 *            True: allow only non-negative numbers. False: Allow negative,
 *            0 and positive.
 */
public NumeralFieldFormatter(AbstractTextField field, String delimiter, String decimalMark, int integerScale,
        int decimalScale, boolean nonNegativeOnly) {
    super(field);
    getState().formatNumeral = true;
    getState().delimiter = delimiter;
    getState().numeralDecimalMark = decimalMark;
    if (integerScale != -1) {
        getState().numeralIntegerScale = integerScale;
    }
    getState().numeralDecimalScale = decimalScale;
    getState().numeralPositiveOnly = nonNegativeOnly;
}
项目:metasfresh-procurement-webui    文件:JavascriptUtils.java   
/**
 * Inject a JavaScript code snippet which will select the text content when the text field gains focus.
 * 
 * Please keep in mind:
 * <ul>
 * <li>This function requires {@link #RESOURCE_JQuery}.
 * <li><code>component</code> has to have the ID set.
 * </ul>
 * 
 * @param component
 */
public static void enableSelectAllOnFocus(final AbstractTextField component)
{
    Preconditions.checkNotNull(component, "component is null");

    final String componentId = component.getId();
    Preconditions.checkNotNull(componentId, "componentId is null");

    Page.getCurrent().getJavaScript().execute("$('#" + componentId + "').focus(function(){$(this).select();});");
}