Class SwingReportViewer
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.inet.viewer.SwingReportViewer
-
- All Implemented Interfaces:
ReportViewer
,ViewerComponent
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public class SwingReportViewer extends javax.swing.JPanel implements ReportViewer
The SwingReportViewer is the top level container for all Swing viewer elements. It is an example implementation of the com.inet.viewer.ReportViewer interface which by default has the SwingToolBar element at the top, collects the various SwingReportViews to be shown in a TabbedPane, and shows the SwingStatusBar at the bottom.Note that the color for the space in which the report pages appear is taken from the UI color resource under the UI property
ReportViewer.UIPROP_SCROLLPANE_BACKGROUND
. If no property is found,Color.LIGHT_GRAY
is taken by default.A simple default SwingReportViewer can be created and shown in a JFrame with the following lines of code:
URLRenderData myConnection = new URLRenderData("http://<reportserver>:9000/?report=file:c:/report1.rpt"); myConnection.setPromptOnRefresh(true); myConnection.setReportTitle("My Test Report"); SwingReportViewer viewer = new SwingReportViewer(); viewer.addNewReportView(myConnection); frame.getContentPane().add(viewer); frame.pack(); frame.setVisible(true);
Note that first, a RenderData object was created (in this case, a URLRenderData object). This RenderData object is passed to the viewer to have it create a ReportView, in either createReportView(RenderData) - which simply is a factory method which creates a new ReportView but does not add it to the Viewer - or in addNewReportView(RenderData) - which first creates a ReportView (with createReportView), and then adds the newly created ReportView to the viewer.
SwingReportViewer offers various possibilities for customizing your own Viewer by either overriding certain methods, or by setting certain options. Here are a few scenarios of possibilities of how the viewer can be customized:
Each ReportView in its own JFrame
It could be that you would like to not have a TabbedPane for various ReportViews, but rather would like to have a JFrame opened for each ReportView which is opened. To do this, you would use code something like the following (for each example, we assume that we have already instanced a RenderData object called "myConnection"):
SwingReportViewer viewer = new SwingReportViewer() { // Here we will override the default behavior of the Viewer. // For this, we'll keep track of the various Views in a HashMap: HashMap myMap = new HashMap(); public void addReportView(ReportView view, boolean isClosable) { // We now override the default behavior of addReportView // which was to open new tabs for each new view. // Instead, we open a new frame, place the new report view // inside it, and remember it in combination with the frame // in our hash map. JFrame frame = new JFrame(view.getReportData(). getReportTitle()); // So that the viewer knows which ReportView is the // current report view (for toolbar actions, etc.), we'll // define a WindowFocusListener so that whenever a user // focuses on a report view window, it becomes the // current report view. WindowFocusListener l = new WindowFocusListener() { public void windowGainedFocus(WindowEvent e) { setCurrentReportView((ReportView)myMap.get(e.getWindow())); } public void windowLostFocus(WindowEvent e) { } }; myMap.put(frame,view); // Now we simply add the view to the frame and show it: frame.addWindowFocusListener(l); frame.getContentPane().add(view.getComponent()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); setCurrentReportView(view); } }; // This is now for initializing the viewer: We create a new // ReportView and add it to the viewer - this will end up // calling our overridden method and opening a new Frame. viewer.addNewReportView(myConnection); // We also want our toolbar to be in its own frame, so we // extract it and place it in a JFrame: JFrame toolbar = new JFrame("Toolbar"); toolbar.getContentPane().add(viewer.getToolBar().getComponent()); toolbar.pack(); toolbar.setVisible(true);
New ReportViews into the same JFrame
If we want each newly opened ReportView to be shown in the same frame, that is, to only show one ReportView at a time and to "navigate" through ReportViews, we do this similarly to the last example, except that only one Frame is created, and the ReportViews are simply swapped within this one Frame:
SwingReportViewer viewer = new SwingReportViewer() { // Here we will override the default behavior of the Viewer. public void addReportView(ReportView view, boolean isClosable) { // We now override the default behavior of addReportView // which was to open a new tab for each new view. // Instead, we remove all old views and replace them with the new view. closeAllReportViews(); super.addReportView( view, isClosable ); } }; // This initializes the viewer: We create a new // ReportView and add it to the viewer viewer.addNewReportView(myConnection); JFrame viewerFrame = new JFrame("Viewer"); viewerFrame.getContentPane().add(viewer); viewerFrame.pack(); viewerFrame.setVisible(true);
Theoretically it would be possible to actually implement navigation backwards and forwards through ReportViews - one would simply have to store each ReportView in a history and run through the history backwards and forwards as needed.- Since:
- 7.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
IS_TECHNICAL_BUILD
FOR INTERNAL USE ONLYstatic int
PRINTER_USE_DEFAULT_FORMAT_IF_SIMILAR
Uses the default format of the printer if it is A4 or Letter while the report format is the other size.static int
PRINTER_USE_REPORT_FORMAT
Always uses the report's paper format, even if it is similar to the printer's paper format.static int
VERSION_MAJOR
FOR INTERNAL USE ONLYstatic int
VERSION_MINOR
FOR INTERNAL USE ONLY-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface com.inet.viewer.ReportViewer
PROP_STATUS_MESSAGE, UIPROP_SCROLLPANE_BACKGROUND
-
-
Constructor Summary
Constructors Constructor Description SwingReportViewer()
Creates an instance of the SwingReportViewer, initializing a set of Actions and a SwingToolBar.SwingReportViewer(ViewerContext context)
Creates an instance of the SwingReportViewer with the given ViewerContext for handling various actions
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReportView
addNewReportView(RenderData data)
Creates a new ReportView object, using the RenderData parameter as its source of report data.ReportView
addNewReportView(RenderData data, boolean isClosable)
Creates a new ReportView object, using the RenderData parameter as its source of report data.void
addNotify()
This method overrides "addNotify" in JComponent, and registers the needed listeners for the SwingReportViewer.void
addReportView(ReportView repView)
Adds a given ReportView to the ReportViewer - this ReportView need not be initialized at this point in time.
Note that as long as the viewer exists, this report view will be held in memory, unless it is removed viaReportViewer.closeReportView(int)
orReportViewer.closeAllReportViews()
.void
addReportView(ReportView repView, boolean isClosable)
Adds a given ReportView to the ReportViewer - this ReportView need not be initialized at this point in time.
Note that as long as the viewer exists, this report view will be held in memory, unless it is removed viaReportViewer.closeReportView(int)
orReportViewer.closeAllReportViews()
.void
addReportViewChangeListener(ReportViewChangeListener rvcl)
Adds anReportViewChangeListener
to the ReportView.void
addStateChangeListener(java.beans.PropertyChangeListener l)
Adds aPropertyChangeListener
to the listener list.void
closeAllReportViews()
This method permanently closes and removes all ReportViews currently in the ReportViewer.void
closeReportView(int index)
Permanently closes and removes the ReportView at the given index, 0-based.void
closeReportView(ReportView view)
Permanently closes and disposes the ReportView given as the parameter and removes it from the ReportViewer.ReportView
createReportView(RenderData data)
Creates a report view and initializes it with the data source "data".ActionPool
getActionPool()
Returns the SwingViewer report actions connected to this viewer.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.
For example, if you have a "ReportViewer" and would like to add it to your own JFrame, simply call:myFrame.add(viewer.getComponent())
ReportView
getCurrentReportView()
Returns the currently visible or selected ReportView object.java.lang.String
getDefaultExportDirectory()
Returns the default directory in that the Java viewer will save the exported files.DefaultSetting
getDefaultSetting(DefaultSetting.Key key)
Returns the setting of the property defined by the key, or null if no value is set.java.lang.Throwable
getLastError()
Returns the last error which occurred in the viewer.static java.io.PrintStream
getLoggingStream()
Returns the PrintStream used by the viewer for log outputs.static int
getMajorVersion()
Returns the number of the "major version" of this SwingReportViewer, that is, for version 7.5, this would return "7".static int
getMinorVersion()
Returns the number of the "minor version" of this SwingReportViewer, that is, for version 7.5, this would return "5".int
getPrinterDefaultFormatHandling()
Returns the printer default format handling.ProgressPool
getProgressPool()
Returns theProgressPool
of the viewer.ReportView
getReportView(int i)
Returns the report view at the given index.int
getReportViewCount()
Returns the number of ReportViews registered and added to this viewer.ToolBar
getToolBar()
Returns the current ToolBar - this tool bar belongs to the currently visible or selected ReportView object.static java.lang.String
getVersion()
Returns the current version of the SwingReportViewer as a String representation, e.g. "7.5".static java.lang.String
getVersionSuffix()
FOR INTERNAL USE ONLY Returns the suffix for the version number.ViewerContext
getViewerContext()
Returns the current ViewerContext for this viewer, which is used for reacting to and handling events occurring in the viewer.boolean
hasGroupTree()
Returns whether the global "hasGroupTree" setting is on or off (by default it is on).boolean
hasStatusBar()
Returns whether the global setting of "hasStatusBar" is on or off (by default it is on).void
removeNotify()
This method overrides "removeNotify" in JComponent, and unregisters the listeners for the SwingReportViewer.void
removeReportViewChangeListener(ReportViewChangeListener rvcl)
Removes anReportViewChangeListener
from the ReportView.void
removeStateChangeListener(java.beans.PropertyChangeListener l)
Removes aPropertyChangeListener
from the list of listeners.void
setCurrentReportView(ReportView rv)
Sets which ReportView is currently selected and to be affected by any toolbar actions, etc.void
setCustomPromptEditor(java.lang.String promptName, int valueType, CustomPromptEditor editor)
Registers the givenCustomPromptEditor
for prompts with the given name and value type, case-insensitive.void
setDefaultExportDirectory(java.lang.String directory)
Sets the default directory in that the Java viewer will save the exported files.void
setDefaultSetting(DefaultSetting.Key key, DefaultSetting value)
Applies a setting defined by the given key-value pair.void
setHasGroupTree(boolean hasGroupTree)
Sets all report views to whether or not they are to show a group tree.void
setHasStatusBar(boolean hasStatusBar)
Sets for all report views whether or not they are to show a status bar.static void
setLoggingStream(java.io.PrintStream stream)
Sets the stream to be used for log outputs.void
setPrinterDefaultFormatHandling(int printerDefaultFormatHandling)
Sets the printer default format handling to use.void
setViewerContext(ViewerContext context)
Sets the ViewerContext for this viewer, used for reacting to and handling events which occur in the viewer.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
VERSION_MAJOR
public static final int VERSION_MAJOR
FOR INTERNAL USE ONLY- See Also:
- Constant Field Values
-
VERSION_MINOR
public static final int VERSION_MINOR
FOR INTERNAL USE ONLY- See Also:
- Constant Field Values
-
IS_TECHNICAL_BUILD
public static final boolean IS_TECHNICAL_BUILD
FOR INTERNAL USE ONLY- See Also:
- Constant Field Values
-
PRINTER_USE_DEFAULT_FORMAT_IF_SIMILAR
public static final int PRINTER_USE_DEFAULT_FORMAT_IF_SIMILAR
Uses the default format of the printer if it is A4 or Letter while the report format is the other size.- See Also:
- Constant Field Values
-
PRINTER_USE_REPORT_FORMAT
public static final int PRINTER_USE_REPORT_FORMAT
Always uses the report's paper format, even if it is similar to the printer's paper format.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SwingReportViewer
public SwingReportViewer()
Creates an instance of the SwingReportViewer, initializing a set of Actions and a SwingToolBar.- Since:
- 7.0
-
SwingReportViewer
public SwingReportViewer(ViewerContext context)
Creates an instance of the SwingReportViewer with the given ViewerContext for handling various actions- Parameters:
context
- ViewerContext object which handles various user actions. Can be null, which causes the default SwingViewerContext to be used.- Since:
- 9.0
-
-
Method Detail
-
setViewerContext
public void setViewerContext(ViewerContext context)
Sets the ViewerContext for this viewer, used for reacting to and handling events which occur in the viewer.- Specified by:
setViewerContext
in interfaceReportViewer
- Parameters:
context
- ViewerContext to use for this viewer. Can not be null.- Since:
- 7.0
- See Also:
ViewerContext
-
getViewerContext
public ViewerContext getViewerContext()
Returns the current ViewerContext for this viewer, which is used for reacting to and handling events occurring in the viewer. By default, this will return an instance ofSwingViewerContext
.- Specified by:
getViewerContext
in interfaceReportViewer
- Returns:
- ViewerContext used by this viewer
- Since:
- 7.0
- See Also:
ViewerContext
-
closeAllReportViews
public void closeAllReportViews()
This method permanently closes and removes all ReportViews currently in the ReportViewer. This will also close any currently open connections to the various RenderData objects to which the ReportViews are connected. Note that this causes the report views to be disposed of - trying to add one of them back to the viewer viaReportViewer.addReportView(ReportView, boolean)
will result in an IllegalStateException. Instead simply create a new report view with the same RenderData.- Specified by:
closeAllReportViews
in interfaceReportViewer
- Since:
- 7.0
-
closeReportView
public void closeReportView(int index)
Permanently closes and removes the ReportView at the given index, 0-based. That is,closeReportView(0)
will close and remove the first ReportView added to the Viewer,closeReportView(1)
the second, etc. This will also close any currently open connections to the ReportView's RenderData object. Note that this causes the report view to be disposed of - trying to add it back to the viewer viaReportViewer.addReportView(ReportView, boolean)
will result in an IllegalStateException. Instead simply create a new report view with the same RenderData. If there is no ReportView at this index, this method will throw a ViewerException.- Specified by:
closeReportView
in interfaceReportViewer
- Parameters:
index
- Index of ReportView to close and remove.- Since:
- 7.0
-
closeReportView
public void closeReportView(ReportView view)
Permanently closes and disposes the ReportView given as the parameter and removes it from the ReportViewer. This will also close any currently open connections to the ReportView's RenderData object. Note that this causes the report view to be disposed of - trying to add it back to the viewer viaReportViewer.addReportView(ReportView, boolean)
will result in an IllegalStateException. Instead simply create a new report view with the same RenderData.- Specified by:
closeReportView
in interfaceReportViewer
- Parameters:
view
- ReportView to close and remove from the ReportViewer- Since:
- 7.0
-
getToolBar
public ToolBar getToolBar()
Returns the current ToolBar - this tool bar belongs to the currently visible or selected ReportView object. This object is responsible for various user actions for navigating through the report, printing, etc.- Specified by:
getToolBar
in interfaceReportViewer
- Returns:
- ToolBar of current ReportView
- Since:
- 7.0
-
addNewReportView
public ReportView addNewReportView(RenderData data, boolean isClosable)
Creates a new ReportView object, using the RenderData parameter as its source of report data. Also adds this newly created ReportView to the ReportViewer, therefore this view should not simply be added somewhere else without first removing it from the viewer. Note that as long as the viewer exists, this report view will be held in memory, unless it is removed viaReportViewer.closeReportView(int)
orReportViewer.closeAllReportViews()
.
If a report with precisely the same properties has already been added, this will not create an identical second view, rather it will give focus to the view already opened. If you want to add two identical reports to the same viewer, simply add an identifying property to the report views, such as a time stamp.- Specified by:
addNewReportView
in interfaceReportViewer
- Parameters:
data
- RenderData object specifying the source of report dataisClosable
- Whether the report view is to have a close button- Returns:
- Newly created ReportView - this ReportView has now been added to a ReportViewer and should not simply be added somewhere else without first removing it from the viewer.
- Since:
- 7.4
- See Also:
ReportViewer.closeReportView(int)
,ReportViewer.closeReportView(ReportView)
,ReportViewer.closeAllReportViews()
-
addReportView
public void addReportView(ReportView repView, boolean isClosable)
Adds a given ReportView to the ReportViewer - this ReportView need not be initialized at this point in time.
Note that as long as the viewer exists, this report view will be held in memory, unless it is removed viaReportViewer.closeReportView(int)
orReportViewer.closeAllReportViews()
.- Specified by:
addReportView
in interfaceReportViewer
- Parameters:
repView
- ReportView to addisClosable
- Whether the report view is to have a close button- Since:
- 7.4
- See Also:
ReportViewer.closeReportView(int)
,ReportViewer.closeReportView(ReportView)
,ReportViewer.closeAllReportViews()
-
addNewReportView
public ReportView addNewReportView(RenderData data)
Creates a new ReportView object, using the RenderData parameter as its source of report data. Also adds this newly created ReportView to the ReportViewer.
Note that as long as the viewer exists, this report view will be held in memory, unless it is removed viaReportViewer.closeReportView(int)
orReportViewer.closeAllReportViews()
. In this case, it can not be added back to the Viewer via this method. Instead it must be recreated with the RenderData.
Note also that the report view will not have a close button if it is the first report view added to the viewer, otherwise it will. If you'd like to customize this behavior, use the methodReportViewer.addNewReportView(RenderData, boolean)
instead, where you can manually set whether or not the view is to have a close button.
If a report with precisely the same properties has already been added, this will not create an identical second view, rather it will give focus to the view already opened. If you want to add two identical reports to the same viewer, simply add an identifying property to the report views, such as a time stamp.- Specified by:
addNewReportView
in interfaceReportViewer
- Parameters:
data
- RenderData object specifying the source of report data- Returns:
- Newly created ReportView - this ReportView has now been added to a ReportViewer and should not simply be added somewhere else without first removing it from the viewer.
- Since:
- 7.0
- See Also:
ReportViewer.closeReportView(int)
,ReportViewer.closeReportView(ReportView)
,ReportViewer.closeAllReportViews()
,ReportViewer.addNewReportView(RenderData, boolean)
-
createReportView
public ReportView createReportView(RenderData data)
Creates a report view and initializes it with the data source "data".- Parameters:
data
- RenderData object for the report data- Returns:
- Newly created ReportView.
- Since:
- 7.0
-
addReportView
public void addReportView(ReportView repView)
Adds a given ReportView to the ReportViewer - this ReportView need not be initialized at this point in time.
Note that as long as the viewer exists, this report view will be held in memory, unless it is removed viaReportViewer.closeReportView(int)
orReportViewer.closeAllReportViews()
. In this case, it can not be added back to the viewer via this method. Instead it must be recreated with theRenderData
.
Note also that the report view will not have a close button if it is the first report view added to the viewer, otherwise it will. If you'd like to customize this behavior, use the methodReportViewer.addReportView(ReportView, boolean)
instead, where you can manually set whether or not the view is to have a close button.- Specified by:
addReportView
in interfaceReportViewer
- Parameters:
repView
- ReportView to add- Since:
- 7.0
- See Also:
ReportViewer.closeReportView(int)
,ReportViewer.closeReportView(ReportView)
,ReportViewer.closeAllReportViews()
,ReportViewer.addReportView(ReportView, boolean)
-
removeNotify
public void removeNotify()
This method overrides "removeNotify" in JComponent, and unregisters the listeners for the SwingReportViewer. Do not call this method yourself, it will be called automatically when the viewer is removed from its container.- Overrides:
removeNotify
in classjavax.swing.JComponent
- Since:
- 7.0
- See Also:
JComponent.addNotify()
-
addNotify
public void addNotify()
This method overrides "addNotify" in JComponent, and registers the needed listeners for the SwingReportViewer. Do not call this method yourself, it will be called automatically when the viewer is placed into a container.- Overrides:
addNotify
in classjavax.swing.JComponent
- Throws:
ViewerException
- If you attempt to place this into a component whose top window is not a Swing component. getRootPane() must return a component.- Since:
- 7.0
- See Also:
JComponent.addNotify()
-
getCurrentReportView
public ReportView getCurrentReportView()
Returns the currently visible or selected ReportView object. Note that this will return null if no ReportView is currently visible or selected.- Specified by:
getCurrentReportView
in interfaceReportViewer
- Returns:
- Currently active ReportView, or null if none is currently active
- Since:
- 7.0
-
setCurrentReportView
public void setCurrentReportView(ReportView rv)
Sets which ReportView is currently selected and to be affected by any toolbar actions, etc. Any time the toolbar or group view needs to fire an action, it asks the viewer for the current report view viaReportViewer.getCurrentReportView()
. This method makes sure that the correct report view is set as "current".
Note that this method also notifies eachReportViewChangeListener
of a change in the currently selected report view.
Note also that "null" is allowed here which causes no view at all to be viewed as the currently selected report view.- Specified by:
setCurrentReportView
in interfaceReportViewer
- Parameters:
rv
- ReportView to give focus to and to set as "current" report view.- Since:
- 7.0
- See Also:
ReportViewer.getCurrentReportView()
-
setHasGroupTree
public void setHasGroupTree(boolean hasGroupTree)
Sets all report views to whether or not they are to show a group tree. If this is false, the report views are not to show any group tree, regardless of whether or not their reports have groups.- Specified by:
setHasGroupTree
in interfaceReportViewer
- Parameters:
hasGroupTree
- Are all report views to show a group tree?- Since:
- 7.0
-
hasGroupTree
public boolean hasGroupTree()
Returns whether the global "hasGroupTree" setting is on or off (by default it is on). Note that there can always be local exceptions to this rule.- Specified by:
hasGroupTree
in interfaceReportViewer
- Returns:
- Global "hasGroupTree" setting
- Since:
- 7.0
-
setHasStatusBar
public void setHasStatusBar(boolean hasStatusBar)
Sets for all report views whether or not they are to show a status bar. If this is false, the report views are not to show a status bar.- Specified by:
setHasStatusBar
in interfaceReportViewer
- Parameters:
hasStatusBar
- Are all report views to show a status bar?- Since:
- 7.0
-
hasStatusBar
public boolean hasStatusBar()
Returns whether the global setting of "hasStatusBar" is on or off (by default it is on).- Specified by:
hasStatusBar
in interfaceReportViewer
- Returns:
- Global "hasStatusBar" setting
- Since:
- 7.0
-
getMajorVersion
public static int getMajorVersion()
Returns the number of the "major version" of this SwingReportViewer, that is, for version 7.5, this would return "7".- Returns:
- Number of "major version" of this SwingReportViewer
- Since:
- 7.0
-
getMinorVersion
public static int getMinorVersion()
Returns the number of the "minor version" of this SwingReportViewer, that is, for version 7.5, this would return "5".- Returns:
- Number of "minor version" of this SwingReportViewer
- Since:
- 7.0
-
getVersionSuffix
public static java.lang.String getVersionSuffix()
FOR INTERNAL USE ONLY Returns the suffix for the version number.- Returns:
- version suffix
- Since:
- 10.0
-
getVersion
public static java.lang.String getVersion()
Returns the current version of the SwingReportViewer as a String representation, e.g. "7.5".- Returns:
- Current version of the SwingReportViewer
- Since:
- 7.0
-
getActionPool
public ActionPool getActionPool()
Returns the SwingViewer report actions connected to this viewer. These can be customized and changed as needed.- Returns:
- SwingViewer report actions connected to this viewer.
- Since:
- 7.0
-
getLastError
public java.lang.Throwable getLastError()
Returns the last error which occurred in the viewer. Returns null if no error has occurred at all.- Returns:
- Last error occurred in the viewer, or null if no error has occurred.
- Since:
- 7.0
-
getComponent
public 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.
For example, if you have a "ReportViewer" and would like to add it to your own JFrame, simply call:myFrame.add(viewer.getComponent())
- Specified by:
getComponent
in interfaceViewerComponent
- Returns:
- Actual AWT component of this object.
- Since:
- 7.0
-
addReportViewChangeListener
public void addReportViewChangeListener(ReportViewChangeListener rvcl)
Adds anReportViewChangeListener
to the ReportView.- Specified by:
addReportViewChangeListener
in interfaceReportViewer
- Parameters:
rvcl
- theReportViewChangeListener
to be added- Since:
- 7.0
-
removeReportViewChangeListener
public void removeReportViewChangeListener(ReportViewChangeListener rvcl)
Removes anReportViewChangeListener
from the ReportView.- Specified by:
removeReportViewChangeListener
in interfaceReportViewer
- Parameters:
rvcl
- the listener to be removed- Since:
- 7.0
-
getLoggingStream
public static java.io.PrintStream getLoggingStream()
Returns the PrintStream used by the viewer for log outputs. This is null if logging is deactivated. By default, this should return the System.out stream.- Returns:
- PrintStream used for log outputs.
- Since:
- 7.8.01
-
setLoggingStream
public static void setLoggingStream(java.io.PrintStream stream)
Sets the stream to be used for log outputs. Set this stream to null in order to deactivate log outputs completely. By default, the log stream is set to System.out.- Parameters:
stream
- PrintStream the viewer is to log to.- Since:
- 7.8.01
-
getReportView
public ReportView getReportView(int i)
Returns the report view at the given index. Note this report view need not be the current report view or even visible. The maximum allowed index isgetReportViewCount()-1
, the minimum allowed is 0.- Specified by:
getReportView
in interfaceReportViewer
- Parameters:
i
- Index of report view to fetch.- Returns:
- ReportView at the index given
- Since:
- 7.0
-
getReportViewCount
public int getReportViewCount()
Returns the number of ReportViews registered and added to this viewer. The return value -1 is the maximum allowed index forReportViewer.getReportView(int)
.- Specified by:
getReportViewCount
in interfaceReportViewer
- Returns:
- The number of ReportViews held by the ReportViewer
- Since:
- 7.0
-
addStateChangeListener
public void addStateChangeListener(java.beans.PropertyChangeListener l)
Adds aPropertyChangeListener
to the listener list. The listener will be informed about status changes of all progresses and messages changes in the StatusBar.- Specified by:
addStateChangeListener
in interfaceReportViewer
- Parameters:
l
- PropertyChangeListener to add to the list of listeners- Since:
- 7.0
-
removeStateChangeListener
public void removeStateChangeListener(java.beans.PropertyChangeListener l)
Removes aPropertyChangeListener
from the list of listeners.- Specified by:
removeStateChangeListener
in interfaceReportViewer
- Parameters:
l
- PropertyChangeListener to remove from the list of listeners.- Since:
- 7.0
-
getProgressPool
public ProgressPool getProgressPool()
Returns theProgressPool
of the viewer. The ProgressPool handles all progresses of the viewer. You can add listeners to the ProgressPool to watch status changes of the progresses.- Specified by:
getProgressPool
in interfaceReportViewer
- Returns:
- Returns the ProgressPool of the viewer.
- Since:
- 7.0
-
getDefaultExportDirectory
public java.lang.String getDefaultExportDirectory()
Returns the default directory in that the Java viewer will save the exported files.- Returns:
- Default directory used to save the exported files
- Since:
- 7.0
-
setDefaultExportDirectory
public void setDefaultExportDirectory(java.lang.String directory)
Sets the default directory in that the Java viewer will save the exported files. The directory can be changed in the export dialog during export.- Parameters:
directory
- Default directory used to save the exported files- Since:
- 7.0
-
setCustomPromptEditor
public void setCustomPromptEditor(java.lang.String promptName, int valueType, CustomPromptEditor editor)
Registers the givenCustomPromptEditor
for prompts with the given name and value type, case-insensitive. Setting null as the editor unregisters any CustomPromptEditor for the given name and value type. An existingCustomPromptEditor
for the given name and value type will be replaced with the one set with this method. Depending on the value type of the prompt, your custom prompt editor should return one of the following types:- If a multiple prompt, a vector containing one or more single values.
- If one of the values is a range, it should be a RangePromptValue.
For single value prompts:
-
- String for value type PromptData#STRING
- Double for value type PromptData#NUMBER and PromptData#CURRENCY
- Boolean for value type PromptData#BOOLEAN
- Date for value type PromptData#DATE and PromptData#DATETIME
- Time for value type PromptData#TIME
- byte[] for value type PromptData#BINARY
- Specified by:
setCustomPromptEditor
in interfaceReportViewer
- Parameters:
promptName
- name of prompt to register custom prompt editor for, may not be nullvalueType
- value type of the promptName. Use the constants form the class PromptData for the types.editor
- custom prompt editor for prompting certain prompts with your own components.- Since:
- 9.0
-
setPrinterDefaultFormatHandling
public void setPrinterDefaultFormatHandling(int printerDefaultFormatHandling)
Sets the printer default format handling to use. Allowed values are:PRINTER_USE_DEFAULT_FORMAT_IF_SIMILAR
(default setting): If the printer default format is A4 while the report page format is Letter, or vice versa, map the paper format to the printer default setting. Note that this may cause your report to be slightly scaled so that it fits the page format of the client's printer.PRINTER_USE_REPORT_FORMAT
: Forces the report paper format setting to be chosen by default when printing. Note that this can cause parts of your report to be truncated if the printer is not able to print in the format in your report.
- Parameters:
printerDefaultFormatHandling
- printer default format handling- Throws:
java.lang.IllegalArgumentException
- if the given parameter is none of the constants allowed for this value.- Since:
- 8.2
- See Also:
getPrinterDefaultFormatHandling()
,PRINTER_USE_DEFAULT_FORMAT_IF_SIMILAR
,PRINTER_USE_REPORT_FORMAT
-
getPrinterDefaultFormatHandling
public int getPrinterDefaultFormatHandling()
Returns the printer default format handling. SeesetPrinterDefaultFormatHandling(int)
for further information.- Returns:
- printer default format handling
- Since:
- 8.2
- See Also:
setPrinterDefaultFormatHandling(int)
,PRINTER_USE_DEFAULT_FORMAT_IF_SIMILAR
,PRINTER_USE_REPORT_FORMAT
-
getDefaultSetting
public DefaultSetting getDefaultSetting(DefaultSetting.Key key)
Returns the setting of the property defined by the key, or null if no value is set.- Parameters:
key
- key specifying which setting to return- Returns:
- value of the setting, or null if the setting has no value set.
- Since:
- 9.0
-
setDefaultSetting
public void setDefaultSetting(DefaultSetting.Key key, DefaultSetting value)
Applies a setting defined by the given key-value pair.- Parameters:
key
- key specifying which setting to applyvalue
- value of the setting to apply- Since:
- 9.0
-
-