Class 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 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 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 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(com.microstrategy.web.tags.Tag) method or by appending the necessary attributes returned by the getTriggerString()

    Since:
    MicroStrategy Web 7.3.1 or earlier
    See Also:
    ContextMenuManager
    • 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 the ContextMenu, this represents the id of this context-menu.
      static int TRIGGER_MENU
      From the attributes necessary to trigger the display of the ContextMenu, this represents the name of the ContextMenuManager.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      ContextMenuItem addItem​(ContextMenuItem item)
      Adds an existing ContextMenuItem instance to the list of options available in this ContextMenu.
      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 use addItem(ContextMenuItem item)
      ContextMenuItem addItem​(java.lang.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.
      ContextMenuItem addItem​(java.lang.String name, java.lang.String url)
      Adds a new ContextMenuItem 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 new ContextMenuItem 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 the ContextMenu.
      void addTagAttributes​(java.util.Map<java.lang.String,​java.lang.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​(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 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 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 this ContextMenu.
      protected int getParentID()
      Deprecated.
      This method should only be used internally.
      java.util.Map<java.lang.String,​java.lang.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.
      java.util.Map<java.lang.String,​java.lang.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()
      Deprecated.
      java.lang.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.
      java.lang.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.
      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 the ContextMenu 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, this ContextMenu will append a separator when a new ContextMenuItem is added.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 the ContextMenu, 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 the ContextMenu, this represents the name of the ContextMenuManager.
        Since:
        MicroStrategy Web 8.0.0
        See Also:
        Constant Field Values
    • Method Detail

      • 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 use addItem(ContextMenuItem item)
        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.
      • addItem

        public ContextMenuItem addItem​(java.lang.String name,
                                       java.lang.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.
      • addItem

        public ContextMenuItem addItem​(java.lang.String name,
                                       java.lang.String jsSubmitFunction,
                                       java.lang.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.
      • addSeparator

        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 "-".
      • addItem

        public ContextMenuItem addItem​(java.lang.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
      • 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 this ContextMenu
      • 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 those ContextMenu 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 those ContextMenu objects that are actually submenus, return the ID of their parent ContextMenu.
      • getTriggerOutput

        @Deprecated
        public MarkupOutput getTriggerOutput()
        Deprecated.
        Returns a new MarkupOutput 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 a String 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 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
        Since:
        MicroStrategy Web 8.0.0
      • attachTo

        public void attachTo​(Tag tag)
        Appends to the HTML Tag 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 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
        Since:
        MicroStrategy Web 8.0.0
      • getTagAttributes

        public java.util.Map<java.lang.String,​java.lang.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.
        Since:
        MicroStrategy Web 8.0.0
      • getTagAttributes

        public java.util.Map<java.lang.String,​java.lang.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
        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 given Map (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. The infoFlag parameter receives a flagged enumeration specifying what information should be included. Possible values:
        1. TRIGGER_ITEM
        2. TRIGGER_MENU
        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, this ContextMenu will append a separator when a new ContextMenuItem 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 a String with the key identifier of this ContextMenu.
        Returns:
        String object.
      • setName

        @Deprecated
        public void setName​(java.lang.String name)
        Deprecated.
        The name of the ContextMenu should be provided as part of the constructor.
        Sets the name of this ContextMenu.
        Since:
        MicroStrategy Web 8.0.0
      • getName

        public java.lang.String getName()
        Returns the name of this ContextMenu.
        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