Class Macro

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

public class Macro extends Object
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:

To record and save a new macro, you'd use the following methods: As 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
  • Field Details

  • Constructor Details

    • Macro

      public Macro()
      Constructor.
    • Macro

      public Macro(File file) throws IOException
      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

      public Macro(String name)
      Constructor.
      Parameters:
      name - The name of the macro.
    • Macro

      public Macro(String name, List<Macro.MacroRecord> records)
      Constructor.
      Parameters:
      name - The name of the macro.
      records - The initial records of the macro.
  • Method Details

    • addMacroRecord

      public void addMacroRecord(Macro.MacroRecord record)
      Adds a macro record to this macro.
      Parameters:
      record - The record to add. If null, nothing happens.
      See Also:
    • getMacroRecords

      public List<Macro.MacroRecord> getMacroRecords()
      Returns the macro records that make up this macro.
      Returns:
      The macro records.
      See Also:
    • 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:
    • initializeFromXMLFile

      private boolean initializeFromXMLFile(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:
      true if the macro initialization went okay; false if an error occurred.
    • 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

      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:
    • 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: