Ejemplo n.º 1
0
 protected void loadCls(Cls cls) {
   setMainIcon(getIcon(cls));
   setMainText(cls.getBrowserText());
   appendText(getInstanceCountString(cls));
   appendType(cls);
   setBackgroundSelectionColor(Colors.getClsSelectionColor());
 }
 public void doMove(Collection paths) {
   Iterator i = paths.iterator();
   while (i.hasNext()) {
     TreePath path = (TreePath) i.next();
     LazyTreeNode draggedNode = (LazyTreeNode) path.getLastPathComponent();
     LazyTreeNode draggedNodeParent = (LazyTreeNode) draggedNode.getParent();
     Cls draggedCls = (Cls) draggedNode.getUserObject();
     Cls draggedClsParent = (Cls) draggedNodeParent.getUserObject();
     if (draggedCls instanceof OWLNamedClass) {
       OWLNamedClass namedClass = (OWLNamedClass) draggedCls;
       if (namedClass.isDefinedClass()) {
         for (Iterator it = namedClass.getEquivalentClasses().iterator(); it.hasNext(); ) {
           RDFSClass equi = (RDFSClass) it.next();
           if (equi instanceof OWLIntersectionClass) {
             if (((OWLIntersectionClass) equi)
                 .hasOperandWithBrowserText(draggedClsParent.getBrowserText())) {
               return;
             }
           }
         }
       }
     }
     draggedCls.removeDirectSuperclass(draggedClsParent);
   }
 }
Ejemplo n.º 3
0
 public int addRow(Cls cls) {
   if (cls.equals(tableModel.getEditedCls())) {
     tableModel.displaySemanticError("Cannot assign " + cls.getBrowserText() + " to itself.");
     return -1;
   } else {
     RDFSClass rdfsClass = (RDFSClass) cls;
     if (tableModel.addRow(rdfsClass, getSelectedRow())) {
       setSelectedRow(rdfsClass);
       return tableModel.getClassRow(rdfsClass);
     } else {
       tableModel.displaySemanticError("Could not add " + cls.getBrowserText() + ".");
       if (rdfsClass instanceof OWLAnonymousClass) {
         rdfsClass.delete();
       }
       return -1;
     }
   }
 }
 private void setAllowedClses(RDFSNamedClass cls, Slot slot, Collection newAllowedClses) {
   if (log.isLoggable(Level.FINE)) {
     log.fine("+ Setting allowed clses of " + cls.getName() + "." + slot.getName());
   }
   for (Iterator it = newAllowedClses.iterator(); it.hasNext(); ) {
     Cls ac = (Cls) it.next();
     if (log.isLoggable(Level.FINE)) {
       log.fine("  - " + ac.getBrowserText());
     }
   }
   ((Cls) cls).setTemplateSlotAllowedClses(slot, newAllowedClses);
 }
Ejemplo n.º 5
0
 private void setCls(Cls cls) {
   selectedCls = cls;
   name = tab.getWrapper().getInternalName(selectedCls);
   value_field.setText(cls.getBrowserText());
 }
Ejemplo n.º 6
0
  public JPanel createPanel() {
    JPanel panel = new JPanel();
    panel.setLocation(450, 300);
    panel.setLayout(new GridLayout(2, 1));

    LabeledComponent lc = null;
    JPanel definingPanel = new JPanel();
    definingPanel.setLayout(new BorderLayout());
    JLabel definingLabel = new JLabel("  Defining");
    definingCheckBox = new JCheckBox();
    definingCheckBox.setSelected(defining);
    definingCheckBox.setEnabled(definingEditable);

    definingPanel.add(definingCheckBox, BorderLayout.WEST);
    definingPanel.add(definingLabel, BorderLayout.CENTER);

    panel.add(definingPanel);

    value_field = new JTextField("");
    value_field.setEditable(false);

    String pt = selectedCls != null ? selectedCls.getBrowserText() : "";
    value_field.setText(pt);

    value_field.setPreferredSize(new Dimension(300, 20));
    lc = new LabeledComponent("Select a superclass", value_field);

    Action SelectPropertyValueAction =
        new AbstractAction("Select a superclass...", OWLIcons.getAddIcon("PrimitiveClass")) {
          private static final long serialVersionUID = 123456009L;

          public void actionPerformed(ActionEvent e) {
            // java.awt.TextField textfield = new TextField();
            String label = "Select a named class";

            Collection clses = tab.getOWLWrapper().getSelectableRoots();

            boolean ok = false;

            while (!ok) {

              final NCISelectClsesPanel p = new NCISelectClsesPanel(owlModel, clses);
              int result = ModalDialog.showDialog(tab, p, label, ModalDialog.MODE_OK_CANCEL);
              if (result == ModalDialogFactory.OPTION_OK) {
                Collection c = p.getSelection();
                if (c != null && c.size() > 0) {
                  Iterator it = c.iterator();
                  Object obj = it.next();
                  String clsName = ((OWLNamedClass) obj).getPrefixedName();
                  // tab.getOWLWrapper()
                  // .getInternalName((Cls) obj);
                  if (clsName.compareTo("owl:Thing") == 0) {

                  } else {
                    setCls((Cls) obj);
                    ok = true;
                  }
                }

              } else {
                // user cancelled
                ok = true;
              }
            }
          }
        };

    lc.addHeaderButton(SelectPropertyValueAction);
    panel.add(lc);

    return panel;
  }