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);
}
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);
}
};
}
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();
}
}
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;
}
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);
}
Aggregations