org.jfree.report.modules.gui.pdf
Class PDFSaveDialog

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byjavax.swing.JDialog
                      extended byorg.jfree.report.modules.gui.pdf.PDFSaveDialog
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class PDFSaveDialog
extends javax.swing.JDialog

A dialog that is used to perform the printing of a report into a PDF file. It is primarily used to edit the properties of the PDFOutputTarget before the target is used to print the report.

The main method to call the dialog is PDFSaveDialog.savePDF(). Given a report and a pageformat, the dialog is shown and if the user approved the dialog, the pdf is saved using the settings made in the dialog.

Author:
Thomas Morgner
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String BASE_RESOURCE_CLASS
          The base resource class.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PDFSaveDialog()
          Creates a new PDF save dialog.
PDFSaveDialog(java.awt.Dialog owner)
          Creates a new PDF save dialog.
PDFSaveDialog(java.awt.Frame owner)
          Creates a new PDF save dialog.
 
Method Summary
 void clear()
          Clears all selections, input fields and set the selected encryption level to none.
protected  javax.swing.Action getActionCancel()
          Returns a single instance of the dialog cancel action.
 java.lang.String getAuthor()
          Gets the author of this report.
 java.util.Properties getDialogContents()
          Returns the user input of this dialog as properties collection.
 java.lang.String getEncoding()
          Returns the selected encoding.
 java.lang.String getEncryptionValue()
          Queries the currently selected encryption.
 java.lang.String getFilename()
          Defines the filename of the pdf file.
 java.lang.String getOwnerPassword()
          Returns the owner password for the pdf file.
 java.lang.String getPDFTitle()
          Defines the title of the pdf file.
protected  java.util.ResourceBundle getResources()
          Retrieves the resources for this PreviewFrame.
 java.lang.String getUserPassword()
          returns the defined user password for the pdf file.
 void initFromConfiguration(ReportConfiguration config)
          Initialises the PDF save dialog from the settings in the report configuration.
 boolean isAllowAssembly()
          Gets the AllowAssembly permission for the generated PDF-file.
 boolean isAllowCopy()
          Defines whether the contents of the file are allowed to be copied.
 boolean isAllowDegradedPrinting()
          Gets the AllowDegradedPrinting permission for the generated PDF-file.
 boolean isAllowFillIn()
          Defines whether the contents of form fields may be changed by the user.
 boolean isAllowModifyAnnotations()
          Defines whether the user is allowed to add or modify annotations in this file.
 boolean isAllowModifyContents()
          Defines whether the user is allowed to modify the contents of this file.
 boolean isAllowPrinting()
          Defines whether the user is allowed to print the file.
 boolean isAllowScreenreaders()
          Defines whether the generated pdf may accessed using screenreaders.
 boolean isConfirmed()
          Gets the confirmation state of the dialog.
static void main(java.lang.String[] args)
          For debugging.
 boolean performQueryForExport(JFreeReport report)
          Opens the dialog to query all necessary input from the user.
protected  void performSelectFile()
          selects a file to use as target for the report processing.
 boolean performValidate()
          Validates the contents of the dialogs input fields.
 void setAllowAssembly(boolean allowAssembly)
          Defines whether the generated pdf may be reassembled.
 void setAllowCopy(boolean allowCopy)
          Defines whether the contents of the file are allowed to be copied.
 void setAllowFillIn(boolean allowFillIn)
          Defines whether the contents of form fields may be changed by the user.
 void setAllowModifyAnnotations(boolean allowModifyAnnotations)
          Defines whether the user is allowed to add or modify annotations in this file.
 void setAllowModifyContents(boolean allowModifyContents)
          Defines whether the user is allowed to modify the contents of this file.
 void setAllowScreenreaders(boolean allowScreenreaders)
          Defines whether the generated pdf may accessed using screenreaders.
 void setAuthor(java.lang.String author)
          Defines the Author of the report.
protected  void setConfirmed(boolean confirmed)
          Defines whether this dialog has been finished using the 'OK' or the 'Cancel' option.
 void setDialogContents(java.util.Properties p)
          Restores the user input from a properties collection.
 void setEncoding(java.lang.String encoding)
          Sets the encoding.
 void setEncryptionValue(java.lang.String b)
          Defines the currently selected encryption.
 void setFilename(java.lang.String filename)
          Defines the filename of the pdf file.
 void setOwnerPassword(java.lang.String ownerPassword)
          Defines the owner password for the pdf file.
 void setPDFTitle(java.lang.String title)
          Defines the title of the pdf file.
 void setPrintLevel(boolean allowPrinting, boolean degraded)
          Defines whether the user is allowed to print the file.
 void setUserPassword(java.lang.String userPassword)
          Defines the user password for the pdf file.
 void storeToConfiguration(ReportConfiguration config)
          Stores the input from the dialog into the report configuration of the report.
protected  void updateSecurityPanelEnabled()
          Updates the security panel state.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_RESOURCE_CLASS

public static final java.lang.String BASE_RESOURCE_CLASS
The base resource class.

Constructor Detail

PDFSaveDialog

public PDFSaveDialog(java.awt.Frame owner)
Creates a new PDF save dialog.

Parameters:
owner - the dialog owner.

PDFSaveDialog

public PDFSaveDialog(java.awt.Dialog owner)
Creates a new PDF save dialog.

Parameters:
owner - the dialog owner.

PDFSaveDialog

public PDFSaveDialog()
Creates a new PDF save dialog. The created dialog is modal.

Method Detail

updateSecurityPanelEnabled

protected void updateSecurityPanelEnabled()
Updates the security panel state. If no encryption is selected, all security setting components will be disabled.


getResources

protected java.util.ResourceBundle getResources()
Retrieves the resources for this PreviewFrame. If the resources are not initialized, they get loaded on the first call to this method.

Returns:
this frames ResourceBundle.

getActionCancel

protected javax.swing.Action getActionCancel()
Returns a single instance of the dialog cancel action.

Returns:
the action.

getUserPassword

public java.lang.String getUserPassword()
returns the defined user password for the pdf file. The user password limits read-only access to the pdf in the PDF-Viewer. The reader/user has to enter the password when opening the file.

Returns:
the defined password. The password can be null.

setUserPassword

public void setUserPassword(java.lang.String userPassword)
Defines the user password for the pdf file. The user password limits read-only access to the pdf in the PDF-Viewer. The reader/user has to enter the password when opening the file.

Parameters:
userPassword - the defined password. The password can be null.

getOwnerPassword

public java.lang.String getOwnerPassword()
Returns the owner password for the pdf file. The owner password limits writing access to the pdf in the PDF-Editor. The user has to enter the password when opening the file to enable editing functionality or to modify the file.

Returns:
the defined password. The password can be null.

setOwnerPassword

public void setOwnerPassword(java.lang.String ownerPassword)
Defines the owner password for the pdf file. The owner password limits writing access to the pdf in the PDF-Editor. The user has to enter the password when opening the file to enable editing functionality or to modify the file.

Parameters:
ownerPassword - the defined password. The password can be null.

getEncoding

public java.lang.String getEncoding()
Returns the selected encoding.

Returns:
The encoding.

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding.

Parameters:
encoding - the encoding (name).

isAllowDegradedPrinting

public boolean isAllowDegradedPrinting()
Gets the AllowDegradedPrinting permission for the generated PDF-file.

Returns:
true if a low quality printing is allowed, false otherwise.

isAllowAssembly

public boolean isAllowAssembly()
Gets the AllowAssembly permission for the generated PDF-file.

Returns:
true, if the generated pdf may be reassembled using an pdf editor.

setAllowAssembly

public void setAllowAssembly(boolean allowAssembly)
Defines whether the generated pdf may be reassembled.

Parameters:
allowAssembly - the flag.

isAllowScreenreaders

public boolean isAllowScreenreaders()
Defines whether the generated pdf may accessed using screenreaders. Screenreaders are used to make pdf files accessible for disabled people.

Returns:
true, if screenreaders are allowed for accessing this file

setAllowScreenreaders

public void setAllowScreenreaders(boolean allowScreenreaders)
Defines whether the generated pdf may accessed using screenreaders. Screenreaders are used to make pdf files accessible for disabled people.

Parameters:
allowScreenreaders - a flag containing true, if screenreaders are allowed to access the content of this file, false otherwise

isAllowFillIn

public boolean isAllowFillIn()
Defines whether the contents of form fields may be changed by the user.

Returns:
true, if the user may change the contents of formulars.

setAllowFillIn

public void setAllowFillIn(boolean allowFillIn)
Defines whether the contents of form fields may be changed by the user.

Parameters:
allowFillIn - set to true to allow the change/filling of form fields

isAllowCopy

public boolean isAllowCopy()
Defines whether the contents of the file are allowed to be copied.

Returns:
true, if the user is allowed to copy the contents of the file.

setAllowCopy

public void setAllowCopy(boolean allowCopy)
Defines whether the contents of the file are allowed to be copied.

Parameters:
allowCopy - set to true, if the user is allowed to copy the contents of the file.

isAllowModifyAnnotations

public boolean isAllowModifyAnnotations()
Defines whether the user is allowed to add or modify annotations in this file.

Returns:
true, if this files annotations can be modified, false otherwise

setAllowModifyAnnotations

public void setAllowModifyAnnotations(boolean allowModifyAnnotations)
Defines whether the user is allowed to add or modify annotations in this file.

Parameters:
allowModifyAnnotations - the flag.

isAllowModifyContents

public boolean isAllowModifyContents()
Defines whether the user is allowed to modify the contents of this file.

Returns:
true, if this files content can be modified, false otherwise

setAllowModifyContents

public void setAllowModifyContents(boolean allowModifyContents)
Defines whether the user is allowed to modify the contents of this file.

Parameters:
allowModifyContents - set to true, if this files content can be modified, false otherwise

isAllowPrinting

public boolean isAllowPrinting()
Defines whether the user is allowed to print the file. If this right is granted, the user is also able to print a degraded version of the file, regardless of the allowDegradedPrinting property

Returns:
true, if this file can be printed, false otherwise

setPrintLevel

public void setPrintLevel(boolean allowPrinting,
                          boolean degraded)
Defines whether the user is allowed to print the file. If this right is granted, the user is also able to print a degraded version of the file, regardless of the allowDegradedPrinting
Parameters:
allowPrinting - set to true, if this file can be printed, false otherwise.
degraded - set to true, to allow degraded printing, and false otherwise.

getFilename

public java.lang.String getFilename()
Defines the filename of the pdf file.

Returns:
the name of the file where to save the pdf file.

setFilename

public void setFilename(java.lang.String filename)
Defines the filename of the pdf file.

Parameters:
filename - the filename of the pdf file

getPDFTitle

public java.lang.String getPDFTitle()
Defines the title of the pdf file.

Returns:
the title

setPDFTitle

public void setPDFTitle(java.lang.String title)
Defines the title of the pdf file.

Parameters:
title - the title

getAuthor

public java.lang.String getAuthor()
Gets the author of this report.

Returns:
the name of the author of this report.

setAuthor

public void setAuthor(java.lang.String author)
Defines the Author of the report. Any freeform text is valid. This defaults to the value of the systemProperty "user.name".

Parameters:
author - the name of the author.

getEncryptionValue

public java.lang.String getEncryptionValue()
Queries the currently selected encryption. If an encryption is selected this method returns either Boolean.TRUE or Boolean.FALSE, when no encryption is set, null is returned. If no encryption is set, the security properties have no defined state.

Returns:
the selection state for the encryption. If no encryption is set, this method returns null, if 40-bit encryption is set, the method returns Boolean.FALSE and on 128-Bit-encryption, Boolean.TRUE is returned.

setEncryptionValue

public void setEncryptionValue(java.lang.String b)
Defines the currently selected encryption.

Parameters:
b - the new encryption state, one of null, Boolean.TRUE or Boolean.FALSE

isConfirmed

public boolean isConfirmed()
Gets the confirmation state of the dialog. A confirmed dialog has no invalid settings and the user confirmed any resource conflicts.

Returns:
true, if the dialog has been confirmed and the pdf should be saved, false otherwise.

setConfirmed

protected void setConfirmed(boolean confirmed)
Defines whether this dialog has been finished using the 'OK' or the 'Cancel' option.

Parameters:
confirmed - set to true, if OK was pressed, false otherwise

clear

public void clear()
Clears all selections, input fields and set the selected encryption level to none.


getDialogContents

public java.util.Properties getDialogContents()
Returns the user input of this dialog as properties collection.

Returns:
the user input.

setDialogContents

public void setDialogContents(java.util.Properties p)
Restores the user input from a properties collection.

Parameters:
p - the user input.

performSelectFile

protected void performSelectFile()
selects a file to use as target for the report processing.


performValidate

public boolean performValidate()
Validates the contents of the dialogs input fields. If the selected file exists, it is also checked for validity.

Returns:
true, if the input is valid, false otherwise

performQueryForExport

public boolean performQueryForExport(JFreeReport report)
Opens the dialog to query all necessary input from the user. This will not start the processing, as this is done elsewhere.

Parameters:
report - the report that should be processed.
Returns:
true, if the processing should continue, false otherwise.

storeToConfiguration

public void storeToConfiguration(ReportConfiguration config)
Stores the input from the dialog into the report configuration of the report.

Parameters:
config - the report configuration that should receive the new settings.

initFromConfiguration

public void initFromConfiguration(ReportConfiguration config)
Initialises the PDF save dialog from the settings in the report configuration.

Parameters:
config - the report configuration.

main

public static void main(java.lang.String[] args)
For debugging.

Parameters:
args - ignored.