Class XMLTreePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class XMLTreePanel extends JPanel
This is a split pane view of an XML tree and its contents.
Author:
Douglas Brown
See Also:
  • Field Details

    • label

      protected JLabel label
    • input

      protected JTextField input
    • xmlPane

      protected JTextPane xmlPane
    • tree

      protected JTree tree
    • treeScroller

      protected JScrollPane treeScroller
    • valueIcon

      protected Icon valueIcon
    • inspectIcon

      protected Icon inspectIcon
    • inspectFolderIcon

      protected Icon inspectFolderIcon
    • folderIcon

      protected Icon folderIcon
    • control

      protected XMLControl control
    • property

      protected XMLProperty property
    • editable

      protected boolean editable
  • Constructor Details

    • XMLTreePanel

      public XMLTreePanel(XMLControl control)
      Constructs a tree panel with an XMLControl
      Parameters:
      control - the XMLControl
    • XMLTreePanel

      public XMLTreePanel(XMLControl control, boolean editable)
      Constructs a tree panel with an XMLControl
      Parameters:
      control - the XMLControl
      editable - true to enable xml edits via the input field
  • Method Details

    • refresh

      public void refresh()
      Refreshes the tree. Called after changing the control externally.
    • getControl

      public XMLControl getControl()
      Gets the control displayed in the tree.
    • setSelectedNode

      public XMLTreeNode setSelectedNode(String propertyName)
      Selects and returns the first node with the specified property name.
      Parameters:
      propertyName - the property name
      Returns:
      the selected node, or null if none found
    • setSelectedNode

      public XMLTreeNode setSelectedNode(TreePath treePath)
      Selects and returns the node with the specified TreePath. This uses only the names of the nodes in the path so it can be used after creating a new similar Tree.
      Parameters:
      treePath - the TreePath
      Returns:
      the selected node, or null if none found
    • getChildNode

      public XMLTreeNode getChildNode(XMLTreeNode root, String name)
      Returns the first child of a specified root node that has a given name.
      Parameters:
      root - the node to search
      name - the name
      Returns:
      the node, or null if none found
    • displayProperty

      protected void displayProperty(XMLTreeNode node, boolean editable)
      Displays the property data for the specified node.
      Parameters:
      node - the XMLTreeNode
      editable - true if the input field is editable
    • getDisplay

      protected String getDisplay(String xml)
      Gets the xml to be displayed.
      Parameters:
      xml - the raw xml
      Returns:
      the displayed xml
    • createGUI

      protected void createGUI()
      Creates the GUI and listeners.
    • getMouseListener

      protected MouseListener getMouseListener()