Search in sources :

Example 26 with WorkspaceProjectContextChangeEvent

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

the class ProjectScreenTest method testContextModuleIsUpdatedSapshot.

@Test
public void testContextModuleIsUpdatedSapshot() {
    final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
    doReturn("module name").when(workspaceProject).getName();
    final Module module = mock(Module.class);
    when(module.getPom()).thenReturn(new POM(new GAV(GROUP_ID, ARTIFACT, VERSION + "-SNAPSHOT")));
    when(workspaceProject.getMainModule()).thenReturn(module);
    presenter.changeProjectAndTitleWhenContextChange(new WorkspaceProjectContextChangeEvent(workspaceProject));
    verify(view).setTitle("module name");
    verify(projectMainActions).setBuildEnabled(eq(false));
    verify(projectMainActions).setDeployEnabled(eq(false));
    verify(projectMainActions).setRedeployEnabled(eq(true));
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 27 with WorkspaceProjectContextChangeEvent

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

the class LibraryPerspectiveTest method libraryResetsContextOnCloseTest.

@Test
public void libraryResetsContextOnCloseTest() {
    perspective.onClose();
    verify(projectContextChangeEvent).fire(new WorkspaceProjectContextChangeEvent());
}
Also used : WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Test(org.junit.Test)

Example 28 with WorkspaceProjectContextChangeEvent

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

the class LibraryPlaces method goToProject.

public void goToProject(final WorkspaceProject project) {
    if (projectContext.getActiveWorkspaceProject().map(activeProject -> !activeProject.equals(project)).orElse(true)) {
        final String lastBranch = cookie.get(getProjectLastBranchCookie(project.getName()));
        cookie.set(getLastProjectCookie(), project.getName());
        closeAllPlacesOrNothing(() -> {
            projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(project, project.getMainModule()));
            if (!lastBranch.equals("")) {
                goToProject(project.getSpace().getName(), project.getName(), lastBranch);
            } else {
                goToProject(project, project.getBranch());
            }
        });
    } else {
        goToProject();
    }
}
Also used : IThenable(elemental2.promise.IThenable) Arrays(java.util.Arrays) Remote(org.kie.workbench.common.screens.library.api.Remote) PerspectiveManager(org.uberfire.client.mvp.PerspectiveManager) Utils(org.kie.workbench.common.screens.explorer.client.utils.Utils) AssetDetailEvent(org.kie.workbench.common.screens.library.client.events.AssetDetailEvent) HasBusyIndicator(org.uberfire.ext.widgets.common.client.common.HasBusyIndicator) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) OrganizationalUnitService(org.guvnor.structure.organizationalunit.OrganizationalUnitService) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) ConcurrentRenameAcceptedEvent(org.uberfire.ext.editor.commons.client.event.ConcurrentRenameAcceptedEvent) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) Observes(javax.enterprise.event.Observes) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) PreferencesCentralSaveEvent(org.uberfire.ext.preferences.client.event.PreferencesCentralSaveEvent) PlaceGainFocusEvent(org.uberfire.client.workbench.events.PlaceGainFocusEvent) SessionInfo(org.uberfire.rpc.SessionInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) CloseUnsavedProjectAssetsPopUpPresenter(org.kie.workbench.common.screens.library.client.screens.project.close.CloseUnsavedProjectAssetsPopUpPresenter) MessageConsoleScreen(org.guvnor.messageconsole.client.console.MessageConsoleScreen) ChangeRequestUtils(org.kie.workbench.common.screens.library.client.screens.project.changerequest.ChangeRequestUtils) Repository(org.guvnor.structure.repositories.Repository) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) PlaceRequest(org.uberfire.mvp.PlaceRequest) Routed(org.kie.workbench.common.screens.library.api.Routed) NewResourceSuccessEvent(org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent) List(java.util.List) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Caller(org.jboss.errai.common.client.api.Caller) PostConstruct(javax.annotation.PostConstruct) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ConcurrentDeleteAcceptedEvent(org.uberfire.ext.editor.commons.client.event.ConcurrentDeleteAcceptedEvent) WorkspaceProjectContextChangeHandler(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeHandler) PreferencesRootScreen(org.uberfire.ext.preferences.client.central.screen.PreferencesRootScreen) PlaceStatus(org.uberfire.client.mvp.PlaceStatus) Space(org.uberfire.spaces.Space) Promises(org.uberfire.client.promise.Promises) RemoveOrganizationalUnitEvent(org.guvnor.structure.organizationalunit.RemoveOrganizationalUnitEvent) HashMap(java.util.HashMap) PlaceManager(org.uberfire.client.mvp.PlaceManager) Promise(elemental2.promise.Promise) ProjectAssetListUpdated(org.kie.workbench.common.screens.library.api.ProjectAssetListUpdated) PreferencesCentralUndoChangesEvent(org.uberfire.ext.preferences.client.event.PreferencesCentralUndoChangesEvent) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) Inject(javax.inject.Inject) ImportRepositoryPopUpPresenter(org.kie.workbench.common.screens.library.client.screens.importrepository.ImportRepositoryPopUpPresenter) Window(com.google.gwt.user.client.Window) PortablePreconditions(org.kie.soup.commons.validation.PortablePreconditions) ImportProjectsSetupEvent(org.kie.workbench.common.screens.library.client.screens.importrepository.ImportProjectsSetupEvent) OrganizationalUnitController(org.guvnor.structure.client.security.OrganizationalUnitController) LibraryBreadcrumbs(org.kie.workbench.common.screens.library.client.util.breadcrumb.LibraryBreadcrumbs) Path(org.uberfire.backend.vfs.Path) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Command(org.uberfire.mvp.Command) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) LibraryConstants(org.kie.workbench.common.screens.library.client.resources.i18n.LibraryConstants) UberfireBreadcrumbs(org.uberfire.ext.widgets.common.client.breadcrumbs.UberfireBreadcrumbs) PartDefinitionImpl(org.uberfire.workbench.model.impl.PartDefinitionImpl) Logger(org.slf4j.Logger) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) RepositoryService(org.guvnor.structure.repositories.RepositoryService) Cookie(org.uberfire.client.util.Cookie) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) VFSService(org.uberfire.backend.vfs.VFSService) ResourceDeletedEvent(org.uberfire.workbench.events.ResourceDeletedEvent) RepositoryRemovedEvent(org.guvnor.structure.repositories.RepositoryRemovedEvent) UnauthorizedException(org.jboss.errai.security.shared.exception.UnauthorizedException) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) Collections(java.util.Collections) LibraryPerspective(org.kie.workbench.common.screens.library.client.perspective.LibraryPerspective) Source(org.kie.workbench.common.screens.library.client.screens.importrepository.Source) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 29 with WorkspaceProjectContextChangeEvent

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

the class ProjectImportServiceImplTest method testImportProjects_ProjectImport.

@Test
public void testImportProjects_ProjectImport() {
    final ImportProject exProject1 = mock(ImportProject.class);
    final ImportProject exProject2 = mock(ImportProject.class);
    final List<ImportProject> exProjects = Arrays.asList(exProject1, exProject2);
    final GitRepository repository1 = mock(GitRepository.class);
    final Path repositoryRoot = mock(Path.class);
    final Path module1Root = mock(Path.class);
    final Path module2Root = mock(Path.class);
    when(exProject1.getName()).thenReturn("project1");
    when(exProject1.getRoot()).thenReturn(module1Root);
    when(exProject2.getName()).thenReturn("project2");
    when(exProject2.getRoot()).thenReturn(module2Root);
    when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
    final Optional<Branch> main = Optional.of(new Branch("main", PathFactory.newPath("testFile", "file:///")));
    when(repository1.getDefaultBranch()).thenReturn(main);
    when(repositoryRoot.toURI()).thenReturn("default:///");
    when(module1Root.toURI()).thenReturn("default:///module1");
    when(module2Root.toURI()).thenReturn("default:///module2");
    when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(organizationalUnit);
    WorkspaceProject project1 = mock(WorkspaceProject.class);
    when(project1.getName()).thenReturn("project1");
    when(project1.getBranch()).thenReturn(main.get());
    WorkspaceProject project2 = mock(WorkspaceProject.class);
    when(project2.getName()).thenReturn("project2");
    when(project2.getBranch()).thenReturn(main.get());
    doReturn(project1).when(service).importProject(eq(organizationalUnit), eq(exProject1));
    doReturn(project2).when(service).importProject(eq(organizationalUnit), eq(exProject2));
    final WorkspaceProject project = spy(new WorkspaceProject());
    doReturn("project").when(project).getName();
    doReturn(project).when(projectService).resolveProject(repository1);
    final WorkspaceProjectContextChangeEvent event = service.importProjects(organizationalUnit, exProjects);
    assertEquals(organizationalUnit, event.getOrganizationalUnit());
    assertEquals(null, event.getWorkspaceProject());
    verify(ouService, never()).createOrganizationalUnit(eq("ou"), eq(""));
    verify(service, times(2)).importProject(eq(organizationalUnit), any());
    verify(spaceConfigStorage).startBatch();
    verify(spaceConfigStorage).endBatch();
}
Also used : Path(org.uberfire.backend.vfs.Path) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) ImportUtils.makeGitRepository(org.kie.workbench.common.screens.examples.backend.server.ImportUtils.makeGitRepository) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Test(org.junit.Test)

Example 30 with WorkspaceProjectContextChangeEvent

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

the class LibraryPlacesTest method goToOrganizationalUnitsTest.

@Test
public void goToOrganizationalUnitsTest() {
    final PlaceRequest placeRequest = new DefaultPlaceRequest(LibraryPlaces.ORGANIZATIONAL_UNITS_SCREEN);
    final PartDefinitionImpl part = new PartDefinitionImpl(placeRequest);
    part.setSelectable(false);
    libraryPlaces.goToOrganizationalUnits();
    verify(projectContextChangeEvent).fire(projectContextChangeEventArgumentCaptor.capture());
    assertNull(projectContextChangeEventArgumentCaptor.getValue().getOrganizationalUnit());
    final ArgumentCaptor<WorkspaceProjectContextChangeEvent> eventArgumentCaptor = ArgumentCaptor.forClass(WorkspaceProjectContextChangeEvent.class);
    verify(projectContextChangeEvent).fire(eventArgumentCaptor.capture());
    final WorkspaceProjectContextChangeEvent event = eventArgumentCaptor.getValue();
    assertNull(event.getOrganizationalUnit());
    assertNull(event.getWorkspaceProject());
    verify(placeManager).closeAllPlaces();
    verify(placeManager).goTo(eq(part), Mockito.<PanelDefinition>any());
    verify(libraryBreadcrumbs).setupForSpacesScreen();
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) PartDefinitionImpl(org.uberfire.workbench.model.impl.PartDefinitionImpl) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Test(org.junit.Test)

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