org.salespointframework.core
Class MenuSheetObject

java.lang.Object
  extended by org.salespointframework.core.MenuSheetObject
Direct Known Subclasses:
MenuSheet, MenuSheetItem, MenuSheetSeparator

public abstract class MenuSheetObject
extends java.lang.Object

A generic menu element.

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

Field Summary
private  boolean m_fVisible
          Is this MenuSheetObject currently on display?
protected  MenuSheet m_msParent
          The MenuSheet that contains this menu element.
protected  SaleProcess m_pAttached
          The SaleProcess attached to this MenuSheetObject, if any.
private  java.lang.String m_sCaption
          The caption of the menu element.
protected  SalesPoint m_spAttached
          The SalesPoint attached to this MenuSheetObject, if any.
private  java.lang.String m_sTag
          Immutable tag, that can be used to identify the menu element.
private static int s_nLastTagID
          The last tag id that was given to a default tag.
private static java.lang.String STD_TAG_PREFIX
          The default tag prefix, if no tag was given.
 
Constructor Summary
MenuSheetObject(java.lang.String sCaption)
          Create a new MenuSheetObject with a caption and a default tag.
MenuSheetObject(java.lang.String sCaption, java.lang.String sTag)
          Create a new MenuSheetObject with a caption and a tag.
 
Method Summary
 SaleProcess attach(SaleProcess p)
          Attach a SaleProcess to this MenuSheetObject.
 SalesPoint attach(SalesPoint sp)
          Attach a SalesPoint to this MenuSheetObject.
 SaleProcess detachSaleProcess()
          Detach the currently attached SaleProcess.
 SalesPoint detachSalesPoint()
          Detach the currently attached SalesPoint.
 boolean equals(java.lang.Object o)
          Compare this MenuSheetObject to the given object and return true if they are equal.
 java.lang.String getCaption()
          Get the MenuSheetObject's caption.
abstract  javax.swing.JMenu getMenuPeer()
          Return the JMenu peer for this MenuSheetObject.
 MenuSheet getParent()
          Get the parent MenuSheet of this MenuSheetObject.
abstract  javax.swing.JMenuItem getPeer()
          Return the JMenuItem peer for this MenuSheetObject.
 java.lang.String getTag()
          Get the MenuSheetObject's tag.
 MenuSheetObject getTaggedItem(java.lang.String sTag)
          Convenience method for in-depth search for a tagged item.
 MenuSheetObject getTaggedItem(java.lang.String sTag, boolean fTopLevelOnly)
          Get the first MenuSheetObject with the given tag which is managed by this one.
 boolean isSeparator()
          Return true if this is a separator.
 boolean isVisible()
          Get the visibility state of this MenuSheetObject.
 void setCaption(java.lang.String sCaption)
          Set the MenuSheetObject's caption.
(package private)  void setParent(MenuSheet msParent)
          Set the parent of the MenuSheetObject.
 void setVisible(boolean fVisible)
          Mark this MenuSheetObject visible or invisible.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_sCaption

private java.lang.String m_sCaption
The caption of the menu element.


m_sTag

private java.lang.String m_sTag
Immutable tag, that can be used to identify the menu element. Never null!


m_fVisible

private boolean m_fVisible
Is this MenuSheetObject currently on display?


m_msParent

protected MenuSheet m_msParent
The MenuSheet that contains this menu element.


m_spAttached

protected SalesPoint m_spAttached
The SalesPoint attached to this MenuSheetObject, if any.


m_pAttached

protected SaleProcess m_pAttached
The SaleProcess attached to this MenuSheetObject, if any.


STD_TAG_PREFIX

private static final java.lang.String STD_TAG_PREFIX
The default tag prefix, if no tag was given.

See Also:
Constant Field Values

s_nLastTagID

private static int s_nLastTagID
The last tag id that was given to a default tag.

Constructor Detail

MenuSheetObject

public MenuSheetObject(java.lang.String sCaption,
                       java.lang.String sTag)
Create a new MenuSheetObject with a caption and a tag.

Parameters:
sCaption - the caption of this MenuObject
sTag - the tag of this MenuObject. If null, a default, unique tag will be given.

MenuSheetObject

public MenuSheetObject(java.lang.String sCaption)
Create a new MenuSheetObject with a caption and a default tag.

You can find out about the tag by calling getTag().

Parameters:
sCaption - the caption of the MenuSheetObject.
Method Detail

getCaption

public java.lang.String getCaption()
Get the MenuSheetObject's caption.


setCaption

public void setCaption(java.lang.String sCaption)
Set the MenuSheetObject's caption.

Parameters:
sCaption - the new caption.

getTag

public java.lang.String getTag()
Get the MenuSheetObject's tag. The tag of a MenuSheetObject can be used to identify a MenuSheetObject in a MenuSheet. It is immutable, never null and should be unique in the containing MenuSheet.

See Also:
MenuSheet, getTaggedItem(java.lang.String, boolean)

getTaggedItem

public MenuSheetObject getTaggedItem(java.lang.String sTag,
                                     boolean fTopLevelOnly)
Get the first MenuSheetObject with the given tag which is managed by this one.

The default implementation returns this MenuSheetObject if it has the given tag, and null otherwise.

Parameters:
sTag - the tag that is searched for.
fTopLevelOnly - if true, only the top level items are searched.

getTaggedItem

public MenuSheetObject getTaggedItem(java.lang.String sTag)
Convenience method for in-depth search for a tagged item.

Equivalent to:

 getTaggedItem (sTag, false);
 

Parameters:
sTag - the tag to be searched for.

attach

public SalesPoint attach(SalesPoint sp)
Attach a SalesPoint to this MenuSheetObject.

Parameters:
sp - the SalesPoint to be attached.
Returns:
the previously attached SalesPoint, if any.

detachSalesPoint

public SalesPoint detachSalesPoint()
Detach the currently attached SalesPoint.

Returns:
the SalesPoint just detached, if any.

attach

public SaleProcess attach(SaleProcess p)
Attach a SaleProcess to this MenuSheetObject.

Parameters:
p - the process to be attached.
Returns:
the previously attached process, if any.

detachSaleProcess

public SaleProcess detachSaleProcess()
Detach the currently attached SaleProcess.

Returns:
the SaleProcess just detached, if any.

setParent

void setParent(MenuSheet msParent)
Set the parent of the MenuSheetObject. This method is used internally only.


getParent

public MenuSheet getParent()
Get the parent MenuSheet of this MenuSheetObject.

Returns:
the MenuSheet containing this MenuSheetObject.

setVisible

public void setVisible(boolean fVisible)
Mark this MenuSheetObject visible or invisible. This does not actually show or hide the MenuSheetObject's peer, but rather helps the MenuSheetObject manage resources.

This method is usually not called directly.

Parameters:
fVisible - the visibility state of the MenuSheetObject.

isVisible

public boolean isVisible()
Get the visibility state of this MenuSheetObject.


isSeparator

public boolean isSeparator()
Return true if this is a separator. Separators need not have peers.

See Also:
getPeer(), getMenuPeer()

equals

public boolean equals(java.lang.Object o)
Compare this MenuSheetObject to the given object and return true if they are equal.

For MenuSheetObjects equality of references is measured, i.e. equals() will only return true if this == o.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare to.

getPeer

public abstract javax.swing.JMenuItem getPeer()
Return the JMenuItem peer for this MenuSheetObject. This can be a JMenuItem or a JMenu, just as is appropriate. You can always return the same peer.


getMenuPeer

public abstract javax.swing.JMenu getMenuPeer()
Return the JMenu peer for this MenuSheetObject. Independently of the actual type of the MenuSheetObject this must return a JMenu object.

For MenuSheetItems and similar MenuSheetObjects it is recommended that you create a JMenu with the same caption and only one item, the MenuElement peer of the MenuSheetObject. Make sure, however, to create all these objects afresh for the JMenu peer, lest there should result inpredictably behaving menus. This does, of course not apply, if the MenuElement peer and the JMenu peer are entirely equal as is the case for MenuSheets.

Although JMenuItem peer and JMenu peer should be different objects, subsequent calls to getMenuPeer() can still return the same object.