public abstract class

AbstractFolderContextMenuItemBuilder

extends ContextMenu.DefaultContextMenuItemBuilder
java.lang.Object
   ↳ com.microstrategy.web.app.gui.ContextMenu.DefaultContextMenuItemBuilder
     ↳ com.microstrategy.web.app.transforms.contextmenus.AbstractFolderContextMenuItemBuilder
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This class is used by Microstrategy Web as a base class for those used to populate context-menus used in the Folder page.

New context-menus-builders can be created simply by extending this class and implementing three methods:

  1. getContextMenuFlag(): Used to maintain backwards compatibility, these builders check for the contextMenuFlags FormalParameter to make sure they can enabled. New builders should return in this method the flag associated with the context-menu-item, for example, a "copy" context-menu would return CM_FLAG_COPY.
  2. isActionEnabled(): Besides checking the context-menu flag, this method enables the builder to check for other conditions to enable the action. For example, to check whether the user has enough privileges/access control. Subclasses can ultimately delegate this logic to the transform.
  3. getEvent(): This method returns the WebEvent to execute when this menu item is selected. Also in this case, subclasses can ultimately delegate this logic to the transform.

The following would be an example of a subclass used to populate an "Edit" context-menu-item:

 public class FolderEdit extends AbstractFolderContextMenuItemBuilder {

     public FolderEdit(Shortcut definition) {
         super(definition);
     }

     protected int getContextMenuFlag() {
      //No flag is defined for this action:
         return FolderViewTransform.CM_FLAG_ALL;
     }

     protected boolean isActionEnabled(TransformContext context) {
         FolderViewTransform t = getTransform(context);
         WebObjectInfo object = getObjectInfo(context);

         return t.canEdit(object);
     }

     protected WebEvent getEvent(TransformContext context) {
         FolderViewTransform t = getTransform(context);
         WebObjectInfo object = getObjectInfo(context);

         return t.getEditEvent(object);
     }

 }
 

Summary

Public Constructors
AbstractFolderContextMenuItemBuilder(Shortcut definition)
Public Methods
ContextMenuItem createItem(TransformContext context)
Creates the item and sets its javascript to submit the corresponding event using the iFrame.
String getItemKey(TransformContext context)
Retrieve the key will be set on the context menu item corresponding to the context input.
boolean isItemAvailable(TransformContext context)
Returns true if the corresponding flag is on and the the corresponding action is available.
Protected Methods
abstract int getContextMenuFlag()
Indicates the abstract class which is the context-menu flag associated with this item.
WebEvent getEvent(TransformContext context)
Provides the abstract class with the corresponding event to execution with this item.
String getJSCode(TransformContext context)
Returns the javascript code to use with this context-menu-item
String getLinkForMenuItem(TransformContext context, FolderViewTransform transform)
WebObjectInfo getObjectInfo(TransformContext context)
Helper method to retrieve the WebObjectInfo from the context.
String getTarget(TransformContext context)
FolderViewTransform getTransform(TransformContext context)
Helper method to retrieve the FolderViewTransform from the context.
String iframeParam(FolderViewTransform transform)
abstract boolean isActionEnabled(TransformContext context)
Indicates the abstract class if the corresponding action of this item is available.
[Expand]
Inherited Methods
From class com.microstrategy.web.app.gui.ContextMenu.DefaultContextMenuItemBuilder
From class java.lang.Object
From interface com.microstrategy.web.app.gui.ContextMenuItemBuilder

Public Constructors

public AbstractFolderContextMenuItemBuilder (Shortcut definition)

Public Methods

public ContextMenuItem createItem (TransformContext context)

Creates the item and sets its javascript to submit the corresponding event using the iFrame.

Parameters
context TransformContext with context information.
Returns
  • a new instance of a ContextMenuItem.

public String getItemKey (TransformContext context)

Retrieve the key will be set on the context menu item corresponding to the context input. The context menu item generated based on the same context input will have the same key. This method can be called by context menu before calling createItem(TransformContext) to check whether the item already exists in the menu to avoid unnecessary creation.

Parameters
context The context for context menu item creation
Returns
  • The key for the context menu item if created using the context. By default null will be return, which means build has no knowledge about the item key. Then context menu item may generate the key by itself. For builder who wants avoid unnecessary item creation should take advantage of this method by overriding with a meaningful implementation.

public boolean isItemAvailable (TransformContext context)

Returns true if the corresponding flag is on and the the corresponding action is available.

Parameters
context TransformContext with context information.
Returns
  • true if the context-menu-item is available and should be included.

Protected Methods

protected abstract int getContextMenuFlag ()

Indicates the abstract class which is the context-menu flag associated with this item.

protected WebEvent getEvent (TransformContext context)

Provides the abstract class with the corresponding event to execution with this item.

protected String getJSCode (TransformContext context)

Returns the javascript code to use with this context-menu-item

protected String getLinkForMenuItem (TransformContext context, FolderViewTransform transform)

protected WebObjectInfo getObjectInfo (TransformContext context)

Helper method to retrieve the WebObjectInfo from the context.

protected String getTarget (TransformContext context)

protected FolderViewTransform getTransform (TransformContext context)

Helper method to retrieve the FolderViewTransform from the context.

protected String iframeParam (FolderViewTransform transform)

protected abstract boolean isActionEnabled (TransformContext context)

Indicates the abstract class if the corresponding action of this item is available.