org.salespointframework.core
Class MenuSheetItem

java.lang.Object
  extended by org.salespointframework.core.MenuSheetObject
      extended by org.salespointframework.core.MenuSheetItem
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class MenuSheetItem
extends MenuSheetObject
implements java.awt.event.ActionListener

A MenuSheetItem that has a label and an associated action.

Since:
v1.0
Version:
2.0 20/05/1999
Author:
Steffen Zschaler
See Also:
Action, MenuSheet, MenuSheetSeparator

Field Summary
private static int DEFAULT_IMAGE
           
private static int DISABLED_IMAGE
           
private static int DISABLED_SELECTED_IMAGE
           
protected  Action m_aAction
          The action associated with this MenuSheetItem.
protected  javax.swing.ImageIcon[] m_aiImages
          The Images associated with the icons of this MenuSheetItem( [0]:DefaultImage, [1]:PressedImage, [2]:DisabledImage, [3]:PressedDiabledImage ).
protected  char m_cMnemonic
          The Mnemonic of this MenuSheetItem.
private  boolean m_fEnabled
          Can this MenuSheetItem be clicked?
protected  javax.swing.JMenuItem m_jmiPeer
          The JMenuItem peer.
protected  javax.swing.JMenu m_jmMenuPeer
          The JMenu peer.
protected  javax.swing.KeyStroke m_ksKeyStroke
          The KeyStroke of this MenuSheetItem.
private  java.lang.Object m_oActionLock
          The monitor synchronizing accesses to m_aAction.
private  java.lang.Object m_oPeerLock
          The monitor synchronizing access to the peers.
protected  java.lang.String m_sToolTip
          The ToolTip of this MenuSheeItemt.
private static int SELECTED_IMAGE
           
 
Fields inherited from class org.salespointframework.core.MenuSheetObject
m_msParent, m_pAttached, m_spAttached
 
Constructor Summary
MenuSheetItem(java.lang.String sCaption, Action aAction)
          Creates a new MenuSheetItem with caption and action.
MenuSheetItem(java.lang.String sCaption, java.lang.String sTag, Action aAction)
          Creates a new MenuSheetItem with caption, tag and action; initially enabled.
MenuSheetItem(java.lang.String sCaption, java.lang.String sTag, Action aAction, char cMnemonic)
          Creates a new MenuSheetItem with caption, tag, an action and a mnemonic.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Hook method called whenever the user selects the MenuSheetItem.
 javax.swing.KeyStroke getAccelerator()
          Get the accelerator of this MenuSheetItem.
protected  java.lang.Object getActionLock()
          Return the monitor used to synchronized access to the m_aAction.
 javax.swing.ImageIcon getDefaultIcon()
          Get the default icon of this MenuSheetItem.
 javax.swing.ImageIcon getDisabledIcon()
          Get the disabled item of this MenuSheetItem.
 javax.swing.ImageIcon getDisabledSelectedIcon()
          Get the disabled selected item of this MenuSheetItem.
 javax.swing.JMenu getMenuPeer()
          Return the JMenu peer for this MenuSheetItem.
 char getMnemonic()
          Get the Mnemonic of this MenuSheetItem.
 javax.swing.JMenuItem getPeer()
          Get the JMenuItem peer of the MenuSheetItem.
protected  java.lang.Object getPeerLock()
          Return the monitor used to synchronized access to the peers.
 javax.swing.ImageIcon getSelectedIcon()
          Get the selected icon of this MenuSheetItem.
 java.lang.String getToolTipText()
          Get the ToolTip of this MenuSheetItem.
 boolean isEnabled()
          Return the current enabled state of this MenuSheetItem.
 void setAccelerator(javax.swing.KeyStroke ks)
          Set the accelerator of this MenuSheetItem.
 Action setAction(Action aAction)
          Set the action to perform when this item is selected.
 void setCaption(java.lang.String sCaption)
          Set the caption of this MenuSheetItem.
 void setDefaultIcon(javax.swing.ImageIcon iiImageIcon)
          Set the default icon of this MenuSheetItem.
 void setDisabledIcon(javax.swing.ImageIcon iiImageIcon)
          Set the disabled icon of this MenuSheetItem.
 void setDisabledSelectedIcon(javax.swing.ImageIcon iiImageIcon)
          Set the disabled selected icon of this MenuSheetItem.
 void setEnabled(boolean fEnabled)
          Set the enabled state of this MenuSheetItem.
private  void setIcon(javax.swing.ImageIcon iiImageIcon, int nIndex)
           
 void setMnemonic(char cMnemonic)
          Set the mnemonic of this MenuSheetItem.
 void setSelectedIcon(javax.swing.ImageIcon iiImageIcon)
          Set the selected icon of this MenuSheetItem.
 void setToolTipText(java.lang.String s)
          Set the ToolTip of this MenuSheetItem.
 void setVisible(boolean fVisible)
          Mark the item visible or invisible.
 
Methods inherited from class org.salespointframework.core.MenuSheetObject
attach, attach, detachSaleProcess, detachSalesPoint, equals, getCaption, getParent, getTag, getTaggedItem, getTaggedItem, isSeparator, isVisible, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_jmiPeer

protected transient javax.swing.JMenuItem m_jmiPeer
The JMenuItem peer.


m_jmMenuPeer

protected transient javax.swing.JMenu m_jmMenuPeer
The JMenu peer.


m_oPeerLock

private transient java.lang.Object m_oPeerLock
The monitor synchronizing access to the peers.


m_aAction

protected Action m_aAction
The action associated with this MenuSheetItem.


m_oActionLock

private transient java.lang.Object m_oActionLock
The monitor synchronizing accesses to m_aAction.


m_fEnabled

private boolean m_fEnabled
Can this MenuSheetItem be clicked?


m_aiImages

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


m_cMnemonic

protected char m_cMnemonic
The Mnemonic of this MenuSheetItem.


m_ksKeyStroke

protected javax.swing.KeyStroke m_ksKeyStroke
The KeyStroke of this MenuSheetItem.


m_sToolTip

protected java.lang.String m_sToolTip
The ToolTip of this MenuSheeItemt.


DEFAULT_IMAGE

private static final int DEFAULT_IMAGE
See Also:
Constant Field Values

SELECTED_IMAGE

private static final int SELECTED_IMAGE
See Also:
Constant Field Values

DISABLED_IMAGE

private static final int DISABLED_IMAGE
See Also:
Constant Field Values

DISABLED_SELECTED_IMAGE

private static final int DISABLED_SELECTED_IMAGE
See Also:
Constant Field Values
Constructor Detail

MenuSheetItem

public MenuSheetItem(java.lang.String sCaption,
                     java.lang.String sTag,
                     Action aAction,
                     char cMnemonic)
Creates a new MenuSheetItem with caption, tag, an action and a mnemonic.

Parameters:
sCaption - the caption of the new MenuSheetItem.
sTag - the tag that will identify this MenuSheetItem.
aAction - the action to perform when this MenuSheetItem is selected.
cMnemonic - the mnemonic of the new MenuSheetItem

MenuSheetItem

public MenuSheetItem(java.lang.String sCaption,
                     java.lang.String sTag,
                     Action aAction)
Creates a new MenuSheetItem with caption, tag and action; initially enabled.

Parameters:
sCaption - the caption of the new MenuSheetItem.
sTag - the tag that will identify this MenuSheetItem.
aAction - the action to perform when this MenuSheetItem is selected.

MenuSheetItem

public MenuSheetItem(java.lang.String sCaption,
                     Action aAction)
Creates a new MenuSheetItem with caption and action. The MenuSheetItem will have a default, unique tag.

Parameters:
sCaption - the caption of the new MenuSheetItem.
aAction - the action to perform when this MenuSheetItem is selected.
Method Detail

getPeerLock

protected java.lang.Object getPeerLock()
Return the monitor used to synchronized access to the peers.


getActionLock

protected java.lang.Object getActionLock()
Return the monitor used to synchronized access to the m_aAction.


setIcon

private void setIcon(javax.swing.ImageIcon iiImageIcon,
                     int nIndex)

setCaption

public void setCaption(java.lang.String sCaption)
Set the caption of this MenuSheetItem. If the MenuSheetItem is already on display, also the peer's caption is set.

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

setEnabled

public void setEnabled(boolean fEnabled)
Set the enabled state of this MenuSheetItem. If the MenuSheetItem is already on display, also the peer's enabled state is set.

Parameters:
fEnabled - the new enabled state.

isEnabled

public boolean isEnabled()
Return the current enabled state of this MenuSheetItem.


setVisible

public void setVisible(boolean fVisible)
Mark the item visible or invisible.

Overrides:
setVisible in class MenuSheetObject
Parameters:
fVisible - the visibility state of the MenuSheetObject.

setAction

public Action setAction(Action aAction)
Set the action to perform when this item is selected.

Parameters:
aAction - the action to perform when this item is selected.
Returns:
the previously set action, if any.

setMnemonic

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

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

Parameters:
cMnemonic - the new mnemonic.

setAccelerator

public void setAccelerator(javax.swing.KeyStroke ks)
Set the accelerator of this MenuSheetItem.

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

Parameters:
ks - the new keystroke.

setToolTipText

public void setToolTipText(java.lang.String s)
Set the ToolTip of this MenuSheetItem.

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

Parameters:
s - the new ToolTip-Text.

setDefaultIcon

public void setDefaultIcon(javax.swing.ImageIcon iiImageIcon)
Set the default icon of this MenuSheetItem.

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

Parameters:
iiImageIcon - the new icon.

setSelectedIcon

public void setSelectedIcon(javax.swing.ImageIcon iiImageIcon)
Set the selected icon of this MenuSheetItem.

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

Parameters:
iiImageIcon - the new icon.

setDisabledIcon

public void setDisabledIcon(javax.swing.ImageIcon iiImageIcon)
Set the disabled icon of this MenuSheetItem.

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

Parameters:
iiImageIcon - the new icon.

setDisabledSelectedIcon

public void setDisabledSelectedIcon(javax.swing.ImageIcon iiImageIcon)
Set the disabled selected icon of this MenuSheetItem.

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

Parameters:
iiImageIcon - the new icon.

getPeer

public javax.swing.JMenuItem getPeer()
Get the JMenuItem peer of the MenuSheetItem. The JMenuItem peer is a JMenuItem with the same caption as this MenuSheetItem. Selecting this JMenuItem will invoke the action associated to this MenuSheetItem.

Specified by:
getPeer in class MenuSheetObject

getMenuPeer

public javax.swing.JMenu getMenuPeer()
Return the JMenu peer for this MenuSheetItem. The JMenu peer is a JMenu with the same caption as this MenuSheetItem, containing just one JMenuItem, which is equivalent to the JMenuItem peer of the MenuSheetItem.

Specified by:
getMenuPeer in class MenuSheetObject

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Hook method called whenever the user selects the MenuSheetItem. As a default invokes the action currently associated with the MenuSheetItem, handing it the currently attached SalesPoint and SaleProcess.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
setAction(org.salespointframework.core.Action), SalesPoint, SaleProcess

getMnemonic

public char getMnemonic()
Get the Mnemonic of this MenuSheetItem.

Returns:
the mnemonic of this MenuSheetItem.

getAccelerator

public javax.swing.KeyStroke getAccelerator()
Get the accelerator of this MenuSheetItem.

Returns:
the keystroke associated with the accelerator of this MenuSheetItem.

getToolTipText

public java.lang.String getToolTipText()
Get the ToolTip of this MenuSheetItem.

Returns:
the ToolTip-String of this MenuSheetItem.

getDefaultIcon

public javax.swing.ImageIcon getDefaultIcon()
Get the default icon of this MenuSheetItem.

Returns:
the default icon of this MenuSheetItem.

getSelectedIcon

public javax.swing.ImageIcon getSelectedIcon()
Get the selected icon of this MenuSheetItem.

Returns:
the pressed icon of this MenuSheetItem.

getDisabledIcon

public javax.swing.ImageIcon getDisabledIcon()
Get the disabled item of this MenuSheetItem.

Returns:
the disabled icon of this MenuSheetItem.

getDisabledSelectedIcon

public javax.swing.ImageIcon getDisabledSelectedIcon()
Get the disabled selected item of this MenuSheetItem.

Returns:
the disabled selected icon of this MenuSheetItem.