Package org.sakaiproject.cheftool.menu
Class MenuImpl
- java.lang.Object
-
- org.sakaiproject.cheftool.menu.MenuImpl
-
- All Implemented Interfaces:
org.sakaiproject.cheftool.api.Menu,org.sakaiproject.cheftool.api.MenuItem
public class MenuImpl extends Object implements org.sakaiproject.cheftool.api.Menu
Menu is an ordered list of MenuItems.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONTEXT_ACTIONstatic StringCONTEXT_MENUprotected booleanm_enabledThe menu's enabled flag.protected Stringm_formThe form name string for the entry.protected Stringm_iconThe menu's icon.protected List<org.sakaiproject.cheftool.api.MenuItem>m_itemsThe MenuItems, in order.protected Stringm_linkBaseUrlThe base url for any action taken after clicking on the menu.protected Stringm_resourceBaseUrlThe base url for any resources (images, etc.) required by the menu.protected booleanm_showDisabledThe menu's flag for whether to display disabled entriesprotected Stringm_titleThe menu's title.static StringSTATE_MENU
-
Constructor Summary
Constructors Constructor Description MenuImpl()Construct a menu (good for a menu bar).MenuImpl(String title, String icon, boolean enabled)Construct a menu (good for sub-menus).MenuImpl(String title, String icon, boolean enabled, String form)Construct a menu (good for sub-menus).MenuImpl(VelocityPortlet p, RunData r, String action)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.sakaiproject.cheftool.api.MenuItemadd(org.sakaiproject.cheftool.api.MenuItem item)Add a menu item to the bar.voidadjustDividers()Adjust by removing any dividers at the start or end.voidclear()Clear the menu of all items.StringgetAccessibilityLabel()StringgetAction()Access the action string for this item; what to do when the user clicks.intgetChecked()Access the checked status of this item.StringgetForm()Access the form name whose values will be used when this item is selected.StringgetIcon()Access the icon name for the item (or null if no icon).booleangetIsContainer()Does this item act as a container for other items?booleangetIsCurrent()booleangetIsDivider()Is this item a divider ?booleangetIsEnabled()Access the enabled flag for the item.booleangetIsField()Access the is-field (not a button) flag.org.sakaiproject.cheftool.api.MenuItemgetItem(int index)Access one sub-items of the item.List<org.sakaiproject.cheftool.api.MenuItem>getItems()Access the sub-items of the item.booleangetShowdisabled()Access whether disabled items in this menu should be shown.StringgetTitle()Access the display title for the item.StringgetUrl()Access the full URL string for this item; what to do when the user clicks.booleanisEmpty()Check if there are any sub-items.org.sakaiproject.cheftool.api.MenusetShowdisabled(boolean value)Set whether disabled items in this menu should be shown.intsize()Count the sub-items of the item.
-
-
-
Field Detail
-
m_title
protected String m_title
The menu's title.
-
m_icon
protected String m_icon
The menu's icon.
-
m_enabled
protected boolean m_enabled
The menu's enabled flag.
-
m_items
protected List<org.sakaiproject.cheftool.api.MenuItem> m_items
The MenuItems, in order.
-
m_form
protected String m_form
The form name string for the entry.
-
m_linkBaseUrl
protected String m_linkBaseUrl
The base url for any action taken after clicking on the menu.
-
m_resourceBaseUrl
protected String m_resourceBaseUrl
The base url for any resources (images, etc.) required by the menu.
-
m_showDisabled
protected boolean m_showDisabled
The menu's flag for whether to display disabled entries
-
CONTEXT_ACTION
public static final String CONTEXT_ACTION
- See Also:
- Constant Field Values
-
CONTEXT_MENU
public static final String CONTEXT_MENU
- See Also:
- Constant Field Values
-
STATE_MENU
public static final String STATE_MENU
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MenuImpl
public MenuImpl(VelocityPortlet p, RunData r, String action)
-
MenuImpl
public MenuImpl(String title, String icon, boolean enabled)
Construct a menu (good for sub-menus).
-
MenuImpl
public MenuImpl(String title, String icon, boolean enabled, String form)
Construct a menu (good for sub-menus).
-
MenuImpl
public MenuImpl()
Construct a menu (good for a menu bar).
-
-
Method Detail
-
add
public org.sakaiproject.cheftool.api.MenuItem add(org.sakaiproject.cheftool.api.MenuItem item)
Add a menu item to the bar.- Specified by:
addin interfaceorg.sakaiproject.cheftool.api.Menu- Parameters:
entry- The menu item to add.- Returns:
- the item.
-
clear
public void clear()
Clear the menu of all items.- Specified by:
clearin interfaceorg.sakaiproject.cheftool.api.Menu
-
getIsContainer
public boolean getIsContainer()
Does this item act as a container for other items?- Specified by:
getIsContainerin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- true if this MenuItem is a container for other items, false if not.
-
getIsDivider
public boolean getIsDivider()
Is this item a divider ?- Specified by:
getIsDividerin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- true if this MenuItem is a divider, false if not.
-
getTitle
public String getTitle()
Access the display title for the item.- Specified by:
getTitlein interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The display title for the item.
-
getIcon
public String getIcon()
Access the icon name for the item (or null if no icon).- Specified by:
getIconin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The icon name for the item (or null if no icon).
-
getIsEnabled
public boolean getIsEnabled()
Access the enabled flag for the item.- Specified by:
getIsEnabledin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- True if the item is enabled, false if not.
-
getAction
public String getAction()
Access the action string for this item; what to do when the user clicks. Note: if getIsMenu(), there will not be an action string (will return "").- Specified by:
getActionin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The action string for this item.
-
getUrl
public String getUrl()
Access the full URL string for this item; what to do when the user clicks. Note: this if defined overrides getAction() which should be "". Note: if getIsMenu(), there will not be a URL string (will return "").- Specified by:
getUrlin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The full URL string for this item.
-
getForm
public String getForm()
Access the form name whose values will be used when this item is selected.- Specified by:
getFormin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The form name whose values will be used when this item is selected.
-
getItems
public List<org.sakaiproject.cheftool.api.MenuItem> getItems()
Access the sub-items of the item. Note: if !isContainer(), there will be no sub-items (will return EmptyIterator).- Specified by:
getItemsin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The sub-items of the item.
-
size
public int size()
Count the sub-items of the item. Note: if !isContainer(), the count is 0.- Specified by:
sizein interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The count of sub-items of the item.
-
isEmpty
public boolean isEmpty()
Check if there are any sub-items. Note: if !isContainer(), this is empty.- Specified by:
isEmptyin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- true of there are no sub-items, false if there are.
-
getItem
public org.sakaiproject.cheftool.api.MenuItem getItem(int index)
Access one sub-items of the item. Note: if !isContainer(), there will be no sub-items (will return null).- Specified by:
getItemin interfaceorg.sakaiproject.cheftool.api.MenuItem- Parameters:
index- The index position (0 based) for the sub-item to get.- Returns:
- The sub-item of the item.
-
getChecked
public int getChecked()
Access the checked status of this item. Possible values:- Specified by:
getCheckedin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- The the checked status of this item.
- See Also:
MenuItem
-
getIsField
public boolean getIsField()
Access the is-field (not a button) flag.- Specified by:
getIsFieldin interfaceorg.sakaiproject.cheftool.api.MenuItem- Returns:
- True if the item is a field, false if not.
-
getIsCurrent
public boolean getIsCurrent()
- Specified by:
getIsCurrentin interfaceorg.sakaiproject.cheftool.api.MenuItem
-
adjustDividers
public void adjustDividers()
Adjust by removing any dividers at the start or end.- Specified by:
adjustDividersin interfaceorg.sakaiproject.cheftool.api.Menu
-
setShowdisabled
public org.sakaiproject.cheftool.api.Menu setShowdisabled(boolean value)
Set whether disabled items in this menu should be shown.- Specified by:
setShowdisabledin interfaceorg.sakaiproject.cheftool.api.Menu- Parameters:
value- True to show disabled items, False otherwise.- Returns:
- This, for convenience.
-
getShowdisabled
public boolean getShowdisabled()
Access whether disabled items in this menu should be shown.- Specified by:
getShowdisabledin interfaceorg.sakaiproject.cheftool.api.Menu- Returns:
- Current setting for show-disabled status (true to show disabled items, false to NOT show disabled items).
-
getAccessibilityLabel
public String getAccessibilityLabel()
- Specified by:
getAccessibilityLabelin interfaceorg.sakaiproject.cheftool.api.MenuItem
-
-