List of usage examples for com.vaadin.ui AbstractField setValue
@Override public void setValue(T value)
From source file:com.klwork.explorer.ui.user.ProfilePanel.java
License:Apache License
protected void addProfileInputField(GridLayout layout, String name, AbstractField inputField, String inputFieldValue) { Label label = new Label(name + ": "); label.addStyleName(ExplorerLayout.STYLE_PROFILE_FIELD); label.setSizeUndefined();//from w w w . j a va 2 s . c o m layout.addComponent(label); layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); if (inputFieldValue != null) { inputField.setValue(inputFieldValue); } layout.addComponent(inputField); layout.setComponentAlignment(inputField, Alignment.MIDDLE_LEFT); }
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 ww w. j av a2s . com*/ 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:fr.amapj.view.engine.popup.formpopup.fieldlink.FieldLink.java
License:Open Source License
private void valueChanged() { boolean actif = isActif(); for (AbstractField<?> field : fields) { // Activation - desactivation if (field instanceof CKEditorTextField) { // Attention : il y a un bug dans le wrapper ckeditor, le setEnabled ne fonctionne pas ((CKEditorTextField) field).setViewWithoutEditor(!actif); } else {//from w ww .ja va 2 s . com field.setEnabled(actif); } // Remise zro si ncessaire if (actif == false) { if (field instanceof TextField) { // Tres important : sinon la desactivation des IntegerTextField ne fonctionne pas ((TextField) field).setValue(""); } else { field.setValue(null); } } } // On passe ensuite aux FieldLink fils for (FieldLink child : childs) { child.valueChanged(); } }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.execution.ExecutionWizardStep.java
License:Apache License
private void updateValue(AbstractField field) { if (field.getData() != null) { //Look for the answer in the database getExecutionStep().getExecutionStepAnswerList().forEach(answer -> { if (answer.getFieldName().equals(field.getData())) { if (field instanceof AbstractTextField) {//This includes NumberField field.setValue(answer.getFieldAnswer()); } else if (field instanceof CheckBox) { field.setValue(answer.getFieldAnswer().equals("true")); }/*from w w w .jav a 2 s . co m*/ } }); } else { LOG.log(Level.SEVERE, "Field missing data! {0}", field); } }
From source file:org.eclipse.hawkbit.ui.common.CommonDialogWindow.java
License:Open Source License
private boolean isMandatoryFieldNotEmptyAndValid(final Component currentChangedComponent, final Object newValue) { boolean valid = true; final List<AbstractField<?>> requiredComponents = allComponents.stream().filter(AbstractField::isRequired) .filter(AbstractField::isEnabled).collect(Collectors.toList()); requiredComponents//from w w w. j a v a 2 s. c o m .addAll(allComponents.stream().filter(this::hasNullValidator).collect(Collectors.toList())); for (final AbstractField field : requiredComponents) { Object value = getCurrentValue(currentChangedComponent, newValue, field); if (Set.class.equals(field.getType())) { value = emptyToNull((Collection<?>) value); } if (value == null) { return false; } // We need to loop through all of components for validity testing. // Otherwise the UI will only mark the first field with errors and // then stop. Setting the value is necessary because not all // required input fields have empty string validator, but emptiness // is checked during isValid() call. Setting the value could be // redundant, check if it could be removed in the future. field.setValue(value); if (!field.isValid()) { valid = false; } } return valid; }
From source file:org.jdal.vaadin.ui.bind.FieldAccessor.java
License:Apache License
/** * {@inheritDoc}/* w ww .j a v a 2s.c o m*/ */ @SuppressWarnings("unchecked") public void setControlValue(Object value) { AbstractField<Object> field = (AbstractField<Object>) getControl(); field.setValue(value); }
From source file:org.opencms.ui.CmsVaadinUtils.java
License:Open Source License
/** * Sets the value of a text field which may be set to read-only mode.<p> * * When setting a Vaadin field to read-only, you also can't set its value programmatically anymore. * So we need to temporarily disable read-only mode, set the value, and then switch back to read-only mode. * * @param field the field//from www .ja va2s . c o m * @param value the value to set */ public static <T> void setReadonlyValue(AbstractField<T> field, T value) { boolean readonly = field.isReadOnly(); try { field.setReadOnly(false); field.setValue(value); } finally { field.setReadOnly(readonly); } }
From source file:org.opennms.features.vaadin.dashboard.config.ui.editors.CriteriaRestrictionComponent.java
License:Open Source License
/** * This method refreshes the components. * * @param criteriaRestriction the new {@link CriteriaRestriction} * @param arr the values to be set *///w w w . ja v a2 s . c om private void refreshComponents(CriteriaRestriction criteriaRestriction, String[] arr) { for (AbstractComponent abstractComponent : m_componentList) { m_leftLayout.removeComponent(abstractComponent); } m_componentList.clear(); int i = 0; for (CriteriaEntry criteriaEntry : criteriaRestriction.getEntries()) { AbstractField abstractField = criteriaEntry.getComponent(m_criteriaBuilderHelper); if (arr != null && arr.length > i) { abstractField.setValue(arr[i]); } m_leftLayout.addComponent(abstractField); m_componentList.add(abstractField); i++; } }
From source file:org.vaadin.addons.javaee.form.BasicForm.java
License:Apache License
@SuppressWarnings("unchecked") public <ENTITY_TYPE> void addHiddenField(String fieldName, ENTITY_TYPE entity) { FieldSpecification fieldSpec = new FieldSpecification(fieldName); AbstractField<ENTITY_TYPE> field = (AbstractField<ENTITY_TYPE>) fieldGroup.getField(fieldName); if (field == null) { field = fieldFactory.createField(getContainer(), fieldSpec); fieldGroup.bind(field, fieldName); }//from ww w. j a v a 2s . c o m field.setValue(entity); }
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 ww w . ja v 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; }