SalesPoint v3.3 API

sale
Class MenuSheetObject

java.lang.Object
  extended by sale.MenuSheetObject
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MenuSheet, MenuSheetItem, MenuSheetSeparator

public abstract class MenuSheetObject
extends Object
implements Serializable

A generic menu element.

Since:
v2.0
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.

Parameters:
sCaption - the new caption.
Override:
Always Override to make sure, the peer's captions gets properly updated.

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.

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

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.

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

getTaggedItem

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

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.
Override:
Never

detachSalesPoint

public SalesPoint detachSalesPoint()
Detach the currently attached SalesPoint.

Returns:
the SalesPoint just detached, if any.
Override:
Never

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.
Override:
Never

detachSaleProcess

public SaleProcess detachSaleProcess()
Detach the currently attached SaleProcess.

Returns:
the SaleProcess just detached, if any.
Override:
Never

getParent

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

Returns:
the MenuSheet containing this MenuSheetObject.
Override:
Never

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.
Override:
Sometimes Override if you have some additional ressources that need visibility dependent management.

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.

See Also:
getPeer(), getMenuPeer()
Override:
Never The default implementation returns false.

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.

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

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

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

SalesPoint v3.3 API