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