public class SwingReportView extends javax.swing.JPanel implements ReportView
SwingReportViewer.addNewReportView(RenderData)
and SwingReportViewer.createReportView(RenderData)
.Hide the navigation view
If your report view does not have a group tree, or does not need a navigation view, you might want to hide the
navigation view. To do this, simply extract it with extractNavigationView()
. This will cause the
navigation view to be hidden. If you should later still want to get a reference to the navigation view object, this
is possible using getNavigationView()
.
"Wrap" the status bar in an own component
Using the methods "extractStatusBar" and "insertAtStatusBarPosition" this is quite simple:
StatusBar oldStatusBar = myView.extractStatusBar(); // We have now extracted the old status bar from the view - it should now no longer be // visible in the report view. Now, we place this status bar into our own component. // Let's say our own component has a green button called "TestGreen". JPanel newStatusBar = new JPanel( new FlowLayout() ); JButton test = new JButton( "TestGreen" ); test.setBackground( Color.GREEN ); newStatusBar.add( woohoo ); newStatusBar.add( oldStatusBar ); // Now we take advantage of the "insertAtStatusBarPosition" method, which places the component // we pass into the old status bar position. myView.insertAtStatusBarPosition( newStatusBar );
Export the report to a file
Once again, this is quite simple using the given "export" method, combined with the various export constants from the interface ReportView:
myView.export( ReportView.EXPORT_PDF, "C:/test.pdf" );
Cause the report to be re-rendered and refreshed
myView.refresh();
CURRENT_PAGE, EXPORT_CSV, EXPORT_DATA, EXPORT_HTML, EXPORT_PDF, EXPORT_PS, EXPORT_PS2, EXPORT_PS3, EXPORT_RTF, EXPORT_SVG, EXPORT_TXT, EXPORT_XLS, EXPORT_XML, MAX_ZOOM_FACTOR, MIN_ZOOM_FACTOR, MODE_HAND, MODE_SNAPSHOT, MODE_TEXT, PROP_LOADING_STATUS, PROP_TIMESTAMP, STATUS_CANCELED, STATUS_FINISHED, STATUS_INITIALIZED, STATUS_LOADING, TOTAL_PAGE_COUNT, TOTAL_PAGE_COUNT_UNKNOWN, VIEW_DOUBLE_CONTINUOUS, VIEW_DOUBLE_PAGE, VIEW_IS_AT_END_OF_REPORT, VIEW_MODE, VIEW_SINGLE_CONTINUOUS, VIEW_SINGLE_PAGE, ZOOM_FACTOR, ZOOM_MANUAL, ZOOM_TO_FULLPAGE, ZOOM_TO_PAGEHEIGHT, ZOOM_TO_PAGEWIDTH
Modifier and Type | Method and Description |
---|---|
void |
cancel()
This cancels the loading of the current report in case it is still loading.
|
ExportProgress |
export()
Exports the report connected to this report view.
|
ExportProgress |
export(int format,
java.lang.String filename)
Exports the report connected to this report view into the given file.
|
ExportProgress |
export(java.util.Properties exportProperties)
Exports the report connected to this report view into the given file.
|
NavigationView |
extractNavigationView()
Removes the navigation view GUI component from the ReportView and returns it.
|
StatusBar |
extractStatusBar()
Removes the status bar GUI component from the ReportView and returns it.
|
int |
getAutomaticZoomType()
Returns which type of automatic zoom is used in the report view whenever the ReportView
is displayed anew, for example after resizing the display.
|
java.awt.Component |
getComponent()
All public graphical components of the viewer must implement this method, which
returns the actual AWT component so that it can be added to containers, etc.
|
int |
getCurrentPage()
Returns the number of the "current page" being displayed in this ReportView.
|
javax.print.attribute.HashPrintRequestAttributeSet |
getDefaultAttributeSet(int fromPage,
int toPage)
Creates and returns a HashPrintRequestAttributeSet for the given page(s) with the default
printing attributes.
|
int |
getLoadingStatus()
Fetches the current "loading status" of this report view.
|
int |
getMouseActionMode()
Returns the currently selected mode for mouse actions such as clicking and dragging in this
ReportView.
|
NavigationView |
getNavigationView()
Returns this ReportView's NavigationView, that is, the element containing this ReportView's SearchView, GroupView and/or IndexView.
|
RenderData |
getReportData()
Returns the RenderData object belonging to this ReportView.
|
java.lang.String |
getReportTitle()
Returns the title of this report if it is known.
|
ReportViewer |
getReportViewer()
Returns the parent ReportViewer for this component.
|
StatusBar |
getStatusBar()
Returns this ReportView's StatusBar, the element which can display messages or progress bars.
|
int |
getTotalPages()
Returns the total number of pages this report has.
|
int |
getViewMode()
Returns which type of layout view this ReportView is to take.
|
float |
getZoomFactor()
Returns the currently set zoom factor of this ReportView - this is not a percentage value,
that is, 1.0 is 1x, 2.0 is 2x view, 0.25 is 1/4 view, etc.
|
void |
goToLastPage()
Navigates directly to the last page in the report - if the current page is
already the last page of the report, or if the total page count is not known
as of yet (that is, the report is still being rendered), this method does nothing.
|
void |
goToPage(int pageNumber)
Causes the page indicated by the parameter pageNum to be displayed in this ReportView.
|
boolean |
hasGroupTree()
Returns whether or not this report view is set to show a group tree.
|
boolean |
isDrilldownEnabled()
Returns whether this report view should allow drill downs on its groups if it has any.
|
boolean |
isExportEnabled()
Returns if at least one export format is enabled for this ReportView.
|
boolean |
isPageLimitExceeded()
Returns whether this report view has more pages than the server page limit for a report allows for (causing the later pages to be truncated
from the report).
|
boolean |
isReportSuppressed()
Returns whether this report was suppressed because it has no rows.
|
void |
nextPage()
Navigates one step forward in the report - if this is not possible (e.g. the current page is
already the last page of the report), this method does nothing.
|
void |
prevPage()
Navigates one step back in the report - if this is not possible (e.g. the current page is
already the first page of the report), this method does nothing.
|
Progress |
print(int fromPage,
int toPage,
boolean showPrintDialog)
Prints the current report in the page range with or without any dialogs.
|
PrinterJobProgress |
print(int fromPage,
int toPage,
java.awt.print.PrinterJob pjob)
Prints the current report to a PrinterJob without any dialogs.
|
PrinterJobProgress |
print(java.awt.print.PrinterJob printerJob,
javax.print.attribute.PrintRequestAttributeSet attributeSet)
Creates a new PrinterJobProgress with the given attributes and start it.
|
void |
refresh()
Causes this ReportView to refresh its pages by re-fetching the report data - this causes a
re-rendering of the report data.
|
void |
reload()
Causes this ReportView to reload its pages and show them again, using the already fetched
data if possible - if not, this causes a fetching of the report data.
|
void |
replaceNavigationView(java.awt.Component component)
Inserts the given component at the position of the navigation view.
|
void |
replaceStatusBar(java.awt.Component component)
Inserts the given component at the position of the status bar.
|
void |
setAutoRefresh(int millis)
Sets the auto-refresh time for this report view.
|
void |
setAutomaticZoomType(int type)
Sets the type of zoom to use in the report view when the ReportView is displayed anew (for
example after resizing the display).
|
void |
setDrilldownEnabled(boolean enabled)
Sets whether this report view should allow drill downs on its groups if it has any.
|
void |
setHasGroupTree(boolean hasGroupTree)
Sets this report view to whether or not it is to show a group tree.
|
void |
setMouseActionMode(int hand)
Sets the mode this ReportView is to be in for mouse actions such as clicking and dragging.
|
void |
setPageLimitExceeded(boolean pageLimitExceeded)
sets the "page limit exceeded" flag which determines whether the toolbar will display the total page count with a "+".
|
void |
setViewMode(int i)
Sets the type of view this ReportView is to take and causes this view to be displayed
immediately.
|
void |
setZoomFactor(float factor)
Sets the zoom factor to this value.
|
void |
showError(java.lang.Throwable th)
Displays an error box showing the Throwable's error message.
|
static boolean |
showPrintDialog(java.awt.Component parentComponent,
java.awt.print.PrinterJob printerJob,
javax.print.attribute.HashPrintRequestAttributeSet attributeSet)
Shows the viewer print dialog.
|
public void showError(java.lang.Throwable th)
showError
in interface ReportView
th
- Throwable to display in an error box. Best if this Throwable is a ViewerException.public NavigationView getNavigationView()
getNavigationView
in interface ReportView
public StatusBar getStatusBar()
getStatusBar
in interface ReportView
public StatusBar extractStatusBar()
extractStatusBar
in interface ReportView
public NavigationView extractNavigationView()
extractNavigationView
in interface ReportView
public void reload()
reload
in interface ReportView
ReportView.refresh()
public void refresh()
refresh
in interface ReportView
ReportView.reload()
public void cancel()
ReportView.STATUS_FINISHED
or ReportView.STATUS_CANCELED
, this
method has no effect.cancel
in interface ReportView
public void nextPage()
nextPage
in interface ReportView
public void prevPage()
prevPage
in interface ReportView
public void goToPage(int pageNumber)
goToPage
in interface ReportView
pageNumber
- Number of page (starting at 1) to be displayed in this ReportView.public void goToLastPage()
goToLastPage
in interface ReportView
public void setViewMode(int i)
setViewMode
in interface ReportView
i
- Layout type to display in this ReportView.ReportView.VIEW_DOUBLE_CONTINUOUS
,
ReportView.VIEW_DOUBLE_PAGE
,
ReportView.VIEW_SINGLE_PAGE
,
ReportView.VIEW_SINGLE_CONTINUOUS
public javax.print.attribute.HashPrintRequestAttributeSet getDefaultAttributeSet(int fromPage, int toPage)
getDefaultAttributeSet
in interface ReportView
fromPage
- Number of the first page for which to create the HashPrintRequestAttributeSet. The first page of a report has the value 1.toPage
- Number of the last page for which to create the HashPrintRequestAttributeSet. A value of -1 means to create the AttributeSet for all pages starting at startPage.HashPrintRequestAttributeSet
public Progress print(int fromPage, int toPage, boolean showPrintDialog)
print
in interface ReportView
fromPage
- the index of the start page to be printed, the first page is 1.toPage
- the index of the last page to be printed. A value of -1 means all pages.showPrintDialog
- if true
, a print dialog is showing.ReportView.print(int, int, PrinterJob)
,
PrinterJobProgress
public PrinterJobProgress print(int fromPage, int toPage, java.awt.print.PrinterJob pjob)
print
in interface ReportView
fromPage
- the index of the start page to be printed, the first page is 1.toPage
- the index of the last page to be printed. A value of -1 means all pages.pjob
- A java.awt.print.PrinterJob object.ReportView.print(int,int,boolean)
,
PrinterJobProgress
public PrinterJobProgress print(java.awt.print.PrinterJob printerJob, javax.print.attribute.PrintRequestAttributeSet attributeSet)
print
in interface ReportView
printerJob
- The PrinterJob with the target PrintService.attributeSet
- attributeSet A list of attributes that can override values in the report design,
for example paper format, paper orientation and page margins.ReportView.getDefaultAttributeSet(int, int)
,
PrinterJobProgress
public static boolean showPrintDialog(java.awt.Component parentComponent, java.awt.print.PrinterJob printerJob, javax.print.attribute.HashPrintRequestAttributeSet attributeSet)
parentComponent
- a parent component, used for showing the dialog as a modal dialog. Can be null.printerJob
- a PrinterJob with the selected PrintService. On output the PrintService is updated. This
parameter may not be null.attributeSet
- print attributes that are to be shown in the dialog. Once the dialog is closed, the contents
are updated to reflect user choices. This parameter may not be null.ViewerException
- if no print services are available.getDefaultAttributeSet(int, int)
,
PrinterJob.pageDialog(PrintRequestAttributeSet)
public ExportProgress export()
export
in interface ReportView
ExportProgress
public ExportProgress export(int format, java.lang.String filename)
export
in interface ReportView
format
- The export format in that the report will be exported.filename
- Name of the file in that the report will be exported.ExportProgress
,
ReportView.EXPORT_CSV
,
ReportView.EXPORT_DATA
,
ReportView.EXPORT_HTML
,
ReportView.EXPORT_PDF
,
ReportView.EXPORT_PS
,
ReportView.EXPORT_PS2
,
ReportView.EXPORT_PS3
,
ReportView.EXPORT_RTF
,
ReportView.EXPORT_SVG
,
ReportView.EXPORT_TXT
,
ReportView.EXPORT_XLS
,
ReportView.EXPORT_XML
public ExportProgress export(java.util.Properties exportProperties)
export
in interface ReportView
exportProperties
- Properties for the export, including format, file and other properties if they are available for the selected format.ExportProgress
public boolean isExportEnabled()
isExportEnabled
in interface ReportView
public void setMouseActionMode(int hand)
setMouseActionMode
in interface ReportView
hand
- Mouse mode to be used in the ReportView.ReportView.MODE_HAND
,
ReportView.MODE_SNAPSHOT
,
ReportView.MODE_TEXT
public boolean hasGroupTree()
hasGroupTree
in interface ReportView
public void setHasGroupTree(boolean hasGroupTree)
setHasGroupTree
in interface ReportView
hasGroupTree
- Is this report view to show a group tree?ReportView.getNavigationView()
,
ReportView.extractNavigationView()
public void setZoomFactor(float factor)
ReportView.setAutomaticZoomType(int)
setZoomFactor
in interface ReportView
factor
- Factor to zoom to - 1.0 as 100%, 2.0 as 200%, etc.ReportView.MIN_ZOOM_FACTOR
,
ReportView.MAX_ZOOM_FACTOR
,
ReportView.setAutomaticZoomType(int)
public void setAutomaticZoomType(int type)
setAutomaticZoomType
in interface ReportView
type
- Zoom type to use when displaying the ReportView.ReportView.ZOOM_MANUAL
,
ReportView.ZOOM_TO_FULLPAGE
,
ReportView.ZOOM_TO_PAGEHEIGHT
,
ReportView.ZOOM_TO_PAGEWIDTH
,
ReportView.getAutomaticZoomType()
public float getZoomFactor()
getZoomFactor
in interface ReportView
public int getCurrentPage()
getCurrentPage
in interface ReportView
public int getTotalPages()
getTotalPages
in interface ReportView
ReportView.TOTAL_PAGE_COUNT_UNKNOWN
public java.awt.Component getComponent()
myFrame.add(viewer.getComponent())
getComponent
in interface ViewerComponent
public void replaceStatusBar(java.awt.Component component)
replaceStatusBar
in interface ReportView
component
- Component to position at the status bar position, null if the status bar is simply to be removed.public void replaceNavigationView(java.awt.Component component)
replaceNavigationView
in interface ReportView
component
- Component to position at the navigation view position, null if the navigation view is simply to be removedpublic int getViewMode()
getViewMode
in interface ReportView
ReportView.setViewMode(int)
,
ReportView.VIEW_DOUBLE_CONTINUOUS
,
ReportView.VIEW_DOUBLE_PAGE
,
ReportView.VIEW_SINGLE_PAGE
,
ReportView.VIEW_SINGLE_CONTINUOUS
public int getAutomaticZoomType()
getAutomaticZoomType
in interface ReportView
ReportView.ZOOM_MANUAL
,
ReportView.ZOOM_TO_PAGEHEIGHT
,
ReportView.ZOOM_TO_PAGEWIDTH
,
ReportView.ZOOM_TO_FULLPAGE
,
ReportView.setAutomaticZoomType(int)
public int getMouseActionMode()
getMouseActionMode
in interface ReportView
ReportView.MODE_HAND
,
ReportView.MODE_SNAPSHOT
,
ReportView.MODE_TEXT
public RenderData getReportData()
getReportData
in interface ReportView
public ReportViewer getReportViewer()
getReportViewer
in interface ReportView
public java.lang.String getReportTitle()
getReportTitle
in interface ReportView
RenderData.setReportTitle(String)
public int getLoadingStatus()
getLoadingStatus
in interface ReportView
ReportView.STATUS_CANCELED
,
ReportView.STATUS_FINISHED
,
ReportView.STATUS_INITIALIZED
,
ReportView.STATUS_LOADING
public void setAutoRefresh(int millis)
millis
milliseconds. Note that if the report has prompts, its prompts will not be re-requested
at each auto-refresh. Also, a refresh will be skipped if the prompt dialog is currently open, if the report is
already currently being refreshed, if the report was manually canceled or if it was stopped due to an error.setAutoRefresh
in interface ReportView
millis
- number of milliseconds for auto-refresh cycle, 0 to turn off auto-refreshpublic boolean isDrilldownEnabled()
ReportView.setDrilldownEnabled(boolean)
and/or as a ViewerSettings entry.isDrilldownEnabled
in interface ReportView
public void setDrilldownEnabled(boolean enabled)
setDrilldownEnabled
in interface ReportView
enabled
- true if it is to be enabledpublic boolean isPageLimitExceeded()
isPageLimitExceeded
in interface ReportView
public void setPageLimitExceeded(boolean pageLimitExceeded)
pageLimitExceeded
- true if page limit was exceededpublic boolean isReportSuppressed()
isReportSuppressed
in interface ReportView
Copyright © 1999-2020 by i-net software GmbH