Package jmri.web.servlet.panel
Class AbstractPanelServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- jmri.web.servlet.panel.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.ObjectMappermapper
-
Constructor Summary
Constructors Constructor Description AbstractPanelServlet()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Handle a GET request for a panel.protected EditorgetEditor(java.lang.String name)protected abstract java.lang.StringgetJsonPanel(java.lang.String name)protected javax.swing.JComponentgetPanel(java.lang.String name)protected java.awt.image.BufferedImagegetPanelImage(java.lang.String name)protected java.lang.StringgetPanelText(java.lang.String name, boolean useXML)protected abstract java.lang.StringgetPanelType()protected org.jdom2.ElementgetSignalMastIconsElement(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.StringgetXmlPanel(java.lang.String name)voidinit()protected voidlistPanels(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected voidparsePortableURIs(org.jdom2.Element element)protected org.jdom2.ElementpositionableElement(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
-
-
-
-
Field Detail
-
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Constructor Detail
-
AbstractPanelServlet
public AbstractPanelServlet()
-
-
Method Detail
-
getPanelType
protected abstract java.lang.String getPanelType()
-
init
public void init() throws javax.servlet.ServletException
- Overrides:
initin classjavax.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:
- If the request contains a parameter
name=someValue, redirect to/panel/someValueifsomeValueis an open panel, otherwise redirect to/panel/. - If the request ends in
/, return an HTML page listing all open panels. - Return the panel named in the last element in the path in the
following formats based on the
format=someFormatparameter:- 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.
formatis not specified, it is treated ashtml. All other formats not listed are treated asxml.
- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
- If the request contains a parameter
-
listPanels
protected void listPanels(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
getPanelImage
protected java.awt.image.BufferedImage getPanelImage(java.lang.String name)
-
getPanel
@CheckForNull protected javax.swing.JComponent getPanel(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)
-
getEditor
@CheckForNull protected Editor getEditor(java.lang.String name)
-
parsePortableURIs
protected void parsePortableURIs(org.jdom2.Element element)
-
getSignalMastIconsElement
protected org.jdom2.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 iconsimageset- 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
-
-