Class ContextMenu
- java.lang.Object
-
- com.microstrategy.web.app.gui.ContextMenu
-
public class ContextMenu extends java.lang.Object
A
ContextMenu
is displayed when the end user makes click using the right mouse button on an element in the interface; the menu displays a list with different actions associated with that element.A
ContextMenu
is basically a collection ofContextMenuItem
objects. EachContextMenuItem
represents a single option to the end user.Context menus can and should be configured using external xml files. All Microstrategy Web transforms that display context-menus have their
AbstractAppTransform.contextMenus
formal parameter assigned in the style catalog. Even those transforms that display no context menus out of the box can be configured to display them simply by creating a new xml definition file and setting thecontextMenus
formal parameter.Optionally, a
ContextMenu
can be populated programatically using one of the severaladdItem
methods it exposes. Once populated, theContextMenu
should be attached to the corresponding HTML tag by calling theattachTo(com.microstrategy.web.tags.Tag)
method or by appending the necessary attributes returned by thegetTriggerString()
- Since:
- MicroStrategy Web 7.3.1 or earlier
- See Also:
ContextMenuManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ContextMenu.DefaultContextMenuItemBuilder
This class is the default implementation of aContextMenuItemBuilder
.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATT_FOR_CONTEXT_MENU_INDICES
static java.lang.String
ATT_FOR_CONTEXT_MENU_MANAGER_ID
static int
TRIGGER_ITEM
From the attributes necessary to trigger the display of theContextMenu
, this represents the id of this context-menu.static int
TRIGGER_MENU
From the attributes necessary to trigger the display of theContextMenu
, this represents the name of theContextMenuManager
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ContextMenuItem
addItem(ContextMenuItem item)
Adds an existingContextMenuItem
instance to the list of options available in thisContextMenu
.ContextMenuItem
addItem(java.lang.String name)
Deprecated.this method may cause context menus to break due to an optimization that finds duplicated menu items, please useaddItem(ContextMenuItem item)
ContextMenuItem
addItem(java.lang.String name, ContextMenu submenu)
Adds a newContextMenuItem
with the given name, and sets the givenContextMenu
as its subMenu; this sub-menu will automatically be displayed when the item is selected.ContextMenuItem
addItem(java.lang.String name, java.lang.String url)
Adds a newContextMenuItem
with the given name and sets its action to be to open the given URL.ContextMenuItem
addItem(java.lang.String name, java.lang.String jsSubmitFunction, java.lang.String jsParameters)
Adds a newContextMenuItem
with the given name and sets its action to be to execute the given javascript function using the corresponding parameters.void
addSeparator()
Adds a new separator item to theContextMenu
.void
addTagAttributes(java.util.Map<java.lang.String,java.lang.String> atts)
Adds to the givenMap
(name/value pairs) all attributes required in an HTML Tag to trigger the display of the context-menu.void
addTagAttributes(java.util.Map<java.lang.String,java.lang.String> atts, int infoFlag)
Appends to the given Map those attributes required in an HTML Tag to trigger the display of the context-menu.void
attachTo(Tag tag)
Appends to the HTMLTag
all those attributes required to trigger the display of the context-menu.void
attachTo(Tag tag, int infoFlag)
Appends to the HTMLTag
those attributes required to trigger the display of the context-menu.static java.util.Map<java.lang.String,java.lang.String>
getEmptyTagAttributes()
protected int
getID()
Deprecated.This method should only be used internally.java.lang.String
getKey()
Deprecated.This method should only be used internally.java.lang.String
getManagerName()
Returns the name of the Context Menu Manager to whom this ContextMenu is associated.java.lang.String
getMenuIndicesAttribute()
int
getMenuSize()
Returns the number of current menu-items in this context-menu.java.lang.String
getName()
Returns the name of thisContextMenu
.protected int
getParentID()
Deprecated.This method should only be used internally.java.util.Map<java.lang.String,java.lang.String>
getTagAttributes()
Returns aMap
(name/value pairs) of all attributes required to append into an HTML Tag to trigger the display of the context-menu.java.util.Map<java.lang.String,java.lang.String>
getTagAttributes(int infoFlag)
Returns aMap
(name/value pairs) of those attributes required to append into an HTML Tag to trigger the display of the context-menu.MarkupOutput
getTriggerOutput()
Deprecated.java.lang.String
getTriggerString()
Returns aString
object with all the attributes that should be used inside an HTML tag to trigger the display of the context-menu.java.lang.String
getTriggerString(int infoFlag)
Returns aString
object with those attributes that should be used inside an HTML tag to trigger the display of the context-menu.protected void
setID(int ID)
Deprecated.This method should only be used internally.void
setManagerName(java.lang.String newValue)
Deprecated.This method should only be used internally.void
setName(java.lang.String name)
Deprecated.The name of theContextMenu
should be provided as part of the constructor.protected void
setParentID(int parentID)
Deprecated.This method should only be used internally.void
startGroup()
After calling this method, thisContextMenu
will append a separator when a newContextMenuItem
is added.
-
-
-
Field Detail
-
ATT_FOR_CONTEXT_MENU_INDICES
public static final java.lang.String ATT_FOR_CONTEXT_MENU_INDICES
- Since:
- MicroStrategy Web 9.0.1
- See Also:
- Constant Field Values
-
ATT_FOR_CONTEXT_MENU_MANAGER_ID
public static final java.lang.String ATT_FOR_CONTEXT_MENU_MANAGER_ID
- Since:
- MicroStrategy Web 9.0.1
- See Also:
- Constant Field Values
-
TRIGGER_ITEM
public static final int TRIGGER_ITEM
From the attributes necessary to trigger the display of theContextMenu
, this represents the id of this context-menu.- Since:
- MicroStrategy Web 8.0.0
- See Also:
- Constant Field Values
-
TRIGGER_MENU
public static final int TRIGGER_MENU
From the attributes necessary to trigger the display of theContextMenu
, this represents the name of theContextMenuManager
.- Since:
- MicroStrategy Web 8.0.0
- See Also:
- Constant Field Values
-
-
Method Detail
-
addItem
public ContextMenuItem addItem(ContextMenuItem item)
Adds an existingContextMenuItem
instance to the list of options available in thisContextMenu
.- Parameters:
item
- TheContextMenuItem
to be added.- Returns:
- The same
ContextMenuItem
-
addItem
@Deprecated public ContextMenuItem addItem(java.lang.String name)
Deprecated.this method may cause context menus to break due to an optimization that finds duplicated menu items, please useaddItem(ContextMenuItem item)
Adds a newContextMenuItem
with the specified name to the ContextMenu.- Parameters:
name
- Name of the newContextMenuItem
to be added.- Returns:
- The new
ContextMenuItem
instance added.
-
addItem
public ContextMenuItem addItem(java.lang.String name, java.lang.String url)
Adds a newContextMenuItem
with the given name and sets its action to be to open the given URL. It is equivalent to:ContextMenuItem item = new ContextMenuItem(name); item.setURL(url); addItem(item);
- Parameters:
name
- name of the new item to be added.url
- URL to be associatied with the item. If the Item is clicked by the user, she will be redirected to such location.- Returns:
- The new
ContextMenuItem
instance added.
-
addItem
public ContextMenuItem addItem(java.lang.String name, java.lang.String jsSubmitFunction, java.lang.String jsParameters)
Adds a newContextMenuItem
with the given name and sets its action to be to execute the given javascript function using the corresponding parameters. It is equivalent to:ContextMenuItem item = new ContextMenuItem(name); item.setJSCode(jsSubmitFunction + "(" + jsParameters + ");"); addItem(item);
- Parameters:
name
- name of the new item to be addedjsSubmitFunction
- Name of the javascript function to executejsParameters
- String with the list of the paramters required by the javascript function.- Returns:
- the ContextMenuItem instance added.
-
addSeparator
public void addSeparator()
Adds a new separator item to theContextMenu
. A separator is identified in the collection ofContextMenuItem
children as those whose name is "-".
-
addItem
public ContextMenuItem addItem(java.lang.String name, ContextMenu submenu)
Adds a newContextMenuItem
with the given name, and sets the givenContextMenu
as its subMenu; this sub-menu will automatically be displayed when the item is selected. This method is equivalent to calling:ContextMenuItem item = new ContextMenuItem(name); item.setSubMenu(submenu); addItem(item);
- Parameters:
name
- name of the new item to be added.submenu
-ContextMenu
containing the submenu items of the current ContextMenu.- Returns:
- The ContextMenuItem
-
setID
@Deprecated protected void setID(int ID)
Deprecated.This method should only be used internally. It will be marked as private in future versions.Sets the id of this menu.
-
getID
@Deprecated protected int getID()
Deprecated.This method should only be used internally. It will be marked as private in future versions.Returns the ID of thisContextMenu
-
setParentID
@Deprecated protected void setParentID(int parentID)
Deprecated.This method should only be used internally. It will be marked as private in future versions.Used by thoseContextMenu
objects which are actually submenus, to know the ID of their parent menu.
-
getParentID
@Deprecated protected int getParentID()
Deprecated.This method should only be used internally. It will be marked as private in future versions.For thoseContextMenu
objects that are actually submenus, return the ID of their parentContextMenu
.
-
getTriggerOutput
@Deprecated public MarkupOutput getTriggerOutput()
Deprecated.Returns a newMarkupOutput
object with the attributes that should be used inside an HTML tag to trigger the display of the context-menu.
-
getTriggerString
public java.lang.String getTriggerString()
Returns aString
object with all the attributes that should be used inside an HTML tag to trigger the display of the context-menu.
-
getTriggerString
public java.lang.String getTriggerString(int infoFlag)
Returns aString
object with those attributes that should be used inside an HTML tag to trigger the display of the context-menu. TheinfoFlag
parameter receives a flagged enumeration specifying what information should be included. Possible values:- Since:
- MicroStrategy Web 8.0.0
-
attachTo
public void attachTo(Tag tag)
Appends to the HTMLTag
all those attributes required to trigger the display of the context-menu.- Since:
- MicroStrategy Web 8.0.0
-
attachTo
public void attachTo(Tag tag, int infoFlag)
Appends to the HTMLTag
those attributes required to trigger the display of the context-menu.
TheinfoFlag
parameter receives a flagged enumeration specifying what information should be included. Possible values:- Since:
- MicroStrategy Web 8.0.0
-
getTagAttributes
public java.util.Map<java.lang.String,java.lang.String> getTagAttributes()
Returns aMap
(name/value pairs) of all attributes required to append into an HTML Tag to trigger the display of the context-menu.- Since:
- MicroStrategy Web 8.0.0
-
getTagAttributes
public java.util.Map<java.lang.String,java.lang.String> getTagAttributes(int infoFlag)
Returns aMap
(name/value pairs) of those attributes required to append into an HTML Tag to trigger the display of the context-menu. TheinfoFlag
parameter receives a flagged enumeration specifying what information should be included. Possible values:- Since:
- MicroStrategy Web 8.0.0
-
getEmptyTagAttributes
public static java.util.Map<java.lang.String,java.lang.String> getEmptyTagAttributes()
- Since:
- MicroStrategy Web 9.0.1
-
addTagAttributes
public void addTagAttributes(java.util.Map<java.lang.String,java.lang.String> atts)
Adds to the givenMap
(name/value pairs) all attributes required in an HTML Tag to trigger the display of the context-menu.- Since:
- MicroStrategy Web 8.1.0
-
addTagAttributes
public void addTagAttributes(java.util.Map<java.lang.String,java.lang.String> atts, int infoFlag)
Appends to the given Map those attributes required in an HTML Tag to trigger the display of the context-menu. TheinfoFlag
parameter receives a flagged enumeration specifying what information should be included. Possible values:- Since:
- MicroStrategy Web 8.1.0
-
getMenuIndicesAttribute
public java.lang.String getMenuIndicesAttribute()
- Since:
- MicroStrategy Web 9.0.1
-
startGroup
public void startGroup()
After calling this method, thisContextMenu
will append a separator when a newContextMenuItem
is added.- Since:
- MicroStrategy Web 8.0.0
-
getKey
@Deprecated public java.lang.String getKey()
Deprecated.This method should only be used internally. It will be marked as private in future versions.Returns aString
with the key identifier of this ContextMenu.- Returns:
- String object.
-
setName
@Deprecated public void setName(java.lang.String name)
Deprecated.The name of theContextMenu
should be provided as part of the constructor.Sets the name of thisContextMenu
.- Since:
- MicroStrategy Web 8.0.0
-
getName
public java.lang.String getName()
Returns the name of thisContextMenu
.- Since:
- MicroStrategy Web 8.0.0
-
setManagerName
@Deprecated public void setManagerName(java.lang.String newValue)
Deprecated.This method should only be used internally. It will be marked as private in future versions.Sets the name of the Context Menu Manager.
-
getManagerName
public java.lang.String getManagerName()
Returns the name of the Context Menu Manager to whom this ContextMenu is associated.- Since:
- MicroStrategy Web 8.0.0
-
getMenuSize
public int getMenuSize()
Returns the number of current menu-items in this context-menu.- Since:
- MicroStrategy Web 7.5.1
-
-