Search in sources :

Example 1 with ClientProjectModule

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

Example 2 with ClientProjectModule

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;
    }
}
Also used : ClientProjectModule(edu.stanford.bmir.protege.web.client.inject.ClientProjectModule) ClientProjectComponent(edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent) CollectionPresenter(edu.stanford.bmir.protege.web.client.collection.CollectionPresenter)

Example 3 with ClientProjectModule

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();
}
Also used : ClientProjectModule(edu.stanford.bmir.protege.web.client.inject.ClientProjectModule) ClientProjectComponent(edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId)

Aggregations

ClientProjectComponent (edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent)3 ClientProjectModule (edu.stanford.bmir.protege.web.client.inject.ClientProjectModule)3 CollectionPresenter (edu.stanford.bmir.protege.web.client.collection.CollectionPresenter)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 Place (com.google.gwt.place.shared.Place)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 SharingSettingsPlace (edu.stanford.bmir.protege.web.shared.sharing.SharingSettingsPlace)1