use of org.uberfire.mvp.impl.PathPlaceRequest in project kie-wb-common by kiegroup.
the class LibraryPlaces method onSelectPlaceEvent.
public void onSelectPlaceEvent(@Observes final PlaceGainFocusEvent placeGainFocusEvent) {
if (isLibraryPerspectiveOpen() && !closingLibraryPlaces) {
final PlaceRequest place = placeGainFocusEvent.getPlace();
if (place instanceof PathPlaceRequest) {
final PathPlaceRequest pathPlaceRequest = (PathPlaceRequest) place;
setupLibraryBreadCrumbsForAsset(pathPlaceRequest.getPath());
showDocks();
} else if (!place.getIdentifier().equals(ALERTS) && isLibraryPlace(place)) {
hideDocks();
if (place.getIdentifier().equals(PROJECT_SETTINGS)) {
setupLibraryBreadCrumbsForAsset(null);
} else if (projectContext.getActiveWorkspaceProject().isPresent() && place.getIdentifier().equals(LibraryPlaces.PROJECT_SCREEN)) {
setupLibraryBreadCrumbs();
} else if (place.getIdentifier().equals(LibraryPlaces.LIBRARY_SCREEN)) {
setupLibraryBreadCrumbsWithoutProject();
}
}
}
}
use of org.uberfire.mvp.impl.PathPlaceRequest in project kie-wb-common by kiegroup.
the class LibraryPlaces method goToAsset.
public void goToAsset(final Path path) {
moduleService.call((RemoteCallback<Package>) response -> {
projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(projectContext.getActiveWorkspaceProject().orElse(null), projectContext.getActiveModule().orElse(null), response));
final PlaceRequest placeRequest = generatePlaceRequest(path);
placeManager.goTo(placeRequest);
if (path != null) {
final ObservablePath observablePath = ((PathPlaceRequest) placeRequest).getPath();
observablePath.onRename(() -> libraryBreadcrumbs.setupForAsset(getActiveWorkspace(), observablePath));
}
}).resolvePackage(path);
}
use of org.uberfire.mvp.impl.PathPlaceRequest in project kie-wb-common by kiegroup.
the class CloseUnsavedProjectAssetsPopUpPresenterTest method showTest.
@Test
public void showTest() {
final Command proceedCallback = mock(Command.class);
final Command cancelCallback = mock(Command.class);
final WorkspaceProject project = mock(WorkspaceProject.class);
doReturn(createPath("default://project/")).when(project).getRootPath();
doReturn("project").when(project).getName();
final PathPlaceRequest pathPlaceRequest = mock(PathPlaceRequest.class);
doReturn(createPath("default://project/package/Asset.java")).when(pathPlaceRequest).getPath();
final List<PlaceRequest> uncloseablePlaces = new ArrayList<>();
uncloseablePlaces.add(new DefaultPlaceRequest("screen"));
uncloseablePlaces.add(pathPlaceRequest);
presenter.show(project, uncloseablePlaces, proceedCallback, cancelCallback);
verify(view).clearPlaces();
verify(closeUnsavedProjectAssetsPopUpListItemPresenter).setup("screen");
verify(closeUnsavedProjectAssetsPopUpListItemPresenter).setup("package/Asset.java");
verify(view, times(2)).addPlace(any());
verify(view).show("project");
}
use of org.uberfire.mvp.impl.PathPlaceRequest in project kie-wb-common by kiegroup.
the class LibraryPlacesTest method goToAssetTestWithPackage.
@Test
public void goToAssetTestWithPackage() {
final ObservablePath path = mock(ObservablePath.class);
final PathPlaceRequest pathPlaceRequest = mock(PathPlaceRequest.class);
doReturn(path).when(pathPlaceRequest).getPath();
doReturn(pathPlaceRequest).when(libraryPlaces).createPathPlaceRequest(any(Path.class));
final Package pkg = mock(Package.class);
doReturn(pkg).when(moduleService).resolvePackage(path);
libraryPlaces.goToAsset(path);
verify(projectContextChangeEvent).fire(projectContextChangeEventArgumentCaptor.capture());
final WorkspaceProjectContextChangeEvent contextChangeEvent = projectContextChangeEventArgumentCaptor.getValue();
assertEquals(activeProject, contextChangeEvent.getWorkspaceProject());
assertEquals(activeModule, contextChangeEvent.getModule());
assertEquals(pkg, contextChangeEvent.getPackage());
verify(placeManager).goTo(pathPlaceRequest);
final ArgumentCaptor<WorkspaceProjectContextChangeEvent> eventArgumentCaptor = ArgumentCaptor.forClass(WorkspaceProjectContextChangeEvent.class);
verify(projectContextChangeEvent).fire(eventArgumentCaptor.capture());
final WorkspaceProjectContextChangeEvent value = eventArgumentCaptor.getValue();
assertEquals(activeProject, value.getWorkspaceProject());
assertEquals(activeModule, value.getModule());
assertEquals(pkg, value.getPackage());
}
use of org.uberfire.mvp.impl.PathPlaceRequest in project kie-wb-common by kiegroup.
the class LibraryPlacesTest method onSelectAssetTest.
@Test
public void onSelectAssetTest() {
doReturn(libraryPerspective).when(perspectiveManager).getCurrentPerspective();
final ObservablePath path = mock(ObservablePath.class);
final PathPlaceRequest pathPlaceRequest = mock(PathPlaceRequest.class);
doReturn(path).when(pathPlaceRequest).getPath();
final PlaceGainFocusEvent placeGainFocusEvent = mock(PlaceGainFocusEvent.class);
doReturn(pathPlaceRequest).when(placeGainFocusEvent).getPlace();
libraryPlaces.onSelectPlaceEvent(placeGainFocusEvent);
verify(libraryBreadcrumbs).setupForAsset(libraryPlaces.getActiveWorkspace(), path);
}
Aggregations