Search in sources :

Example 1 with WorkspaceProjectContextChangeEvent

use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.

the class NewWorkspaceProjectHandler method getCommand.

@Override
public Command getCommand(final NewResourcePresenter newResourcePresenter) {
    return new Command() {

        @Override
        public void execute() {
            if (!context.getActiveOrganizationalUnit().isPresent()) {
                ouService.call(new RemoteCallback<OrganizationalUnit>() {

                    @Override
                    public void callback(OrganizationalUnit organizationalUnit) {
                        projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(organizationalUnit));
                        init();
                    }
                }).getOrganizationalUnit(libraryPreferences.getOrganizationalUnitPreferences().getName());
            } else {
                init();
            }
        }
    };
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 2 with WorkspaceProjectContextChangeEvent

use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.

the class ExamplesServiceImpl method setupExamples.

@Override
public WorkspaceProjectContextChangeEvent setupExamples(final ExampleOrganizationalUnit exampleTargetOU, final List<ExampleProject> exampleProjects) {
    PortablePreconditions.checkNotNull("exampleTargetOU", exampleTargetOU);
    PortablePreconditions.checkNotNull("exampleProjects", exampleProjects);
    PortablePreconditions.checkCondition("Must have at least one ExampleProject", exampleProjects.size() > 0);
    // Retrieve or create Organizational Unit
    final String targetOUName = exampleTargetOU.getName();
    final OrganizationalUnit targetOU = getOrganizationalUnit(targetOUName);
    WorkspaceProject firstExampleProject = null;
    for (final ExampleProject exampleProject : exampleProjects) {
        try {
            final Repository targetRepository = repositoryCopier.copy(targetOU, exampleProject.getName(), exampleProject.getRoot());
            // Signal creation of new Project (Creation of OU and Repository, if applicable,
            // are already handled in the corresponding services).
            WorkspaceProject project = projectService.resolveProject(targetRepository);
            project = renameIfNecessary(targetOU, project);
            newProjectEvent.fire(new NewProjectEvent(project));
            // Store first new example project
            if (firstExampleProject == null) {
                firstExampleProject = project;
            }
        } catch (IOException ioe) {
            logger.error("Unable to create Example(s).", ioe);
        }
    }
    return new WorkspaceProjectContextChangeEvent(firstExampleProject, firstExampleProject.getMainModule());
}
Also used : NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) IOException(org.uberfire.java.nio.IOException) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 3 with WorkspaceProjectContextChangeEvent

use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.

the class LibraryPlaces method goToOrganizationalUnits.

public void goToOrganizationalUnits() {
    if (closeAllPlacesOrNothing()) {
        PortablePreconditions.checkNotNull("libraryPerspective.closeAllPlacesOrNothing", libraryPerspective);
        projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent());
        final DefaultPlaceRequest placeRequest = new DefaultPlaceRequest(LibraryPlaces.ORGANIZATIONAL_UNITS_SCREEN);
        final PartDefinitionImpl part = new PartDefinitionImpl(placeRequest);
        part.setSelectable(false);
        placeManager.goTo(part, libraryPerspective.getRootPanel());
        setupLibraryBreadCrumbs();
    }
}
Also used : PartDefinitionImpl(org.uberfire.workbench.model.impl.PartDefinitionImpl) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 4 with WorkspaceProjectContextChangeEvent

use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.

the class LibraryPlaces method openBestSuitedScreen.

private void openBestSuitedScreen(final String eventType, final Path path, final WorkspaceProject project) {
    if (!projectContext.getActiveWorkspaceProject().map(active -> active.equals(project)).orElse(false)) {
        projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(project, project.getMainModule()));
    }
    final PlaceRequest libraryPerspectivePlace = getLibraryPlaceRequestWithoutRefresh();
    if (isRepositoryEvent(eventType)) {
        placeManager.goTo(REPOSITORY_STRUCTURE_SCREEN);
    } else if (isModuleEvent(eventType)) {
        placeManager.goTo(libraryPerspectivePlace);
        goToProject();
    } else if (path != null) {
        placeManager.goTo(libraryPerspectivePlace);
        goToProject(() -> goToAsset(path));
    }
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 5 with WorkspaceProjectContextChangeEvent

use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.

the class LibraryPlaces method goToLibrary.

public void goToLibrary() {
    if (!projectContext.getActiveOrganizationalUnit().isPresent()) {
        libraryService.call(new RemoteCallback<OrganizationalUnit>() {

            @Override
            public void callback(OrganizationalUnit organizationalUnit) {
                projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(organizationalUnit));
                setupLibraryPerspective();
            }
        }).getDefaultOrganizationalUnit();
    } else {
        setupLibraryPerspective();
    }
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

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