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

项目:openeos    文件:DefaultVaadinFieldFactory.java   
private Field createFieldByPropertyType(Class<?> type) {
    final IClassDefinition classDefinition = dictionaryService.getClassDefinition(type.getName());
    if (classDefinition != null) {
        LOG.debug("Found field with dictionary in dictionary service for class {}, create new Select", type.getName());
        Select select = new EntitySelect(new EntitySelectIdProvider() {

            @Override
            public Object getId(Object entityObject) {
                return classDefinition.getId(entityObject);
            }
        });
        select.setItemCaptionMode(Select.ITEM_CAPTION_MODE_ITEM);
        select.setContainerDataSource(containerFactory.createContainer(classDefinition.getClassDefined().getName()));
        return select;
    }
    return DefaultFieldFactory.createFieldByPropertyType(type);
}
项目:lodms-plugins    文件:WkdXmlConfigDialog.java   
public WkdXmlConfigDialog(WkdXmlConfig config) {
    form = new Form();
    addComponent(form);
    beanItem = new BeanItem<WkdXmlConfig>(config);
    form.setImmediate(true);
    form.setFormFieldFactory(new DefaultFieldFactory() {
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field f = super.createField(item, propertyId, uiContext);
            f.setRequired(true);
            f.setWidth(500,UNITS_PIXELS);
            return f;
        }
    });
    form.setItemDataSource(beanItem);
    form.focus();
}
项目:holon-vaadin7    文件:DefaultItemListing.java   
@SuppressWarnings("unchecked")
@Override
public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) {
    P property = (P) propertyId;

    // check read-only property
    if (requireDataSource().getConfiguration().isPropertyReadOnly(property)) {
        return null;
    }

    // check editable and custom editor
    PropertyColumn<T, P> propertyColumn = getPropertyColumn(property);
    if (propertyColumn != null) {
        if (!propertyColumn.isEditable()) {
            return null;
        }

        if (propertyColumn.getEditor().isPresent()) {
            return propertyColumn.getEditor().get();
        }
    }

    // check PropertyRenderer or use DefaultFieldFactory
    return renderField(property)
            .orElse(DefaultFieldFactory.get().createField(container, itemId, propertyId, uiContext));

}
项目:field-binder    文件:DefaultSearchFieldFactory.java   
/**
 * In this implementation, {@link com.vaadin.ui.ComboBox}es are distinguished
 * from other Fields.
 *
 * ComboBoxes get their own {@link SearchPatternComboBox};
 * other fields are rendered using a {@link SearchPatternTextField}.
 */
public SearchPatternField<?,?> createField(Object propertyId, Class<?> propertyType) {

    SearchPatternField f ;
    if (java.lang.Enum.class.isAssignableFrom(propertyType)) {
        f = new SearchPatternComboBox(propertyId, (Class<java.lang.Enum>)propertyType);
    } else {
        f = new SearchPatternTextField(propertyId, propertyType);
    }
    f.setCaption(DefaultFieldFactory.createCaptionByPropertyId(propertyId));
    return f;
}
项目:field-binder    文件:DefaultSearchFieldFactory.java   
@Override
public SearchPatternField<?, ?> createField(Object propertyId, Class<?> propertyType, Container.Filterable container) {

    SearchPatternField f ;
    if (java.lang.Enum.class.isAssignableFrom(propertyType)) {
        f = new SearchPatternComboBox(propertyId, propertyType, container);
    } else {
        f = new SearchPatternTextField(propertyId, propertyType, container);
    }
    f.setCaption(DefaultFieldFactory.createCaptionByPropertyId(propertyId));
    return f;
}
项目:ods-lodms-plugins    文件:VirtuosoLoaderConfigDialog.java   
public VirtuosoLoaderConfigDialog(VirtuosoLoaderConfig configuration) {
    config = configuration;
    form.setFormFieldFactory(new DefaultFieldFactory() {
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            if ("graph".equals(propertyId)) {
                Field f = super.createField(item, propertyId, uiContext);
                f.setVisible(config.getGraphSource().equals(VirtuosoLoaderConfig.GRAPHSOURCE_CUSTOM));

            } else if ("graphSource".equals(propertyId)) {
                Select selector = new Select("Graph");
                selector.addItem(VirtuosoLoaderConfig.GRAPHSOURCE_CKANURI);
                selector.addItem(VirtuosoLoaderConfig.GRAPHSOURCE_ODSURI);
                selector.addItem(VirtuosoLoaderConfig.GRAPHSOURCE_CUSTOM);
                selector.addListener(new Property.ValueChangeListener() {
                    @Override
                    public void valueChange(Property.ValueChangeEvent event) {
                        Field graph = form.getField("graph");
                        if (event.getProperty().getValue() == null || graph == null)
                            return;
                        else {
                            boolean isCustom = event.getProperty().getValue().equals(VirtuosoLoaderConfig.GRAPHSOURCE_CUSTOM);
                            graph.setVisible(isCustom);
                            graph.setRequired(isCustom);
                        }
                    }
                });
                selector.setImmediate(true);
                return selector;
            }
            return super.createField(item, propertyId, uiContext);
        }
    });
    form.setItemDataSource(new BeanItem<VirtuosoLoaderConfig>(this.config));
    form.setVisibleItemProperties(new String[]{"host", "port", "userName", "password", "versioned", "graphSource", "graph"});
    addComponent(form);
}
项目:ods-lodms-plugins    文件:ODSCSVExtractorDialog.java   
public ODSCSVExtractorDialog(ODSCSVExtractorConfig config) {
    this.config = config;
    form.setFormFieldFactory(new DefaultFieldFactory() {
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            TextField f = new TextField();
            f.setCaption(createCaptionByPropertyId(propertyId));
            f.setImmediate(true);
            f.setWidth(350, VerticalLayout.UNITS_PIXELS);
            f.addValidator(new AbstractStringValidator(null) {
                @Override
                protected boolean isValidString(String value) {
                    if (value.isEmpty())
                        return true;
                    try {
                        URL u = new URL(value);
                        return true;
                    } catch (Exception ex) {
                        setErrorMessage("Invalid Url: " + ex.getMessage());
                        return false;
                    }
                }
            });
            return f;
        }
    });
    form.setVisibleItemProperties(new String[]{"catalogCsv", "recordCsv", "datasetCsv", "distributionCsv", "agentCsv", "licenseCsv"});
    form.setItemDataSource(new BeanItem<ODSCSVExtractorConfig>(this.config));
    addComponent(form);
}
项目:openeos    文件:DefaultVaadinFieldFactory.java   
private String createCaptionByPropertyId(Object propertyId) {
    return DefaultFieldFactory.createCaptionByPropertyId(propertyId);
}
项目:ods-lodms-plugins    文件:OdsValidatorDialog.java   
private void initEditor() {
    ruleEditor.addComponent(removeButton);
    ruleFields.setFormFieldFactory(new DefaultFieldFactory() {
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            if ("sparqlQuery".equals(propertyId)) {
                TextArea sparqlQuery = new TextArea();
                sparqlQuery.setCaption(createCaptionByPropertyId(propertyId));
                sparqlQuery.setImmediate(true);
                sparqlQuery.setRows(10);
                sparqlQuery.setColumns(30);
                sparqlQuery.addValidator(new AbstractStringValidator("invalid sparql query") {
                    @Override
                    protected boolean isValidString(String value) {
                        SPARQLParser parser = new SPARQLParser();
                        try {
                            ParsedUpdate parsed = parser.parseUpdate(value, null);
                        } catch (Exception ex) {

                            return false;
                        }
                        return true;
                    }
                });
                return sparqlQuery;
            }
            if ("severity".equals(propertyId)) {
                Select s = new Select();
                s.setCaption(createCaptionByPropertyId(propertyId));
                s.addItem(ValidationRule.SEVERITY_ERROR);
                s.addItem(ValidationRule.SEVERITY_WARN);
                return s;
            }

            TextField f = new TextField();
            f.setCaption(createCaptionByPropertyId(propertyId));
            f.setWidth("300px");
            return f;

        }
    });
    ruleFields.setVisibleItemProperties(new String[]{"description", "sparqlQuery"});
    ruleEditor.addComponent(ruleFields);
}
项目:ods-lodms-plugins    文件:TranslatorDialog.java   
public TranslatorDialog(TranslatorConfig tConfig) {
  config = tConfig;
  urlList.addAll(config.DEFAULT_PREDICATES);

  form.setFormFieldFactory(new DefaultFieldFactory() {
    @Override
    public Field createField(Item item, Object propertyId, Component uiContext) {
      if ("predicates".equals(propertyId)) {
        ListSelect box = new ListSelect("predicates to translate");
        box.setMultiSelect(true);
        box.setContainerDataSource(urlList);
        box.setValue(config.getPredicates());
        box.setRows(3);
        box.setNewItemsAllowed(true);
        for (URI predicate : config.getPredicates())
          box.addItem(predicate.stringValue());
        return box;
      } else if ("translationCache".equals("propertyId")) {
        TextField uriField = new TextField("Translation Cache Graph");
        uriField.setWidth(350, VerticalLayout.UNITS_PIXELS);
        uriField.setDescription("Graph URI were translations are stored");
        uriField.setImmediate(true);
        uriField.addValidator(new AbstractStringValidator(null) {
          @Override
          protected boolean isValidString(String value) {
            try {
              new URIImpl(value);
              return true;
            } catch (Exception ex) {
              setErrorMessage("Invalid graph URI: " + ex.getMessage());
              return false;
            }
          }
        });
        return uriField;
      } else
        return super.createField(item, propertyId, uiContext);
    }
  });
  form.setItemDataSource(new BeanItem<TranslatorConfig>(this.config));
  form.setVisibleItemProperties(new String[]{"providerClientID", "providerClientSecret", "predicates", "translationCache"});
  addComponent(form);
}
项目:enterprise-app    文件:DefaultCrudFieldFactory.java   
/**
 * Returns the field caption for the specified property. Gets the error string from properties file.
 * @param propertyId property name.
 * @param type property type.
 * @return field caption.
 */
public static String getFieldCaption(Object propertyId, Class<?> type) {
    String typeName = type.getSimpleName();
    String nameFromFile = Utils.getPropertyLabel(typeName, propertyId);
    return nameFromFile.isEmpty() ? DefaultFieldFactory.createCaptionByPropertyId(propertyId) : nameFromFile;
}
项目:enterprise-app    文件:CrudComponent.java   
/**
 * Creates a new instance using the specified DefaultFieldFactory.
 * @param type Entity type.
 * @param fieldFactory DefaultFieldFactory to use.
 */
public CrudComponent(Class<T> type, DefaultFieldFactory fieldFactory) {
    this(type, null, fieldFactory, null, null, true, true, true, true, true, false, false, false, 0);
}
项目:enterprise-app    文件:CrudComponent.java   
/**
 * Creates a new instance using the specified DefaultFieldFactory and Container.
 * @param type Entity type.
 * @param fieldFactory DefaultFieldFactory to use.
 * @param container Container to use.
 */
public CrudComponent(Class<T> type, DefaultFieldFactory fieldFactory, Container container) {
    this(type, container, fieldFactory, null, null, true, true, true, true, true, false, false, false, 0);
}
项目:enterprise-app    文件:CrudComponent.java   
/**
 * Creates a new instance using the specified DefaultFieldFactory and vertical layout configuration.
 * @param type Entity type.
 * @param fieldFactory FieldFactory to use.
 * @param verticalLayout true to use a vertical split (table top, form below), false to use horizontal
 * split (table on the left, form on the right).
 */
public CrudComponent(Class<T> type, DefaultFieldFactory fieldFactory, boolean verticalLayout) {
    this(type, null, fieldFactory, null, null, true, true, true, true, true, false, false, verticalLayout, 0);
}
项目:enterprise-app    文件:CrudBuilder.java   
/**
 * Use a custom FieldFactory.
 * @param fieldFactory FieldFactory to use.
 * @return
 */
public CrudBuilder<T> setFieldFactory(DefaultFieldFactory fieldFactory) {
    this.fieldFactory = fieldFactory;
    return this;
}
项目:enterprise-app    文件:EmbeddedCrudComponent.java   
/**
 * @param type Entity type.
 * @param fieldFactory DefaultFieldFactory to use.
 * @param container EntitySetContainer to use.
 */
public EmbeddedCrudComponent(Class<T> type, DefaultFieldFactory fieldFactory, EntitySetContainer<T> container) {
    super(type, container, fieldFactory, null, null, false, true, true, true, true, true, true, false, 0);
}
项目:enterprise-app    文件:Utils.java   
/**
 * 
 * @param typeName
 * @param propertyId
 * @return The corresponding label for the property and type specified.
 */
public static String getPropertyLabel(String typeName, Object propertyId) {
    typeName = typeName.substring(0, 1).toLowerCase() + typeName.substring(1, typeName.length());
    return getProperty("ui." + typeName + "." + propertyId, DefaultFieldFactory.createCaptionByPropertyId(propertyId));
}