Search in sources :

Example 1 with ColumnType

use of edu.stanford.bmir.protege.web.shared.csv.ColumnType in project webprotege by protegeproject.

the class CSVColumnRelationEditorViewImpl method handleRelationTypeFieldChanged.

@UiHandler("relationTypeField")
protected void handleRelationTypeFieldChanged(ChangeEvent event) {
    final Optional<OWLPrimitiveData> property = propertyField.getValue();
    if (property.isPresent()) {
        EntityType<?> propertyType = ((OWLEntity) property.get().getObject()).getEntityType();
        if (getColumnType().isPresent()) {
            ColumnType type = getColumnType().get();
            List<EntityType<?>> propertyTypes = type.getPropertyTypes();
            if (!propertyTypes.contains(propertyType)) {
                final EntityType<?> firstPermissiblePropertyType = propertyTypes.get(0);
                propertyField.coerceToEntityType(firstPermissiblePropertyType);
            }
        }
    }
    ValueChangeEvent.fire(this, property);
}
Also used : EntityType(org.semanticweb.owlapi.model.EntityType) ColumnType(edu.stanford.bmir.protege.web.shared.csv.ColumnType) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 2 with ColumnType

use of edu.stanford.bmir.protege.web.shared.csv.ColumnType in project webprotege by protegeproject.

the class CSVColumnRelationEditorViewImpl method updateRelationTypeField.

private void updateRelationTypeField() {
    Optional<OWLPrimitiveData> property = propertyField.getValue();
    int selIndex = relationTypeField.getSelectedIndex();
    Optional<String> selectedItem;
    if (selIndex != -1) {
        selectedItem = Optional.of(relationTypeField.getItemText(selIndex));
    } else {
        selectedItem = Optional.empty();
    }
    List<String> nextItems = new ArrayList<>();
    if (property.isPresent()) {
        OWLPrimitiveData primitiveData = property.get();
        final OWLEntity prop = (OWLEntity) primitiveData.getObject();
        boolean freshEntity = DataFactory.isFreshEntity(prop);
        if (freshEntity) {
            for (ColumnType columnType : ColumnType.values()) {
                nextItems.add(columnType.getDisplayName());
            }
        } else {
            for (ColumnType columnType : ColumnType.values()) {
                if (columnType.isPropertyType(prop.getEntityType())) {
                    nextItems.add(columnType.getDisplayName());
                }
            }
        }
    }
    int nextSelIndex = 0;
    relationTypeField.clear();
    for (int i = 0; i < nextItems.size(); i++) {
        String nextItem = nextItems.get(i);
        relationTypeField.addItem(nextItem);
        if (selectedItem.orElse("").equals(nextItem)) {
            nextSelIndex = i;
        }
    }
    relationTypeField.setSelectedIndex(nextSelIndex);
}
Also used : ColumnType(edu.stanford.bmir.protege.web.shared.csv.ColumnType) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) ArrayList(java.util.ArrayList) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Aggregations

ColumnType (edu.stanford.bmir.protege.web.shared.csv.ColumnType)2 OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)2 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 UiHandler (com.google.gwt.uibinder.client.UiHandler)1 ArrayList (java.util.ArrayList)1 EntityType (org.semanticweb.owlapi.model.EntityType)1