org.projectforge.web
Class MenuItemDef

java.lang.Object
  extended by org.projectforge.web.MenuItemDef
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ToDoMenuItemDef

public class MenuItemDef
extends Object
implements Serializable

The menu is defined once. The user's personal menu is calculated by this menu definitions (which menu entries are visible and which not).

Author:
Kai Reinhard (k.reinhard@micromata.de)
See Also:
Serialized Form

Constructor Summary
MenuItemDef()
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, Class<? extends org.apache.wicket.Page> pageClass, ProjectForgeGroup... visibleForGroups)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, Class<? extends org.apache.wicket.Page> pageClass, String[] params, ProjectForgeGroup... visibleForGroups)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, Class<? extends org.apache.wicket.Page> pageClass, String[] params, UserRightId requiredRightId, UserRightValue... requiredRightValues)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, Class<? extends org.apache.wicket.Page> pageClass, UserRightId requiredRightId, UserRightValue... requiredRightValues)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, ProjectForgeGroup... visibleForGroups)
          A menu entry without a link (e. g. a parent menu entry).
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, String url, boolean newWindow, ProjectForgeGroup... visibleForGroups)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, String url, boolean newWindow, UserRightId requiredRightId, UserRightValue... requiredRightValues)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, String url, ProjectForgeGroup... visibleForGroups)
           
MenuItemDef(MenuItemDef parent, String id, int orderNumber, String i18nKey, String url, UserRightId requiredRightId, UserRightValue... requiredRightValues)
           
 
Method Summary
protected  void afterMenuEntryCreation(MenuEntry createdMenuEntry, MenuBuilderContext context)
          Override this method if some modifications needed after a menu entry for an user's menu is created.
protected  MenuEntry createMenuEntry(Menu menu, MenuBuilderContext context)
           
 String getI18nKey()
           
 String getId()
           
 int getMobileMenuOrderNumber()
          Order number for sorting menu entries (mobile menu).
 Class<? extends org.apache.wicket.Page> getMobilePageClass()
           
 MenuItemDef getMobileParentMenu()
           
 int getOrderNumber()
          Order number for sorting menu entries.
 Class<? extends org.apache.wicket.Page> getPageClass()
           
 String[] getParams()
           
 MenuItemDef getParent()
           
 UserRightId getRequiredRightId()
           
 UserRightValue[] getRequiredRightValues()
           
 String getUrl()
           
 ProjectForgeGroup[] getVisibleForGroups()
           
 boolean hasRight(AccessChecker accessChecker, PFUserDO loggedInUser)
           
 boolean hasUrl()
           
 boolean isLink()
           
 boolean isNewWindow()
           
 boolean isVisible()
           
protected  boolean isVisible(MenuBuilderContext context)
          Overwrite this if you need special access checking.
 boolean isWicketPage()
           
 void setDesktopMenuSupport(boolean desktopMenuSupport)
          If set to false then this menu entry will not be displayed in the classical web menu version.
 MenuItemDef setMobileMenu(Class<? extends org.apache.wicket.Page> mobilePageClass, int mobileMenuOrderNumber)
          Adds the given menu entry as root menu entry.
 MenuItemDef setMobileMenu(MenuItemDef mobileParentEntry, Class<? extends org.apache.wicket.Page> mobilePageClass, int mobileMenuOrderNumber)
          TODO: Not yet supported.
 void setMobileMenuSupport(boolean mobileMenuSupport)
          Will be automatically set if any setter regarding mobile menu properties is calles (with not-null params), default is false.
 MenuItemDef setVisible(boolean visible)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MenuItemDef

public MenuItemDef()

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   Class<? extends org.apache.wicket.Page> pageClass,
                   UserRightId requiredRightId,
                   UserRightValue... requiredRightValues)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
pageClass - The linked page class (if the user clicks on this menu entry).
requiredRightId - Reduce the visibility of this menu entry (if wanted): which user right is required?
requiredRightValues - Reducing the visibility: which right values are required?

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   Class<? extends org.apache.wicket.Page> pageClass,
                   String[] params,
                   UserRightId requiredRightId,
                   UserRightValue... requiredRightValues)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
pageClass - The linked page class (if the user clicks on this menu entry).
params - Parameters used when calling the pageClass (PageParameters).
requiredRightId - Reduce the visibility of this menu entry (if wanted): which user right is required?
requiredRightValues - Reducing the visibility: which right values are required?

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   Class<? extends org.apache.wicket.Page> pageClass,
                   ProjectForgeGroup... visibleForGroups)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
pageClass - The linked page class (if the user clicks on this menu entry).
visibleForGroups - Reduce the visibility of this menu entry (if wanted).

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   Class<? extends org.apache.wicket.Page> pageClass,
                   String[] params,
                   ProjectForgeGroup... visibleForGroups)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
pageClass - The linked page class (if the user clicks on this menu entry).
params - Parameters used when calling the pageClass (PageParameters).
visibleForGroups - Reduce the visibility of this menu entry (if wanted).

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   String url,
                   ProjectForgeGroup... visibleForGroups)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
url - The linked url (if the user clicks on this menu entry).
visibleForGroups - Reduce the visibility of this menu entry (if wanted).

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   String url,
                   boolean newWindow,
                   ProjectForgeGroup... visibleForGroups)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
url - The linked url (if the user clicks on this menu entry).
newWindow - If true, then the link will be opened in a new browser window.
visibleForGroups - Reduce the visibility of this menu entry (if wanted).

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   ProjectForgeGroup... visibleForGroups)
A menu entry without a link (e. g. a parent menu entry).

Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
visibleForGroups - Reduce the visibility of this menu entry (if wanted).

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   String url,
                   UserRightId requiredRightId,
                   UserRightValue... requiredRightValues)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
url - The linked url (if the user clicks on this menu entry).
requiredRightId - Reduce the visibility of this menu entry (if wanted): which user right is required?
requiredRightValues - Reducing the visibility: which right values are required?

MenuItemDef

public MenuItemDef(MenuItemDef parent,
                   String id,
                   int orderNumber,
                   String i18nKey,
                   String url,
                   boolean newWindow,
                   UserRightId requiredRightId,
                   UserRightValue... requiredRightValues)
Parameters:
parent - The parent menu entry
id - The unique id
orderNumber - The order of the sibling menu entries is done implemented by this order number (ascending order).
i18nKey - For displaying the menu entry localized.
url - The linked url (if the user clicks on this menu entry).
newWindow - If true, then the link will be opened in a new browser window.
requiredRightId - Reduce the visibility of this menu entry (if wanted): which user right is required?
requiredRightValues - Reducing the visibility: which right values are required?
Method Detail

isVisible

protected boolean isVisible(MenuBuilderContext context)
Overwrite this if you need special access checking.

Parameters:
context -
Returns:
true (at default).

isVisible

public boolean isVisible()

setVisible

public MenuItemDef setVisible(boolean visible)
Parameters:
visible -
Returns:
this for chaining.

createMenuEntry

protected MenuEntry createMenuEntry(Menu menu,
                                    MenuBuilderContext context)
Returns:
null if not visible otherwise the created MenuEntry.

afterMenuEntryCreation

protected void afterMenuEntryCreation(MenuEntry createdMenuEntry,
                                      MenuBuilderContext context)
Override this method if some modifications needed after a menu entry for an user's menu is created.

Parameters:
createdMenuEntry - The fresh created menu entry (is never null).
context -

getParent

public MenuItemDef getParent()
Returns:
parent menu item definition or null if this definition represents a top level menu item.

getId

public String getId()
Returns:
Id used for html markup and for referencing in config.xml.

getOrderNumber

public int getOrderNumber()
Order number for sorting menu entries.


setDesktopMenuSupport

public void setDesktopMenuSupport(boolean desktopMenuSupport)
If set to false then this menu entry will not be displayed in the classical web menu version. Default is true.

Parameters:
desktopMenuSupport -

setMobileMenuSupport

public void setMobileMenuSupport(boolean mobileMenuSupport)
Will be automatically set if any setter regarding mobile menu properties is calles (with not-null params), default is false.

Parameters:
mobileMenuSupport -

getMobileMenuOrderNumber

public int getMobileMenuOrderNumber()
Order number for sorting menu entries (mobile menu).


getMobileParentMenu

public MenuItemDef getMobileParentMenu()
Returns:
The parent menu entry of the mobile menu.

setMobileMenu

public MenuItemDef setMobileMenu(MenuItemDef mobileParentEntry,
                                 Class<? extends org.apache.wicket.Page> mobilePageClass,
                                 int mobileMenuOrderNumber)
TODO: Not yet supported. The menu entry is set as a top level menu entry.

Parameters:
mobileParentEntry -
mobileMenuOrderNumber -
Returns:
this for chaining.

setMobileMenu

public MenuItemDef setMobileMenu(Class<? extends org.apache.wicket.Page> mobilePageClass,
                                 int mobileMenuOrderNumber)
Adds the given menu entry as root menu entry.

Parameters:
mobileParentEntry -
mobileMenuOrderNumber -
Returns:
this for chaining.

getI18nKey

public String getI18nKey()
Returns:
Key used in the i18n resource bundle.

getPageClass

public Class<? extends org.apache.wicket.Page> getPageClass()
Returns:
Wicket page or null for non Wicket pages.

getMobilePageClass

public Class<? extends org.apache.wicket.Page> getMobilePageClass()
Returns:
Wicket page or null for non Wicket pages.

isWicketPage

public boolean isWicketPage()
Returns:
true, if pageClass (Wicket page) is given otherwise false.

hasUrl

public boolean hasUrl()

isLink

public boolean isLink()
Returns:
true if this menu entry has a link (to a Wicket page or an url). Otherwise false (e. g. if this menu item def represents only a menu with sub menus).

getUrl

public String getUrl()
Returns:
The url for non-Wicket pages (relative to "secure/") or the bookmarkable url for Wicket pages (relative to "wa/").

getParams

public String[] getParams()

isNewWindow

public boolean isNewWindow()

getVisibleForGroups

public ProjectForgeGroup[] getVisibleForGroups()

getRequiredRightId

public UserRightId getRequiredRightId()

getRequiredRightValues

public UserRightValue[] getRequiredRightValues()

hasRight

public boolean hasRight(AccessChecker accessChecker,
                        PFUserDO loggedInUser)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 Kai Reinhard. All Rights Reserved.