Search in sources :

Example 1 with CollectionViewPlace

use of edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace in project webprotege by protegeproject.

the class CollectionItemListPresenter method displayCurrentPlace.

private void displayCurrentPlace() {
    Place place = placeController.getWhere();
    if (!(place instanceof CollectionViewPlace)) {
        return;
    }
    CollectionViewPlace collectionViewPlace = (CollectionViewPlace) place;
    collectionViewPlace.getSelection().ifPresent(view::setSelection);
}
Also used : CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) Place(com.google.gwt.place.shared.Place)

Example 2 with CollectionViewPlace

use of edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace in project webprotege by protegeproject.

the class CollectionPresenter method displayCurrentPlace.

private void displayCurrentPlace() {
    Place currentPlace = placeController.getWhere();
    GWT.log("[CollectionPresenter] Display current place: " + currentPlace);
    if (currentPlace instanceof CollectionViewPlace) {
        submitFormData();
        CollectionViewPlace collectionViewPlace = (CollectionViewPlace) currentPlace;
        displayForm(collectionViewPlace);
    }
}
Also used : CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) Place(com.google.gwt.place.shared.Place)

Example 3 with CollectionViewPlace

use of edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace in project webprotege by protegeproject.

the class CollectionViewPlaceTokenizer method getPlace.

@Override
public CollectionViewPlace getPlace(String token) {
    MatchResult result = regExp.exec(token);
    ProjectId projectId = ProjectId.get(result.getGroup(1));
    CollectionId collectionId = CollectionId.get(result.getGroup(2));
    FormId formId = new FormId(result.getGroup(3));
    String selectionString = result.getGroup(5);
    GWT.log("[CollectionViewPlaceTokenizer] Selection string: " + selectionString);
    Optional<CollectionItem> selection = Optional.ofNullable(selectionString).map(CollectionItem::get);
    return new CollectionViewPlace(projectId, collectionId, formId, selection);
}
Also used : CollectionId(edu.stanford.bmir.protege.web.shared.collection.CollectionId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) FormId(edu.stanford.bmir.protege.web.shared.form.FormId) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 4 with CollectionViewPlace

use of edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace in project webprotege by protegeproject.

the class CollectionPresenter method handleAddCollectionItems.

private void handleAddCollectionItems() {
    current.ifPresent(subject -> {
        addItemPromptProvider.get().showPrompt(itemNamesString -> {
            // Create Empty Data for the fresh item
            List<String> itemNames = Arrays.stream(itemNamesString.split("\n")).map(String::trim).collect(Collectors.toList());
            if (itemNames.isEmpty()) {
                return;
            }
            CollectionItem freshItem = CollectionItem.get(itemNames.get(0));
            dispatchServiceManager.execute(new CreateCollectionItemsAction(subject.getProjectId(), subject.getCollectionId(), itemNames), result -> {
                placeController.goTo(new CollectionViewPlace(subject.getProjectId(), subject.getCollectionId(), subject.getFormId(), Optional.of(freshItem)));
                listPresenter.refresh(() -> {
                });
            });
        });
    });
}
Also used : CreateCollectionItemsAction(edu.stanford.bmir.protege.web.shared.collection.CreateCollectionItemsAction) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem)

Example 5 with CollectionViewPlace

use of edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace 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();
    });
}
Also used : CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) GetCollectionItemsAction(edu.stanford.bmir.protege.web.shared.collection.GetCollectionItemsAction) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) Place(com.google.gwt.place.shared.Place)

Aggregations

CollectionViewPlace (edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace)6 Place (com.google.gwt.place.shared.Place)4 CollectionItem (edu.stanford.bmir.protege.web.shared.collection.CollectionItem)3 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 CollectionId (edu.stanford.bmir.protege.web.shared.collection.CollectionId)1 CreateCollectionItemsAction (edu.stanford.bmir.protege.web.shared.collection.CreateCollectionItemsAction)1 GetCollectionItemsAction (edu.stanford.bmir.protege.web.shared.collection.GetCollectionItemsAction)1 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1