Search in sources :

Example 16 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 17 with WorkspaceProjectContextChangeEvent

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

the class LibraryServiceImplTest method importProjectFromExampleTest.

@Test
public void importProjectFromExampleTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final ExampleProject exampleProject = mock(ExampleProject.class);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Module module = mock(Module.class);
    doReturn(module).when(project).getMainModule();
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
    doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
    doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
    final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
    assertEquals(module, importedProject.getMainModule());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 18 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)) {
        if (closeAllPlacesOrNothing()) {
            projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(project, project.getMainModule()));
            goToProject();
        }
    } else {
        goToProject();
    }
}
Also used : Remote(org.kie.workbench.common.screens.library.api.Remote) WorkbenchProjectMetricsEvent(org.kie.workbench.common.screens.library.client.events.WorkbenchProjectMetricsEvent) AssetDetailEvent(org.kie.workbench.common.screens.library.client.events.AssetDetailEvent) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) PreferenceScopeResolutionStrategyInfo(org.uberfire.preferences.shared.impl.PreferenceScopeResolutionStrategyInfo) ProjectScopedResolutionStrategySupplier(org.guvnor.common.services.project.client.preferences.ProjectScopedResolutionStrategySupplier) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) 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) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) MessageConsoleScreen(org.guvnor.messageconsole.client.console.MessageConsoleScreen) Repository(org.guvnor.structure.repositories.Repository) LibraryToolbarPresenter(org.kie.workbench.common.screens.library.client.widgets.library.LibraryToolbarPresenter) 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) ExtendedTypes(org.ext.uberfire.social.activities.model.ExtendedTypes) SocialFileSelectedEvent(org.ext.uberfire.social.activities.model.SocialFileSelectedEvent) 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) WorkspaceProjectContextChangeHandler(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeHandler) PreferencesRootScreen(org.uberfire.ext.preferences.client.central.screen.PreferencesRootScreen) PlaceStatus(org.uberfire.client.mvp.PlaceStatus) RenameModuleEvent(org.guvnor.common.services.project.events.RenameModuleEvent) RemoveOrganizationalUnitEvent(org.guvnor.structure.organizationalunit.RemoveOrganizationalUnitEvent) HashMap(java.util.HashMap) PlaceManager(org.uberfire.client.mvp.PlaceManager) ProjectAssetListUpdated(org.kie.workbench.common.screens.library.api.ProjectAssetListUpdated) PreferencesCentralUndoChangesEvent(org.uberfire.ext.preferences.client.event.PreferencesCentralUndoChangesEvent) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ImportRepositoryPopUpPresenter(org.kie.workbench.common.screens.library.client.screens.importrepository.ImportRepositoryPopUpPresenter) PortablePreconditions(org.kie.soup.commons.validation.PortablePreconditions) Path(org.uberfire.backend.vfs.Path) 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) ModuleEventType(org.guvnor.common.services.project.social.ModuleEventType) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) PreferencesCentralInitializationEvent(org.uberfire.ext.preferences.client.event.PreferencesCentralInitializationEvent) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) VFSService(org.uberfire.backend.vfs.VFSService) RepositoryRemovedEvent(org.guvnor.structure.repositories.RepositoryRemovedEvent) AuthoringWorkbenchDocks(org.kie.workbench.common.workbench.client.docks.AuthoringWorkbenchDocks) Collections(java.util.Collections) LibraryPerspective(org.kie.workbench.common.screens.library.client.perspective.LibraryPerspective) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 19 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).closeAllPlacesOrNothing();
    verify(placeManager).goTo(eq(part), any(PanelDefinition.class));
    verify(libraryPlaces).setupLibraryBreadCrumbs();
}
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) PanelDefinition(org.uberfire.workbench.model.PanelDefinition) 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)19 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)10 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)8 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)7 Test (org.junit.Test)7 DefaultPlaceRequest (org.uberfire.mvp.impl.DefaultPlaceRequest)7 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)6 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)6 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)6 Path (org.uberfire.backend.vfs.Path)5 PartDefinitionImpl (org.uberfire.workbench.model.impl.PartDefinitionImpl)5 ArrayList (java.util.ArrayList)4 Repository (org.guvnor.structure.repositories.Repository)4 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)4 ObservablePath (org.uberfire.backend.vfs.ObservablePath)4 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)3 Package (org.guvnor.common.services.project.model.Package)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2