public Object setValue(Object aValue, int row) { RDFProperty property = getPredicate(row); Object oldValue = getValue(row); if (oldValue == null || !oldValue.equals(aValue)) { try { Object newValue; String str = aValue.toString(); OWLModel owlModel = property.getOWLModel(); if (owlModel.getOWLOntologyProperties().contains(property)) { String message = str + " is not a valid URI."; try { new URI(str); } catch (Exception ex) { ProtegeUI.getModalDialogFactory().showErrorMessageDialog(owlModel, message); return oldValue; } if (!str.startsWith("http://") && !str.startsWith("file:")) { ProtegeUI.getModalDialogFactory().showErrorMessageDialog(owlModel, message); return oldValue; } } String lang = getLanguage(row); if (aValue instanceof RDFSLiteral && ((RDFSLiteral) aValue).getLanguage() != null) { newValue = aValue; } else if (lang != null) { newValue = createNewValue(property, str, lang); } else if (oldValue instanceof RDFSLiteral) { RDFSLiteral oldLiteral = (RDFSLiteral) oldValue; newValue = getOWLModel().createRDFSLiteral(str, oldLiteral.getDatatype()); } else if (oldValue instanceof Boolean) { newValue = Boolean.valueOf(str.equals("true")); } else if (oldValue instanceof Float) { newValue = Float.valueOf(str); } else if (oldValue instanceof Integer) { newValue = Integer.valueOf(str); } else { newValue = str; } if (!subject.getPropertyValues(property).contains(newValue)) { if (oldValue != null) { subject.removePropertyValue(property, oldValue); } subject.addPropertyValue(property, newValue); } return newValue; } catch (NumberFormatException ex) { // Ignore illegal number format } } return oldValue; }
public Object getValueAt(int rowIndex, int columnIndex) { if (columnIndex == COL_PROPERTY) { return getPredicate(rowIndex); } else if (columnIndex == COL_VALUE) { return getDisplayValue(rowIndex); } else if (isTypeColumn(columnIndex)) { Object value = getValue(rowIndex); if (value instanceof RDFResource) { return ((RDFResource) value).getRDFType(); } else if (value instanceof RDFSLiteral) { return ((RDFSLiteral) value).getDatatype(); } else { RDFSLiteral literal = DefaultRDFSLiteral.create(getOWLModel(), value); return literal.getDatatype(); } } else { return getLanguage(rowIndex); } }