List of usage examples for com.vaadin.ui AbstractField setDescription
public void setDescription(String description)
From source file:nz.co.senanque.vaadinsupport.HintsImpl.java
License:Apache License
public void setCommonProperties(final AbstractField ret, final MaduraPropertyWrapper property, final MessageSource messageSource) { ret.setWidth(getWidth());/*from ww w . j a v a 2s. c o m*/ ret.setReadThrough(true); ret.setPropertyDataSource(property); ret.setCaption(property.getLabel()); ret.setRequired(property.isRequired()); if (property.isRequired()) { ret.setInvalidCommitted(true); } if (property.isReadOnly()) { ret.setReadOnly(true); } ret.setEnabled(property.isEnabled()); ret.setVisible(property.isVisible()); ret.setImmediate(m_forceImmediate); ret.setLocale(LocaleContextHolder.getLocale()); MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource); ret.setDescription( messageSourceAccessor.getMessage(property.getDescription(), null, property.getDescription())); if (property.isNumeric()) { ret.addStyleName("v-textfield-align-right"); } ret.setErrorHandler(new ComponentErrorHandler() { private static final long serialVersionUID = -1393935533100204195L; public boolean handleComponentError(ComponentErrorEvent event) { Throwable t = event.getThrowable(); while (t != null) { if (t instanceof ValidationException) { ret.setComponentError(new UserError(((ValidationException) t).getMessage())); return true; } t = t.getCause(); } return false; } }); }
From source file:nz.co.senanque.vaadinsupport.TouchkitHintsImpl.java
License:Apache License
public void setCommonProperties(final AbstractField ret, final MaduraPropertyWrapper property, final MessageSource messageSource) { ret.setWidth(getWidth());/*ww w .ja v a2 s.c om*/ ret.setReadThrough(true); ret.setPropertyDataSource(property); ret.setCaption(property.getLabel()); ret.setRequired(property.isRequired()); if (property.isRequired()) { ret.setInvalidCommitted(true); } ret.setReadOnly(property.isReadOnly()); ret.setEnabled(property.isEnabled()); ret.setVisible(property.isVisible()); ret.setImmediate(m_forceImmediate); ret.setLocale(LocaleContextHolder.getLocale()); MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource); ret.setDescription( messageSourceAccessor.getMessage(property.getDescription(), null, property.getDescription())); if (property.isNumeric()) { ret.addStyleName("v-textfield-align-right"); } ret.setErrorHandler(new ComponentErrorHandler() { private static final long serialVersionUID = -1393935533100204195L; public boolean handleComponentError(ComponentErrorEvent event) { Throwable t = event.getThrowable(); while (t != null) { if (t instanceof ValidationException) { ret.setComponentError(new UserError(((ValidationException) t).getMessage())); return true; } t = t.getCause(); } return false; } }); }
From source file:org.opencms.ui.apps.scheduler.CmsJobEditView.java
License:Open Source License
/** * Binds the given component to the given bean property.<p> * * @param field the component//from ww w .j a va2 s .com * @param property the bean property */ void bindField(AbstractField<?> field, String property) { m_group.bind(field, property); field.setCaption(CmsVaadinUtils.getMessageText("label." + property)); field.setDescription(CmsVaadinUtils.getMessageText("label." + property + ".help")); }
From source file:uk.q3c.krail.core.option.DefaultOptionPopup.java
License:Apache License
private void setFieldMetaData(OptionKey<?> key, AbstractField<?> uiField) { uiField.setCaption(translate.from(key.getKey())); uiField.setDescription(translate.from(key.getDescriptionKey())); // Optional<String> optionKeyName = Optional.of(((Enum) key.getKey()).name()); // uiField.setId(ID.getId(optionKeyName, this, uiField)); // log.debug("Component id for '{}' set to: '{}'", uiField.getCaption(), uiField.getId()); }
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;// w ww.ja v a 2 s .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; }