use of com.haulmont.cuba.gui.components.data.meta.DatasourceDataUnit 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);
}
}
use of com.haulmont.cuba.gui.components.data.meta.DatasourceDataUnit in project cuba by cuba-platform.
the class UiTestIds method getInferredTestId.
@Nullable
public static String getInferredTestId(DataUnit dataUnit, String suffix) {
if (dataUnit instanceof ContainerDataUnit) {
ContainerDataUnit dcDataUnit = (ContainerDataUnit) dataUnit;
MetaClass entityMetaClass = dcDataUnit.getEntityMetaClass();
return entityMetaClass.getName() + suffix;
} else if (dataUnit instanceof DatasourceDataUnit) {
DatasourceDataUnit dsDataUnit = (DatasourceDataUnit) dataUnit;
MetaClass entityMetaClass = dsDataUnit.getDatasource().getMetaClass();
return entityMetaClass.getName() + suffix;
}
return null;
}
Aggregations