Package com.inet.viewer
Class SwingViewerContext
- java.lang.Object
-
- com.inet.viewer.SwingViewerContext
-
- All Implemented Interfaces:
ViewerContext
public class SwingViewerContext extends java.lang.Object implements ViewerContext
The default implementation of ViewerContext for i-net Clear Reports Viewer. This takes all errors and displays them in a small error dialog, and shows a simple info dialog when one is requested.Note that most often the source given for an error will be a SwingReportView, allowing you to make further adjustments to your settings for that view.
For example, if an UnknownHostException comes for a ReportView, you might want to make an adjustment to the ReportView's RenderData object, making it fall back onto a backup report server instead of the original one:
class MyErrorHandler extends SwingViewerContext { public void showError( ViewerException e, Object source ) { if (source instanceof ReportView && e.getCause() instanceof UnknownHostException) { ((ReportView)source).getReportData().setReportLocation( "http://www.backupserver.com:9000/?report=file:backupreport.rpt" ); ((ReportView)source).reload(); } }
It is also possible you would like to add specific logging to all errors shown:
class MyErrorHandler extends SwingViewerContext {
public void showError( ViewerException e, Object source ) {
// ...log the error here...
super.showError(e,source);
}- Since:
- 7.1
- See Also:
ReportViewer.setViewerContext(ViewerContext)
-
-
Constructor Summary
Constructors Constructor Description SwingViewerContext(SwingReportViewer viewer)
Creates a SwingViewerContext with a reference to a SwingReportViewer which is used for example when parent components are needed for dialogs, etc.SwingViewerContext(java.awt.Component parent)
Creates a SwingViewerContext with a reference to a parent Component which is used for example when parent components are needed for dialogs, etc.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExportProgress
export(ReportView view)
This method is called when the export action is to be performed.ExportProgress
export(java.awt.Component parent, RenderData data)
Opens the export dialog with the given parent as its parent and exports using the provided RenderData object.ExportProgress
export(java.awt.Component parent, RenderData data, java.beans.PropertyChangeListener changeListener)
Opens the export dialog with the given parent as its parent and exports using the provided RenderData object.SwingReportViewer
getViewer()
Returns the viewer to which this context belongs.Progress
print(ReportView view)
This method is called when the print action is to be performed.void
setViewer(SwingReportViewer viewer)
Sets the viewer to which this context belongs.void
showError(java.lang.Throwable e, java.lang.Object source)
This method will be called whenever an error occurs and thereby allows the implementor of this interface to handle the error as seen fit.void
showHelp(java.lang.String helpPageKey, java.awt.Component comp)
Opens a HelpPage with a key in a window that corresponds to the component.void
showInfo()
Shows the info screen of this viewer.boolean
showPrompts(PromptData[] prompts, RenderData data)
Handles a prompt request from the server.void
showStatusMessage(ReportView view, java.lang.String message, boolean isError)
Handled when a status message is to be displayed.void
showUrl(java.lang.String url, java.util.Properties props)
Handles opening a URL, e.g. a click on a hyperlink.
-
-
-
Constructor Detail
-
SwingViewerContext
public SwingViewerContext(SwingReportViewer viewer)
Creates a SwingViewerContext with a reference to a SwingReportViewer which is used for example when parent components are needed for dialogs, etc.- Parameters:
viewer
- SwingReportViewer to which this context belongs.- Since:
- 7.1
-
SwingViewerContext
public SwingViewerContext(java.awt.Component parent)
Creates a SwingViewerContext with a reference to a parent Component which is used for example when parent components are needed for dialogs, etc.- Parameters:
parent
- Parent to which this context belongs.- Since:
- 15.0
-
-
Method Detail
-
showInfo
public void showInfo()
Shows the info screen of this viewer.- Specified by:
showInfo
in interfaceViewerContext
- Since:
- 7.0
-
showError
public void showError(java.lang.Throwable e, java.lang.Object source)
This method will be called whenever an error occurs and thereby allows the implementor of this interface to handle the error as seen fit.- Specified by:
showError
in interfaceViewerContext
- Parameters:
e
- The Throwable of the error that actually occurred.source
- The source where the exception occurred, such as the SwingReportView or SwingPageView.- Since:
- 7.0
-
export
public ExportProgress export(ReportView view)
This method is called when the export action is to be performed. By default, this will show the export dialog and then export the currently visible report view's report with the settings given by the user.- Specified by:
export
in interfaceViewerContext
- Parameters:
view
- ReportView whose report is to be exported- Returns:
- the progress
- Since:
- 7.0
-
export
public ExportProgress export(java.awt.Component parent, RenderData data, java.beans.PropertyChangeListener changeListener)
Opens the export dialog with the given parent as its parent and exports using the provided RenderData object. This method can be called without first initializing a ReportViewer if so desired. Note that this method is never called by the viewer itself, rather it is meant for you to call yourself if you want to export without initializing a viewer.- Parameters:
parent
- Parent to display the dialog indata
- RenderData to use for retrieving the export datachangeListener
- PropertyChangeListener that will be notified whenever a bean changes a "bound" property.- Returns:
- the running export progress
- Since:
- 7.6
-
export
public ExportProgress export(java.awt.Component parent, RenderData data)
Opens the export dialog with the given parent as its parent and exports using the provided RenderData object. This method can be called without first initializing a ReportViewer if so desired. Note that this method is never called by the viewer itself, rather it is meant for you to call yourself if you want to export without initializing a viewer.- Parameters:
parent
- Parent to display the dialog indata
- RenderData to use for retrieving the export data- Returns:
- the running export progress
- Since:
- 7.6
-
print
public Progress print(ReportView view)
This method is called when the print action is to be performed. By default, this will show a print dialog and then print the given report view's report.- Specified by:
print
in interfaceViewerContext
- Parameters:
view
- ReportView whose report is to be printed.- Returns:
- the progress
- Since:
- 7.0
-
showStatusMessage
public void showStatusMessage(ReportView view, java.lang.String message, boolean isError)
Handled when a status message is to be displayed. Normally the implementor will display this message in the status bar.- Specified by:
showStatusMessage
in interfaceViewerContext
- Parameters:
view
- the ReportView which is to display the status message, must not be nullmessage
- the message to be displayedisError
- true if the message is an error message, false otherwise.- Since:
- 8.1
-
showUrl
public void showUrl(java.lang.String url, java.util.Properties props) throws java.net.MalformedURLException
Handles opening a URL, e.g. a click on a hyperlink. Actually opening the link should run asynchronously, so it won't block the control flow.- Specified by:
showUrl
in interfaceViewerContext
- Parameters:
url
- String of the hyperlink URL which is to be shown. The length need to be > 0.props
- Extra optional Properties for the URL connection (can be null for no extra properties)- Throws:
java.net.MalformedURLException
- The supplied URL String is invalid.
-
setViewer
public void setViewer(SwingReportViewer viewer)
Sets the viewer to which this context belongs.- Parameters:
viewer
- the viewer to which this context belongs, can be null if the context is not to be bound to a viewer- Since:
- 9.0
-
getViewer
public SwingReportViewer getViewer()
Returns the viewer to which this context belongs.- Returns:
- the viewer to which this context belongs, or null if the context is not bound to a viewer
- Since:
- 9.0
-
showPrompts
public boolean showPrompts(PromptData[] prompts, RenderData data)
Handles a prompt request from the server. The chosen value of the prompts in the array must be set in the PromptData objects usingPromptData.setChosenValues(Object)
.- Specified by:
showPrompts
in interfaceViewerContext
- Parameters:
prompts
- list of required promptsdata
- RenderData of the report requiring prompts- Returns:
- true if prompts were successfully set, false if the prompt dialog was canceled
-
showHelp
public void showHelp(java.lang.String helpPageKey, java.awt.Component comp)
Opens a HelpPage with a key in a window that corresponds to the component.- Specified by:
showHelp
in interfaceViewerContext
- Parameters:
helpPageKey
- key of the page to opencomp
- component to use when opening the window
-
-