org.fife.rtext.plugins.langsupport.JavaSourceBrowserTreeConstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rtext Show documentation
Show all versions of rtext Show documentation
RText is a powerful, cross-platform programmer's text editor written in Java. It is designed
to be easy to use, highly customizable and flexible. Part of RText's design is for the source code
to be simple, easy to understand, and well documented, so that other programmers can look into its
inner-workings and figure out how RText ticks with ease. A good place to start (besides the source
code) is the Javadoc for all classes used in the project.
/*
* 11/10/2010
*
* JavaSourceBrowserTreeConstructor.java - "Plug-in" for the SourceBrowser
* plug-in that creates the tree view to use for Java source code.
* Copyright (C) 2008 Robert Futrell
* http://fifesoft.com/rtext
* Licensed under a modified BSD license.
* See the included license file for details.
*/
package org.fife.rtext.plugins.langsupport;
import javax.swing.JTree;
import org.fife.rsta.ac.java.tree.JavaOutlineTree;
import org.fife.rtext.RText;
import org.fife.rtext.RTextEditorPane;
/**
* Constructs the source browser tree for Java source files. This is a more
* sophisticated one than the default one created from ctags output. Features
* include:
*
*
* - Informative icons for each node that describe the access modifiers of
* an element (public/protected/private, static, final, etc.) and
* type (method, field, etc.), just like Eclipse.
* - Members are grouped under their parent classes to show logical
* structure.
* - Local variables are added.
* - The tree automatically updates after a small delay whenever the user
* types - no need to wait for them to save the file.
*
*
* @author Robert Futrell
* @version 1.0
*/
public class JavaSourceBrowserTreeConstructor {
public JTree constructSourceBrowserTree(RText rtext) {
RTextEditorPane textArea = rtext.getMainView().getCurrentTextArea();
JavaOutlineTree tree = new JavaOutlineTree(false);
tree.listenTo(textArea);
return tree;
}
}