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