SalesPoint Framework v3.0

sale
Class MenuSheet

java.lang.Object
  |
  +--sale.MenuSheetObject
        |
        +--sale.MenuSheet

public class MenuSheet
extends MenuSheetObject

A MenuSheet consisting of MenuSheetObjects.

MenuSheets represent menus, abstracting from the form they are being displayed in. A MenuSheet could be displayed as a JMenuBar as well as a JMenu or JPopUpMenu. Independently of this it will always behave in the same way from the point of view of the applicion developer.

Hooks:
Define a MenuSheet , Define Shop MenuSheet
Since:
v1.0
Version:
2.0 20/05/1999
Author:
Steffen Zschaler
See Also:
Serialized Form

Field Summary
static String HELP_MENU_TAG
          A tag that will identify the help menu, should this MenuSheet be displayed as a JMenuBar.
protected  ImageIcon[] m_aiImages
          The Images associated with the icons of this MenuSheet( [0]:DefaultImage, [1]:PressedImage, [2]:DisabledImage, [3]:PressedDiabledImage ).
protected  char m_cMnemonic
          The Mnemonic of this MenuSheet.
protected  JMenuBar m_jmbBarPeer
          The JMenuBar peer, if any.
protected  JMenu m_jmPeer
          The JMenu peer, if any.
protected  LinkedList m_lmsoItems
          The items of this MenuSheet.
protected  MenuSheet m_msMerged
          The MenuSheet that has been merged into this one, if any.
protected  MenuSheet m_msMergeParent
          The MenuSheet into which this MenuSheet was merged, if any.
protected  int m_nMergedAt
          The peer index at which the merged menu was inserted.
protected  String m_sMergedBefore
          The tag before which the merged menu was inserted.
protected  String m_sToolTip
          The ToolTip of this MenuSheet.
 
Fields inherited from class sale.MenuSheetObject
m_msParent, m_pAttached, m_spAttached
 
Constructor Summary
MenuSheet(String sCaption)
          Create a new MenuSheet with a default tag.
MenuSheet(String sCaption, String sTag)
          Create a new MenuSheet.
MenuSheet(String sCaption, String sTag, char cMnemonic)
          Create a new MenuSheet.
 
Method Summary
 void add(MenuSheetObject mso)
          Add a MenuSheetObject to the end of this MenuSheet.
 SaleProcess attach(SaleProcess p)
          Attach a SaleProcess to this MenuSheet.
 SalesPoint attach(SalesPoint sp)
          Attach a SalesPoint to this MenuSheet.
 ImageIcon getDefaultIcon()
          Get the default icon of this MenuSheet.
 ImageIcon getDisabledIcon()
          Get the disabled item of this MenuSheet.
 ImageIcon getDisabledSelectedIcon()
          Get the disabled selected item of this MenuSheet.
 JMenuBar getMenuBar()
          Return the JMenuBar peer.
 JMenu getMenuPeer()
          For MenuSheets there is no difference between JMenuItem and JMenu peer, they are both JMenus.
 char getMnemonic()
          Get the Mnemonic of this MenuSheet.
 JMenuItem getPeer()
          The JMenuItem peer of a MenuSheet is, of course, a JMenu.
protected  Object getPeerLock()
          Return the monitor used to synchronized access to the peers.
 ImageIcon getSelectedIcon()
          Get the selected icon of this MenuSheet.
 MenuSheetObject getTaggedItem(String sTag, boolean fTopLevelOnly)
          Get a MenuSheetObject by its tag.
 String getToolTipText()
          Get the ToolTip of this MenuSheet.
 Iterator iterator()
          Return a fail-fast, readonly iterator of the items in this MenuSheet.
 JMenuBar mergePeers(MenuSheet msToMerge, String sBeforeTag)
          Merge the peers of two MenuSheets.
 MenuSheetObject remove(MenuSheetObject msoRemove)
          Remove a MenuSheetObject from the MenuSheet.
 MenuSheetObject remove(String sTag)
          Remove a tagged top level item from the MenuSheet.
 void setCaption(String sCaption)
          Set the caption of this MenuSheet.
 void setDefaultIcon(ImageIcon iiImageIcon)
          Set the default icon of this MenuSheet.
 void setDisabledIcon(ImageIcon iiImageIcon)
          Set the disabled icon of this MenuSheet.
 void setDisabledSelectedIcon(ImageIcon iiImageIcon)
          Set the disabled selected icon of this MenuSheet.
 void setMnemonic(char cMnemonic)
          Set the mnemonic of this MenuSheet.
 void setSelectedIcon(ImageIcon iiImageIcon)
          Set the selected icon of this MenuSheet.
 void setToolTipText(String s)
          Set the ToolTip of this MenuSheet.
 void setVisible(boolean fVisible)
          Mark this MenuSheet, all its descendants and merged peer MenuSheets visible or invisible.
 
Methods inherited from class sale.MenuSheetObject
detachSaleProcess, detachSalesPoint, equals, getCaption, getParent, getTag, getTaggedItem, isSeparator, isVisible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_jmPeer

protected transient JMenu m_jmPeer
The JMenu peer, if any.

m_jmbBarPeer

protected transient JMenuBar m_jmbBarPeer
The JMenuBar peer, if any.

m_msMerged

protected MenuSheet m_msMerged
The MenuSheet that has been merged into this one, if any.

m_sMergedBefore

protected String m_sMergedBefore
The tag before which the merged menu was inserted.

m_nMergedAt

protected int m_nMergedAt
The peer index at which the merged menu was inserted.

m_msMergeParent

protected MenuSheet m_msMergeParent
The MenuSheet into which this MenuSheet was merged, if any.

m_lmsoItems

protected LinkedList m_lmsoItems
The items of this MenuSheet.

m_aiImages

protected ImageIcon[] m_aiImages
The Images associated with the icons of this MenuSheet( [0]:DefaultImage, [1]:PressedImage, [2]:DisabledImage, [3]:PressedDiabledImage ).

m_cMnemonic

protected char m_cMnemonic
The Mnemonic of this MenuSheet.

m_sToolTip

protected String m_sToolTip
The ToolTip of this MenuSheet.

HELP_MENU_TAG

public static final String HELP_MENU_TAG
A tag that will identify the help menu, should this MenuSheet be displayed as a JMenuBar.
Constructor Detail

MenuSheet

public MenuSheet(String sCaption,
                 String sTag,
                 char cMnemonic)
Create a new MenuSheet.
Parameters:
sCaption - the caption of the new MenuSheet.
sTag - the tag of the new MenuSheet. If null a default tag will be created.
cMnemonic - the mnemonic of the new MenuSheet.

MenuSheet

public MenuSheet(String sCaption,
                 String sTag)
Create a new MenuSheet.
Parameters:
sCaption - the caption of the new MenuSheet.
sTag - the tag of the new MenuSheet. If null a default tag will be created.

MenuSheet

public MenuSheet(String sCaption)
Create a new MenuSheet with a default tag.
Parameters:
sCaption - the caption of the new MenuSheet.
Method Detail

getPeerLock

protected final Object getPeerLock()
Return the monitor used to synchronized access to the peers.
Override:
Never.

add

public void add(MenuSheetObject mso)
Add a MenuSheetObject to the end of this MenuSheet.

Should the MenuSheet currently be displayed, the new item will be displayed as well.

Override:
Never.
Parameters:
mso - the new MenuSheetObject.
Hooks:
Define a MenuSheet

remove

public MenuSheetObject remove(String sTag)
Remove a tagged top level item from the MenuSheet.

If an item with the given tag is found among the top level items of this MenuSheet, it is removed and the removed item is returned. Otherwise, the call is ignored.

If the MenuSheet is currently on display, the peer will reflect the changes.

Override:
Never.
Parameters:
sTag - the tag of the item to be removed.
Returns:
the removed item

remove

public MenuSheetObject remove(MenuSheetObject msoRemove)
Remove a MenuSheetObject from the MenuSheet.

If the MenuSheet is currently on display, the peer will reflect the changes.

Override:
Never.
Parameters:
mso - the MenuSheetObject to be removed.
Returns:
the removed MenuSheetObject.

iterator

public Iterator iterator()
Return a fail-fast, readonly iterator of the items in this MenuSheet.

Fail-fast means, that this iterator will throw a ConcurrentModificationException when a structural change occured to the underlying MenuSheet.

Also, the remove() method will throw an UnsupportedOperationException, as this is a readonly iterator.

Override:
Never.
See Also:
ConcurrentModificationException

mergePeers

public final JMenuBar mergePeers(MenuSheet msToMerge,
                                 String sBeforeTag)
Merge the peers of two MenuSheets. If a MenuSheet is already merged into this one, it will be removed and marked invisible.

The peers of the top level MenuSheetObjects of the given MenuSheet are merged into the JMenuBar peer of this MenuSheet. They will be inserted into the JMenuBar peer before the MenuSheetpObject with the given tag. If no such MenuSheetObject can be found in the MenuSheet they are appended to the end of the peer.

Merging can always only result in a JMenuBar peer. A JMenu peer cannot be merged. However, merging can be nested. I.e. it is legal, to merge a MenuSheet, into whose peer another MenuSheet's peer has been merged, into a third MenuSheet.

Although the peers of the two MenuSheets are merged, they stay independent with respect to anything else. The MenuSheetObjects of the merged MenuSheet can still only be accessed through that MenuSheet and vice-vera. Also, the attached SalesPoint and SaleProcess stay independent.

For merging to function correctly, you must set the created JMenuBar in your JFrame. Something like this will do the trick:

   setJMenuBar (ms.mergePeers (msToMerge, "MERGE_BEFORE_THIS"));
 

This method is usually not called directly.

Override:
Never.
Parameters:
msToMerge - the MenuSheet to be merged into this one.
sBeforeTag - before which tag to merge in the MenuSheet.

getTaggedItem

public MenuSheetObject getTaggedItem(String sTag,
                                     boolean fTopLevelOnly)
Get a MenuSheetObject by its tag.

This will iterate over all MenuSheetObjects in this MenuSheet and return the first one, that has the given tag.

Override:
Never.
Parameters:
sTag - the tag to search for.
fTopLevelOnly - if true, only the direct elements in this MenuSheet are searched.
Returns:
the first MenuSheetObject that has the given tag, if any.
Throws:
ConcurrentModificationException - if the structure of the MenuSheet changed during the search.
Overrides:
getTaggedItem in class MenuSheetObject

attach

public SalesPoint attach(SalesPoint sp)
Attach a SalesPoint to this MenuSheet.
Override:
Never.
Overrides:
attach in class MenuSheetObject

attach

public SaleProcess attach(SaleProcess p)
Attach a SaleProcess to this MenuSheet.
Override:
Never.
Overrides:
attach in class MenuSheetObject

setVisible

public void setVisible(boolean fVisible)
Mark this MenuSheet, all its descendants and merged peer MenuSheets visible or invisible.
Override:
Never.
Overrides:
setVisible in class MenuSheetObject

setCaption

public void setCaption(String sCaption)
Set the caption of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
sCaption - the new caption.
Overrides:
setCaption in class MenuSheetObject

setMnemonic

public void setMnemonic(char cMnemonic)
Set the mnemonic of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
sMnemonic - the new mnemonic.

setToolTipText

public void setToolTipText(String s)
Set the ToolTip of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
s - the new ToolTip-Text.

setDefaultIcon

public void setDefaultIcon(ImageIcon iiImageIcon)
Set the default icon of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
iiImageIcon - the new icon.

setSelectedIcon

public void setSelectedIcon(ImageIcon iiImageIcon)
Set the selected icon of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
iiImageIcon - the new icon.

setDisabledIcon

public void setDisabledIcon(ImageIcon iiImageIcon)
Set the disabled icon of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
iiImageIcon - the new icon.

setDisabledSelectedIcon

public void setDisabledSelectedIcon(ImageIcon iiImageIcon)
Set the disabled selected icon of this MenuSheet.

If there is a peer it will reflect the changes immediately.

Override:
Never.
Parameters:
iiImageIcon - the new icon.

getPeer

public JMenuItem getPeer()
The JMenuItem peer of a MenuSheet is, of course, a JMenu.
Override:
Never.
Overrides:
getPeer in class MenuSheetObject

getMenuPeer

public JMenu getMenuPeer()
For MenuSheets there is no difference between JMenuItem and JMenu peer, they are both JMenus.
Override:
Never.
Overrides:
getMenuPeer in class MenuSheetObject

getMenuBar

public JMenuBar getMenuBar()
Return the JMenuBar peer.

For a MenuSheet there is a special peer: the JMenuBar peer. All items of this MenuSheet will present their JMenu peer in the JMenuBar. Only MenuSheetSeparators are not displayed in a JMenuBar representation. Merged peers are only displayed in the JMenuBar representation.

Override:
Never.

getMnemonic

public char getMnemonic()
Get the Mnemonic of this MenuSheet.
Override:
Never.
Returns:
the mnemonic of this MenuSheet.

getToolTipText

public String getToolTipText()
Get the ToolTip of this MenuSheet.
Override:
Never.
Returns:
the ToolTip-String of this MenuSheet.

getDefaultIcon

public ImageIcon getDefaultIcon()
Get the default icon of this MenuSheet.
Override:
Never.
Returns:
the default icon of this MenuSheet.

getSelectedIcon

public ImageIcon getSelectedIcon()
Get the selected icon of this MenuSheet.
Override:
Never.
Returns:
the pressed icon of this MenuSheet.

getDisabledIcon

public ImageIcon getDisabledIcon()
Get the disabled item of this MenuSheet.
Override:
Never.
Returns:
the disabled icon of this MenuSheet.

getDisabledSelectedIcon

public ImageIcon getDisabledSelectedIcon()
Get the disabled selected item of this MenuSheet.
Override:
Never.
Returns:
the disabled selected icon of this MenuSheet.

SalesPoint Framework v3.0