org.fife.rtext.plugins.macros
Class MacroManager

java.lang.Object
  extended byorg.fife.rtext.plugins.macros.MacroManager

public class MacroManager
extends java.lang.Object

Manages all of the macros in an RText session.

Version:
1.0
Author:
Robert Futrell

Field Summary
static java.lang.String PROPERTY_MACROS
          Event fired when a macro is added or removed.
 
Method Summary
 void addMacro(Macro macro)
          Adds a macro.
 void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener l)
          Adds a property change listener to this macro manager.
 java.util.SortedSet clearMacros()
          Removes all macros from this manager.
 boolean containsMacroNamed(java.lang.String name)
          Returns whether a macro is defined with the specified name.
static MacroManager get()
          Returns the singleton instance of the macro manager.
 int getMacroCount()
          returns the number of macros.
 java.util.Iterator getMacroIterator()
          Returns an iterator over the macros.
 void loadMacros(java.io.File dir)
          Loads all macros from a directory.
 void removeMacro(Macro macro)
          Removes a macro.
 void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener l)
          Removes a property change listener from this macro manager.
 void saveMacros(java.io.File dir)
          Saves all macros known to this macro manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_MACROS

public static final java.lang.String PROPERTY_MACROS
Event fired when a macro is added or removed.

See Also:
Constant Field Values
Method Detail

addMacro

public void addMacro(Macro macro)
Adds a macro. This methods fires a property change event of type PROPERTY_MACROS.

Parameters:
macro - The macro to add.
See Also:
removeMacro(Macro)

addPropertyChangeListener

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

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

clearMacros

public java.util.SortedSet clearMacros()
Removes all macros from this manager. This fires a property change event of type PROPERTY_MACROS.

Returns:
The macros that existed before the clear operation. This may be empty, but will never be null.

containsMacroNamed

public boolean containsMacroNamed(java.lang.String name)
Returns whether a macro is defined with the specified name.

Parameters:
name - The name to check for.
Returns:
Whether a macro is already defined with that name.

get

public static MacroManager get()
Returns the singleton instance of the macro manager.

Returns:
The macro manager instance.

getMacroCount

public int getMacroCount()
returns the number of macros.

Returns:
The number of macros.

getMacroIterator

public java.util.Iterator getMacroIterator()
Returns an iterator over the macros.

Returns:
An iterator over the macros.

loadMacros

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

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

removePropertyChangeListener

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

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

removeMacro

public void removeMacro(Macro macro)
Removes a macro. This method fires a property change event of type PROPERTY_MACROS.

Parameters:
macro - The macro to remove.
See Also:
addMacro(Macro)

saveMacros

public void saveMacros(java.io.File dir)
                throws java.io.IOException
Saves all macros known to this macro manager.

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