Class JavaScriptOutlineTree

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

public class JavaScriptOutlineTree extends AbstractSourceTree
A tree view showing the outline of JavaScript 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 JavaScriptLanguageSupport installed by calling listenTo(RSyntaxTextArea). Note that, if you have an application with multiple RSTA editors, you would want to call this method each time a new editor is focused.

Version:
1.0
See Also:
  • Field Details

  • Constructor Details

    • JavaScriptOutlineTree

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

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

    • checkForJavaScriptParsing

      private void checkForJavaScriptParsing()
      Refreshes listeners on the text area when its syntax style changes.
    • 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()
      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)
      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()
      Makes this outline tree stop listening to its current text area.
      Specified by:
      uninstall in class AbstractSourceTree
      See Also:
    • update

      private void update(org.mozilla.javascript.ast.AstRoot ast)
      Refreshes this tree.
      Parameters:
      ast - The AST. If this is null then the tree is cleared.
    • updateUI

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