Package org.fife.ui.rtextarea
Class Macro
java.lang.Object
org.fife.ui.rtextarea.Macro
A macro as recorded/played back by an
RTextArea.
Macros 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.beginRecordingMacro()(this discards the previous "current" macro, if any)RTextArea.endRecordingMacro()(at this point, you could callplaybackLastMacro()to play this macro immediately if desired)RTextArea.getCurrentMacro().saveToFile(File)
Macros 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classA "record" of a macro is a single action in the macro (corresponding to a key type and some action in the editor, such as a letter inserted into the document, scrolling one page down, selecting the current line, etc.). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMacroRecord(Macro.MacroRecord record) Adds a macro record to this macro.Returns the macro records that make up this macro.getName()Returns the name of this macro.private booleaninitializeFromXMLFile(Element root) Used in parsing an XML document containing a macro.voidsaveToFile(File file) Saves this macro to an XML file.voidsaveToFile(String fileName) Saves this macro to a file.voidSets the name of this macro.
-
Field Details
-
name
-
macroRecords
-
ROOT_ELEMENT
- See Also:
-
MACRO_NAME
- See Also:
-
ACTION
- See Also:
-
ID
- See Also:
-
UNTITLED_MACRO_NAME
- See Also:
-
FILE_ENCODING
- See Also:
-
-
Constructor Details
-
Macro
public Macro()Constructor. -
Macro
Loads a macro from a file on disk.- Parameters:
file- The file from which to load the macro.- Throws:
IOException- If the file does not exist or an I/O exception occurs while reading the file.- See Also:
-
Macro
Constructor.- Parameters:
name- The name of the macro.
-
Macro
Constructor.- Parameters:
name- The name of the macro.records- The initial records of the macro.
-
-
Method Details
-
addMacroRecord
Adds a macro record to this macro.- Parameters:
record- The record to add. Ifnull, nothing happens.- See Also:
-
getMacroRecords
Returns the macro records that make up this macro.- Returns:
- The macro records.
- See Also:
-
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:
-
initializeFromXMLFile
Used in parsing an XML document containing a macro. This method initializes this macro with the data contained in the passed-in node.- Parameters:
root- The root node of the parsed XML document.- Returns:
trueif the macro initialization went okay;falseif an error occurred.
-
saveToFile
Saves this macro to an XML file. This file can later be read in by the constructor taking aFileparameter; 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
Saves this macro to a file. This file can later be read in by the constructor taking aFileparameter; 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:
-
setName
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:
-