Class JavaOutlineTree

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

public class JavaOutlineTree extends AbstractSourceTree
A tree view showing the outline of Java source, similar to the "Outline" view in the Eclipse JDT. 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 JavaLanguageSupport 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 JavaOutlineTree 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

    • JavaOutlineTree

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

      public JavaOutlineTree(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

    • update

      private void update(CompilationUnit cu)
      Refreshes this tree.
      Parameters:
      cu - The parsed compilation unit. If this is null then the tree is cleared.
    • checkForJavaParsing

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

      private MemberTreeNode createMemberNode(Member member)
    • createTypeDeclarationNode

      private TypeDeclarationTreeNode createTypeDeclarationNode(TypeDeclaration td)
    • expandInitialNodes

      public void expandInitialNodes()
      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:
    • updateUI

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