List of usage examples for com.vaadin.ui AbstractField setId
@Override public void setId(String id)
From source file:com.yoncabt.ebr.ui.ReportWindow.java
private void showFields(ReportDefinition definition, final Window w, final FormLayout fl) throws AssertionError, JSONException { fl.removeAllComponents();/*from w w w. ja v a 2 s . c o m*/ w.setCaption(definition.getCaption()); for (ReportParam param : definition.getReportParams()) { AbstractField comp = null; if (param.getInputType() == InputType.COMBO) { ComboBox f = new ComboBox(param.getLabel()); param.getLovData().forEach((k, v) -> { f.addItem(k); f.setItemCaption(k, (String) v); }); comp = f; } else { switch (param.getFieldType()) { case STRING: { TextField f = new TextField(param.getLabel()); comp = f; break; } case INTEGER: { TextField f = new TextField(param.getLabel()); f.addValidator(new IntegerRangeValidator("Say kontrol", (Integer) param.getMin(), (Integer) param.getMax())); comp = f; break; } case LONG: { TextField f = new TextField(param.getLabel()); f.addValidator(new LongRangeValidator("Say kontrol", (Long) param.getMin(), (Long) param.getMax())); comp = f; break; } case DOUBLE: { TextField f = new TextField(param.getLabel()); f.addValidator(new DoubleRangeValidator("Say kontrol", (Double) param.getMin(), (Double) param.getMax())); comp = f; break; } case DATE: { DateField f = new DateField(param.getLabel()); f.setDateFormat(param.getFormat()); comp = f; break; } default: { throw new AssertionError(param.getName() + " in tipi tannmyor :" + param.getJavaType()); } } } if (param.getDefaultValue() != null) { comp.setValue(param.getDefaultValue()); } comp.setImmediate(true); comp.setValidationVisible(false); comp.setId(param.getName()); fl.addComponent(comp); } if (report instanceof SQLReport) { reportType.addItem(ReportOutputFormat.xls); reportType.setItemCaption(ReportOutputFormat.xls, ReportOutputFormat.xls.getTypeName()); } else { for (ReportOutputFormat value : ReportOutputFormat.values()) { reportType.addItem(value); reportType.setItemCaption(value, value.getTypeName()); } } reportType.setValue(ReportOutputFormat.xls); fl.addComponent(reportType); fl.addComponent(reportLocale); fl.addComponent(email); }
From source file:org.vaadin.addons.javaee.fields.factory.GlobalFieldFactory.java
License:Apache License
public void configureTableField(Object itemId, Object propertyId, AbstractField<?> field, String entityName) { field.setId(entityName + ":" + itemId + ":" + propertyId); field.setImmediate(true);//from ww w . j a v a2s . com }
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;/*from w w w . j av a 2 s . co m*/ 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; }