Search in sources :

Example 11 with WorkspaceProjectContextChangeEvent

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

the class LibraryPlaces method onProjectDeleted.

public void onProjectDeleted(@Observes final RepositoryRemovedEvent repositoryRemovedEvent) {
    if (isLibraryPerspectiveOpen() && isRepoForActiveProject(repositoryRemovedEvent)) {
        closeAllPlaces();
        WorkspaceProjectContextChangeEvent contextChangeEvent = projectContext.getActiveOrganizationalUnit().map(ou -> new WorkspaceProjectContextChangeEvent(ou)).orElseGet(() -> new WorkspaceProjectContextChangeEvent());
        projectContextChangeEvent.fire(contextChangeEvent);
        goToLibrary();
        notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.ProjectDeleted), NotificationEvent.NotificationType.DEFAULT));
    }
}
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) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 12 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)

Example 13 with WorkspaceProjectContextChangeEvent

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

the class LibraryServiceImpl method importProject.

@Override
public WorkspaceProject importProject(final OrganizationalUnit organizationalUnit, final ExampleProject exampleProject) {
    final ExampleOrganizationalUnit exampleOrganizationalUnit = new ExampleOrganizationalUnit(organizationalUnit.getName());
    final List<ExampleProject> exampleProjects = Collections.singletonList(exampleProject);
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = examplesService.setupExamples(exampleOrganizationalUnit, exampleProjects);
    return projectContextChangeEvent.getWorkspaceProject();
}
Also used : ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 14 with WorkspaceProjectContextChangeEvent

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

the class LibraryServiceImplTest method importDefaultProjectTest.

@Test
public void importDefaultProjectTest() {
    final Repository repository = mock(Repository.class);
    when(repository.getAlias()).thenReturn("example");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getName()).thenReturn("ou");
    when(organizationalUnit.getIdentifier()).thenReturn("ou");
    when(organizationalUnit.getRepositories()).thenReturn(singletonList(repository));
    when(ouService.getOrganizationalUnits()).thenReturn(singletonList(organizationalUnit));
    final ExampleProject exampleProject = mock(ExampleProject.class);
    doReturn("example").when(exampleProject).getName();
    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());
    verify(examplesService).setupExamples(new ExampleOrganizationalUnit(organizationalUnit.getName()), singletonList(exampleProject));
}
Also used : 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) 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 15 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)

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