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