List of usage examples for com.vaadin.ui AbstractField addValueChangeListener
@Override
public Registration addValueChangeListener(ValueChangeListener<T> listener)
From source file:fr.amapj.view.engine.popup.formpopup.validator.ValidatorHolder.java
License:Open Source License
/** * Retourne une liste vide si tout est ok, sinon retourne une liste de message d'erreur * @return/* w ww. j ava 2s . co m*/ */ public List<String> validate() { errorMessage = new ArrayList<>(); Object value = f.getValue(); validator.performValidate(value, this); if (errorMessage.size() > 0) { String str = computeHtml(); f.setComponentError(new UserError(str, ContentMode.HTML, ErrorLevel.ERROR)); if (validator.canCheckOnFly()) { f.addValueChangeListener(e -> handleValueChange()); AbstractField[] fields = validator.revalidateOnChangeOf(); if (fields != null) { for (AbstractField field : fields) { field.addValueChangeListener(e -> handleValueChange()); } } } } return errorMessage; }
From source file:info.magnolia.configuration.app.overview.toolbar.ToolbarViewImpl.java
License:Open Source License
private void initFilterInputProperties(AbstractField component) { component.setImmediate(true);/*w w w.jav a2 s . c o m*/ component.addValueChangeListener(filterChangeListener); if (component instanceof AbstractSelect) { component.addStyleName("filter-input"); component.setWidth("160px"); final AbstractSelect select = (AbstractSelect) component; select.setNullSelectionAllowed(true); } }
From source file:org.eclipse.hawkbit.ui.common.CommonDialogWindow.java
License:Open Source License
/** * adds a listener to a component. Depending on the type of component a * valueChange-, textChange- or itemSetChangeListener will be added. *//*w w w. jav a2 s . c om*/ public void addComponentListeners() { // avoid duplicate registration removeListeners(); for (final AbstractField<?> field : allComponents) { if (field instanceof TextChangeNotifier) { ((TextChangeNotifier) field).addTextChangeListener(new ChangeListener(field)); } if (field instanceof Table) { ((Table) field).addItemSetChangeListener(new ChangeListener(field)); } field.addValueChangeListener(new ChangeListener(field)); } }
From source file:org.eclipse.hawkbit.ui.common.CommonDialogWindow.java
License:Open Source License
/** * Adds the component manually to the allComponents-List and adds a * ValueChangeListener to it. Necessary in Update Distribution Type as the * CheckBox concerned is an ItemProperty... * * @param component//from w w w . ja v a 2s . com * AbstractField */ public void updateAllComponents(final AbstractField<?> component) { allComponents.add(component); component.addValueChangeListener(new ChangeListener(component)); }
From source file:org.vaadin.tori.component.AuthoringComponent.java
License:Apache License
private AbstractField<String> buildEditor() { AbstractField<String> result = null; if (Page.getCurrent().getWebBrowser().isAndroid()) { result = new TextArea(); } else {// w w w. j av a 2 s . c om result = new BBCodeWysiwygEditor(true, true); result.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { if (!ignoreInputChanges) { listener.inputValueChanged(editor.getValue()); } } }); ((BBCodeWysiwygEditor) result).addBlurListener(new BlurListener() { @Override public void blur(final BlurEvent event) { UI.getCurrent().setPollInterval(ToriUI.DEFAULT_POLL_INTERVAL); } }); ((BBCodeWysiwygEditor) result).addFocusListener(new FocusListener() { @Override public void focus(final FocusEvent event) { UI.getCurrent().setPollInterval(3000); } }); } result.setSizeFull(); return result; }
From source file:uk.q3c.krail.core.user.opt.DefaultOptionPopup.java
License:Apache License
@Override public void popup(@Nonnull OptionContext context, I18NKey windowCaption) { // changing context, so we need to clear the context fields if (context != activeContext) { contextFields = null;// ww w . j av a 2s.c om if (window != null) { window.close(); } } Option option = context.getOption(); window = new Window(); window.setCaption(windowCaption(windowCaption)); Map<OptionKey, Class<?>> keys = contextKeys(context); GridLayout baseLayout = new GridLayout(2, keys.size()); baseLayout.setSizeUndefined(); if (keys.size() == 0) { Label label = new Label(translate.from(LabelKey.No_Options_to_Show)); baseLayout.addComponent(label, 0, 0); } else { calculateWindowSize(window, keys.size()); int row = 0; for (OptionKey key : keys.keySet()) { Object value = option.get(key); AbstractField uiField = dataTypeToUI.componentFor(value); uiField.setCaption(translate.from(key.getKey())); uiField.setDescription(translate.from(key.getDescriptionKey())); uiField.setId(ID.getId(Optional.of(((Enum) key.getKey()).name()), this, uiField)); log.debug("Component id for '{}' set to: '{}'", uiField.getCaption(), uiField.getId()); //noinspection unchecked uiField.setValue(value); uiField.addValueChangeListener(event -> { option.set(uiField.getValue(), key); context.optionValueChanged(event); }); Button defaultsButton = new Button(translate.from(LabelKey.Reset_to_Default)); defaultsButton.setId(ID.getId(Optional.of(((Enum) key.getKey()).name()), this, defaultsButton)); defaultsButton.addClickListener((event -> { option.delete(0, key); //we create an event to represent the field which whose value will be affected by this change AbstractField.ValueChangeEvent changeEvent = new AbstractField.ValueChangeEvent(uiField); context.optionValueChanged(changeEvent); //update the value of the field - it may have changed uiField.setValue(option.get(key)); })); baseLayout.addComponent(new FormLayout(uiField), 0, row); baseLayout.addComponent(new FormLayout(defaultsButton), 1, row); row++; } } window.setId(ID.getId(Optional.empty(), context, this, window)); window.setClosable(true); window.setContent(baseLayout); window.center(); UI.getCurrent().addWindow(window); this.activeContext = context; }