Class ReportViewer

All Implemented Interfaces:
DynamicPropertyProvider, LocaleListener, MutableDynamicPropertyProvider, StyleProvider, ComponentLifecycle, ExtensibleComponent, QualityMonitor, VisionComponent, ImageObserver, MenuContainer, Serializable, Accessible

public class ReportViewer extends AbstractVisionPanel implements ExtensibleComponent
filename: ReportViewer.java author: Perry

The ReportViewer component allows the display of a Report in an Ignition Client Window.

Implements DynamicPropertyProvider to override the default component inheritance of MutableDynamicPropertyProvider as Report-specific Properties originate from the ReportDataSourceConfig object's ReportParameters. ReportParameters should be configured in the ReportDataEditor of a given Report.

See Also:
  • Field Details

    • CAT_REPORTING

      public static final String CAT_REPORTING
      See Also:
    • EXPORT_EXECUTOR

      public static final ExecutorService EXPORT_EXECUTOR
      Warning: This executor is shared across different instances of ReportViewers, as such it should not be shutdown by any individual instance. If at any time this executor is shutdown, future instances of ReportViewers will no longer be able to produce PDF exports.
    • popupMenu

      protected JPopupMenu popupMenu
    • controls

      protected ReportViewer.ControlsPanel controls
  • Constructor Details

    • ReportViewer

      public ReportViewer()
  • Method Details

    • onStartup

      public void onStartup()
      We override these PropertyProvider methods to expose the ReportResource's parameters as custom properties in the Property Editor, but we don't want the names to be editable outside of the ReportData configuration panel. Otherwise, AbstractVisionPanel implements MutableDynamicPropertyProvider which would allow Custom Properties panels.
      Overrides:
      onStartup in class AbstractVisionPanel
    • onShutdown

      public void onShutdown()
      Description copied from class: AbstractVisionPanel
      Subclasses should override this to provide shutdown logic.
      Overrides:
      onShutdown in class AbstractVisionPanel
    • getProperties

      public DynamicPropertyDescriptor[] getProperties()
      Specified by:
      getProperties in interface DynamicPropertyProvider
      Overrides:
      getProperties in class AbstractVisionPanel
    • getDynamicProps

      public TreeMap<String,DynamicPropertyDescriptor> getDynamicProps()
      Specified by:
      getDynamicProps in interface MutableDynamicPropertyProvider
      Overrides:
      getDynamicProps in class AbstractVisionPanel
    • setDynamicProps

      public void setDynamicProps(@Nullable TreeMap<String,DynamicPropertyDescriptor> map)
      Specified by:
      setDynamicProps in interface MutableDynamicPropertyProvider
      Overrides:
      setDynamicProps in class AbstractVisionPanel
    • setPropertyValue

      public void setPropertyValue(String name, Object value) throws ClassCastException
      The Property (aka Report Parameter) values can be set from the Property editor to override the default value. Property names are based on the Report Data panel Parameter names. These properties can be null/empty, but if a default is not specified the key won't get run in the report.
      Specified by:
      setPropertyValue in interface DynamicPropertyProvider
      Overrides:
      setPropertyValue in class AbstractVisionPanel
      Throws:
      ClassCastException
    • setPropertyValueQuiet

      public void setPropertyValueQuiet(String name, Object value) throws ClassCastException
      Sets the property value without reloading the report. Used by the report converter
      Throws:
      ClassCastException
    • bulkSetValues

      public void bulkSetValues(Map<String,Object> map)
    • getPropertyValue

      public Object getPropertyValue(String name)
      Specified by:
      getPropertyValue in interface DynamicPropertyProvider
      Overrides:
      getPropertyValue in class AbstractVisionPanel
    • isPropertyDefined

      public boolean isPropertyDefined(String name)
      Specified by:
      isPropertyDefined in interface DynamicPropertyProvider
      Overrides:
      isPropertyDefined in class AbstractVisionPanel
    • isReportLoading

      public boolean isReportLoading()
    • setReportLoading

      public void setReportLoading(boolean reportLoading)
    • getReportPath

      public String getReportPath()
    • setReportPath

      public void setReportPath(String reportPath)
    • loadReport

      public void loadReport()
      loadReport() starts most of the checking and loading duties for the ReportViewer. If the context has loaded and there is a reportPath entered, it will try to find the resource, show the loading animation pane, and call the SwingWorker to handle the RDP calls to collect the data configuration, update the Component's property (aka parameter) list, and finally run/draw the report.
    • setBackground

      public void setBackground(Color bg)
      Overrides:
      setBackground in class JComponent
    • getBackground

      public Color getBackground()
      Gets the background color of this component.
      Overrides:
      getBackground in class Component
    • setForeground

      public void setForeground(Color fg)
      Overrides:
      setForeground in class JComponent
    • getExtensionFunctions

      public Map<String,ExtensionFunction> getExtensionFunctions()
      Specified by:
      getExtensionFunctions in interface ExtensibleComponent
    • setExtensionFunctions

      public void setExtensionFunctions(Map<String,ExtensionFunction> map)
      Specified by:
      setExtensionFunctions in interface ExtensibleComponent
    • localeChanged

      public void localeChanged(Locale newLocale)
      Specified by:
      localeChanged in interface LocaleListener
      Overrides:
      localeChanged in class AbstractVisionPanel
    • getZoomFactor

      public float getZoomFactor()
    • setZoomFactor

      public void setZoomFactor(float zoomFactor)
    • isFitPanel

      public boolean isFitPanel()
    • setFitPanel

      public void setFitPanel(boolean fitPanel)
    • getCurrentPage

      public int getCurrentPage()
    • setCurrentPage

      public void setCurrentPage(int pageNumber)
    • getPageCount

      public int getPageCount()
    • setPageCount

      public void setPageCount(int unused)
    • initMenu

      protected JPopupMenu initMenu()
    • print

      public void print()
    • print

      public void print(String printerName)
    • print

      public void print(String printerName, boolean showDialog)
    • getBytesPDF

      @Nullable public byte[] getBytesPDF()
      Allows scripts to get the bytes in PDF format. Useful for emailing or saving to a database.
      Returns:
      Bytes of report in PDF format, or null if trial is expired.
    • getBytesPNG

      @Nullable public byte[] getBytesPNG()
      Allows scripts to get the bytes in png format. Useful for emailing or saving to a database.
      Returns:
      Bytes of report in png format, or null if trial is expired.
    • saveAsPDF

      public void saveAsPDF(String fileName)
    • saveAsHTML

      @Nullable public String saveAsHTML(String fname, boolean continuous)
    • saveAsPNG

      public String saveAsPNG(String fname)
    • saveAsXls

      @Deprecated public String saveAsXls(String fname)
      Deprecated.
    • saveAsXlsx

      public String saveAsXlsx(String filename)
      saves the RMDocument in xlsx format to the supplied file name.
      Parameters:
      filename - the filename to save to
      Returns:
      the path to the saved file or null if the action was unsuccessful or canceled
    • checkExpirationAccess

      protected boolean checkExpirationAccess()
    • getPanelBackground

      public Color getPanelBackground()
    • setPanelBackground

      public void setPanelBackground(Color panelBackground)
    • setSuggestedFilename

      public void setSuggestedFilename(String suggestedFilename)
    • getSuggestedFilename

      public String getSuggestedFilename()
    • isShowControls

      public boolean isShowControls()
    • setShowControls

      public void setShowControls(boolean show)
    • updateControlVisibility

      public void updateControlVisibility()