org.fife.rtext.plugins.sourcebrowser
Class SourceBrowserPlugin

java.lang.Object
  extended byorg.fife.ui.app.AbstractPlugin
      extended byorg.fife.ui.app.GUIPlugin
          extended byorg.fife.rtext.plugins.sourcebrowser.SourceBrowserPlugin
All Implemented Interfaces:
CurrentTextAreaListener, DockableWindowConstants, java.util.EventListener, GUIApplicationConstants, Plugin

public class SourceBrowserPlugin
extends GUIPlugin
implements CurrentTextAreaListener

A panel that uses Exuberant CTags (installed separately from RText) to keep a list of all variables, functions, classes, methods, etc. defined in the currently-opened source file. Clicking on an item in the Source Browser moves the cursor to that item's position in the source file; also, right- clicking on an item displays a popup menu.

Version:
1.2
Author:
Robert Futrell

Field Summary
static java.lang.String CTAGS_TYPE_EXUBERANT
           
static java.lang.String CTAGS_TYPE_STANDARD
           
static java.lang.String CUSTOM_HANDLER_PREFIX
           
 
Fields inherited from interface org.fife.ui.app.GUIApplicationConstants
OS_LINUX, OS_MAC_OSX, OS_OTHER, OS_WINDOWS
 
Fields inherited from interface org.fife.ui.dockablewindows.DockableWindowConstants
BOTTOM, FLOATING, LEFT, RIGHT, TOP
 
Constructor Summary
SourceBrowserPlugin(AbstractPluggableGUIApplication app)
          Creates a new SourceBrowserPlugin.
 
Method Summary
 void currentTextAreaPropertyChanged(CurrentTextAreaEvent e)
          Called whenever the currently-active document in RText changes, or one of its properties changes.
protected  void ensureSourceTreeSortedProperly()
          Ensures that a source tree is sorted or not sorted, to match the sorting button's current state.
 java.lang.String getCTagsExecutableLocation()
          Returns the path used to run the ctags executable.
 java.lang.String getCTagsType()
          Returns a string representation of the type of Ctags specified by the user.
protected  java.lang.String getHTMLForLine(int line)
          Returns HTML (to use in tool tips) representing the specified line in the current text area.
 PluginOptionsDialogPanel getOptionsDialogPanel()
          Returns the options panel for this source browser.
 java.lang.String getPluginAuthor()
          Returns the author of the plugin.
 javax.swing.Icon getPluginIcon()
          Returns the icon for this plugin.
 java.lang.String getPluginName()
          Returns the name of this GUIPlugin.
 java.lang.String getPluginVersion()
          Returns the plugin version.
 boolean getUseHTMLToolTips()
          Return whether HTML tooltips are being used by the source browser.
 void install(AbstractPluggableGUIApplication app)
          Called just after a plugin is added to a GUI application.
 void refresh()
          Refreshes the tag list for the current document.
 void savePreferences()
          Called when the GUI application is shutting down. When this method is called, the Plugin should save any preferences.
 void setCTagsExecutableLocation(java.lang.String location)
          Sets the path used to run the ctags executable.
 void setCTagsType(java.lang.String type)
          Sets the type of Ctags specified by the user.
 void setUseHTMLToolTips(boolean use)
          Sets whether HTML tooltips are used in this source browser.
 boolean uninstall()
          Called just before this Plugin is removed from an RText instance.
 void updateUI()
          This method is overridden so that the embedded tree and its right- click popup menu are updated.
 
Methods inherited from class org.fife.ui.app.GUIPlugin
dockableWindowIterator, getDockableWindow, putDockableWindow
 
Methods inherited from class org.fife.ui.app.AbstractPlugin
getOptionsDialogPanelParentPanelID, setOptionsDialogPanelParentPanelID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CTAGS_TYPE_EXUBERANT

public static final java.lang.String CTAGS_TYPE_EXUBERANT
See Also:
Constant Field Values

CTAGS_TYPE_STANDARD

public static final java.lang.String CTAGS_TYPE_STANDARD
See Also:
Constant Field Values

CUSTOM_HANDLER_PREFIX

public static final java.lang.String CUSTOM_HANDLER_PREFIX
See Also:
Constant Field Values
Constructor Detail

SourceBrowserPlugin

public SourceBrowserPlugin(AbstractPluggableGUIApplication app)
Creates a new SourceBrowserPlugin.

Parameters:
app - The RText instance.
Method Detail

currentTextAreaPropertyChanged

public void currentTextAreaPropertyChanged(CurrentTextAreaEvent e)
Called whenever the currently-active document in RText changes, or one of its properties changes. We are looking for cues to update our source browser tree.

Specified by:
currentTextAreaPropertyChanged in interface CurrentTextAreaListener
Parameters:
e - The event.

ensureSourceTreeSortedProperly

protected void ensureSourceTreeSortedProperly()
Ensures that a source tree is sorted or not sorted, to match the sorting button's current state.


getCTagsExecutableLocation

public java.lang.String getCTagsExecutableLocation()
Returns the path used to run the ctags executable.

Returns:
The path used.
See Also:
setCTagsExecutableLocation(java.lang.String)

getCTagsType

public java.lang.String getCTagsType()
Returns a string representation of the type of Ctags specified by the user.

Returns:
The type of Ctags specified.
See Also:
setCTagsType(String), CTAGS_TYPE_EXUBERANT, CTAGS_TYPE_STANDARD

getHTMLForLine

protected java.lang.String getHTMLForLine(int line)
Returns HTML (to use in tool tips) representing the specified line in the current text area.

Parameters:
line - The line.
Returns:
An HTML representation of the line.

getOptionsDialogPanel

public PluginOptionsDialogPanel getOptionsDialogPanel()
Returns the options panel for this source browser.

Specified by:
getOptionsDialogPanel in interface Plugin
Returns:
The options panel.

getPluginAuthor

public java.lang.String getPluginAuthor()
Returns the author of the plugin.

Specified by:
getPluginAuthor in interface Plugin
Returns:
The plugin's author.

getPluginIcon

public javax.swing.Icon getPluginIcon()
Returns the icon for this plugin.

Specified by:
getPluginIcon in interface Plugin
Returns:
The icon for this plugin.

getPluginName

public java.lang.String getPluginName()
Returns the name of this GUIPlugin.

Specified by:
getPluginName in interface Plugin
Returns:
This plugin's name.

getPluginVersion

public java.lang.String getPluginVersion()
Returns the plugin version.

Specified by:
getPluginVersion in interface Plugin
Returns:
The version number of this plugin.

getUseHTMLToolTips

public boolean getUseHTMLToolTips()
Return whether HTML tooltips are being used by the source browser.

Returns:
Whether HTML tooltips are used.
See Also:
setUseHTMLToolTips(boolean)

install

public void install(AbstractPluggableGUIApplication app)
Called just after a plugin is added to a GUI application.

This method adds a listener to RText's main view so that we are notified when the current document changes (so we can update the displayed ctags).

Specified by:
install in interface Plugin
Parameters:
app - The application to which this plugin was just added.
See Also:
uninstall()

refresh

public void refresh()
Refreshes the tag list for the current document.


savePreferences

public void savePreferences()
Called when the GUI application is shutting down. When this method is called, the Plugin should save any preferences.

Specified by:
savePreferences in interface Plugin

setCTagsExecutableLocation

public void setCTagsExecutableLocation(java.lang.String location)
Sets the path used to run the ctags executable.

Parameters:
location - The path to use.
See Also:
getCTagsExecutableLocation()

setCTagsType

public void setCTagsType(java.lang.String type)
Sets the type of Ctags specified by the user.

Parameters:
type - The type of Ctags specified. If this is null or invalid, CTAGS_TYPE_EXUBERANT is used.
See Also:
getCTagsType(), CTAGS_TYPE_EXUBERANT, CTAGS_TYPE_STANDARD

setUseHTMLToolTips

public void setUseHTMLToolTips(boolean use)
Sets whether HTML tooltips are used in this source browser.

Parameters:
use - Whether or not to use HTML tooltips.
See Also:
getUseHTMLToolTips()

uninstall

public boolean uninstall()
Called just before this Plugin is removed from an RText instance. Here we uninstall any listeners we registered.

Specified by:
uninstall in interface Plugin
Returns:
Whether the uninstall went cleanly.
See Also:
Plugin.install(org.fife.ui.app.AbstractPluggableGUIApplication)

updateUI

public void updateUI()
This method is overridden so that the embedded tree and its right- click popup menu are updated.