Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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);
   }
 }
Esempio n. 3
0
  public O2WXSLTDialog(
      OWLModel okb, OWLIndividual aP, String wsdl, String wsdlM, OWLIndividual owlInst)
      throws XSLTException {
    super(okb, wsdl);
    atomicProcess = aP;
    wsdlmessageuri = wsdlM;
    m_owlInst = owlInst;
    // Do some sanity checking
    if (wsdl == null) throw new XSLTException("No WSDL document defined.");
    if (wsdlM == null) throw new XSLTException("No WSDL Input Message defined.");
    OWLDatatypeProperty wsdlMessagePartProp =
        okb.getOWLDatatypeProperty("grounding:wsdlMessagePart");
    RDFSLiteral wsdlpart = (RDFSLiteral) owlInst.getPropertyValue(wsdlMessagePartProp);
    if (wsdlpart == null) throw new XSLTException("No WSDL Input Message Part defined.");
    wsdlparturi = wsdlpart.getString();
    if (wsdlparturi == null) throw new XSLTException("No WSDL Input Message Part defined.");
    wsdlInputMessage = getWsdlMessage(wsdlM);
    if (wsdlInputMessage == null)
      throw new XSLTException("WSDL Input Message " + wsdlM + " not found.");
    // WSDL4J sucks. It expects just the local part of the message part uri.
    wsdlInputMessagePart =
        wsdlInputMessage.getPart(wsdlparturi.substring(wsdlparturi.indexOf('#') + 1));
    if (wsdlInputMessagePart == null)
      throw new XSLTException("WSDL Input Message Part " + wsdlparturi + " not found.");

    prepareTree();
    setupGUI();
    Collection inputs = generateParameterNameList(generateParameterList());
    createTranslationPanel();
    O2WParameterPanel pp = (O2WParameterPanel) transPanel;
    pp.getAttributePanel().addParameters(inputs);
    pp.getDataPanel().addParameters(inputs);
    pp.getVariablePanel().addParameters(inputs);
    tree.addTreeSelectionListener((O2WParameterPanel) transPanel);
    tree.addTreeSelectionListener(this);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(new XMLTreeRenderer());
  }