|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.salespointframework.core.MenuSheetObject
org.salespointframework.core.MenuSheet
public class MenuSheet
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.
Field Summary | |
---|---|
private static int |
DEFAULT_IMAGE
|
private static int |
DISABLED_IMAGE
|
private static int |
DISABLED_SELECTED_IMAGE
|
static java.lang.String |
HELP_MENU_TAG
A tag that will identify the help menu, should this MenuSheet be displayed as a JMenuBar. |
protected javax.swing.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 javax.swing.JMenuBar |
m_jmbBarPeer
The JMenuBar peer, if any. |
protected javax.swing.JMenu |
m_jmPeer
The JMenu peer, if any. |
protected java.util.LinkedList<MenuSheetObject> |
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. |
private java.lang.Object |
m_oPeerLock
The monitor used to synchronize access to the peers. |
protected java.lang.String |
m_sMergedBefore
The tag before which the merged menu was inserted. |
protected java.lang.String |
m_sToolTip
The ToolTip of this MenuSheet. |
private static int |
SELECTED_IMAGE
|
Fields inherited from class org.salespointframework.core.MenuSheetObject |
---|
m_msParent, m_pAttached, m_spAttached |
Constructor Summary | |
---|---|
MenuSheet(java.lang.String sCaption)
Creates a new MenuSheet with caption and a default tag. |
|
MenuSheet(java.lang.String sCaption,
java.lang.String sTag)
Creates a new MenuSheet with caption and tag. |
|
MenuSheet(java.lang.String sCaption,
java.lang.String sTag,
char cMnemonic)
Creates a new MenuSheet with caption, tag and mnemonic. |
Method Summary | |
---|---|
void |
add(MenuSheetObject mso)
Adds 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. |
javax.swing.ImageIcon |
getDefaultIcon()
Get the default icon of this MenuSheet. |
javax.swing.ImageIcon |
getDisabledIcon()
Get the disabled item of this MenuSheet. |
javax.swing.ImageIcon |
getDisabledSelectedIcon()
Get the disabled selected item of this MenuSheet. |
javax.swing.JMenuBar |
getMenuBar()
Return the JMenuBar peer. |
javax.swing.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. |
javax.swing.JMenuItem |
getPeer()
The JMenuItem peer of a MenuSheet is, of course, a JMenu. |
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 MenuSheet. |
MenuSheetObject |
getTaggedItem(java.lang.String sTag,
boolean fTopLevelOnly)
Get a MenuSheetObject by its tag. |
java.lang.String |
getToolTipText()
Get the ToolTip of this MenuSheet. |
java.util.Iterator<MenuSheetObject> |
iterator()
Return a fail-fast, readonly iterator of the items in this MenuSheet. |
(package private) void |
mergedAdd(MenuSheetObject mso,
int nIndex)
Internal method used for updating merged peers correctly. |
(package private) void |
mergedRemove(MenuSheetObject mso)
Internal method used to properly update merged peers. |
javax.swing.JMenuBar |
mergePeers(MenuSheet msToMerge,
java.lang.String sBeforeTag)
Merges the peers of two MenuSheets. |
(package private) javax.swing.JMenuBar |
remergePeers()
Internal method used for proper merging of peers. |
MenuSheetObject |
remove(MenuSheetObject msoRemove)
Remove a MenuSheetObject from the MenuSheet. |
MenuSheetObject |
remove(java.lang.String sTag)
Remove a tagged top level item from the MenuSheet. |
void |
setCaption(java.lang.String sCaption)
Set the caption of this MenuSheet. |
void |
setDefaultIcon(javax.swing.ImageIcon iiImageIcon)
Set the default icon of this MenuSheet. |
void |
setDisabledIcon(javax.swing.ImageIcon iiImageIcon)
Set the disabled icon of this MenuSheet. |
void |
setDisabledSelectedIcon(javax.swing.ImageIcon iiImageIcon)
Set the disabled selected icon of this MenuSheet. |
private void |
setIcon(javax.swing.ImageIcon iiImageIcon,
int nIndex)
|
(package private) void |
setMergeParent(MenuSheet msMergeParent)
Internal method used when merging peers. |
void |
setMnemonic(char cMnemonic)
Set the mnemonic of this MenuSheet. |
void |
setSelectedIcon(javax.swing.ImageIcon iiImageIcon)
Set the selected icon of this MenuSheet. |
void |
setToolTipText(java.lang.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 org.salespointframework.core.MenuSheetObject |
---|
detachSaleProcess, detachSalesPoint, equals, getCaption, getParent, getTag, getTaggedItem, isSeparator, isVisible, setParent |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient javax.swing.JMenu m_jmPeer
protected transient javax.swing.JMenuBar m_jmbBarPeer
private transient java.lang.Object m_oPeerLock
protected MenuSheet m_msMerged
protected java.lang.String m_sMergedBefore
protected int m_nMergedAt
protected MenuSheet m_msMergeParent
protected java.util.LinkedList<MenuSheetObject> m_lmsoItems
protected javax.swing.ImageIcon[] m_aiImages
protected char m_cMnemonic
protected java.lang.String m_sToolTip
public static final java.lang.String HELP_MENU_TAG
private static final int DEFAULT_IMAGE
private static final int SELECTED_IMAGE
private static final int DISABLED_IMAGE
private static final int DISABLED_SELECTED_IMAGE
Constructor Detail |
---|
public MenuSheet(java.lang.String sCaption, java.lang.String sTag, char cMnemonic)
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.public MenuSheet(java.lang.String sCaption, java.lang.String sTag)
sCaption
- the caption of the new MenuSheet.sTag
- the tag of the new MenuSheet. If null
a default tag will be created.public MenuSheet(java.lang.String sCaption)
sCaption
- the caption of the new MenuSheet.Method Detail |
---|
protected final java.lang.Object getPeerLock()
private void setIcon(javax.swing.ImageIcon iiImageIcon, int nIndex)
public void add(MenuSheetObject mso)
Should the MenuSheet currently be displayed, the new item will be displayed as well.
mso
- the new MenuSheetObject.void mergedAdd(MenuSheetObject mso, int nIndex)
mso
- the MenuSheet that was added in the merged MenuSheet.nIndex
- the peer index at which the element was added into the merged MenuSheet.public MenuSheetObject remove(java.lang.String sTag)
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.
sTag
- the tag of the item to be removed.
public MenuSheetObject remove(MenuSheetObject msoRemove)
If the MenuSheet is currently on display, the peer will reflect the changes.
msoRemove
- the MenuSheetObject to be removed.
void mergedRemove(MenuSheetObject mso)
mso
- the MenuSheetObject that was removed from the merged MenuSheet.public java.util.Iterator<MenuSheetObject> iterator()
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.
ConcurrentModificationException
void setMergeParent(MenuSheet msMergeParent)
public final javax.swing.JMenuBar mergePeers(MenuSheet msToMerge, java.lang.String sBeforeTag)
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.
msToMerge
- the MenuSheet to be merged into this one.sBeforeTag
- before which tag to merge in the MenuSheet.javax.swing.JMenuBar remergePeers()
public MenuSheetObject getTaggedItem(java.lang.String sTag, boolean fTopLevelOnly)
This will iterate over all MenuSheetObjects in this MenuSheet and return the first one, that has the given tag.
getTaggedItem
in class MenuSheetObject
sTag
- the tag to search for.fTopLevelOnly
- if true, only the direct elements in this MenuSheet are searched.
java.util.ConcurrentModificationException
- if the structure of the MenuSheet changed
during the search.public SalesPoint attach(SalesPoint sp)
attach
in class MenuSheetObject
sp
- the SalesPoint to be attached.
public SaleProcess attach(SaleProcess p)
attach
in class MenuSheetObject
p
- the process to be attached.
public void setVisible(boolean fVisible)
setVisible
in class MenuSheetObject
fVisible
- the visibility state of the MenuSheetObject.public void setCaption(java.lang.String sCaption)
If there is a peer it will reflect the changes immediately.
setCaption
in class MenuSheetObject
sCaption
- the new caption.public void setMnemonic(char cMnemonic)
If there is a peer it will reflect the changes immediately.
cMnemonic
- the new mnemonic.public void setToolTipText(java.lang.String s)
If there is a peer it will reflect the changes immediately.
s
- the new ToolTip-Text.public void setDefaultIcon(javax.swing.ImageIcon iiImageIcon)
If there is a peer it will reflect the changes immediately.
iiImageIcon
- the new icon.public void setSelectedIcon(javax.swing.ImageIcon iiImageIcon)
If there is a peer it will reflect the changes immediately.
iiImageIcon
- the new icon.public void setDisabledIcon(javax.swing.ImageIcon iiImageIcon)
If there is a peer it will reflect the changes immediately.
iiImageIcon
- the new icon.public void setDisabledSelectedIcon(javax.swing.ImageIcon iiImageIcon)
If there is a peer it will reflect the changes immediately.
iiImageIcon
- the new icon.public javax.swing.JMenuItem getPeer()
getPeer
in class MenuSheetObject
public javax.swing.JMenu getMenuPeer()
getMenuPeer
in class MenuSheetObject
public javax.swing.JMenuBar getMenuBar()
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.
public char getMnemonic()
public java.lang.String getToolTipText()
public javax.swing.ImageIcon getDefaultIcon()
public javax.swing.ImageIcon getSelectedIcon()
public javax.swing.ImageIcon getDisabledIcon()
public javax.swing.ImageIcon getDisabledSelectedIcon()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |