Class AbstractPanelServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
jmri.web.servlet.panel.AbstractPanelServlet
All Implemented Interfaces:
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:
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    convertNamedColors(org.jdom2.Element element)
    Convert named colors in a panel response to CSS-compatible RGB hex values.
    protected void
    doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handle a GET request for a panel.
    protected Editor
     
    protected abstract String
     
    protected JComponent
     
    protected BufferedImage
     
    protected String
    getPanelText(String name, boolean useXML)
     
    protected abstract String
     
    protected org.jdom2.Element
    Build and return an "icons" element containing icon URLs for all SignalMast states.
    protected abstract String
     
    void
     
    protected void
    listPanels(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
     
    protected void
    parsePortableURIs(org.jdom2.Element element)
     
    protected org.jdom2.Element
    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 Details

    • mapper

      protected com.fasterxml.jackson.databind.ObjectMapper mapper
  • Constructor Details

  • Method Details

    • getPanelType

      protected abstract 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, 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
      IOException
    • listPanels

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

    • getPanel

    • getPanelText

      protected String getPanelText(String name, boolean useXML)
    • getJsonPanel

      protected abstract String getJsonPanel(String name)
    • getXmlPanel

      protected abstract String getXmlPanel(String name)
    • getEditor

    • parsePortableURIs

      protected void parsePortableURIs(org.jdom2.Element element)
    • getSignalMastIconsElement

      protected org.jdom2.Element getSignalMastIconsElement(String name, 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 org.jdom2.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
    • convertNamedColors

      protected void convertNamedColors(@Nonnull org.jdom2.Element element)
      Convert named colors in a panel response to CSS-compatible RGB hex values.