示例#1
0
 public boolean isCellEditable(int rowIndex, int columnIndex) {
   if (columnIndex == COL_ENABLED) return true;
   else if (columnIndex == COL_NAME || columnIndex == COL_EXPRESSION) {
     SWRLImp imp = getImp(rowIndex);
     return imp.isEditable();
   } else return false;
 }
示例#2
0
 private boolean isSuitable(SWRLImp imp) {
   if (rdfResource == null) {
     return true;
   } else {
     Set<RDFResource> set = imp.getReferencedInstances();
     return set.contains(rdfResource);
   }
 }
示例#3
0
 private int getRowFor(SWRLImp imp) {
   final String impName = imp.getName();
   int i = 0;
   while (i < imps.size() && impName.compareToIgnoreCase(getImp(i).getName()) >= 0) {
     i++;
   }
   return i;
 }
示例#4
0
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
   SWRLImp imp = getImp(rowIndex);
   if (columnIndex == COL_EXPRESSION) {
     String text = (String) aValue;
     try {
       imp.setExpression(text);
       if (!isSuitable(imp)) {
         ProtegeUI.getModalDialogFactory()
             .showMessageDialog(
                 owlModel,
                 "The replacing rule no longer fits the selection\n"
                     + "criteria of this rules list, and will therefore no\n"
                     + "longer be visible here.  But no reason to panic: It\n"
                     + "should still show up on the SWRL tab.");
       }
     } catch (Exception ex) {
       Log.getLogger().warning("Exception caught defining rule " + ex);
     }
   } else if (columnIndex == COL_NAME) {
     String newName = (String) aValue;
     if (owlModel.isValidResourceName(newName, imp)) {
       RDFResource resource = owlModel.getRDFResource(newName);
       if (resource != null) {
         if (!imp.equals(resource)) {
           ProtegeUI.getModalDialogFactory()
               .showErrorMessageDialog(
                   owlModel, "The name " + newName + " is already used in this ontology.");
         }
       } else {
         imp = (SWRLImp) imp.rename(newName);
         setImp(rowIndex, imp);
       }
     } else
       ProtegeUI.getModalDialogFactory()
           .showErrorMessageDialog(owlModel, newName + " is not a valid rule name.");
   } else if (columnIndex == COL_ENABLED) {
     Boolean enabled = (Boolean) aValue;
     if (enabled.booleanValue()) imp.enable();
     else imp.disable();
   } // if
 } // setValueAt
示例#5
0
  public void disableAll() {
    for (SWRLImp imp : imps) imp.disable();

    fireTableRowsUpdated(0, getRowCount());
  }