MicroStrategy ONE

Adding Context Menu Items that Display Information about the Object

This customization scenario illustrates how to add context menu items that display information about an object. Information about the object is called context information. Some context information, such as the object ID, is available through FolderViewtransform, the transform that is used by default to render the Folder Browsing page. Other context information requires the creation of a custom transform to provide the information.

There are two customizations performed in this scenario. For both examples, you add a new context menu item that displays certain information about the selected object, a folder object in this example, when the context menu item is clicked. 

Displaying object information using the default transform

In the first example in this scenario, you add a new context menu item, called View Object ID, to context menus on the Folder Browsing page. When this context menu item is clicked, it displays the ID of the selected object (in this case, the folder ID). This information is available from FolderViewtransform.

Before customization:

After customization:

After you have performed the customization and saved your changes, the View Object ID menu item appears on the context menu for the Folder Browsing page when you right-click a folder. If you click View Object ID, a message box displays the Folder ID.

This customization can be accomplished using either of the following methods:

Deploying the plug-in provided with MicroStrategy SDK

MicroStrategy SDK provides a plug-in (ZIP file) that can simply be extracted to thepluginsfolder to view the customization in MicroStrategy Web. The following steps guide you in locating the plug-in and deploying it. 

  1. Access the plug-in: JSP version or ASP .NET version

  2. Extract the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder.   

  3. Launch MicroStrategy Web to view the customization.

Using the Web Customization Editor to create a plug-in

MicroStrategy SDK provides a Web Customization Editor that can be used to create a customization plug-in. The following steps guide you in creating the plug-in and deploying it. 

  1. Launch the Web Customization Editor

  2. Create a new plug-in and give it a meaningful name. For example: AddingContextMenuDefaultTransform

  3. Exit the Web Customization Editor. 

  4. Use the Eclipse IDE to create a specialized ContextMenuItem builder class. The sample, CustomAlert.java, contains the entire code for this custom builder class. 

  5. Compile CustomAlert.java and place the class file inside the classes folder of this customization plug-in adhering to the package structure. For example: plugins\pluginName\WEB-INF\classes\com\microstrategy\sdk\samples\transforms\contextmenu

  6. If the Web Customization Editor is closed, launch it again and access your plug-in.

  7. Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list comprises the different settings that can be modified to perform customizations. 

  8. Click on Context Menus to expand the list of context menus used in MicroStrategy Web. 

  9. Navigate to folderContextMenus->default

  10. Right-click the default context menu and select New Shortcut

  11. Enter group3 in the text field and click OK. This launches the Shortcut Attributes editor for group3

  12. Enter - in the Descriptor text field. 

  13. Save your changes. group3 will be a horizontal line that will separate the View Object ID context menu item from the rest of the menu items. 

  14. Navigate back to folderContextMenus->default

  15. Right-click the default context menu and select New Shortcut

  16. Enter viewObjectID in the text field and click OK. This will be the View Object ID context menu item. 

  17. In the Shortcut Attributes editor for viewObjectID, enter View Object ID in the Descriptor text field. 

  18. Click the Advanced Properties tab at the bottom. 

  19. Enter com.microstrategy.sdk.samples.transforms.contextmenus.CustomAlert in the text field for Builder ClassName

  20. Save your changes. 

  21. Launch MicroStrategy Web to view the customization.

In this customization, View Object ID is the last item on the context menu, and it is set apart from the other menu items by a separator. You can vary the location of the new menu item by changing the placement of the shortcut in the list of shortcuts. To change the position of View Object ID, navigate to folderContextMenus->default and double-click default to launch the Shortcut Attributes editor for default. The position of context menu items can be ordered in the List of Shortcuts section.

Displaying object information using a custom transform

In the second example in this scenario, you add a new context menu item, called View Object Index, that displays the index (relative position of the selected object within the list of objects displayed on the page— in this case, the relative position of the folder). This information must be provided by a custom transform.

Before customization:

After customization:

After you have performed the customization and saved your changes, the View Object Index menu item appears on the context menu for the Folder Browsing page when you right-click a folder. When you click View Object Index, a message box displays the index of the folder (that is, the relative position of the folder within the list of folders displayed on the page). The index of the first folder always starts with '0'.

This customization can be accomplished using either of the following methods:

Deploying the plug-in provided with MicroStrategy SDK

MicroStrategy SDK provides a plug-in (ZIP file) that can simply be extracted to thepluginsfolder to view the customization in MicroStrategy Web. The following steps guide you in locating the plug-in and deploying it. 

  1. Access the plug-in: JSP version or ASP .NET version

  2. Extract the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder.   

  3. Launch MicroStrategy Web to view the customization.

Using the Web Customization Editor to create a plug-in

MicroStrategy SDK provides a Web Customization Editor that can be used to create a customization plug-in. The following steps guide you in creating the plug-in and deploying it. 

  1. Launch the Web Customization Editor

  2. Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list comprises the different settings that can be modified to perform customizations. 

  3. Right-click Styles and select Create Transform to launch the Transform Creation Wizard

  4. Click Browse... next to the Source folder text field to select the src folder and click OK

  5. Enter the following information for the rest of the text fields.
    Package
    : com.microstrategy.sdk.samples.transforms
    Name
    : CustomFolderTransform
    Transform description
    : This transform displays the folder contents.
    Superclass
    : com.microstrategy.web.app.transforms.ProjectsTransform

  6. Click Next

  7. Click the radio button for Uncheck all methods

  8. Click Next

  9. Click Finish. CustomFolderTransform.java opens in the editor. The sample, CustomFolderTransform.java, contains the entire code for this custom transform. You can use this code in CustomFolderTransform.java that is open for editing. 

  1. Save your changes. 

  2. Navigate to Styles->FolderStyleIcon

  3. Double-click FolderStyleIcon to launch the Style Properties editor in the right frame. 

  4. Click Change to select a new transform. 

  5. Enter CustomFolderTransform in the text field. 

  6. Select CustomFolderTransform from your project and click OK

  7. Save your changes. 

  8. Double-click FolderStyleList to launch the Style Properties editor in the right frame. 

  9. Click Change to select a new transform. 

  10. Enter CustomFolderTransform in the text field. 

  11. Select CustomFolderTransform from your project and click OK.

  12. Save your changes. 

  13. Use the Eclipse IDE to create a specialized ContextMenuItem builder class. The sample, CustomFolderMenuItem.java, contains the entire code for this custom builder class.  CustomFolderMenuItem extends DefaultContextMenuItemBuilder, which contains the logic to enable and populate each item on context menus on the Folder Browsing page. CustomFolderMenuItem adds logic to enable and populate a new context menu item that displays the index of the folder that is right-clicked. 

  14. Compile CustomFolderMenuItem.java and place the class file inside the classes folder of this customization plug-in adhering to the package structure. For example: plugins\pluginName\WEB-INF\classes\com\microstrategy\sdk\samples\transforms\contextmenus

  15. If the Web Customization Editor is closed, launch it again and access your plug-in

  16. Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list comprises the different settings that can be modified to perform customizations. 

  17. Click Context Menus to expand the list of context menus used in MicroStrategy Web. 

  18. Navigate to folderContextMenus->default

  19. Right-click the default context menu and select New Shortcut

  20. Enter group3 in the text field and click OK. This launches the Shortcut Attributes editor for group3

  21. Enter - in the Descriptor text field. 

  22. Save your changes. group3 will be a horizontal line that will separate the View Object Index context menu item from the rest of the menu items. 

  23. Navigate back to folderContextMenus->default

  24. Right-click the default context menu and select New Shortcut

  25. Enter ObjectIndex in the text field and click OK. This will be the View Object Index context menu item. 

  26. In the Shortcut Attributes editor for ObjectIndex, enter View Object Index in the Descriptor text field. 

  27. Click the Advanced Properties tab at the bottom. 

  28. Enter com.microstrategy.sdk.samples.transforms.contextmenus.CustomFolderMenuItem in the text field for Builder ClassName

  29. Save your changes. 

  30. Launch MicroStrategy Web to view the customization.

In this customization, View Object Index is the last item on the context menu, and it is set apart from the other menu items by a separator. You can vary the location of the new menu item by changing the placement of the shortcut in the list of shortcuts. To change the position of View Object ID, navigate to folderContextMenus->default and double-click default to launch the Shortcut Attributes editor for default. The position of context menu items can be ordered in the List of Shortcuts section.

See Also