use of com.haulmont.cuba.gui.components.filter.FtsFilterHelper in project cuba by cuba-platform.
the class WebFilterHelper method initTableFtsTooltips.
@Override
public void initTableFtsTooltips(ListComponent listComponent, MetaClass metaClass, String searchTerm) {
FtsFilterHelper ftsFilterHelper;
if (beanLocator.containsBean(FtsFilterHelper.NAME)) {
ftsFilterHelper = beanLocator.get(FtsFilterHelper.class);
} else {
return;
}
if (listComponent instanceof Table) {
Map<Object, String> tooltipsCache = new HashMap<>();
Map<Object, String> metaClassesCache = new HashMap<>();
listComponent.withUnwrapped(com.vaadin.v7.ui.Table.class, vTable -> vTable.setItemDescriptionGenerator((source, itemId, propertyId) -> {
return tooltipsCache.computeIfAbsent(itemId, k -> {
if (k instanceof GroupInfo) {
return "";
}
return ftsFilterHelper.buildTableTooltip(metaClassesCache.computeIfAbsent(itemId, id -> {
DataUnit dataUnit = listComponent.getItems();
Entity<?> entity = null;
if (dataUnit instanceof DatasourceDataUnit) {
// legacy GUI
entity = ((DatasourceDataUnit) dataUnit).getDatasource().getItem(id);
} else if (dataUnit instanceof ContainerDataUnit) {
entity = ((ContainerDataUnit) dataUnit).getContainer().getItem(id);
}
if (entity != null)
return entity.getMetaClass().getName();
return metaClass.getName();
}), k, searchTerm);
});
}));
} else if (listComponent instanceof DataGrid) {
((DataGrid) listComponent).setRowDescriptionProvider(o -> {
if (o instanceof Entity) {
Entity entity = (Entity) o;
return ftsFilterHelper.buildTableTooltip(entity.getMetaClass().getName(), entity.getId(), searchTerm);
} else {
return null;
}
}, ContentMode.HTML);
}
}
Aggregations