Search in sources :

Example 1 with AssetItemWidget

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());
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) UpdatedAssetsEvent(org.kie.workbench.common.screens.library.client.screens.assets.events.UpdatedAssetsEvent) Optional(java.util.Optional) ClientResourceType(org.uberfire.client.workbench.type.ClientResourceType) List(java.util.List) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) AssetItemWidget(org.kie.workbench.common.screens.library.client.widgets.project.AssetItemWidget)

Aggregations

List (java.util.List)1 Optional (java.util.Optional)1 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)1 UpdatedAssetsEvent (org.kie.workbench.common.screens.library.client.screens.assets.events.UpdatedAssetsEvent)1 AssetItemWidget (org.kie.workbench.common.screens.library.client.widgets.project.AssetItemWidget)1 Path (org.uberfire.backend.vfs.Path)1 ClientResourceType (org.uberfire.client.workbench.type.ClientResourceType)1