Class XmlOutlineTree

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class XmlOutlineTree extends AbstractSourceTree
A tree view showing the outline of XML, similar to the "Outline" view in Eclipse. It also uses Eclipse's icons, just like the rest of this code completion library.

You can get this tree automatically updating in response to edits in an RSyntaxTextArea with XmlLanguageSupport installed by calling listenTo(RSyntaxTextArea). Note that an instance of this class can only listen to a single editor at a time, so if your application contains multiple instances of RSyntaxTextArea, you'll either need a separate XmlOutlineTree for each one, or call uninstall() and listenTo(RSyntaxTextArea) each time a new RSTA receives focus.

Version:
1.0
See Also:
  • Field Details

  • Constructor Details

    • XmlOutlineTree

      public XmlOutlineTree()
      Constructor. The tree created will not have its elements sorted alphabetically.
    • XmlOutlineTree

      public XmlOutlineTree(boolean sorted)
      Constructor.
      Parameters:
      sorted - Whether the tree should sort its elements alphabetically. Note that outline trees will likely group nodes by type before sorting (i.e. methods will be sorted in one group, fields in another group, etc.).
  • Method Details

    • checkForXmlParsing

      private void checkForXmlParsing()
      Refreshes listeners on the text area when its syntax style changes.
    • expandInitialNodes

      public void expandInitialNodes()
      Description copied from class: AbstractSourceTree
      Expands all nodes in the specified tree. Subclasses should implement this in a way logical for the language.
      Specified by:
      expandInitialNodes in class AbstractSourceTree
    • gotoElementAtPath

      private void gotoElementAtPath(TreePath path)
    • gotoSelectedElement

      public boolean gotoSelectedElement()
      Description copied from class: AbstractSourceTree
      Highlights the selected source element in the text editor, if any.
      Specified by:
      gotoSelectedElement in class AbstractSourceTree
      Returns:
      Whether anything was selected in the tree.
    • listenTo

      public void listenTo(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Description copied from class: AbstractSourceTree
      Causes this outline tree to reflect the source code in the specified text area.
      Specified by:
      listenTo in class AbstractSourceTree
      Parameters:
      textArea - The text area. This should have been registered with the LanguageSupportFactory, and be editing the language we're interested in.
      See Also:
    • uninstall

      public void uninstall()
      Description copied from class: AbstractSourceTree
      Makes this outline tree stop listening to its current text area.
      Specified by:
      uninstall in class AbstractSourceTree
      See Also:
    • update

      private void update(XmlTreeNode root)
    • updateUI

      public void updateUI()
      Overridden to update the cell renderer.
      Overrides:
      updateUI in class JTree