Search in sources :

Example 21 with WorkspaceProjectContextChangeEvent

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));
            }
        }
    };
}
Also used : Package(org.guvnor.common.services.project.model.Package) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 22 with WorkspaceProjectContextChangeEvent

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);
    }
}
Also used : Package(org.guvnor.common.services.project.model.Package) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 23 with WorkspaceProjectContextChangeEvent

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);
        }
    });
}
Also used : RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Paths(org.uberfire.backend.server.util.Paths) POM(org.guvnor.common.services.project.model.POM) FileSystemProvider(org.uberfire.java.nio.file.spi.FileSystemProvider) RepositoryEnvironmentConfigurations(org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations) ImportService(org.kie.workbench.common.screens.examples.service.ImportService) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) BasicFileAttributes(org.uberfire.java.nio.file.attribute.BasicFileAttributes) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ProjectScreenService(org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService) NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) Repository(org.guvnor.structure.repositories.Repository) MetadataService(org.guvnor.common.services.shared.metadata.MetadataService) SpaceConfigStorageRegistry(org.guvnor.structure.organizationalunit.config.SpaceConfigStorageRegistry) Collection(java.util.Collection) Set(java.util.Set) SCHEME(org.guvnor.structure.repositories.EnvironmentParameters.SCHEME) EmptyRemoteRepositoryException(org.kie.workbench.common.screens.examples.exception.EmptyRemoteRepositoryException) ExampleProjectError(org.kie.workbench.common.screens.examples.model.ExampleProjectError) Collectors(java.util.stream.Collectors) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) List(java.util.List) Stream(java.util.stream.Stream) RepositoryConfiguration(org.guvnor.structure.organizationalunit.config.RepositoryConfiguration) ImportProjectValidators(org.kie.workbench.common.screens.examples.validation.ImportProjectValidators) PathUtil(org.guvnor.common.services.project.backend.server.utils.PathUtil) Optional(java.util.Optional) HashMap(java.util.HashMap) EnvironmentParameters(org.guvnor.structure.repositories.EnvironmentParameters) MessageFormat(java.text.MessageFormat) ProjectAlreadyExistException(org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException) StreamSupport(java.util.stream.StreamSupport) PortablePreconditions(org.kie.soup.commons.validation.PortablePreconditions) Credentials(org.kie.workbench.common.screens.examples.model.Credentials) Path(org.uberfire.backend.vfs.Path) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) RepositoryService(org.guvnor.structure.repositories.RepositoryService) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) MIRROR(org.guvnor.structure.repositories.EnvironmentParameters.MIRROR) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) Collectors.toList(java.util.stream.Collectors.toList) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) IOService(org.uberfire.io.IOService) ImportProjectValidator(org.kie.workbench.common.screens.examples.validation.ImportProjectValidator) Collections(java.util.Collections) FileSystem(org.uberfire.java.nio.file.FileSystem) Branch(org.guvnor.structure.repositories.Branch) NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 24 with WorkspaceProjectContextChangeEvent

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());
    }
}
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)

Example 25 with WorkspaceProjectContextChangeEvent

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);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Aggregations

WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)31 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)14 Test (org.junit.Test)14 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)10 Path (org.uberfire.backend.vfs.Path)9 DefaultPlaceRequest (org.uberfire.mvp.impl.DefaultPlaceRequest)8 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)8 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)7 Module (org.guvnor.common.services.project.model.Module)6 Branch (org.guvnor.structure.repositories.Branch)6 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)6 ImportProject (org.kie.workbench.common.screens.examples.model.ImportProject)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)6 PartDefinitionImpl (org.uberfire.workbench.model.impl.PartDefinitionImpl)6 Package (org.guvnor.common.services.project.model.Package)5 Repository (org.guvnor.structure.repositories.Repository)5 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)5 List (java.util.List)4 POM (org.guvnor.common.services.project.model.POM)4 ObservablePath (org.uberfire.backend.vfs.ObservablePath)4