Package org.fife.ui.rtextarea
Class Macro
- java.lang.Object
-
- org.fife.ui.rtextarea.Macro
-
public class Macro extends java.lang.ObjectA macro as recorded/played back by anRTextArea.
To record and save a new macro, you'd use the following methods:Macros are static; when a Macro is loaded, it can be run by any instance ofRTextAreain 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 "", and place them all in a common directory.getName().xml- Version:
- 0.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classMacro.MacroRecordA "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 Modifier and Type Field Description private static java.lang.StringACTIONprivate static java.lang.StringFILE_ENCODINGprivate static java.lang.StringIDprivate static java.lang.StringMACRO_NAMEprivate java.util.ArrayList<Macro.MacroRecord>macroRecordsprivate java.lang.Stringnameprivate static java.lang.StringROOT_ELEMENTprivate static java.lang.StringUNTITLED_MACRO_NAME
-
Constructor Summary
Constructors Constructor Description Macro()Constructor.Macro(java.io.File file)Loads a macro from a file on disk.Macro(java.lang.String name)Constructor.Macro(java.lang.String name, java.util.List<Macro.MacroRecord> records)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMacroRecord(Macro.MacroRecord record)Adds a macro record to this macro.java.util.List<Macro.MacroRecord>getMacroRecords()Returns the macro records that make up this macro.java.lang.StringgetName()Returns the name of this macro.private booleaninitializeFromXMLFile(org.w3c.dom.Element root)Used in parsing an XML document containing a macro.voidsaveToFile(java.io.File file)Saves this macro to an XML file.voidsaveToFile(java.lang.String fileName)Saves this macro to a file.voidsetName(java.lang.String name)Sets the name of this macro.
-
-
-
Field Detail
-
name
private java.lang.String name
-
macroRecords
private java.util.ArrayList<Macro.MacroRecord> macroRecords
-
ROOT_ELEMENT
private static final java.lang.String ROOT_ELEMENT
- See Also:
- Constant Field Values
-
MACRO_NAME
private static final java.lang.String MACRO_NAME
- See Also:
- Constant Field Values
-
ACTION
private static final java.lang.String ACTION
- See Also:
- Constant Field Values
-
ID
private static final java.lang.String ID
- See Also:
- Constant Field Values
-
UNTITLED_MACRO_NAME
private static final java.lang.String UNTITLED_MACRO_NAME
- See Also:
- Constant Field Values
-
FILE_ENCODING
private static final java.lang.String FILE_ENCODING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Macro
public Macro()
Constructor.
-
Macro
public Macro(java.io.File file) throws java.io.IOExceptionLoads a macro from a file on disk.- Parameters:
file- The file from which to load the macro.- Throws:
java.io.IOException- If the file does not exist or an I/O exception occurs while reading the file.- See Also:
saveToFile(String),saveToFile(File)
-
Macro
public Macro(java.lang.String name)
Constructor.- Parameters:
name- The name of the macro.
-
Macro
public Macro(java.lang.String name, java.util.List<Macro.MacroRecord> records)Constructor.- Parameters:
name- The name of the macro.records- The initial records of the macro.
-
-
Method Detail
-
addMacroRecord
public void addMacroRecord(Macro.MacroRecord record)
Adds a macro record to this macro.- Parameters:
record- The record to add. Ifnull, nothing happens.- See Also:
getMacroRecords()
-
getMacroRecords
public java.util.List<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 java.lang.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)
-
initializeFromXMLFile
private boolean initializeFromXMLFile(org.w3c.dom.Element root)
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
public void saveToFile(java.io.File file) throws java.io.IOExceptionSaves 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:
java.io.IOException- If an error occurs while generating the XML for the output file.- See Also:
saveToFile(String)
-
saveToFile
public void saveToFile(java.lang.String fileName) throws java.io.IOExceptionSaves 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:
java.io.IOException- If an error occurs while generating the XML for the output file.- See Also:
saveToFile(File)
-
setName
public void setName(java.lang.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()
-
-