org.fife.ui.rtextarea

## Class Macro

- java.lang.Object
- - org.fife.ui.rtextarea.Macro

    public class Macro
    extends Object

A macro as recorded/played back by an `RTextArea`.

`Macro`s are static; when a Macro is loaded, it can be run by any instance of `RTextArea` in the application. To activate and play back a macro, use the following methods:

- `RTextArea.loadMacro(Macro)`
- `RTextArea.playbackLastMacro()`

To record and save a new macro, you'd use the following methods:

- `RTextArea.beginRecordingMacro()` (this discards the previous "current" macro, if any)
- `RTextArea.endRecordingMacro()` (at this point, you could call `playbackLastMacro()` to play this macro immediately if desired)
- `RTextArea.getCurrentMacro()`.`saveToFile(File)`

As `Macro`s save themselves as XML files, a common technique is to save all macros in files named "``getName()`.xml`", and place them all in a common directory.

Version:
  0.1
Author:
  Robert Futrell

### Constructor Summary

Constructors
Constructor and Description
`Macro()` Constructor.
`Macro(File file)` Loads a macro from a file on disk.
`Macro(String name)` Constructor.
`Macro(String name, List<org.fife.ui.rtextarea.Macro.MacroRecord> records)` Constructor.

### Method Summary

Methods
`void` `addMacroRecord(org.fife.ui.rtextarea.Macro.MacroRecord record)` Adds a macro record to this macro.
`List<org.fife.ui.rtextarea.Macro.MacroRecord>` `getMacroRecords()` Returns the macro records that make up this macro.
`String` `getName()` Returns the name of this macro.
`void` `saveToFile(File file)` Saves this macro to an XML file.
`void` `saveToFile(String fileName)` Saves this macro to a file.
`void` `setName(String name)` Sets the name of this macro.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Macro

    public Macro()

Constructor.

#### Macro

    public Macro(File file)
          throws FileNotFoundException,
                 IOException

Loads a macro from a file on disk.

Parameters:
  `file` - The file from which to load the macro.
Throws:
  `FileNotFoundException` - If the specified file does not exist, is a directory instead of a regular file, or otherwise cannot be opened.
  `IOException` - If an I/O exception occurs while reading the file.
See Also:
  `saveToFile(String)`, `saveToFile(File)`

#### Macro

    public Macro(String name)

Constructor.

Parameters:
  `name` - The name of the macro.

#### Macro

    public Macro(String name,
         List<org.fife.ui.rtextarea.Macro.MacroRecord> records)

Constructor.

Parameters:
  `name` - The name of the macro.
  `records` - The initial records of the macro.

### Method Detail

#### addMacroRecord

    public void addMacroRecord(org.fife.ui.rtextarea.Macro.MacroRecord record)

Adds a macro record to this macro.

Parameters:
  `record` - The record to add. If `null`, nothing happens.
See Also:
  `getMacroRecords()`

#### getMacroRecords

    public List<org.fife.ui.rtextarea.Macro.MacroRecord> getMacroRecords()

Returns the macro records that make up this macro.

Returns:
  The macro records.
See Also:
  `addMacroRecord(org.fife.ui.rtextarea.Macro.MacroRecord)`

#### getName

    public String getName()

Returns the name of this macro. A macro's name is simply something to identify it with in a UI; it has nothing to do with the name of the file to save the macro to.

Returns:
  The macro's name.
See Also:
  `setName(String)`

#### saveToFile

    public void saveToFile(File file)
                    throws IOException

Saves this macro to an XML file. This file can later be read in by the constructor taking a `File` parameter; this is the mechanism for saving macros.

Parameters:
  `file` - The file in which to save the macro.
Throws:
  `IOException` - If an error occurs while generating the XML for the output file.
See Also:
  `saveToFile(String)`

#### saveToFile

    public void saveToFile(String fileName)
                    throws IOException

Saves this macro to a file. This file can later be read in by the constructor taking a `File` parameter; this is the mechanism for saving macros.

Parameters:
  `fileName` - The name of the file in which to save the macro.
Throws:
  `IOException` - If an error occurs while generating the XML for the output file.
See Also:
  `saveToFile(File)`

#### setName

    public void setName(String name)

Sets the name of this macro. A macro's name is simply something to identify it with in a UI; it has nothing to do with the name of the file to save the macro to.

Parameters:
  `name` - The new name for the macro.
See Also:
  `getName()`