org.salespointframework.core
Class JDisplayDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.salespointframework.core.JDisplayDialog
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, Display, FormSheetContainer

public class JDisplayDialog
extends javax.swing.JDialog
implements Display, FormSheetContainer

A JDialog that can display Form- and MenuSheets.

You can use this frame to pop up messages and dialogs in extra windows, while maintaining consistency with the rest of the GUI by using the familiar FormSheet look'n'feel.

The frame will display one FormSheet, and, by default, will close when the FormSheet is closed. Closing the frame using the systems menu or any other OS dependent gesture will result in a call to FormSheet.cancel() on the FormSheet.

Also, the frame may display a MenuSheet. It can therefore be used wherever a Display can be used.

Attention: This class is not meant to be serialized.

Since:
v2.0
Version:
2.0 25/05/1999
Author:
Steffen Zschaler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.event.EventListenerList m_ellListeners
          The list of listeners.
private  FormSheet m_fsCurrent
          The current FormSheet.
private  javax.swing.JComponent m_jcmpComponent
          The currently displaying component.
private  javax.swing.JPanel m_jpButtonBar
          The currently displaying button bar panel.
private  MenuSheet m_msCurrent
          The current MenuSheet.
private  java.lang.Object m_oWaiter
          Object used to block setFormSheet(org.salespointframework.core.FormSheet) when the FormSheet demands it.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
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
JDisplayDialog()
          Create a new JDisplayDialog.
JDisplayDialog(java.awt.Window jfOwner)
          Create a new JDisplayDialog with the given owner.
 
Method Summary
 void addFormSheetListener(FormSheetListener fsl)
          Add a listener to receive notification on the JDisplayDialog's FormSheet.
 void closeFormSheet()
          Close the current FormSheet.
 void closeFormSheet(FormSheet fs)
          Close a FormSheet.
 void dispose()
          In addition to disposing of the peer resources, remove the FormSheet and the MenuSheet.
protected  void fireFormSheetRemoved(FormSheet fs, boolean fExplicit)
          Fire an event to all FormSheetListeners indicating that a FormSheet was removed from this display.
protected  void fireFormSheetSet(FormSheet fs)
          Fire an event to all FormSheetListeners indicating that a FormSheet was set on this display.
protected  void formSheetClosed()
          Hook method called when the FormSheet was closed.
 FormSheet getFormSheet()
          Return the FormSheet that is currently attached to the display.
 MenuSheet getMenuSheet()
          Return the MenuSheet that is currently attached to the display.
private  java.lang.Object getWaiter()
          Return the object used to block setFormSheet(org.salespointframework.core.FormSheet) when the FormSheet demands it.
 boolean isUseableDisplay()
          Return true to indicate this is a useable display.
 void load(java.io.ObjectInputStream ois)
          Restores the display from a stream.
static void main(java.lang.String[] args)
          JDisplayDialog test suite.
 void onFormSheetButtonAdded(FormSheet fs, FormSheet.FormButton fb)
          Notification event informing that a button was added to the FormSheet's button bar.
 void onFormSheetButtonbarPositionChanged(FormSheet fs, int position)
          Notification event informing about a change of the Buttonbar's position
 void onFormSheetButtonRemoved(FormSheet fs, FormSheet.FormButton fb)
          Notification event informing that a button was removed from the FormSheet's button bar.
 void onFormSheetButtonsCleared(FormSheet fs)
          Notification event informing that all buttons were removed from a FormSheet's button bar.
 void onFormSheetCaptionChanged(FormSheet fs, java.lang.String sNewCaption)
          Notification event informing about a change of a FormSheet's caption.
 void onFormSheetComponentChanged(FormSheet fs, javax.swing.JComponent jcmpNew)
          Notification event informing about a change of a FormSheet's component.
 void popUpFormSheet(FormSheet fs)
          Open a fresh JDisplayDialog and display the FormSheet in it.
 void popUpFormSheet(FormSheet fsParent, FormSheet fsToSet)
          Opens a fresh JDisplayDialog which is assigned to a FormSheet and displays another FormSheet in it.
 void removeFormSheetListener(FormSheetListener fsl)
          Remove a listener to receive notification on the JDisplayDialog's FormSheet.
 void save(java.io.ObjectOutputStream oos)
          Writes the display to a stream.
 void setButtonbarPosition(int position)
          Called to update the Buttonbar position
 void setFormSheet(FormSheet fs)
          Set and display a FormSheet.
 void setMenuSheet(MenuSheet ms)
          Remove any old MenuSheet and display the new one.
 void setVisible(boolean value)
           
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.salespointframework.core.Display
getBounds, setBounds, toFront
 

Field Detail

m_oWaiter

private transient java.lang.Object m_oWaiter
Object used to block setFormSheet(org.salespointframework.core.FormSheet) when the FormSheet demands it.


m_jcmpComponent

private transient javax.swing.JComponent m_jcmpComponent
The currently displaying component.


m_jpButtonBar

private transient javax.swing.JPanel m_jpButtonBar
The currently displaying button bar panel.


m_fsCurrent

private transient FormSheet m_fsCurrent
The current FormSheet.


m_msCurrent

private transient MenuSheet m_msCurrent
The current MenuSheet.


m_ellListeners

protected transient javax.swing.event.EventListenerList m_ellListeners
The list of listeners.

Constructor Detail

JDisplayDialog

public JDisplayDialog()
Create a new JDisplayDialog.


JDisplayDialog

public JDisplayDialog(java.awt.Window jfOwner)
Create a new JDisplayDialog with the given owner.

Parameters:
jfOwner - the JFrame owning the display dialog.
Method Detail

getWaiter

private java.lang.Object getWaiter()
Return the object used to block setFormSheet(org.salespointframework.core.FormSheet) when the FormSheet demands it.


setVisible

public void setVisible(boolean value)
Overrides:
setVisible in class java.awt.Dialog

closeFormSheet

public void closeFormSheet(FormSheet fs)
Close a FormSheet.

If a FormSheet is closed, by default, the JDisplayDialog containing it is also closed. You can, however, alter this behavior by overriding formSheetClosed().

Specified by:
closeFormSheet in interface FormSheetContainer
Parameters:
fs - the FormSheet to be closed.

formSheetClosed

protected void formSheetClosed()
Hook method called when the FormSheet was closed.


dispose

public void dispose()
In addition to disposing of the peer resources, remove the FormSheet and the MenuSheet.

Overrides:
dispose in class java.awt.Window

onFormSheetCaptionChanged

public void onFormSheetCaptionChanged(FormSheet fs,
                                      java.lang.String sNewCaption)
Notification event informing about a change of a FormSheet's caption.

Specified by:
onFormSheetCaptionChanged in interface FormSheetContainer
Parameters:
fs - the FormSheet whose caption changed.
sNewCaption - the new caption of the FormSheet.

onFormSheetComponentChanged

public void onFormSheetComponentChanged(FormSheet fs,
                                        javax.swing.JComponent jcmpNew)
Notification event informing about a change of a FormSheet's component.

Specified by:
onFormSheetComponentChanged in interface FormSheetContainer
Parameters:
fs - the FormSheet whose component changed.
jcmpNew - the new component of the FormSheet.

onFormSheetButtonAdded

public void onFormSheetButtonAdded(FormSheet fs,
                                   FormSheet.FormButton fb)
Notification event informing that a button was added to the FormSheet's button bar.

Specified by:
onFormSheetButtonAdded in interface FormSheetContainer
Parameters:
fs - the FormSheet whose button bar changed.
fb - the button that was added to the FormSheet.

onFormSheetButtonRemoved

public void onFormSheetButtonRemoved(FormSheet fs,
                                     FormSheet.FormButton fb)
Notification event informing that a button was removed from the FormSheet's button bar.

Specified by:
onFormSheetButtonRemoved in interface FormSheetContainer
Parameters:
fs - the FormSheet whose button bar changed.
fb - the button that was removed from the FormSheet.

onFormSheetButtonsCleared

public void onFormSheetButtonsCleared(FormSheet fs)
Notification event informing that all buttons were removed from a FormSheet's button bar.

Specified by:
onFormSheetButtonsCleared in interface FormSheetContainer
Parameters:
fs - the FormSheet whose button bar was cleared.

setFormSheet

public void setFormSheet(FormSheet fs)
                  throws java.lang.InterruptedException
Set and display a FormSheet.

If fs.waitResponse() returns true, setFormSheet() blocks, until the FormSheet is closed by a matching call to closeFormSheet(org.salespointframework.core.FormSheet).

Specified by:
setFormSheet in interface Display
Parameters:
fs - the FormSheet to be displayed.
Throws:
java.lang.InterruptedException - if an interrupt occurs while waiting for the FormSheet to be closed.

getFormSheet

public FormSheet getFormSheet()
Return the FormSheet that is currently attached to the display.

Specified by:
getFormSheet in interface Display

closeFormSheet

public void closeFormSheet()
Close the current FormSheet.

Specified by:
closeFormSheet in interface Display

popUpFormSheet

public void popUpFormSheet(FormSheet fs)
                    throws java.lang.InterruptedException
Open a fresh JDisplayDialog and display the FormSheet in it.

Specified by:
popUpFormSheet in interface Display
Parameters:
fs - the FormSheet to be displayed.
Throws:
java.lang.InterruptedException - if an interrupt occured while waiting for the FormSheet to be closed.

popUpFormSheet

public void popUpFormSheet(FormSheet fsParent,
                           FormSheet fsToSet)
                    throws java.lang.InterruptedException
Opens a fresh JDisplayDialog which is assigned to a FormSheet and displays another FormSheet in it.

Parameters:
fsParent - the FormSheet to which the JDisplayDialog is assigned.
fsToSet - the FormSheet which is displayed by the JDisplayDialog.
Throws:
java.lang.InterruptedException - if an interrupt occured while waiting for the FormSheet to be closed.

setMenuSheet

public void setMenuSheet(MenuSheet ms)
Remove any old MenuSheet and display the new one.

Specified by:
setMenuSheet in interface Display
Parameters:
ms - the MenuSheet to be displayed.

getMenuSheet

public MenuSheet getMenuSheet()
Return the MenuSheet that is currently attached to the display.

Specified by:
getMenuSheet in interface Display

isUseableDisplay

public boolean isUseableDisplay()
Return true to indicate this is a useable display.

Specified by:
isUseableDisplay in interface Display

addFormSheetListener

public void addFormSheetListener(FormSheetListener fsl)
Add a listener to receive notification on the JDisplayDialog's FormSheet.

Specified by:
addFormSheetListener in interface Display
Parameters:
fsl - the FormSheetListener to be registered.

removeFormSheetListener

public void removeFormSheetListener(FormSheetListener fsl)
Remove a listener to receive notification on the JDisplayDialog's FormSheet.

Specified by:
removeFormSheetListener in interface Display
Parameters:
fsl - the FormSheetListener to be unregistered.

fireFormSheetSet

protected void fireFormSheetSet(FormSheet fs)
Fire an event to all FormSheetListeners indicating that a FormSheet was set on this display. As FormSheet setting is always explicit, no extra parameter is necessary.

Parameters:
fs - the FormSheet that was set

fireFormSheetRemoved

protected void fireFormSheetRemoved(FormSheet fs,
                                    boolean fExplicit)
Fire an event to all FormSheetListeners indicating that a FormSheet was removed from this display.

Parameters:
fs - the FormSheet that was set
fExplicit - true, if the FormSheet was closed explicitly, i.e. either by a call to one of the closeFormSheet methods or by setFormSheet (null).
See Also:
closeFormSheet(), closeFormSheet(FormSheet), setFormSheet(org.salespointframework.core.FormSheet)

main

public static void main(java.lang.String[] args)
JDisplayDialog test suite.


load

public void load(java.io.ObjectInputStream ois)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Description copied from interface: Display
Restores the display from a stream.

As displays should not be serialized when making the Shop persistent, they cannot be normally deserialized. Instead they should individually read the attributes they previously saved. The attributes must be read in the same order they have previously been writtn.

Attention: The current class that has been written by the save() method must not be read here!

Example:
 FormSheet fsCurrent = (FormSheet)ois.readObject();
 MenuSheet msCurrent = (MenuSheet)ois.readObject();
 ...
 

Specified by:
load in interface Display
Parameters:
ois - the stream to read attributes from
Throws:
java.io.IOException
java.lang.ClassNotFoundException

save

public void save(java.io.ObjectOutputStream oos)
          throws java.io.IOException
Description copied from interface: Display
Writes the display to a stream.

Displays should not be serialized as a whole. Instead use this method to individually write all attributes of the display to the stream.

Attention: The very first attribute to be written must be the display's class!

Example:
 oos.writeObject(getClass());
 oos.writeObject(fsCurrent); //current FormSheet
 oos.writeObject(msCurrent); //current MenuSheet
 ...
 

Specified by:
save in interface Display
Parameters:
oos - the stream to write attributes to
Throws:
java.io.IOException

setButtonbarPosition

public void setButtonbarPosition(int position)
Description copied from interface: Display
Called to update the Buttonbar position

Specified by:
setButtonbarPosition in interface Display

onFormSheetButtonbarPositionChanged

public void onFormSheetButtonbarPositionChanged(FormSheet fs,
                                                int position)
Description copied from interface: FormSheetContainer
Notification event informing about a change of the Buttonbar's position

Specified by:
onFormSheetButtonbarPositionChanged in interface FormSheetContainer
Parameters:
fs - the Formsheet whose Buttonbar position changed
position - the new buttonbar position