use of org.kie.workbench.common.screens.library.client.widgets.project.AssetItemWidget in project kie-wb-common by kiegroup.
the class PopulatedAssetsScreen method addAssetsToView.
protected void addAssetsToView(AssetQueryResult result) {
switch(result.getResultType()) {
case Normal:
{
List<AssetInfo> assetInfos = result.getAssetInfos().get();
if (assetInfos.isEmpty()) {
this.view.clear();
this.showSearchHitNothing();
} else {
List<AssetItemWidget> items = assetInfos.stream().map(asset -> {
AssetItemWidget item = null;
if (!asset.getFolderItem().getType().equals(FolderItemType.FOLDER)) {
item = assetItemWidget.get();
final ClientResourceType assetResourceType = getResourceType(asset);
final String assetName = getAssetName(asset, assetResourceType);
item.init(assetName, getAssetPath(asset), assetResourceType.getDescription(), assetResourceType.getIcon(), getLastModifiedTime(asset), getCreatedTime(asset), detailsCommand((Path) asset.getFolderItem().getItem()), selectCommand((Path) asset.getFolderItem().getItem()));
}
return Optional.ofNullable(item);
}).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
this.hideEmptyState();
this.view.clear();
items.forEach(this.view::addAssetItem);
}
this.updatedAssetsEventEvent.fire(new UpdatedAssetsEvent(assetInfos));
}
break;
case Unindexed:
showIndexingNotFinished();
break;
case DoesNotExist:
contextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(workspaceProject.getOrganizationalUnit()));
break;
default:
throw new UnsupportedOperationException("No case for " + result.getResultType());
}
}
Aggregations