All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.samples.dips.print.PrintDip

java.lang.Object
   |
   +----com.ibm.beans.dip.SimpleDip
           |
           +----com.ibm.beans.samples.dips.print.PrintDip

public class PrintDip
extends SimpleDip
implements DipMethodCallListener, Serializable

This class provides basic printing support to any dippable AWT bean. The dip provides a small floating frame containing a Print button. When this button is pressed, a standard print dialog is presented. This dialog allows the user to select options, such as the target print queue, number of copies, and printer-driver-specific settings, such as paper-size, orientation, resolution, and so forth. The user may then submit the print job or cancel.

By using the customizer, the assembler or user can set properties such as whether to show the floating frame, where it should appear, its size, what text to display in the Print button, the title bar text, the print job title, and so forth.

This class essentially implements the dip model, while the PrintButtonFrame class implements its view.

See the Print Dip Usage Guide for information regarding how to set up and use the Print Dip.

See Also:
PrintButtonFrame, PrintDipBeanInfo, PrintDipCustomizer, PrintingSupport

Constructor Index

 o PrintDip()
Constructs a new Print Dip, using default values for each property.

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified whenever a change occurs to one of the properties of the dip.
 o createImplementation(Object)
Checks the object to which the dip is being applied to ensure that the object is a java.awt.Component.
 o createMethodCallListener(Object, String[])
Wires the dip to be notified when the addNotify and removeNotify methods of the dippable bean are called.
 o createPrintButtonFrame()
Creates the Print button dialog and initializes it.
 o destroyPrintButtonFrame()
Destroys the Print button dialog.
 o getDippableBean()
Gets the dippableBean property.
 o getPrintButtonFrame()
Gets the printButtonFrame property.
 o getPrintButtonFrameHeight()
Gets the printButtonFrameHeight property.
 o getPrintButtonFrameTitleText()
Gets the printButtonFrameTitleText property.
 o getPrintButtonFrameWidth()
Gets the printButtonFrameWidth property.
 o getPrintButtonFrameXPos()
Gets the printButtonFrameXPos property.
 o getPrintButtonFrameYPos()
Gets the printButtonFrameYPos property.
 o getPrintButtonText()
Gets the printButtonText property.
 o getPrintJobProperties()
Gets the printJobProperties property.
 o getPrintJobTitleText()
Gets the printJobTitleText property.
 o getShowPrintButtonFrame()
Gets the showPrintButtonFrame property.
 o handleMethodCall(MethodCallEvent)
Responds to method calls on the dippable bean.
 o includeInMorphedClass(String)
Determines if a method should be included in a morphed class.
 o lockPrintButtonFrame(boolean)
Locks the Print button dialog.
 o needsArguments()
Communicates to the dipping framework that this dip does not require the arguments for intercepted methods of the dippable bean.
 o printDippableBean()
Prints the dippable bean.
 o releaseImplementation()
Notifies the PrintDip that it is being removed from its dippable bean.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from the notification list.
 o setPrintButtonFrameHeight(short)
Sets the printButtonFrameHeight property.
 o setPrintButtonFrameTitleText(String)
Sets the printButtonFrameTitleText property.
 o setPrintButtonFrameWidth(short)
Sets the printButtonFrameWidth property.
 o setPrintButtonFrameXPos(short)
Sets the printButtonFrameXPos property.
 o setPrintButtonFrameYPos(short)
Sets the printButtonFrameYPos property.
 o setPrintButtonText(String)
Sets the printButtonText property.
 o setPrintJobProperties(Properties)
Sets the printJobProperties property.
 o setPrintJobTitleText(String)
Sets the printJobTitleText property.
 o setShowPrintButtonFrame(boolean)
Sets the showPrintButtonFrame property.
 o typeName()
Defines this dip to be related to printing.

Constructors

 o PrintDip
 public PrintDip()
Constructs a new Print Dip, using default values for each property. The owner of the dip is responsible for ensuring proper customization by invoking the customizer for this class.

Methods

 o typeName
 public String typeName()
Defines this dip to be related to printing.

Returns:
The type name of the dip.
Overrides:
typeName in class SimpleDip
 o includeInMorphedClass
 public boolean includeInMorphedClass(String methodName)
Determines if a method should be included in a morphed class. When the dip is applied to a class as a pre-dip during morphing, and the user elects to only override those methods in the dippable class that the pre-dips agrees to, this method is used to determine if a dip agrees to including a specific method.

The only methods of the dippable bean that the PrintDip needs to be wrapped are the addNotify and removeNotify methods.

Parameters:
methodName - Name of the method to be considered
Returns:
boolean indicating whether to wrap given method
Overrides:
includeInMorphedClass in class SimpleDip
 o createImplementation
 public Object createImplementation(Object obj) throws DipRejectAdditionException
Checks the object to which the dip is being applied to ensure that the object is a java.awt.Component. If it is not, then an exception is thrown, and the application of the dip is rejected.

Parameters:
obj - The bean being dipped.
Throws: DipRejectAdditionException
Thrown if obj is not a descendant of java.awt.Component.
Overrides:
createImplementation in class SimpleDip
 o releaseImplementation
 public void releaseImplementation()
Notifies the PrintDip that it is being removed from its dippable bean. The PrintDip uses this notification to take down the floating Print button dialog, by calling the destroyPrintButtonFrame method.

Overrides:
releaseImplementation in class SimpleDip
See Also:
destroyPrintButtonFrame, releaseImplementation
 o createMethodCallListener
 public DipMethodCallListener[] createMethodCallListener(Object impl,
                                                         String methods[]) throws DipRejectAdditionException
Wires the dip to be notified when the addNotify and removeNotify methods of the dippable bean are called. The dip hooks these methods in order to know when to show or hide the Print button dialog.

Parameters:
impl - This value should be null. There is no separate implementation.
methods - An array of method signatures from the dippable bean.
Returns:
Array of DipMethodCallListeners with PrintDip set to listen at the appropriate method indices.
Throws: DipRejectAdditionException
Thrown if dippable bean's addNotify and/or removeNotify methods not wrapped.
Overrides:
createMethodCallListener in class SimpleDip
See Also:
handleMethodCall, createMethodCallListener
 o needsArguments
 public boolean needsArguments()
Communicates to the dipping framework that this dip does not require the arguments for intercepted methods of the dippable bean. Returning false avoids the performance impact of parameter marshaling.

Returns:
Always false, indicating that this dip does not require the arguments from intercepted methods.
 o handleMethodCall
 public void handleMethodCall(MethodCallEvent methodDescription)
Responds to method calls on the dippable bean. Calls the createPrintButtonFrame method in response to the addNotify method of the dippable bean being called. Calls the destroyPrintButtonFrame method in response to the removeNotify method of the dippable bean being called.

Parameters:
methodDescription - Describes the method of the dippable bean that was called. This dip only intercepts the addNotify and removeNotify methods.
See Also:
createMethodCallListener, createPrintButtonFrame, destroyPrintButtonFrame
 o createPrintButtonFrame
 public void createPrintButtonFrame()
Creates the Print button dialog and initializes it. Whether the dialog is shown depends on the value of the showPrintButtonFrame property.

See Also:
getPrintButtonFrame, destroyPrintButtonFrame, PrintButtonFrame
 o destroyPrintButtonFrame
 public void destroyPrintButtonFrame()
Destroys the Print button dialog. Should be called when the dippable bean is being destroyed.

See Also:
getPrintButtonFrame, createPrintButtonFrame, PrintButtonFrame
 o lockPrintButtonFrame
 public void lockPrintButtonFrame(boolean lock)
Locks the Print button dialog. This keeps a series of updates to the properties related to the floating dialog from causing unnecessary flicker.

Parameters:
lock - Specifies whether the floating dialog
See Also:
PrintButtonFrame
 o printDippableBean
 public void printDippableBean()
Prints the dippable bean. This method is generally called from the action listener attached to the Print button in the PrintButtonFrame class.

Another scenario is that an assembly tool could wire this method to an event fired by another bean. In this scenario, the showPrintButtonFrame property is set to false, and printing of the dippable bean is initiated by an external event such as a button click or menu item selection from another bean in the aggregation comprising the application.

The implementation of the actual printing is deferred to the PrintingSupport utility class from the com.ibm.beans.widgets package, which is called from this method.

See Also:
PrintingSupport, actionPerformed
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified whenever a change occurs to one of the properties of the dip. Another bean would call this method if it wished to be notified of changes occuring within this dip. All of the properties of the Print Dip are bound, but none are constrained.

Parameters:
listener - The object to be notified of changes.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from the notification list.

Parameters:
listener - The object to be removed from the notification list.
 o getDippableBean
 public Object getDippableBean()
Gets the dippableBean property.

Returns:
The dippable bean to which this dip is applied.
 o getPrintButtonFrame
 public Frame getPrintButtonFrame()
Gets the printButtonFrame property.

Returns:
The java.awt.Frame containing the Print button. The returned frame can be cast up to an instance of the PrintButtonFrame class if needed. Note that, in general, the returned frame should not be modified directly, but rather by modifying the other properties exposed by this dip.
See Also:
createPrintButtonFrame, destroyPrintButtonFrame, PrintButtonFrame
 o getPrintJobProperties
 public Properties getPrintJobProperties()
Gets the printJobProperties property.

Returns:
The properties used for the next print job.
See Also:
setPrintJobProperties, printDippableBean
 o setPrintJobProperties
 public void setPrintJobProperties(Properties newPrintJobProperties)
Sets the printJobProperties property.

Parameters:
newPrintJobProperties - The properties used for the next print job.
See Also:
getPrintJobProperties, printDippableBean
 o getPrintButtonFrameTitleText
 public String getPrintButtonFrameTitleText()
Gets the printButtonFrameTitleText property.

Returns:
The title bar text of the Print button dialog.
See Also:
setPrintButtonFrameTitleText
 o setPrintButtonFrameTitleText
 public void setPrintButtonFrameTitleText(String newPrintButtonFrameTitleText)
Sets the printButtonFrameTitleText property.

Parameters:
newPrintButtonFrameTitleText - The title bar text of the Print button dialog.
See Also:
getPrintButtonFrameTitleText
 o getPrintButtonText
 public String getPrintButtonText()
Gets the printButtonText property.

Returns:
The label of the button inside the floating dialog.
See Also:
setPrintButtonText
 o setPrintButtonText
 public void setPrintButtonText(String newPrintButtonText)
Sets the printButtonText property.

Parameters:
newPrintButtonText - The label of the button inside the floating dialog.
See Also:
getPrintButtonText
 o getPrintJobTitleText
 public String getPrintJobTitleText()
Gets the printJobTitleText property.

Returns:
The title of the next print job.
See Also:
setPrintJobTitleText, printDippableBean
 o setPrintJobTitleText
 public void setPrintJobTitleText(String newPrintJobTitleText)
Sets the printJobTitleText property.

Parameters:
newPrintJobTitleText - The title of the next print job.
See Also:
getPrintJobTitleText, printDippableBean
 o getShowPrintButtonFrame
 public boolean getShowPrintButtonFrame()
Gets the showPrintButtonFrame property.

Returns:
true, if the Print button dialog is visible; false otherwise.
See Also:
setShowPrintButtonFrame
 o setShowPrintButtonFrame
 public void setShowPrintButtonFrame(boolean newShowPrintButtonFrame)
Sets the showPrintButtonFrame property.

Parameters:
newShowPrintButtonFrame - Sets whether the Print button dialog is visible.
See Also:
getShowPrintButtonFrame
 o getPrintButtonFrameXPos
 public short getPrintButtonFrameXPos()
Gets the printButtonFrameXPos property.

Returns:
The horizontal position of the Print button dialog.
See Also:
setPrintButtonFrameXPos
 o setPrintButtonFrameXPos
 public void setPrintButtonFrameXPos(short newPrintButtonFrameXPos)
Sets the printButtonFrameXPos property.

Parameters:
newPrintButtonFrameXPos - The horizontal position of the Print button dialog.
See Also:
getPrintButtonFrameXPos
 o getPrintButtonFrameYPos
 public short getPrintButtonFrameYPos()
Gets the printButtonFrameYPos property.

Returns:
The vertical position of the Print button dialog.
See Also:
setPrintButtonFrameYPos
 o setPrintButtonFrameYPos
 public void setPrintButtonFrameYPos(short newPrintButtonFrameYPos)
Sets the printButtonFrameYPos property.

Parameters:
newPrintButtonFrameYPos - The vertical position of the Print button dialog.
See Also:
getPrintButtonFrameYPos
 o getPrintButtonFrameWidth
 public short getPrintButtonFrameWidth()
Gets the printButtonFrameWidth property.

Returns:
The width of the Print button dialog.
See Also:
setPrintButtonFrameWidth
 o setPrintButtonFrameWidth
 public void setPrintButtonFrameWidth(short newPrintButtonFrameWidth)
Sets the printButtonFrameWidth property.

Parameters:
newPrintButtonFrameWidth - The width of the Print button dialog.
See Also:
getPrintButtonFrameWidth
 o getPrintButtonFrameHeight
 public short getPrintButtonFrameHeight()
Gets the printButtonFrameHeight property.

Returns:
The height of the Print button dialog.
See Also:
setPrintButtonFrameHeight
 o setPrintButtonFrameHeight
 public void setPrintButtonFrameHeight(short newPrintButtonFrameHeight)
Sets the printButtonFrameHeight property.

Parameters:
newPrintButtonFrameHeight - The height of the Print button dialog.
See Also:
getPrintButtonFrameHeight

All Packages  Class Hierarchy  This Package  Previous  Next  Index