Class LoadXMLAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

    class LoadXMLAction
    extends javax.swing.AbstractAction
    Encapsulates the action to load an XML file.
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static Logger LOG
      use to log messages
      private javax.swing.JFileChooser mChooser
      the file chooser - configured to allow only the selection of a single file.
      private XMLFileHandler mHandler
      the content handler
      private javax.swing.JFrame mParent
      the parent frame
      private org.xml.sax.XMLReader mParser
      parser to read XML files
      • Fields inherited from class javax.swing.AbstractAction

        changeSupport, enabled
      • Fields inherited from interface javax.swing.Action

        ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
    • Constructor Summary

      Constructors 
      Constructor Description
      LoadXMLAction​(javax.swing.JFrame aParent, MyTableModel aModel)
      Creates a new LoadXMLAction instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent aIgnore)
      Prompts the user for a file to load events from.
      private int loadFile​(java.lang.String aFile)
      Loads the contents of file into the model
      • Methods inherited from class javax.swing.AbstractAction

        addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.Action

        accept
    • Field Detail

      • LOG

        private static final Logger LOG
        use to log messages
      • mParent

        private final javax.swing.JFrame mParent
        the parent frame
      • mChooser

        private final javax.swing.JFileChooser mChooser
        the file chooser - configured to allow only the selection of a single file.
      • mParser

        private final org.xml.sax.XMLReader mParser
        parser to read XML files
    • Constructor Detail

      • LoadXMLAction

        LoadXMLAction​(javax.swing.JFrame aParent,
                      MyTableModel aModel)
               throws org.xml.sax.SAXException,
                      javax.xml.parsers.ParserConfigurationException
        Creates a new LoadXMLAction instance.
        Parameters:
        aParent - the parent frame
        aModel - the model to add events to
        Throws:
        org.xml.sax.SAXException - if an error occurs
        javax.xml.parsers.ParserConfigurationException - if an error occurs
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent aIgnore)
        Prompts the user for a file to load events from.
        Parameters:
        aIgnore - an ActionEvent value
      • loadFile

        private int loadFile​(java.lang.String aFile)
                      throws org.xml.sax.SAXException,
                             java.io.IOException
        Loads the contents of file into the model
        Parameters:
        aFile - the file to extract events from
        Returns:
        the number of events loaded
        Throws:
        org.xml.sax.SAXException - if an error occurs
        java.io.IOException - if an error occurs