Search in sources :

Example 1 with ProjectPresenter

use of edu.stanford.bmir.protege.web.client.project.ProjectPresenter 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;
}
Also used : SharingSettingsActivity(edu.stanford.bmir.protege.web.client.sharing.SharingSettingsActivity) CollectionPresenter(edu.stanford.bmir.protege.web.client.collection.CollectionPresenter) ClientProjectModule(edu.stanford.bmir.protege.web.client.inject.ClientProjectModule) ClientProjectComponent(edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent) ProjectSettingsActivity(edu.stanford.bmir.protege.web.client.projectsettings.ProjectSettingsActivity) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectPresenter(edu.stanford.bmir.protege.web.client.project.ProjectPresenter) LoginPlace(edu.stanford.bmir.protege.web.shared.login.LoginPlace) SharingSettingsPlace(edu.stanford.bmir.protege.web.shared.sharing.SharingSettingsPlace) ProjectTagsActivity(edu.stanford.bmir.protege.web.client.tag.ProjectTagsActivity) Place(com.google.gwt.place.shared.Place) LoginPlace(edu.stanford.bmir.protege.web.shared.login.LoginPlace) SharingSettingsPlace(edu.stanford.bmir.protege.web.shared.sharing.SharingSettingsPlace) SharingSettingsPresenter(edu.stanford.bmir.protege.web.client.sharing.SharingSettingsPresenter)

Aggregations

Place (com.google.gwt.place.shared.Place)1 CollectionPresenter (edu.stanford.bmir.protege.web.client.collection.CollectionPresenter)1 ClientProjectComponent (edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent)1 ClientProjectModule (edu.stanford.bmir.protege.web.client.inject.ClientProjectModule)1 ProjectPresenter (edu.stanford.bmir.protege.web.client.project.ProjectPresenter)1 ProjectSettingsActivity (edu.stanford.bmir.protege.web.client.projectsettings.ProjectSettingsActivity)1 SharingSettingsActivity (edu.stanford.bmir.protege.web.client.sharing.SharingSettingsActivity)1 SharingSettingsPresenter (edu.stanford.bmir.protege.web.client.sharing.SharingSettingsPresenter)1 ProjectTagsActivity (edu.stanford.bmir.protege.web.client.tag.ProjectTagsActivity)1 LoginPlace (edu.stanford.bmir.protege.web.shared.login.LoginPlace)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 SharingSettingsPlace (edu.stanford.bmir.protege.web.shared.sharing.SharingSettingsPlace)1