Class AbstractPanelServlet

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
    Direct Known Subclasses:
    ControlPanelServlet, LayoutPanelServlet, PanelServlet, SwitchboardServlet

    public abstract class AbstractPanelServlet
    extends javax.servlet.http.HttpServlet
    Abstract servlet for using panels in browser.

    See JMRI Web Server - Panel Servlet Help in help/en/html/web/PanelServlet.shtml for an example description of the interaction between the Web Servlets, the Web Browser and the JMRI application.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.fasterxml.jackson.databind.ObjectMapper mapper  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handle a GET request for a panel.
      protected Editor getEditor​(java.lang.String name)  
      protected abstract java.lang.String getJsonPanel​(java.lang.String name)  
      protected javax.swing.JComponent getPanel​(java.lang.String name)  
      protected java.awt.image.BufferedImage getPanelImage​(java.lang.String name)  
      protected java.lang.String getPanelText​(java.lang.String name, boolean useXML)  
      protected abstract java.lang.String getPanelType()  
      protected Element getSignalMastIconsElement​(java.lang.String name, java.lang.String imageset)
      Build and return an "icons" element containing icon URLs for all SignalMast states.
      protected abstract java.lang.String getXmlPanel​(java.lang.String name)  
      void init()  
      protected void listPanels​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      protected void parsePortableURIs​(Element element)  
      protected Element positionableElement​(Positionable sub)
      Build and return a panel state display element containing icon URLs for all states.
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mapper

        protected com.fasterxml.jackson.databind.ObjectMapper mapper
    • Method Detail

      • getPanelType

        protected abstract java.lang.String getPanelType()
      • init

        public void init()
                  throws javax.servlet.ServletException
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             java.io.IOException
        Handle a GET request for a panel.

        The request is processed in this order:

        1. If the request contains a parameter name=someValue, redirect to /panel/someValue if someValue is an open panel, otherwise redirect to /panel/.
        2. If the request ends in /, return an HTML page listing all open panels.
        3. Return the panel named in the last element in the path in the following formats based on the format=someFormat parameter:
          html
          An HTML page rendering the panel.
          png
          A PNG image of the panel.
          json
          A JSON document of the panel (currently incomplete).
          xml
          An XML document of the panel ready to render within a browser.
          If format is not specified, it is treated as html. All other formats not listed are treated as xml.
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • listPanels

        protected void listPanels​(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)
                           throws javax.servlet.ServletException,
                                  java.io.IOException
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • getPanelImage

        protected java.awt.image.BufferedImage getPanelImage​(java.lang.String name)
      • getPanelText

        protected java.lang.String getPanelText​(java.lang.String name,
                                                boolean useXML)
      • getJsonPanel

        protected abstract java.lang.String getJsonPanel​(java.lang.String name)
      • getXmlPanel

        protected abstract java.lang.String getXmlPanel​(java.lang.String name)
      • getSignalMastIconsElement

        protected Element getSignalMastIconsElement​(java.lang.String name,
                                                    java.lang.String imageset)
        Build and return an "icons" element containing icon URLs for all SignalMast states. Element names are cleaned-up aspect names, aspect attribute is actual name of aspect.
        Parameters:
        name - user/system name of the signalMast using the icons
        imageset - imageset name or "default"
        Returns:
        an icons element containing icon URLs for SignalMast states
      • positionableElement

        protected Element positionableElement​(@Nonnull
                                              Positionable sub)
        Build and return a panel state display element containing icon URLs for all states.
        Parameters:
        sub - Positional containing additional icons for display (in MultiSensorIcon)
        Returns:
        a display element based on element name