SalesPoint Framework v3.0

sale
Class MenuSheetObject

java.lang.Object
  |
  +--sale.MenuSheetObject
Direct Known Subclasses:
MenuSheet, MenuSheetItem, MenuSheetSeparator

public abstract class MenuSheetObject
extends Object
implements Serializable

A generic menu element.

Hooks:
Define New MenuSheet Element Type
Since:
v2.0
Version:
2.0 20/05/1999
Author:
Steffen Zschaler
See Also:
MenuSheet, MenuSheetItem, MenuSheetSeparator, Serialized Form

Field Summary
protected  MenuSheet m_msParent
          The MenuSheet that contains this menu element.
protected  SaleProcess m_pAttached
          The SaleProcess attached to this MenuSheetObject, if any.
protected  SalesPoint m_spAttached
          The SalesPoint attached to this MenuSheetObject, if any.
 
Constructor Summary
MenuSheetObject(String sCaption)
          Create a new MenuSheetObject with a caption and a default tag.
MenuSheetObject(String sCaption, 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(Object o)
          Compare this MenuSheetObject to the given object and return true if they are equal.
 String getCaption()
          Get the MenuSheetObject's caption.
abstract  JMenu getMenuPeer()
          Return the JMenu peer for this MenuSheetObject.
 MenuSheet getParent()
          Get the parent MenuSheet of this MenuSheetObject.
abstract  JMenuItem getPeer()
          Return the JMenuItem peer for this MenuSheetObject.
 String getTag()
          Get the MenuSheetObject's tag.
 MenuSheetObject getTaggedItem(String sTag)
          Convenience method for in-depth search for a tagged item.
 MenuSheetObject getTaggedItem(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(String sCaption)
          Set the MenuSheetObject's caption.
 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_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.
Constructor Detail

MenuSheetObject

public MenuSheetObject(String sCaption,
                       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(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 String getCaption()
Get the MenuSheetObject's caption.
Override:
Never.

setCaption

public void setCaption(String sCaption)
Set the MenuSheetObject's caption.
Override:
Always.
Override to make sure, the peer's captions gets properly updated.
Parameters:
sCaption - the new caption.
Hooks:
Define New MenuSheet Element Type

getTag

public 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.
Override:
Never.
See Also:
MenuSheet, getTaggedItem(java.lang.String, boolean)

getTaggedItem

public MenuSheetObject getTaggedItem(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.

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

getTaggedItem

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

Equivalent to:

 getTaggedItem (sTag, false);
 
Override:
Never.
Parameters:
sTag - the tag to be searched for.

attach

public SalesPoint attach(SalesPoint sp)
Attach a SalesPoint to this MenuSheetObject.
Override:
Never.
Parameters:
sp - the SalesPoint to be attached.
Returns:
the previously attached SalesPoint, if any.

detachSalesPoint

public SalesPoint detachSalesPoint()
Detach the currently attached SalesPoint.
Override:
Never.
Returns:
the SalesPoint just detached, if any.

attach

public SaleProcess attach(SaleProcess p)
Attach a SaleProcess to this MenuSheetObject.
Override:
Never.
Parameters:
p - the process to be attached.
Returns:
the previously attached process, if any.

detachSaleProcess

public SaleProcess detachSaleProcess()
Detach the currently attached SaleProcess.
Override:
Never.
Returns:
the SaleProcess just detached, if any.

getParent

public MenuSheet getParent()
Get the parent MenuSheet of this MenuSheetObject.
Override:
Never.
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.

Override:
Sometimes.
Override if you have some additional ressources that need visibility dependent management.
Parameters:
fVisible - the visibility state of the MenuSheetObject.
Hooks:
Define New MenuSheet Element Type

isVisible

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

isSeparator

public boolean isSeparator()
Return true if this is a separator. Separators need not have peers.
Override:
Never.
The default implementation returns false.
See Also:
getPeer(), getMenuPeer()

equals

public boolean equals(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.

Override:
Never.
You should only override this method when there is an absolute need for a different equality measurement.
Parameters:
o - the object to compare to.
Overrides:
equals in class Object

getPeer

public abstract 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.
Override:
Always.
Hooks:
Define New MenuSheet Element Type

getMenuPeer

public abstract 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.

Override:
Always.
Hooks:
Define New MenuSheet Element Type

SalesPoint Framework v3.0