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