public AnnotationsViewSettingsPanel(final OWLModel owlModel) {
    this.owlModel = owlModel;
    list = new SelectableList();
    list.setListData(
        ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView().toArray());
    list.setCellRenderer(new ResourceRenderer());
    LabeledComponent lc =
        new OWLLabeledComponent(
            "Default annotation properties to be shown in the Annotation Widget",
            new JScrollPane(list));
    lc.addHeaderButton(
        new AbstractAction("Add property...", OWLIcons.getAddIcon(OWLIcons.RDF_PROPERTY)) {
          public void actionPerformed(ActionEvent e) {
            addProperty();
          }
        });

    lc.addHeaderButton(
        new AllowableAction(
            "Remove selected property", OWLIcons.getRemoveIcon(OWLIcons.RDF_PROPERTY), list) {
          public void actionPerformed(ActionEvent e) {
            removeSelectedProperty();
          }
        });

    setLayout(new BorderLayout());
    add(BorderLayout.CENTER, lc);
  }
 public Icon getIcon() {
   // Suffix after "Default" in the class name is the icon name
   String className = getClass().getName();
   int index = className.lastIndexOf('.');
   String iconName = className.substring(index + 8);
   if (isEditable()) {
     return OWLIcons.getImageIcon(iconName);
   } else {
     return OWLIcons.getReadOnlyClsIcon(OWLIcons.getImageIcon(iconName));
   }
 }
 protected Collection getActions() {
   ArrayList actions = new ArrayList();
   actions.add(getCreateOWLDatatypePropertyAction());
   Action createSubPropertyAction = getCreateSubpropertyAction();
   createSubPropertyAction.putValue(
       Action.SMALL_ICON, OWLIcons.getCreatePropertyIcon("DatatypeSubProperty"));
   actions.add(createSubPropertyAction);
   getDeletePropertyAction()
       .putValue(Action.SMALL_ICON, OWLIcons.getDeleteIcon("OWLDatatypeProperty"));
   return actions;
 }
 public ImageIcon getImageIcon() {
   // Suffix after "Default" in the class name is the icon name
   String className = getClass().getName();
   int index = className.lastIndexOf('.');
   String iconName = className.substring(index + 8);
   return OWLIcons.getImageIcon(iconName);
 }
  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;
  }
Esempio n. 6
0
  public JPanel makeTreeButtons() {
    JPanel treeButtons = new JPanel(new BorderLayout()); // Box.createHorizontalBox();
    JToolBar toolbar = new JToolBar();

    createClass = new JButton(OWLIcons.getCreateIcon(OWLIcons.RDF_INDIVIDUAL));
    createClass.setToolTipText("Create Instance");
    createClass.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            OWLNamedClass cls = chooseClass();
            if (cls != null) addNewNode(new ClassNode(cls));
          }
        });
    createClass.setBorderPainted(false);
    toolbar.add(createClass);

    createObjectProp = new JButton(OWLIcons.getCreateIcon(OWLIcons.OWL_OBJECT_PROPERTY));
    createObjectProp.setToolTipText("Create object property");
    createObjectProp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            OWLObjectProperty prop = chooseObjectProperty();
            if (prop != null) addNewNode(new ObjectPropertyNode(prop));
          }
        });
    createObjectProp.setBorderPainted(false);
    toolbar.add(createObjectProp);

    createDatatypeProp = new JButton(OWLIcons.getCreateIcon(OWLIcons.OWL_DATATYPE_PROPERTY));
    createDatatypeProp.setToolTipText("Create datatype property");
    createDatatypeProp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            OWLDatatypeProperty prop = chooseDatatypeProperty();
            if (prop != null) addNewNode(new DatatypePropertyNode(prop));
          }
        });
    createDatatypeProp.setBorderPainted(false);
    toolbar.add(createDatatypeProp);

    createData =
        new JButton(((DefaultTreeCellRenderer) tree.getCellRenderer()).getDefaultLeafIcon());
    createData.setToolTipText("Create Data");
    createData.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addNewNode(new DataNode());
          }
        });
    createData.setBorderPainted(false);
    toolbar.add(createData);

    createRDFAttribute = new JButton(OWLSIcons.getXMLAttributeIcon());
    createRDFAttribute.setToolTipText("Create RDF Attribute");
    createRDFAttribute.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            XSLTNode parentNode = (XSLTNode) tree.getLastSelectedPathComponent();
            if (parentNode instanceof ClassNode) addNewNode(new RDFNameNode());
            else if (parentNode instanceof ObjectPropertyNode) addNewNode(new RDFResourceNode());
            else System.out.println("WARNING! Wrong parent type!");
          }
        });
    createRDFAttribute.setBorderPainted(false);
    createRDFAttribute.setEnabled(false);
    toolbar.add(createRDFAttribute);

    createVariable = new JButton(OWLSIcons.getXSLTVariableIcon());
    createVariable.setToolTipText("Create XSLT Variable");
    createVariable.setBorderPainted(false);
    createVariable.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addNewNode(new VariableNode(getNewVariableName()));
          }
        });
    toolbar.add(createVariable);

    deleteNode = new JButton(OWLSIcons.getDeleteControlConstructIcon());
    deleteNode.setToolTipText("Delete Node");
    deleteNode.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deleteNode();
            tree.updateUI();
          }
        });
    deleteNode.setBorderPainted(false);
    deleteNode.setEnabled(false);
    toolbar.add(deleteNode);

    toolbar.setFloatable(false);
    treeButtons.add(toolbar, BorderLayout.EAST);
    return treeButtons;
  }
 protected Icon getHeaderIcon() {
   return OWLIcons.getImageIcon("OWLDatatypeProperty");
 }