Java 类com.vaadin.ui.Field 实例源码

项目:holon-vaadin7    文件:DefaultFieldPropertyRenderer.java   
/**
 * 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);
}
项目:holon-vaadin7    文件:DefaultItemListing.java   
@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);
}
项目:holon-vaadin7    文件:DefaultValidatableInputBuilder.java   
@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;
}
项目:esup-ecandidat    文件:CtrCandFormationWindow.java   
/**
 * 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;
}
项目:esup-ecandidat    文件:CustomFieldGroupFieldFactoryAdr.java   
/**
 * @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());
    }
}
项目:esup-ecandidat    文件:CustomBeanFieldGroup.java   
/**  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;
   }
项目:cuba    文件:CubaTreeTable.java   
@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);
}
项目:cuba    文件:CubaTable.java   
@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);
}
项目:cuba    文件:CubaGrid.java   
@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);
}
项目:cuba    文件:CubaGrid.java   
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);
    }
}
项目:SecureBPMN    文件:FormPropertiesComponent.java   
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);
      }
    }
  }
}
项目:SecureBPMN    文件:FormPropertiesComponent.java   
/**
 * 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;
}
项目:SecureBPMN    文件:LongFormPropertyRenderer.java   
@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;
}
项目:SecureBPMN    文件:DateFormPropertyRenderer.java   
@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;
}
项目:SecureBPMN    文件:EnumFormPropertyRenderer.java   
@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;
}
项目:sensorhub    文件:HttpServerConfigForm.java   
@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;
}
项目:metl    文件:EditAgentParametersDialog.java   
public Field<?> createField(final Container dataContainer, final Object itemId, final Object propertyId, Component uiContext) {
    final AgentParameter parameter = (AgentParameter) itemId;
    final TextField textField = new ImmediateUpdateTextField(null) {
        protected void save(String text) {
            parameter.setValue(text);
            context.getConfigurationService().save(parameter);
        }
    };
    textField.setWidth(100, Unit.PERCENTAGE);
    textField.addFocusListener(new FocusListener() {
        public void focus(FocusEvent event) {
            table.select(itemId);
        }
    });
    return textField;
}
项目:metl    文件:DesignNavigator.java   
protected Field<?> buildEditableNavigatorField(Object itemId) {
    if (itemBeingEdited != null && itemBeingEdited.equals(itemId)) {
        final EnableFocusTextField field = new EnableFocusTextField();
        field.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        field.setImmediate(true);
        field.setWidth(95, Unit.PERCENTAGE);
        field.addFocusListener(e -> {
            field.setFocusAllowed(false);
            field.selectAll();
            field.setFocusAllowed(true);
        });
        field.focus();
        field.addShortcutListener(new ShortcutListener("Escape", KeyCode.ESCAPE, null) {

            @Override
            public void handleAction(Object sender, Object target) {
                abortEditingItem();
            }
        });
        field.addValueChangeListener(event -> finishEditingItem((String) event.getProperty().getValue()));
        field.addBlurListener(event -> abortEditingItem());
        return field;
    } else {
        return null;
    }
}
项目:mycollab    文件:ProjectRoleAddViewImpl.java   
@Override
protected AbstractBeanFieldGroupEditFieldFactory<ProjectRole> initBeanFormFieldFactory() {
    return new AbstractBeanFieldGroupEditFieldFactory<ProjectRole>(editForm) {
        private static final long serialVersionUID = 1L;

        @Override
        protected Field<?> onCreateField(Object propertyId) {
            if (propertyId.equals("description")) {
                final TextArea textArea = new TextArea();
                textArea.setNullRepresentation("");
                return textArea;
            } else if (propertyId.equals("rolename")) {
                final TextField tf = new TextField();
                if (isValidateForm) {
                    tf.setNullRepresentation("");
                    tf.setRequired(true);
                    tf.setRequiredError("Please enter a role name");
                }
                return tf;
            }
            return null;
        }
    };
}
项目:mycollab    文件:MeetingReadFormFieldFactory.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    SimpleMeeting meeting = attachForm.getBean();

    if (propertyId.equals("type")) {
        return new RelatedReadItemField(meeting);
    } else if (propertyId.equals("startdate")) {
        return new DateTimeViewField(meeting.getStartdate());
    } else if (propertyId.equals("enddate")) {
        return new DateTimeViewField(meeting.getEnddate());
    } else if (propertyId.equals("isrecurrence")) {
        return null;
    } else if (propertyId.equals("description")) {
        return new RichTextViewField(meeting.getDescription());
    } else if (MeetingWithBLOBs.Field.status.equalTo(propertyId)) {
        return new I18nFormViewField(meeting.getStatus(), CallStatus.class).withStyleName(UIConstants.FIELD_NOTE);
    }
    return null;
}
项目:field-binder    文件:AbstractFieldBinder.java   
/**
 * Build a field of the given type, for the given propertyId,
 * with the given caption,
 *
 */
public <T extends Field<?>> T build(Object propertyId, Class<T> fieldType) {
    Class<?> dataType = getPropertyType(propertyId);

    T field = getFieldFactory().createField(dataType, fieldType);
    if (field == null) {
        throw new BuildException("Unable to build a field of type "
                + fieldType.getName() + " for editing "
                + dataType.getName());
    }

    field.setCaption(createCaptionByPropertyId(propertyId));
    bind(field, propertyId);

    return field;
}
项目:field-binder    文件:AbstractFieldBinder.java   
/**
 * Build a field of the given type, for the given propertyId,
 * with the given caption,
 *
 */
public <T extends Field<?>> T build(String caption, Object propertyId, Class<T> fieldType) {
    Class<?> dataType = getPropertyType(propertyId);

    T field = getFieldFactory().createField(dataType, fieldType);
    if (field == null) {
        throw new BuildException("Unable to build a field of type "
                + fieldType.getName() + " for editing "
                + dataType.getName());
    }

    field.setCaption(caption);
    bind(field, propertyId);

    return field;
}
项目:FiWare-Template-Handler    文件:FormPropertiesComponent.java   
/**
 * 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;
}
项目:field-binder    文件:FieldBinderSearchFieldManager.java   
/**
 * replace the fields in the fieldbinder in this SearchFieldManager
 */
public void replaceFields() {
    makeSearchFieldsFromFieldBinder();

    for (Map.Entry<Object, SearchPatternField<?,?>> e : getPropertyIdToSearchPatternField().entrySet()) {
        Object propertyId = e.getKey();
        Field<?> replacement = e.getValue();
        Field<?> original = fieldBinder.getPropertyIdToFieldBindings().get(propertyId);

        // this should be moved somewhere else
        replacement.setCaption(original.getCaption());
        replacement.setWidth(original.getWidth(), original.getWidthUnits());

        replace(original, replacement);
    }
}
项目:mycollab    文件:AccountReadFormFieldFactory.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    SimpleAccount account = attachForm.getBean();

    if (propertyId.equals("email")) {
        return new EmailViewField(account.getEmail());
    } else if (propertyId.equals("assignuser")) {
        return new UserLinkViewField(account.getAssignuser(), account.getAssignUserAvatarId(), account.getAssignUserFullName());
    } else if (propertyId.equals("website")) {
        return new UrlLinkViewField(account.getWebsite());
    } else if (propertyId.equals("type")) {
        return new I18nFormViewField(account.getType(), AccountType.class);
    } else if (Account.Field.industry.equalTo(propertyId)) {
        return new I18nFormViewField(account.getIndustry(), AccountIndustry.class);
    } else if (propertyId.equals("description")) {
        return new RichTextViewField(account.getDescription());
    } else if (Account.Field.billingcountry.equalTo(propertyId)) {
        return new CountryViewField(account.getBillingcountry());
    } else if (Account.Field.shippingcountry.equalTo(propertyId)) {
        return new CountryViewField(account.getShippingcountry());
    }

    return null;
}
项目:vaadinator    文件:DefaultFieldInitializer.java   
@Override
public void initializeField(Component component, Component view) {
    if (view instanceof EagerValidatableView) {
        EagerValidatableView eagerValidatableView = (EagerValidatableView) view;
        if (component instanceof Field<?>) {
            ((AbstractComponent) component).setImmediate(true);
            ((Field<?>) component).addValueChangeListener(eagerValidatableView);
            if (component instanceof EagerValidateable) {
                ((EagerValidateable) component).setEagerValidation(true);
            }
            if (component instanceof TextChangeNotifier) {
                final TextChangeNotifier abstractTextField = (TextChangeNotifier) component;
                abstractTextField.addTextChangeListener(eagerValidatableView);
            }
        }
    }
}
项目:mycollab    文件:VersionEditFormFieldFactory.java   
@Override
protected Field<?> onCreateField(final Object propertyId) {
    if (Version.Field.name.equalTo(propertyId)) {
        final TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);
            tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext
                    .getMessage(GenericI18Enum.FORM_NAME)));
        }
        return tf;
    } else if (Version.Field.description.equalTo(propertyId)) {
        return new RichTextArea();
    } else if (Version.Field.duedate.equalTo(propertyId)) {
        final PopupDateFieldExt dateField = new PopupDateFieldExt();
        dateField.setResolution(Resolution.DAY);
        return dateField;
    }

    return null;
}
项目:ilves    文件:FieldDescriptor.java   
/**
 * Constructor for setting values of the FieldDefinition.
 * @param id ID of the field.
 * @param labelKey Localization key of the field.
 * @param fieldClass Field editor component or null.
 * @param converter Field converter.
 * @param width Width of the field.
 * @param valueAlignment Value vertical alignment.
 * @param valueType Type of the field value.
 * @param defaultValue Default value for field.
 * @param readOnly true if field is readonly.
 * @param sortable true if field is sortable.
 * @param required true if field is required.
 */
public FieldDescriptor(final String id, final String labelKey, final Class<? extends Field> fieldClass,
        final Converter<?,?> converter, final int width,
        final HorizontalAlignment valueAlignment, final Class<?> valueType,
        final Object defaultValue, final boolean readOnly, final boolean sortable, final boolean required) {
    super();
    this.id = id;
    this.labelKey = labelKey;
    this.width = width;
    this.valueType = valueType;
    this.defaultValue = defaultValue;
    this.fieldClass = fieldClass;
    this.converter = converter;
    this.readOnly = readOnly;
    this.sortable = sortable;
    this.required = required;
    if (valueAlignment != null) {
        this.valueAlignment = valueAlignment;
    }
}
项目:magnolia-handlebars    文件:SupplierPageSelectorFieldFactory.java   
@Override
protected AbstractSelect createFieldComponent() {

    final AbstractSelect supplierPageSelect = super.createFieldComponent();
    supplierPageSelect.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);

    final AbstractSelect templateSelect = findTemplateSelect();
    if (templateSelect == null) {
        throw new RuntimeException("Cannot find template ComboBox");
    }
    Property.ValueChangeListener listener = getValueChangeListener(templateSelect, supplierPageSelect);
    templateSelect.addValueChangeListener(listener);
    listener.valueChange(new Field.ValueChangeEvent(templateSelect));

    supplierPageSelect.setVisible(utils.requiresParentTemplate((String) templateSelect.getValue()));
    return supplierPageSelect;
}
项目:mycollab    文件:AccountReadFormFieldFactory.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    SimpleAccount account = attachForm.getBean();

    if (propertyId.equals("email")) {
        return new DefaultViewField(account.getEmail());
    } else if (propertyId.equals("assignuser")) {
        return new DefaultViewField(account.getAssignUserFullName());
    } else if (propertyId.equals("website")) {
        return new DefaultViewField(account.getWebsite());
    } else if (Account.Field.industry.equalTo(propertyId)) {
        return new I18nFormViewField(account.getIndustry(), AccountIndustry.class);
    }

    return null;
}
项目:mycollab    文件:CampaignReadFormFieldFactory.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    SimpleCampaign campaign = attachForm.getBean();

    if (propertyId.equals("assignuser")) {
        return new DefaultViewField(campaign.getAssignUserFullName());
    } else if (propertyId.equals("startdate")) {
        return new DefaultViewField(UserUIContext.formatDate(campaign.getStartdate()));
    } else if (propertyId.equals("enddate")) {
        return new DefaultViewField(UserUIContext.formatDate(campaign.getEnddate()));
    } else if (propertyId.equals("currencyid")) {
        if (campaign.getCurrencyid() != null) {
            return new DefaultViewField(campaign.getCurrencyid());
        } else {
            return new DefaultViewField("");
        }
    } else if (CampaignWithBLOBs.Field.type.equalTo(propertyId)) {
        return new I18nFormViewField(campaign.getType(), CampaignType.class);
    } else if (CampaignWithBLOBs.Field.status.equalTo(propertyId)) {
        return new I18nFormViewField(campaign.getStatus(), CampaignStatus.class).withStyleName(UIConstants.FIELD_NOTE);
    }

    return null;
}
项目:mycollab    文件:AssignmentReadFormFieldFactory.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("assignuser")) {
        return new DefaultViewField(attachForm.getBean().getAssignUserFullName());
    } else if (propertyId.equals("startdate")) {
        if (attachForm.getBean().getStartdate() == null)
            return null;
        return new DateTimeViewField(attachForm.getBean().getStartdate());
    } else if (propertyId.equals("duedate")) {
        if (attachForm.getBean().getDuedate() == null)
            return null;
        return new DateTimeViewField(attachForm.getBean().getDuedate());
    } else if (propertyId.equals("contactid")) {
        return new DefaultViewField(attachForm.getBean().getContactName());
    } else if (propertyId.equals("typeid")) {
        return new RelatedReadItemField(attachForm.getBean());

    }

    return null;
}
项目:mycollab    文件:MeetingReadFormFieldFactory.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("typeid")) {
        return new RelatedReadItemField(attachForm.getBean());
    } else if (propertyId.equals("startdate")) {
        if (attachForm.getBean().getStartdate() == null)
            return null;
        return new DateTimeViewField(attachForm.getBean().getStartdate());
    } else if (propertyId.equals("enddate")) {
        if (attachForm.getBean().getEnddate() == null)
            return null;
        return new DateTimeViewField(attachForm.getBean().getEnddate());
    } else if (propertyId.equals("isrecurrence")) {
        return null;
    }
    return null;
}
项目:FiWare-Template-Handler    文件:FormPropertiesComponent.java   
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);
      }
    }
  }
}
项目:mycollab    文件:VersionPreviewForm.java   
@Override
protected Field<?> onCreateField(Object propertyId) {
    Version beanItem = attachForm.getBean();
    if (Version.Field.duedate.equalTo(propertyId)) {
        return new DateViewField(beanItem.getDuedate());
    } else if (Version.Field.id.equalTo(propertyId)) {
        ContainerViewField containerField = new ContainerViewField();
        containerField.addComponentField(new BugsComp(beanItem));
        return containerField;
    } else if (Version.Field.status.equalTo(propertyId)) {
        return new I18nFormViewField(beanItem.getStatus(), StatusI18nEnum.class).withStyleName(UIConstants.FIELD_NOTE);
    } else if (Version.Field.description.equalTo(propertyId)) {
        return new RichTextViewField(beanItem.getDescription());
    }
    return null;
}
项目:holon-vaadin7    文件:ExampleRenderers.java   
@SuppressWarnings("unchecked")
public void renderers1() {
    // tag::renderers1[]
    final PathProperty<String> TEXT = PathProperty.create("text", String.class);
    final PathProperty<Long> LONG = PathProperty.create("long", Long.class);

    Input<String> input = TEXT.render(Input.class); // <1>

    Field<Long> field = LONG.render(Field.class); // <2>

    ViewComponent<String> view = TEXT.render(ViewComponent.class); // <3>
    // end::renderers1[]
}
项目:holon-vaadin7    文件:DefaultFieldPropertyRenderer.java   
@Override
public Field render(Property<T> property) {

    ObjectUtils.argumentNotNull(property, "Property must be not null");

    Class<?> propertyType = property.getType();

    // Try to render property according to a supported property type
    if (TypeUtils.isString(propertyType)) {
        // String
        return renderString(property);
    }
    if (TypeUtils.isBoolean(propertyType)) {
        // Boolean
        return renderBoolean(property);
    }
    if (TypeUtils.isEnum(propertyType)) {
        // Enum
        return renderEnum(property);
    }
    if (TypeUtils.isTemporal(propertyType)) {
        // Temporal
        return renderTemporal(property);
    }
    if (TypeUtils.isDate(propertyType)) {
        // Date
        return renderDate(property);
    }
    if (TypeUtils.isNumber(propertyType)) {
        // Number
        return renderNumber(property);
    }

    return null;
}
项目:holon-vaadin7    文件:DefaultFieldPropertyRenderer.java   
/**
 * Renders a Date value type Field
 * @param property Property to render
 * @return Field instance
 */
protected Field<T> renderDate(Property<T> property) {
    final TemporalType type = property.getConfiguration().getTemporalType().orElse(TemporalType.DATE);
    return postProcessField(
            input.date((type == TemporalType.DATE_TIME) ? Resolution.MINUTE : Resolution.DAY, false).asField(),
            property);
}
项目:holon-vaadin7    文件:DefaultFieldPropertyRenderer.java   
/**
 * Renders a numeric value type Field
 * @param property Property to render
 * @return Field instance
 */
@SuppressWarnings("unchecked")
protected Field<T> renderNumber(Property<T> property) {
    // Number format

    Class<? extends Number> type = (Class<? extends Number>) property.getType();

    int decimals = property.getConfiguration().getParameter(StringValuePresenter.DECIMAL_POSITIONS).orElse(-1);
    boolean disableGrouping = property.getConfiguration().getParameter(StringValuePresenter.DISABLE_GROUPING)
            .orElse(Boolean.FALSE);

    Locale locale = LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap(l -> l.getLocale())
            .orElse(Locale.getDefault());

    NumberFormat numberFormat = LocalizationContext.getCurrent().filter(l -> l.isLocalized())
            .map((l) -> l.getNumberFormat(type, decimals, disableGrouping))
            .orElse(TypeUtils.isDecimalNumber(property.getType()) ? NumberFormat.getNumberInstance(locale)
                    : NumberFormat.getIntegerInstance(locale));

    if (decimals > -1) {
        numberFormat.setMinimumFractionDigits(decimals);
        numberFormat.setMaximumFractionDigits(decimals);
    }
    if (disableGrouping) {
        numberFormat.setGroupingUsed(false);
    }

    return postProcessField(input.number(type).numberFormat(numberFormat).asField(), property);
}
项目:holon-vaadin7    文件:DefaultInputPropertyRenderer.java   
@Override
public Input render(Property<T> property) {

    ObjectUtils.argumentNotNull(property, "Property must be not null");

    // try to render as Field and convert to Input
    return PropertyRendererRegistry.get().getRenderer(Field.class, property).map(r -> r.render(property))
            .map(field -> asInput(field)).orElse(null);
}