Search in sources :

Example 1 with EntitySuggestion

use of edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion in project webprotege by protegeproject.

the class PrimitiveDataEditorViewImpl method addSelectionHandler.

@Override
public HandlerRegistration addSelectionHandler(final SelectionHandler<EntitySuggestion> handler) {
    final HandlerRegistration handlerReg = addHandler(handler, SelectionEvent.getType());
    final HandlerRegistration delegateReg = textBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {

        @Override
        public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
            SuggestOracle.Suggestion suggestion = event.getSelectedItem();
            if (suggestion instanceof EntitySuggestion) {
                SelectionEvent.fire(PrimitiveDataEditorViewImpl.this, (EntitySuggestion) suggestion);
            }
        }
    });
    return new HandlerRegistration() {

        @Override
        public void removeHandler() {
            handlerReg.removeHandler();
            delegateReg.removeHandler();
        }
    };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion) EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)

Example 2 with EntitySuggestion

use of edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion in project webprotege by protegeproject.

the class PropertyValueDescriptorEditorImpl method getValue.

@Override
public Optional<PropertyValueDescriptor> getValue() {
    if (state == State.DERIVED) {
        return currentValue;
    } else {
        if (propertyField.getValue().isPresent() && valueField.getValue().isPresent()) {
            Set<OWLAxiom> augmentingAxioms = Sets.newHashSet();
            java.util.Optional<EntitySuggestion> selectedSuggestion = valueField.getSelectedSuggestion();
            if (selectedSuggestion.isPresent()) {
                if (selectedSuggestion.get() instanceof FreshEntitySuggestion) {
                    augmentingAxioms.addAll(((FreshEntitySuggestion) selectedSuggestion.get()).getAugmentingAxioms());
                }
            }
            return Optional.of(new PropertyValueDescriptor((OWLPropertyData) propertyField.getValue().get(), valueField.getValue().get(), state, false, augmentingAxioms));
        } else {
            return Optional.empty();
        }
    }
}
Also used : OWLPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData) EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion) PropertyValueDescriptor(edu.stanford.bmir.protege.web.shared.frame.PropertyValueDescriptor) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom)

Example 3 with EntitySuggestion

use of edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion in project webprotege by protegeproject.

the class AugmentedFreshEntitiesSuggestStrategy method getSuggestions.

@Override
public List<EntitySuggestion> getSuggestions(String query, List<EntityType<?>> suggestedTypes) {
    List<EntitySuggestion> result = Lists.newArrayList();
    for (EntityType<?> type : suggestedTypes) {
        for (Optional<OWLEntityData> auxiliaryType : auxiliaryTypes) {
            Optional<FreshEntitySuggestion> suggestion = getSuggestion(query, type, auxiliaryType);
            if (suggestion.isPresent()) {
                result.add(suggestion.get());
            }
        }
        OWLEntity entity = DataFactory.getFreshOWLEntity(type, query);
        OWLEntityData entityData = DataFactory.getOWLEntityData(entity, query);
        result.add(new EntitySuggestion(entityData, formatSuggestText(query, type)));
    }
    return result;
}
Also used : EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Example 4 with EntitySuggestion

use of edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion in project webprotege by protegeproject.

the class SimpleFreshEntitySuggestStrategy method getSuggestions.

@Override
public List<EntitySuggestion> getSuggestions(String query, List<EntityType<?>> suggestedTypes) {
    List<EntitySuggestion> suggestions = Lists.newArrayList();
    for (EntityType<?> allowedType : suggestedTypes) {
        OWLEntity entity = DataFactory.getFreshOWLEntity(allowedType, query);
        OWLEntityData entityData = DataFactory.getOWLEntityData(entity, query);
        suggestions.add(new EntitySuggestion(entityData, formatSuggestText(query, allowedType)));
    }
    return suggestions;
}
Also used : EntitySuggestion(edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Aggregations

EntitySuggestion (edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)4 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)2 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 OWLPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData)1 PropertyValueDescriptor (edu.stanford.bmir.protege.web.shared.frame.PropertyValueDescriptor)1 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)1