Пример #1
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;
  }
Пример #2
0
  public JPanel makeTreeButtons() {
    JPanel treeButtons = new JPanel(new BorderLayout()); // Box.createHorizontalBox();
    JToolBar toolbar = new JToolBar();

    createTag =
        new JButton(((DefaultTreeCellRenderer) tree.getCellRenderer()).getDefaultClosedIcon());
    createTag.setToolTipText("Create Element");
    createTag.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addNewNode(new ElementNode());
          }
        });
    createTag.setBorderPainted(false);
    toolbar.add(createTag);

    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);

    createAttribute = new JButton(OWLSIcons.getXMLAttributeIcon());
    createAttribute.setToolTipText("Create Attribute");
    createAttribute.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addNewNode(new AttributeNode());
          }
        });
    createAttribute.setBorderPainted(false);
    createAttribute.setEnabled(false);
    toolbar.add(createAttribute);

    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;
  }