当前位置: 首页>>代码示例>>Java>>正文


Java Field类代码示例

本文整理汇总了Java中com.vaadin.ui.Field的典型用法代码示例。如果您正苦于以下问题:Java Field类的具体用法?Java Field怎么用?Java Field使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Field类属于com.vaadin.ui包,在下文中一共展示了Field类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderTemporal

import com.vaadin.ui.Field; //导入依赖的package包/类
/**
 * Renders a Temporal value type Field
 * @param property Property to render
 * @return Field instance
 */
@SuppressWarnings("unchecked")
protected Field<T> renderTemporal(Property<T> property) {

	TemporalInputBuilder builder = null;

	if (LocalDate.class.isAssignableFrom(property.getType())) {
		builder = input.localDate(false);
	} else if (LocalDateTime.class.isAssignableFrom(property.getType())) {
		builder = input.localDateTime(false);
	} else {
		throw new UnsupportedTemporalTypeException(
				"Temporal type " + property.getType().getName() + " is not supported by default field renderer");
	}

	final TemporalInputBuilder<Temporal, ?> b = builder;

	// set locale from LocalizationContext, if any
	LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap((c) -> c.getLocale())
			.ifPresent((l) -> b.locale(l));

	return postProcessField(b.asField(), property);
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:28,代码来源:DefaultFieldPropertyRenderer.java

示例2: buildAndBind

import com.vaadin.ui.Field; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Field<?> buildAndBind(Object propertyId) throws BindException {
	// If property is a Property, try to render Field using UIContext
	if (propertyId != null && Property.class.isAssignableFrom(propertyId.getClass())) {
		Field<?> field = renderField((P) propertyId).map((f) -> {
			setupField((P) propertyId, f);
			if (f instanceof CheckBox)
				f.setCaption(null);
			bind(f, propertyId);
			return f;
		}).orElse(null);
		if (field != null) {
			return field;
		}
	}
	return super.buildAndBind(propertyId);
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:19,代码来源:DefaultItemListing.java

示例3: build

import com.vaadin.ui.Field; //导入依赖的package包/类
@Override
public ValidatableInput<T> build() {
	// check required
	if (required) {
		if (input instanceof RequiredIndicatorSupport) {
			((RequiredIndicatorSupport) input).setRequiredIndicatorVisible(true);
		} else {
			// fallback to default required setup
			if (input instanceof Field) {
				((Field<?>) input).setRequired(true);
			} else if (input.getComponent() != null && input.getComponent() instanceof Field) {
				((Field<?>) input.getComponent()).setRequired(true);
			}
		}
		// add required validator
		instance.addValidator(getRequiredValidator().orElse(new RequiredInputValidator<>(input,
				getRequiredMessage().orElse(RequiredInputValidator.DEFAULT_REQUIRED_ERROR))));
	}
	return instance;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:21,代码来源:DefaultValidatableInputBuilder.java

示例4: getField

import com.vaadin.ui.Field; //导入依赖的package包/类
/**
 * Renvoie le field construit
 * 
 * @param fieldName
 * @return
 */
private Field<?> getField(String fieldName) {
	String caption = applicationContext.getMessage("formation.table." + fieldName, null,
			UI.getCurrent().getLocale());
	Field<?> field;
	if (fieldName.equals(Formation_.motCleForm.getName())) {
		field = fieldGroup.buildAndBind(caption, fieldName, RequiredTextArea.class);
	} /*
		 * else if (fieldName.equals(Formation_.i18nInfoCompForm.getName())){ field =
		 * fieldGroup.buildAndBind(caption, fieldName, I18nField.class); }
		 */else if (fieldName.equals(Formation_.codEtpVetApoForm.getName())
			|| fieldName.equals(Formation_.codVrsVetApoForm.getName())
			|| fieldName.equals(Formation_.libApoForm.getName())) {
		if (parametreController.getIsFormCodApoOblig()) {
			field = fieldGroup.buildAndBind(caption, fieldName, true);
		} else {
			field = fieldGroup.buildAndBind(caption, fieldName);
		}
		field.setEnabled(false);
	} else {
		field = fieldGroup.buildAndBind(caption, fieldName);
	}

	field.setWidth(100, Unit.PERCENTAGE);
	return field;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:32,代码来源:CtrCandFormationWindow.java

示例5: createField

import com.vaadin.ui.Field; //导入依赖的package包/类
/**
 * @see com.vaadin.data.fieldgroup.DefaultFieldGroupFieldFactory#createField(java.lang.Class, java.lang.Class)
 */
@SuppressWarnings("rawtypes")
@Override
public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) {
	/*Le type du champs est un entier*/
	if (fieldType==RequiredIntegerField.class){	
		return fieldType.cast(new RequiredIntegerField());
	}
	/*La valeur est siScolPays*/
	else if (dataType==SiScolPays.class){
		return fieldType.cast(new ComboBoxPays(cacheController.getListePays().stream().filter(e->e.getTemEnSvePay()).collect(Collectors.toList()),applicationContext.getMessage("adresse.siScolPays.suggest", null,  UI.getCurrent().getLocale())));
	}	
	/*La valeur est SiScolCommune*/
	else if (dataType==SiScolCommune.class){
		return fieldType.cast(new ComboBoxCommune(applicationContext.getMessage("adresse.commune.suggest", null,  UI.getCurrent().getLocale())));
	}
	
	/*Sinon, le champs est un simple TextField*/
	else{	
		return fieldType.cast(new RequiredTextField());
	}
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:25,代码来源:CustomFieldGroupFieldFactoryAdr.java

示例6: buildAndBind

import com.vaadin.ui.Field; //导入依赖的package包/类
/**  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;
   }
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:24,代码来源:CustomBeanFieldGroup.java

示例7: getPropertyValue

import com.vaadin.ui.Field; //导入依赖的package包/类
@Override
protected Object getPropertyValue(Object rowId, Object colId,
                                  Property property) {
    if (isColumnEditable(colId, isEditable()) && fieldFactory != null) {
        final Field<?> f = fieldFactory.createField(
                getContainerDataSource(), rowId, colId, this);
        if (f != null) {
            // Remember that we have made this association so we can remove
            // it when the component is removed
            associatedProperties.put(f, property);
            if (autowirePropertyDsForFields) {
                bindPropertyToField(rowId, colId, property, f);
            }
            return f;
        }
    }

    return formatPropertyValue(rowId, colId, property);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:CubaTreeTable.java

示例8: doEditItem

import com.vaadin.ui.Field; //导入依赖的package包/类
@Override
protected void doEditItem() {
    clearFields(editorFields);

    Map<Column, Field> columnFieldMap = new HashMap<>();
    for (Column column : getColumns()) {
        Field<?> field = editorFieldFactory.createField(editedItemId, column.getPropertyId());
        column.getState().editorConnector = field;
        if (field != null) {
            configureField(field);
            editorFields.add(field);
            columnFieldMap.put(column, field);
        }
    }

    editorActive = true;
    // Must ensure that all fields, recursively, are sent to the client
    // This is needed because the fields are hidden using isRendered
    for (Field<?> f : getEditorFields()) {
        f.markAsDirtyRecursive();
    }

    fireEditorOpenEvent(columnFieldMap);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:CubaGrid.java

示例9: commitEditor

import com.vaadin.ui.Field; //导入依赖的package包/类
protected void commitEditor() throws FieldGroup.CommitException {
    if (!isEditorBuffered()) {
        // Not using buffered mode, nothing to do
        return;
    }
    try {
        fireEditorPreCommitEvent();

        Map<Field<?>, Validator.InvalidValueException> invalidValueExceptions = commitFields();
        if (invalidValueExceptions.isEmpty()) {
            fireEditorPostCommitEvent();
        } else {
            throw new FieldGroup.FieldGroupInvalidValueException(invalidValueExceptions);
        }
    } catch (Exception e) {
        throw new FieldGroup.CommitException("Commit failed", null, e);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:CubaGrid.java

示例10: setFormProperties

import com.vaadin.ui.Field; //导入依赖的package包/类
public void setFormProperties(List<FormProperty> formProperties) {
  this.formProperties = formProperties;
  
  form.removeAllProperties();
  
  // Clear current components in the grid
  if(formProperties != null) {
    for(FormProperty formProperty : formProperties) {
      FormPropertyRenderer renderer = getRenderer(formProperty);
     
      Field editorComponent = renderer.getPropertyField(formProperty);
      if(editorComponent != null) {
        // Get label for editor component.
        form.addField(formProperty.getId(), editorComponent);
      }
    }
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:19,代码来源:FormPropertiesComponent.java

示例11: getFormPropertyValues

import com.vaadin.ui.Field; //导入依赖的package包/类
/**
 * Returns all values filled in in the writable fields on the form.
 * 
 * @throws InvalidValueException when a validation error occurs.
 */
public Map<String, String> getFormPropertyValues() throws InvalidValueException {
  // Commit the form to ensure validation is executed
  form.commit();
  
  Map<String, String> formPropertyValues = new HashMap<String, String>();
  
  // Get values from fields defined for each form property
  for(FormProperty formProperty : formProperties) {
    if(formProperty.isWritable()) {
      Field field = form.getField(formProperty.getId());
      FormPropertyRenderer renderer = getRenderer(formProperty);
      String fieldValue = renderer.getFieldValue(formProperty, field);
      
      formPropertyValues.put(formProperty.getId(), fieldValue);
    }
  }
  return formPropertyValues;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:24,代码来源:FormPropertiesComponent.java

示例12: getPropertyField

import com.vaadin.ui.Field; //导入依赖的package包/类
@Override
public Field getPropertyField(FormProperty formProperty) {
  final TextField textField = new TextField(getPropertyLabel(formProperty));
  textField.setRequired(formProperty.isRequired());
  textField.setEnabled(formProperty.isWritable());
  textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
  
  if (formProperty.getValue() != null) {
    textField.setValue(formProperty.getValue());
  }

  // Add validation of numeric value
  textField.addValidator(new LongValidator("Value must be a long"));
  textField.setImmediate(true);

  return textField;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:18,代码来源:LongFormPropertyRenderer.java

示例13: getPropertyField

import com.vaadin.ui.Field; //导入依赖的package包/类
@Override
public Field getPropertyField(FormProperty formProperty) {
  // Writable string
  PopupDateField dateField = new PopupDateField(getPropertyLabel(formProperty));
  String datePattern = (String) formProperty.getType().getInformation("datePattern");
  dateField.setDateFormat(datePattern);
  dateField.setRequired(formProperty.isRequired());
  dateField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
  dateField.setEnabled(formProperty.isWritable());

  if (formProperty.getValue() != null) {
    // Try parsing the current value
    SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern);

    try {
      Date date = dateFormat.parse(formProperty.getValue());
      dateField.setValue(date);
    } catch (ParseException e) {
      // TODO: what happens if current value is illegal date?
    }
  }
  return dateField;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:24,代码来源:DateFormPropertyRenderer.java

示例14: getPropertyField

import com.vaadin.ui.Field; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Field getPropertyField(FormProperty formProperty) {
  ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty));
  comboBox.setRequired(formProperty.isRequired());
  comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
  comboBox.setEnabled(formProperty.isWritable());

  Map<String, String> values = (Map<String, String>) formProperty.getType().getInformation("values");
  if (values != null) {
    for (Entry<String, String> enumEntry : values.entrySet()) {
      // Add value and label (if any)
      comboBox.addItem(enumEntry.getKey());
      if (enumEntry.getValue() != null) {
        comboBox.setItemCaption(enumEntry.getKey(), enumEntry.getValue());
      }
    }
  }
  return comboBox;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:21,代码来源:EnumFormPropertyRenderer.java

示例15: buildAndBindField

import com.vaadin.ui.Field; //导入依赖的package包/类
@Override
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
    Field<?> field = super.buildAndBindField(label, propId, prop);
    
    if (propId.equals(PROP_SERVLET_ROOT))
    {
        field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 2, 256, false));
    }
    else if (propId.equals(PROP_HTTP_PORT))
    {
        field.setWidth(100, Unit.PIXELS);
        //((TextField)field).getConverter().
        field.addValidator(new Validator() {
            private static final long serialVersionUID = 1L;
            public void validate(Object value) throws InvalidValueException
            {
                int portNum = (Integer)value;
                if (portNum > 10000 || portNum <= 80)
                    throw new InvalidValueException("Port number must be an integer number greater than 80 and lower than 10000");
            }
        });
    }
    
    return field;
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:27,代码来源:HttpServerConfigForm.java


注:本文中的com.vaadin.ui.Field类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。