use of edu.stanford.bmir.protege.web.client.inject.ClientProjectModule in project webprotege by protegeproject.
the class WebProtegeActivityMapper method getActivity.
public Activity getActivity(final Place place) {
GWT.log("[WebProtegeActivityMapper] Map place: " + place);
if (shouldRedirectToLogin(place)) {
GWT.log("[WebProtegeActivityMapper] User is not logged in. Redirecting to login.");
loginPresenter.setNextPlace(place);
Scheduler.get().scheduleFinally(() -> placeController.goTo(new LoginPlace(place)));
return new LoginActivity(loginPresenter);
}
if (place instanceof ApplicationSettingsPlace) {
return new AdminActivity(applicationSettingsPresenter);
}
if (place instanceof ProjectSettingsPlace) {
ProjectSettingsPlace projectSettingsPlace = (ProjectSettingsPlace) place;
ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectSettingsPlace.getProjectId()));
return new ProjectSettingsActivity(projectComponent.getProjectSettingsPresenter(), projectSettingsPlace.getNextPlace());
}
if (place instanceof ProjectPrefixDeclarationsPlace) {
ProjectPrefixDeclarationsPlace projectPrefixDeclarationsPlace = (ProjectPrefixDeclarationsPlace) place;
ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectPrefixDeclarationsPlace.getProjectId()));
return new ProjectPrefixDeclarationsActivity(projectPrefixDeclarationsPlace.getProjectId(), projectComponent.getProjectPrefixesPresenter());
}
if (place instanceof ProjectTagsPlace) {
ProjectTagsPlace projectTagsPlace = (ProjectTagsPlace) place;
ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectTagsPlace.getProjectId()));
return new ProjectTagsActivity(projectTagsPlace.getProjectId(), projectComponent.getProjectTagsPresenter(), projectTagsPlace.getNextPlace());
}
if (place instanceof LoginPlace) {
if (!loggedInUserProvider.getCurrentUserId().isGuest()) {
Scheduler.get().scheduleFinally(() -> placeController.goTo(new ProjectListPlace()));
} else {
LoginPlace loginPlace = (LoginPlace) place;
Optional<Place> continueTo = loginPlace.getContinueTo();
if (continueTo.isPresent()) {
loginPresenter.setNextPlace(continueTo.get());
} else {
loginPresenter.setNextPlace(new ProjectListPlace());
}
return new LoginActivity(loginPresenter);
}
}
if (place instanceof SignUpPlace) {
SignUpPlace signUpPlace = (SignUpPlace) place;
Optional<Place> continueTo = signUpPlace.getContinueTo();
continueTo.ifPresent(signUpPresenter::setContinueTo);
return new SignUpActivity(signUpPresenter);
}
if (place instanceof ProjectListPlace) {
return new ProjectListActivity(projectManagerPresenter);
}
if (place instanceof ProjectViewPlace) {
ProjectViewPlace projectViewPlace = (ProjectViewPlace) place;
ProjectPresenter presenter = getProjectPresenter(projectViewPlace);
lastProjectPresenter = Optional.of(presenter);
lastUser = Optional.of(loggedInUserProvider.getCurrentUserId());
return new ProjectViewActivity(presenter, projectViewPlace);
}
if (place instanceof SharingSettingsPlace) {
SharingSettingsPlace sharingSettingsPlace = (SharingSettingsPlace) place;
ProjectId projectId = sharingSettingsPlace.getProjectId();
ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectId));
SharingSettingsPresenter presenter = projectComponent.getSharingSettingsPresenter();
return new SharingSettingsActivity(presenter, sharingSettingsPlace);
}
if (place instanceof CollectionViewPlace) {
CollectionViewPlace collectionViewPlace = (CollectionViewPlace) place;
CollectionPresenter collectionPresenter = getCollectionPresenter(collectionViewPlace);
// lastUser = Optional.of(loggedInUserProvider.getCurrentUserId());
return new CollectionViewActivity(collectionPresenter, collectionViewPlace);
}
return null;
}
use of edu.stanford.bmir.protege.web.client.inject.ClientProjectModule in project webprotege by protegeproject.
the class WebProtegeActivityMapper method getCollectionPresenter.
private CollectionPresenter getCollectionPresenter(CollectionViewPlace place) {
if (lastCollectionPresenter.isPresent()) {
GWT.log("[WebProtegeActivityMapper] Reusing collection presenter");
return lastCollectionPresenter.get();
} else {
GWT.log("[WebProtegeActivityMapper] Instantiating collection presenter");
ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(place.getProjectId()));
CollectionPresenter collectionPresenter = projectComponent.getCollectionPresenter();
lastCollectionPresenter = Optional.of(collectionPresenter);
return collectionPresenter;
}
}
use of edu.stanford.bmir.protege.web.client.inject.ClientProjectModule in project webprotege by protegeproject.
the class WebProtegeActivityMapper method getProjectPresenter.
private ProjectPresenter getProjectPresenter(ProjectViewPlace projectViewPlace) {
if (lastProjectPresenter.isPresent()) {
ProjectId lastProjectId = lastProjectPresenter.get().getProjectId();
if (lastProjectId.equals(projectViewPlace.getProjectId()) && lastUser.equals(Optional.of(loggedInUserProvider.getCurrentUserId()))) {
GWT.log("[WebProtegeActivityMapper] Presenter for place is already being displayed for current user");
return lastProjectPresenter.get();
} else {
GWT.log("[WebProtegeActivityMapper] Different place. Disposing of previous place.");
lastProjectPresenter.get().dispose();
}
}
ProjectIdProvider.setProjectId(projectViewPlace.getProjectId());
GWT.log("[WebProtegeActivityMapper] Instantiating project presenter for " + projectViewPlace.getProjectId());
ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectViewPlace.getProjectId()));
return projectComponent.getProjectPresenter();
}
Aggregations