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
-
PrintDip()
- Constructs a new Print Dip, using default values for each property.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a listener to be notified whenever a change occurs to one of the
properties of the dip.
-
createImplementation(Object)
- Checks the object to which the dip is being applied to ensure that
the object is a java.awt.Component.
-
createMethodCallListener(Object, String[])
- Wires the dip to be notified when the addNotify and removeNotify methods
of the dippable bean are called.
-
createPrintButtonFrame()
- Creates the Print button dialog and initializes it.
-
destroyPrintButtonFrame()
- Destroys the Print button dialog.
-
getDippableBean()
- Gets the dippableBean property.
-
getPrintButtonFrame()
- Gets the printButtonFrame property.
-
getPrintButtonFrameHeight()
- Gets the printButtonFrameHeight property.
-
getPrintButtonFrameTitleText()
- Gets the printButtonFrameTitleText property.
-
getPrintButtonFrameWidth()
- Gets the printButtonFrameWidth property.
-
getPrintButtonFrameXPos()
- Gets the printButtonFrameXPos property.
-
getPrintButtonFrameYPos()
- Gets the printButtonFrameYPos property.
-
getPrintButtonText()
- Gets the printButtonText property.
-
getPrintJobProperties()
- Gets the printJobProperties property.
-
getPrintJobTitleText()
- Gets the printJobTitleText property.
-
getShowPrintButtonFrame()
- Gets the showPrintButtonFrame property.
-
handleMethodCall(MethodCallEvent)
- Responds to method calls on the dippable bean.
-
includeInMorphedClass(String)
- Determines if a method should be included in a morphed class.
-
lockPrintButtonFrame(boolean)
- Locks the Print button dialog.
-
needsArguments()
- Communicates to the dipping framework that this dip does not require
the arguments for intercepted methods of the dippable bean.
-
printDippableBean()
- Prints the dippable bean.
-
releaseImplementation()
- Notifies the PrintDip that it is being removed from its dippable bean.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes a listener from the notification list.
-
setPrintButtonFrameHeight(short)
- Sets the printButtonFrameHeight property.
-
setPrintButtonFrameTitleText(String)
- Sets the printButtonFrameTitleText property.
-
setPrintButtonFrameWidth(short)
- Sets the printButtonFrameWidth property.
-
setPrintButtonFrameXPos(short)
- Sets the printButtonFrameXPos property.
-
setPrintButtonFrameYPos(short)
- Sets the printButtonFrameYPos property.
-
setPrintButtonText(String)
- Sets the printButtonText property.
-
setPrintJobProperties(Properties)
- Sets the printJobProperties property.
-
setPrintJobTitleText(String)
- Sets the printJobTitleText property.
-
setShowPrintButtonFrame(boolean)
- Sets the showPrintButtonFrame property.
-
typeName()
- Defines this dip to be related to printing.
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.
typeName
public String typeName()
- Defines this dip to be related to printing.
- Returns:
- The type name of the dip.
- Overrides:
- typeName in class SimpleDip
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
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
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
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
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.
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
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
destroyPrintButtonFrame
public void destroyPrintButtonFrame()
- Destroys the Print button dialog. Should be called when the dippable
bean is being destroyed.
- See Also:
- getPrintButtonFrame, createPrintButtonFrame, PrintButtonFrame
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
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
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.
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
- Removes a listener from the notification list.
- Parameters:
- listener - The object to be removed from the notification list.
getDippableBean
public Object getDippableBean()
- Gets the dippableBean property.
- Returns:
- The dippable bean to which this dip is applied.
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
getPrintJobProperties
public Properties getPrintJobProperties()
- Gets the printJobProperties property.
- Returns:
- The properties used for the next print job.
- See Also:
- setPrintJobProperties, printDippableBean
setPrintJobProperties
public void setPrintJobProperties(Properties newPrintJobProperties)
- Sets the printJobProperties property.
- Parameters:
- newPrintJobProperties - The properties used for the next print job.
- See Also:
- getPrintJobProperties, printDippableBean
getPrintButtonFrameTitleText
public String getPrintButtonFrameTitleText()
- Gets the printButtonFrameTitleText property.
- Returns:
- The title bar text of the Print button dialog.
- See Also:
- setPrintButtonFrameTitleText
setPrintButtonFrameTitleText
public void setPrintButtonFrameTitleText(String newPrintButtonFrameTitleText)
- Sets the printButtonFrameTitleText property.
- Parameters:
- newPrintButtonFrameTitleText - The title bar text of the Print button dialog.
- See Also:
- getPrintButtonFrameTitleText
getPrintButtonText
public String getPrintButtonText()
- Gets the printButtonText property.
- Returns:
- The label of the button inside the floating dialog.
- See Also:
- setPrintButtonText
setPrintButtonText
public void setPrintButtonText(String newPrintButtonText)
- Sets the printButtonText property.
- Parameters:
- newPrintButtonText - The label of the button inside the floating dialog.
- See Also:
- getPrintButtonText
getPrintJobTitleText
public String getPrintJobTitleText()
- Gets the printJobTitleText property.
- Returns:
- The title of the next print job.
- See Also:
- setPrintJobTitleText, printDippableBean
setPrintJobTitleText
public void setPrintJobTitleText(String newPrintJobTitleText)
- Sets the printJobTitleText property.
- Parameters:
- newPrintJobTitleText - The title of the next print job.
- See Also:
- getPrintJobTitleText, printDippableBean
getShowPrintButtonFrame
public boolean getShowPrintButtonFrame()
- Gets the showPrintButtonFrame property.
- Returns:
- true, if the Print button dialog is visible;
false otherwise.
- See Also:
- setShowPrintButtonFrame
setShowPrintButtonFrame
public void setShowPrintButtonFrame(boolean newShowPrintButtonFrame)
- Sets the showPrintButtonFrame property.
- Parameters:
- newShowPrintButtonFrame - Sets whether the Print button dialog is visible.
- See Also:
- getShowPrintButtonFrame
getPrintButtonFrameXPos
public short getPrintButtonFrameXPos()
- Gets the printButtonFrameXPos property.
- Returns:
- The horizontal position of the Print button dialog.
- See Also:
- setPrintButtonFrameXPos
setPrintButtonFrameXPos
public void setPrintButtonFrameXPos(short newPrintButtonFrameXPos)
- Sets the printButtonFrameXPos property.
- Parameters:
- newPrintButtonFrameXPos - The horizontal position of the Print button dialog.
- See Also:
- getPrintButtonFrameXPos
getPrintButtonFrameYPos
public short getPrintButtonFrameYPos()
- Gets the printButtonFrameYPos property.
- Returns:
- The vertical position of the Print button dialog.
- See Also:
- setPrintButtonFrameYPos
setPrintButtonFrameYPos
public void setPrintButtonFrameYPos(short newPrintButtonFrameYPos)
- Sets the printButtonFrameYPos property.
- Parameters:
- newPrintButtonFrameYPos - The vertical position of the Print button dialog.
- See Also:
- getPrintButtonFrameYPos
getPrintButtonFrameWidth
public short getPrintButtonFrameWidth()
- Gets the printButtonFrameWidth property.
- Returns:
- The width of the Print button dialog.
- See Also:
- setPrintButtonFrameWidth
setPrintButtonFrameWidth
public void setPrintButtonFrameWidth(short newPrintButtonFrameWidth)
- Sets the printButtonFrameWidth property.
- Parameters:
- newPrintButtonFrameWidth - The width of the Print button dialog.
- See Also:
- getPrintButtonFrameWidth
getPrintButtonFrameHeight
public short getPrintButtonFrameHeight()
- Gets the printButtonFrameHeight property.
- Returns:
- The height of the Print button dialog.
- See Also:
- setPrintButtonFrameHeight
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