Package com.vaadin.data.util

Examples of com.vaadin.data.util.PropertyFormatter


            public Field createField(Item item, Object propertyId,
                    Component uiContext) {
                AbstractField f = (AbstractField) DefaultFieldFactory.get()
                        .createField(item, propertyId, uiContext);
                if (propertyId.equals("age")) {
                    f.setPropertyDataSource(new PropertyFormatter() {

                        @Override
                        public Object parse(String formattedValue)
                                throws Exception {
                            String str = formattedValue.replaceAll("[^0-9.]",
View Full Code Here


        final Property property = item.getItemProperty(pid);
        if (property == null && !formatNullProperties) {
          return null;
        }//not exists

        PropertyFormatter propertyFormatter = instances.get(pid);
        if (propertyFormatter != null) {
            propertyFormatter.setPropertyDataSource(property);
            return propertyFormatter;
        }

        Class<? extends PropertyFormatter> propertyFormatterClass = classes.get(pid);
        if (propertyFormatterClass != null) {
            try {
                propertyFormatter = propertyFormatterClass.newInstance();
            } catch (InstantiationException e) {
                throw new IllegalStateException(
                        "getItemProperty: can't create "
                                + propertyFormatterClass.getName()
                                + " instance for PID=" + pid, e);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException(
                        "getItemProperty: can't create "
                                + propertyFormatterClass.getName()
                                + " instance for PID=" + pid + ": IAE", e);
            }// t

            propertyFormatter.setPropertyDataSource(property);
            return propertyFormatter;
        }// i

        return property;// as is
    }//getItemProperty
View Full Code Here

            @Override
            public Component generateCell(Table source, final Object itemId, Object columnId) {
                Property prop = source.getItem(itemId).getItemProperty(columnId);
                if (prop.getType().equals(UserData.class)) {
                    Label l = new Label();       
                    l.setPropertyDataSource(new PropertyFormatter(prop) {
                        @Override
                        public String format(Object o) {
                            return ((UserData)o).getRealName();
                        }
View Full Code Here

  public void setPropertyDataSource(final Property newDataSource) {
    super.setPropertyDataSource(getPropertyFormatter(newDataSource));
  }

  protected PropertyFormatter getPropertyFormatter(final Property newDataSource) {
    PropertyFormatter propertyFormatter = new PropertyFormatter(newDataSource) {
      @Override
      public String format(Object value) {
        if (value == null) {
          return getNullRepresentation();
        }
View Full Code Here

  public void setPropertyDataSource(final Property newDataSource) {
    super.setPropertyDataSource(getPropertyFormatter(newDataSource));
  }

    protected PropertyFormatter getPropertyFormatter(Property newDataSource) {
        return new PropertyFormatter(newDataSource) {
            @Override
            public String format(Object value) {
                if (value == null) {
                    return getNullRepresentation();
                }
View Full Code Here

TOP

Related Classes of com.vaadin.data.util.PropertyFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.