use of com.google.gwt.place.shared.Place in project webprotege by protegeproject.
the class SelectionModel method setSelection.
public void setSelection(OWLEntity entity) {
Place place = placeController.getWhere();
if (!(place instanceof ProjectViewPlace)) {
return;
}
Item<?> item = entity.accept(new OWLEntityVisitorEx<Item<?>>() {
@Nonnull
@Override
public Item<?> visit(@Nonnull OWLClass desc) {
selectedClassManager.setSelection(desc);
return new OWLClassItem(desc);
}
@Nonnull
@Override
public Item<?> visit(@Nonnull OWLDatatype node) {
selectedDatatypeManager.setSelection(node);
throw new RuntimeException("Not Supported");
}
@Nonnull
@Override
public Item<?> visit(@Nonnull OWLDataProperty property) {
selectedDataPropertyManager.setSelection(property);
return new OWLDataPropertyItem(property);
}
@Nonnull
@Override
public Item<?> visit(@Nonnull OWLObjectProperty property) {
selectedObjectPropertyManager.setSelection(property);
return new OWLObjectPropertyItem(property);
}
@Nonnull
@Override
public Item<?> visit(@Nonnull OWLNamedIndividual individual) {
selectedIndividualManager.setSelection(individual);
return new OWLNamedIndividualItem(individual);
}
@Nonnull
@Override
public Item<?> visit(@Nonnull OWLAnnotationProperty property) {
selectedAnnotationPropertyManager.setSelection(property);
return new OWLAnnotationPropertyItem(property);
}
});
ItemSelection nextSelection = ItemSelection.builder().addItem(item).build();
if (nextSelection.equals(selection)) {
return;
}
ProjectViewPlace projectViewPlace = (ProjectViewPlace) place;
ProjectViewPlace nextPlace = projectViewPlace.builder().clearSelection().withSelectedItem(item).build();
placeController.goTo(nextPlace);
}
use of com.google.gwt.place.shared.Place in project webprotege by protegeproject.
the class PerspectiveSwitcherPresenter method goToPlaceForPerspective.
private void goToPlaceForPerspective(PerspectiveId perspectiveId) {
Place currentPlace = placeController.getWhere();
GWT.log("[PerspectiveSwitcherPresenter] Current Place: " + currentPlace);
if (!(currentPlace instanceof ProjectViewPlace)) {
return;
}
ProjectViewPlace projectPerspectivePlace = (ProjectViewPlace) currentPlace;
// Preserve the selection for the current perspective.
// (This could be optional. Previously, we carried selection over)
perspective2Selection.put(projectPerspectivePlace.getPerspectiveId(), projectPerspectivePlace.getItemSelection());
ItemSelection previousSelection = perspective2Selection.get(perspectiveId);
ProjectViewPlace.Builder builder = projectPerspectivePlace.builder();
builder.withPerspectiveId(perspectiveId);
if (previousSelection != null) {
// Restore the selection
builder.clearSelection();
builder.withSelectedItems(previousSelection);
}
ProjectViewPlace nextPlace = builder.build();
placeController.goTo(nextPlace);
}
use of com.google.gwt.place.shared.Place in project webprotege by protegeproject.
the class WebProtegeActivityMapper method start.
public void start() {
GWT.log("[WebProtegeActivityMapper] Started activity mapper.");
eventBus.addHandler(UserLoggedOutEvent.ON_USER_LOGGED_OUT, event -> {
GWT.log("[WebProtegeActivityMapper] User logged out. Going to the Login Place.");
LoginPlace loginPlace;
Place currentPlace = placeController.getWhere();
if (!(currentPlace instanceof LoginPlace)) {
loginPlace = new LoginPlace(placeController.getWhere());
} else {
loginPlace = new LoginPlace();
}
placeController.goTo(loginPlace);
});
}
use of com.google.gwt.place.shared.Place in project webprotege by protegeproject.
the class DispatchServiceManager method handleError.
private void handleError(final Throwable throwable, final Action<?> action, final DispatchServiceCallback<?> callback) {
if (throwable instanceof PermissionDeniedException) {
// Try to determine if the user is logged in. The session might have expired.
UserInSession userInSession = ((PermissionDeniedException) throwable).getUserInSession();
if (userInSession.isGuest()) {
// Set up next place
Place continueTo = placeController.getWhere();
loggedInUser.setLoggedInUser(userInSession);
GWT.log("[Dispatch] Permission denied. User is the guest user so redirecting to login.");
signInRequiredHandler.handleSignInRequired(continueTo);
}
}
// Skip handling for actions that do not care about errors
if (action instanceof InvocationExceptionTolerantAction) {
Optional<String> errorMessage = ((InvocationExceptionTolerantAction) action).handleInvocationException((InvocationException) throwable);
errorMessage.ifPresent(this::displayAlert);
return;
}
callback.onFailure(throwable);
}
use of com.google.gwt.place.shared.Place in project webprotege by protegeproject.
the class CollectionItemListPresenter method refresh.
public void refresh(Runnable runnable) {
Place place = placeController.getWhere();
if (!(place instanceof CollectionViewPlace)) {
return;
}
CollectionViewPlace collectionViewPlace = (CollectionViewPlace) place;
dispatchServiceManager.execute(new GetCollectionItemsAction(collectionViewPlace.getProjectId(), collectionViewPlace.getCollectionId(), PageRequest.requestPage(view.getPageNumber())), busy -> {
}, result -> {
Page<CollectionItem> page = result.getElementIdPage();
view.setPageCount(page.getPageCount());
view.setPageNumber(page.getPageNumber());
view.setElements(page.getPageElements());
collectionViewPlace.getSelection().ifPresent(view::setSelection);
runnable.run();
});
}
Aggregations