public class

ContextMenu

extends Object
java.lang.Object
   ↳ com.microstrategy.web.app.gui.ContextMenu

Class Overview

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 of ContextMenuItem objects. Each ContextMenuItem 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 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 the contextMenus formal parameter.

Optionally, a ContextMenu can be populated programatically using one of the several addItem methods it exposes. Once populated, the ContextMenu should be attached to the corresponding HTML tag by calling the attachTo(Tag) method or by appending the necessary attributes returned by the getTriggerString()

Summary

Nested Classes
class ContextMenu.DefaultContextMenuItemBuilder This class is the default implementation of a ContextMenuItemBuilder
Constants
String ATT_FOR_CONTEXT_MENU_INDICES
String ATT_FOR_CONTEXT_MENU_MANAGER_ID
int TRIGGER_ITEM From the attributes necessary to trigger the display of the ContextMenu, this represents the id of this context-menu.
int TRIGGER_MENU From the attributes necessary to trigger the display of the ContextMenu, this represents the name of the ContextMenuManager.
Public Methods
ContextMenuItem addItem(String name)
This method is deprecated. this method may cause context menus to break due to an optimization that finds duplicated menu items, please use addItem(ContextMenuItem)
ContextMenuItem addItem(String name, String jsSubmitFunction, String jsParameters)
Adds a new ContextMenuItem with the given name and sets its action to be to execute the given javascript function using the corresponding parameters.
ContextMenuItem addItem(String name, String url)
Adds a new ContextMenuItem with the given name and sets its action to be to open the given URL.
ContextMenuItem addItem(ContextMenuItem item)
Adds an existing ContextMenuItem instance to the list of options available in this ContextMenu.
ContextMenuItem addItem(String name, ContextMenu submenu)
Adds a new ContextMenuItem with the given name, and sets the given ContextMenu as its subMenu; this sub-menu will automatically be displayed when the item is selected.
void addSeparator()
Adds a new separator item to the ContextMenu.
void addTagAttributes(Map<String, String> atts)
Adds to the given Map (name/value pairs) all attributes required in an HTML Tag to trigger the display of the context-menu.
void addTagAttributes(Map<String, 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 HTML Tag all those attributes required to trigger the display of the context-menu.
void attachTo(Tag tag, int infoFlag)
Appends to the HTML Tag those attributes required to trigger the display of the context-menu.
static Map<String, String> getEmptyTagAttributes()
String getKey()
This method is deprecated. This method should only be used internally. It will be marked as private in future versions.
String getManagerName()
Returns the name of the Context Menu Manager to whom this ContextMenu is associated.
String getMenuIndicesAttribute()
int getMenuSize()
Returns the number of current menu-items in this context-menu.
String getName()
Returns the name of this ContextMenu.
Map<String, String> getTagAttributes()
Returns a Map (name/value pairs) of all attributes required to append into an HTML Tag to trigger the display of the context-menu.
Map<String, String> getTagAttributes(int infoFlag)
Returns a Map (name/value pairs) of those attributes required to append into an HTML Tag to trigger the display of the context-menu.
MarkupOutput getTriggerOutput()
This method is deprecated. Use getTriggerString()
String getTriggerString()
Returns a String object with all the attributes that should be used inside an HTML tag to trigger the display of the context-menu.
String getTriggerString(int infoFlag)
Returns a String object with those attributes that should be used inside an HTML tag to trigger the display of the context-menu.
void setManagerName(String newValue)
This method is deprecated. This method should only be used internally. It will be marked as private in future versions.
void setName(String name)
This method is deprecated. The name of the ContextMenu should be provided as part of the constructor.
void startGroup()
After calling this method, this ContextMenu will append a separator when a new ContextMenuItem is added.
Protected Methods
int getID()
This method is deprecated. This method should only be used internally. It will be marked as private in future versions.
int getParentID()
This method is deprecated. This method should only be used internally. It will be marked as private in future versions.
void setID(int ID)
This method is deprecated. This method should only be used internally. It will be marked as private in future versions.
void setParentID(int parentID)
This method is deprecated. This method should only be used internally. It will be marked as private in future versions.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ATT_FOR_CONTEXT_MENU_INDICES

Constant Value: "CX"

public static final String ATT_FOR_CONTEXT_MENU_MANAGER_ID

Constant Value: "CXID"

public static final int TRIGGER_ITEM

From the attributes necessary to trigger the display of the ContextMenu, this represents the id of this context-menu.

Constant Value: 1 (0x00000001)

public static final int TRIGGER_MENU

From the attributes necessary to trigger the display of the ContextMenu, this represents the name of the ContextMenuManager.

Constant Value: 2 (0x00000002)

Public Methods

public ContextMenuItem addItem (String name)

This method is deprecated.
this method may cause context menus to break due to an optimization that finds duplicated menu items, please use addItem(ContextMenuItem)

Adds a new ContextMenuItem with the specified name to the ContextMenu.

Parameters
name Name of the new ContextMenuItem to be added.
Returns
  • The new ContextMenuItem instance added.

public ContextMenuItem addItem (String name, String jsSubmitFunction, String jsParameters)

Adds a new ContextMenuItem 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 added
jsSubmitFunction Name of the javascript function to execute
jsParameters String with the list of the paramters required by the javascript function.
Returns
  • the ContextMenuItem instance added.

public ContextMenuItem addItem (String name, String url)

Adds a new ContextMenuItem 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.

public ContextMenuItem addItem (ContextMenuItem item)

Adds an existing ContextMenuItem instance to the list of options available in this ContextMenu.

Parameters
item The ContextMenuItem to be added.
Returns
  • The same ContextMenuItem

public ContextMenuItem addItem (String name, ContextMenu submenu)

Adds a new ContextMenuItem with the given name, and sets the given ContextMenu 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

public void addSeparator ()

Adds a new separator item to the ContextMenu. A separator is identified in the collection of ContextMenuItem children as those whose name is "-".

public void addTagAttributes (Map<String, String> atts)

Adds to the given Map (name/value pairs) all attributes required in an HTML Tag to trigger the display of the context-menu.

public void addTagAttributes (Map<String, String> atts, int infoFlag)

Appends to the given Map those attributes required in an HTML Tag to trigger the display of the context-menu. The infoFlag parameter receives a flagged enumeration specifying what information should be included. Possible values:

  1. TRIGGER_ITEM
  2. TRIGGER_MENU

public void attachTo (Tag tag)

Appends to the HTML Tag all those attributes required to trigger the display of the context-menu.

public void attachTo (Tag tag, int infoFlag)

Appends to the HTML Tag those attributes required to trigger the display of the context-menu.
The infoFlag parameter receives a flagged enumeration specifying what information should be included. Possible values:

  1. TRIGGER_ITEM
  2. TRIGGER_MENU

public static Map<String, String> getEmptyTagAttributes ()

public String getKey ()

This method is deprecated.
This method should only be used internally. It will be marked as private in future versions.

Returns a String with the key identifier of this ContextMenu.

Returns
  • String object.

public String getManagerName ()

Returns the name of the Context Menu Manager to whom this ContextMenu is associated.

public String getMenuIndicesAttribute ()

public int getMenuSize ()

Returns the number of current menu-items in this context-menu.

public String getName ()

Returns the name of this ContextMenu.

public Map<String, String> getTagAttributes ()

Returns a Map (name/value pairs) of all attributes required to append into an HTML Tag to trigger the display of the context-menu.

public Map<String, String> getTagAttributes (int infoFlag)

Returns a Map (name/value pairs) of those attributes required to append into an HTML Tag to trigger the display of the context-menu. The infoFlag parameter receives a flagged enumeration specifying what information should be included. Possible values:

  1. TRIGGER_ITEM
  2. TRIGGER_MENU

public MarkupOutput getTriggerOutput ()

This method is deprecated.
Use getTriggerString()

Returns a new MarkupOutput object with the attributes that should be used inside an HTML tag to trigger the display of the context-menu.

public String getTriggerString ()

Returns a String object with all the attributes that should be used inside an HTML tag to trigger the display of the context-menu.

public String getTriggerString (int infoFlag)

Returns a String object with those attributes that should be used inside an HTML tag to trigger the display of the context-menu. The infoFlag parameter receives a flagged enumeration specifying what information should be included. Possible values:

  1. TRIGGER_ITEM
  2. TRIGGER_MENU

public void setManagerName (String newValue)

This method is 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.

public void setName (String name)

This method is deprecated.
The name of the ContextMenu should be provided as part of the constructor.

Sets the name of this ContextMenu.

public void startGroup ()

After calling this method, this ContextMenu will append a separator when a new ContextMenuItem is added.

Protected Methods

protected int getID ()

This method is deprecated.
This method should only be used internally. It will be marked as private in future versions.

Returns the ID of this ContextMenu

protected int getParentID ()

This method is deprecated.
This method should only be used internally. It will be marked as private in future versions.

For those ContextMenu objects that are actually submenus, return the ID of their parent ContextMenu.

protected void setID (int ID)

This method is deprecated.
This method should only be used internally. It will be marked as private in future versions.

Sets the id of this menu.

protected void setParentID (int parentID)

This method is deprecated.
This method should only be used internally. It will be marked as private in future versions.

Used by those ContextMenu objects which are actually submenus, to know the ID of their parent menu.