Search in sources :

Example 21 with Property

use of com.vaadin.data.Property in project cuba by cuba-platform.

the class WebSearchField method createComponent.

@Override
protected void createComponent() {
    this.component = new CubaSearchSelect() {

        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null) {
                super.setPropertyDataSource(null);
            } else {
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
            }
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null) {
                handled = componentErrorHandler.handleError(componentError);
            }
            if (!handled) {
                super.setComponentError(componentError);
            }
        }
    };
    getSearchComponent().setFilterHandler(this::executeSearch);
}
Also used : CubaSearchSelect(com.haulmont.cuba.web.toolkit.ui.CubaSearchSelect) ErrorMessage(com.vaadin.server.ErrorMessage) Property(com.vaadin.data.Property)

Example 22 with Property

use of com.vaadin.data.Property in project cuba by cuba-platform.

the class WebLookupField method createComponent.

protected void createComponent() {
    this.component = new CubaComboBox() {

        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null)
                super.setPropertyDataSource(null);
            else
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null)
                handled = componentErrorHandler.handleError(componentError);
            if (!handled)
                super.setComponentError(componentError);
        }
    };
}
Also used : CubaComboBox(com.haulmont.cuba.web.toolkit.ui.CubaComboBox) ErrorMessage(com.vaadin.server.ErrorMessage) Property(com.vaadin.data.Property)

Example 23 with Property

use of com.vaadin.data.Property in project cuba by cuba-platform.

the class WebAbstractOptionsField method setDatasource.

@Override
public void setDatasource(Datasource datasource, String property) {
    if ((datasource == null && property != null) || (datasource != null && property == null))
        throw new IllegalArgumentException("Datasource and property should be either null or not null at the same time");
    if (datasource == this.datasource && ((metaPropertyPath != null && metaPropertyPath.toString().equals(property)) || (metaPropertyPath == null && property == null)))
        return;
    if (this.datasource != null) {
        metaProperty = null;
        metaPropertyPath = null;
        component.setPropertyDataSource(null);
        // noinspection unchecked
        this.datasource.removeItemChangeListener(securityWeakItemChangeListener);
        securityWeakItemChangeListener = null;
        this.datasource = null;
        if (itemWrapper != null) {
            itemWrapper.unsubscribe();
        }
        disableBeanValidator();
    }
    if (datasource != null) {
        // noinspection unchecked
        this.datasource = datasource;
        MetaClass metaClass = datasource.getMetaClass();
        resolveMetaPropertyPath(metaClass, property);
        if (metaProperty.getRange().getCardinality() != null) {
            setMultiSelect(metaProperty.getRange().getCardinality().isMany());
        }
        itemWrapper = createDatasourceWrapper(datasource, Collections.singleton(metaPropertyPath));
        Property itemProperty = itemWrapper.getItemProperty(metaPropertyPath);
        initRequired(metaPropertyPath);
        if (metaProperty.getRange().isEnum()) {
            Enumeration enumeration = metaProperty.getRange().asEnumeration();
            List options = Arrays.asList(enumeration.getJavaClass().getEnumConstants());
            setComponentContainerDs(createEnumContainer(options));
            setCaptionMode(CaptionMode.ITEM);
        }
        if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
            CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty);
            if (categoryAttribute != null && categoryAttribute.getDataType() == PropertyType.ENUMERATION) {
                setOptionsMap(categoryAttribute.getLocalizedEnumerationMap());
            }
        }
        component.setPropertyDataSource(itemProperty);
        if (metaProperty.isReadOnly()) {
            setEditable(false);
        }
        handleFilteredAttributes(this, this.datasource, metaPropertyPath);
        securityItemChangeListener = e -> handleFilteredAttributes(this, this.datasource, metaPropertyPath);
        securityWeakItemChangeListener = new WeakItemChangeListener(datasource, securityItemChangeListener);
        // noinspection unchecked
        this.datasource.addItemChangeListener(securityWeakItemChangeListener);
        initBeanValidator();
    }
}
Also used : WeakItemChangeListener(com.haulmont.cuba.gui.data.impl.WeakItemChangeListener) Enumeration(com.haulmont.chile.core.datatypes.Enumeration) CategoryAttribute(com.haulmont.cuba.core.entity.CategoryAttribute) MetaClass(com.haulmont.chile.core.model.MetaClass) Property(com.vaadin.data.Property)

Example 24 with Property

use of com.vaadin.data.Property in project opennms by OpenNMS.

the class NCSServiceContainer method getChildren.

@Override
public Collection<Long> getChildren(Object itemId) {
    // Assert.isInstanceOf(Long.class, itemId);
    BeanItem<NCSServiceItem> component = getItem(itemId);
    String foreignSource = (String) component.getItemProperty(FOREIGN_SOURCE_PROPERTY).getValue();
    LOG.trace("entering method getChildren");
    List<Long> retval = new ArrayList<>();
    for (Long id : getAllItemIds()) {
        // Per talks with Paulo, only descend to the level of ServiceElement.
        // ServiceElementComponents have no representation on the current map
        // implementation.
        boolean isRoot = (Boolean) getItem(id).getItemProperty("isRoot").getValue();
        @SuppressWarnings("rawtypes") Property itemProperty = getItem(id).getItemProperty(FOREIGN_SOURCE_PROPERTY);
        String fSource = (String) itemProperty.getValue();
        if (!isRoot && fSource.equals(foreignSource)) {
            retval.add(id);
        }
    }
    return retval;
}
Also used : ArrayList(java.util.ArrayList) Property(com.vaadin.data.Property)

Example 25 with Property

use of com.vaadin.data.Property in project VaadinUtils by rlsutton1.

the class GridContainerCSVExport method writeRow.

private void writeRow(CSVWriter writer, Grid grid, Object id, Set<Object> properties) {
    Item item = grid.getContainerDataSource().getItem(id);
    String[] values = new String[properties.size() + extraColumnHeadersAndPropertyIds.size()];
    int i = 0;
    for (Object propertyId : properties) {
        @SuppressWarnings("rawtypes") final Property itemProperty = item.getItemProperty(propertyId);
        if (itemProperty != null) {
            Object value = itemProperty.getValue();
            if (value != null) {
                final Object convertedValue = convert(value);
                if (convertedValue != null) {
                    values[i++] = sanitiseValue(convertedValue);
                } else {
                    values[i++] = "";
                }
            } else {
                values[i++] = "";
            }
        }
    }
    for (Object columnId : extraColumnHeadersAndPropertyIds.values()) {
        String value = getValueForExtraColumn(item, columnId);
        if (value == null) {
            value = "";
        }
        values[i++] = value;
    }
    writer.writeNext(values);
}
Also used : Item(com.vaadin.data.Item) Property(com.vaadin.data.Property)

Aggregations

Property (com.vaadin.data.Property)26 Item (com.vaadin.data.Item)18 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)16 Table (com.vaadin.ui.Table)15 UriFragment (org.activiti.explorer.navigation.UriFragment)11 LazyLoadingContainer (org.activiti.explorer.data.LazyLoadingContainer)10 ThemeImageColumnGenerator (org.activiti.explorer.ui.util.ThemeImageColumnGenerator)8 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)4 WeakItemChangeListener (com.haulmont.cuba.gui.data.impl.WeakItemChangeListener)3 Label (com.vaadin.ui.Label)3 LazyLoadingQuery (org.activiti.explorer.data.LazyLoadingQuery)3 MetaClass (com.haulmont.chile.core.model.MetaClass)2 WeakItemPropertyChangeListener (com.haulmont.cuba.gui.data.impl.WeakItemPropertyChangeListener)2 ErrorMessage (com.vaadin.server.ErrorMessage)2 Collection (java.util.Collection)2 HistoricFormProperty (org.activiti.engine.history.HistoricFormProperty)2 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)2 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)2 ClickableLabel (au.com.vaadinutils.fields.ClickableLabel)1 Enumeration (com.haulmont.chile.core.datatypes.Enumeration)1