use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class ActiveContextItems method getResolvePackageRemoteCallback.
private RemoteCallback<Package> getResolvePackageRemoteCallback() {
return new RemoteCallback<Package>() {
@Override
public void callback(final Package pkg) {
if (Utils.hasPackageChanged(pkg, activePackage)) {
activePackage = pkg;
contextChangedEvent.fire(new WorkspaceProjectContextChangeEvent(activeProject, activeModule, activePackage));
}
}
};
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class ActiveContextItems method fireContextChangeEvent.
void fireContextChangeEvent() {
if (activeFolderItem.getItem() instanceof Package) {
activePackage = (Package) activeFolderItem.getItem();
contextChangedEvent.fire(new WorkspaceProjectContextChangeEvent(activeProject, activeModule, activePackage));
} else if (activeFolderItem.getType().equals(FolderItemType.FOLDER)) {
explorerService.call(getResolvePackageRemoteCallback()).resolvePackage(activeFolderItem);
}
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class BaseProjectImportService method importProjects.
@Override
public WorkspaceProjectContextChangeEvent importProjects(OrganizationalUnit activeOU, List<ImportProject> projects) {
PortablePreconditions.checkNotNull("activeOU", activeOU);
PortablePreconditions.checkNotNull("projects", projects);
PortablePreconditions.checkCondition("Must have at least one Project", projects.size() > 0);
return spaceConfigStorageRegistry.getBatch(activeOU.getSpace().getName()).run(context -> {
List<WorkspaceProject> importedProjects = projects.stream().map(exampleProject -> {
WorkspaceProject project = this.importProject(activeOU, exampleProject);
newProjectEvent.fire(new NewProjectEvent(project));
return project;
}).collect(Collectors.toList());
if (importedProjects.size() == 1) {
final WorkspaceProject importedProject = importedProjects.get(0);
return new WorkspaceProjectContextChangeEvent(importedProject, importedProject.getMainModule());
} else {
return new WorkspaceProjectContextChangeEvent(activeOU);
}
});
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent 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());
}
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class ExternalImportPresenter method importProjects.
@Override
protected void importProjects(List<ImportProject> projects, RemoteCallback<WorkspaceProjectContextChangeEvent> callback, ErrorCallback<Message> errorCallback) {
final OrganizationalUnit activeOU = activeOrganizationalUnit();
this.importService.call((WorkspaceProjectContextChangeEvent event) -> callback.callback(event), errorCallback).importProjects(activeOU, projects);
}
Aggregations