org.fife.rtext.plugins.tools
Class ToolManager

java.lang.Object
  extended byorg.fife.rtext.plugins.tools.ToolManager

public class ToolManager
extends java.lang.Object

Manages the tools available in an RText session.

Version:
1.0
Author:
Robert Futrell

Field Summary
static java.lang.String PROPERTY_TOOLS
          Event fired when a tool is added or removed.
 
Method Summary
 void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener l)
          Adds a property change listener to this tool manager.
 void addTool(Tool tool)
          Adds a tool.
 void clearTools()
          Removes all tools from this manager.
 boolean containsToolWithName(java.lang.String name)
          Returns whether a tool with a given name is already defined.
static ToolManager get()
          Returns the singleton instance of the tool manager.
 int getToolCount()
          returns the number of tools.
 java.util.Iterator getToolIterator()
          Returns an iterator over the tools.
 void loadTools(java.io.File dir)
          Loads all tools from a directory.
 void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener l)
          Removes a property change listener from this tool manager.
 void removeTool(Tool tool)
          Removes a tool.
 void saveTools(java.io.File dir)
          Saves all tools known to this tool manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_TOOLS

public static final java.lang.String PROPERTY_TOOLS
Event fired when a tool is added or removed.

See Also:
Constant Field Values
Method Detail

addTool

public void addTool(Tool tool)
Adds a tool. This methods fires a property change event of type PROPERTY_TOOLS.

Parameters:
tool - The tool to add.
See Also:
removeTool(Tool)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String property,
                                      java.beans.PropertyChangeListener l)
Adds a property change listener to this tool manager.

Parameters:
property - The property to listen for.
l - The listener.
See Also:
removePropertyChangeListener(String, PropertyChangeListener)

clearTools

public void clearTools()
Removes all tools from this manager. This fires a property change event of type PROPERTY_TOOLS.


containsToolWithName

public boolean containsToolWithName(java.lang.String name)
Returns whether a tool with a given name is already defined.

Parameters:
name - The name of the tool.
Returns:
Whether a tool with that name is already defined.

get

public static ToolManager get()
Returns the singleton instance of the tool manager.

Returns:
The tool manager instance.

getToolCount

public int getToolCount()
returns the number of tools.

Returns:
The number of tools.

getToolIterator

public java.util.Iterator getToolIterator()
Returns an iterator over the tools.

Returns:
An iterator over the tools.

loadTools

public void loadTools(java.io.File dir)
               throws java.io.IOException
Loads all tools from a directory.

Parameters:
dir - The directory to load tools from.
Throws:
java.io.IOException - If an IO error occurs reading the tools.
See Also:
saveTools(File)

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String property,
                                         java.beans.PropertyChangeListener l)
Removes a property change listener from this tool manager.

Parameters:
property - The property listened for.
l - The listener to remove.
See Also:
addPropertyChangeListener(String, PropertyChangeListener)

removeTool

public void removeTool(Tool tool)
Removes a tool. This method fires a property change event of type PROPERTY_TOOLS.

Parameters:
tool - The tool to remove.
See Also:
addTool(Tool)

saveTools

public void saveTools(java.io.File dir)
               throws java.io.IOException
Saves all tools known to this tool manager.

Parameters:
dir - The directory to save the tool definitions to. The old contents of this directory are deleted.
Throws:
java.io.IOException - If an IO error occurs writing the files.
See Also:
loadTools(File)