Adding Custom Menu Items

The StudioPlugin class has a getDeclaredActions() method that returns a DeclaredActions object. This object contains all the menu items displayed by Content Studio. You can add menu items of your own by calling its addAction() method. addAction() has two signatures:

addAction(action)

This form of addAction adds the menu item defined by the action parameter to Content Studio's Plug-in menu.

addAction(placement,action)

This form of addAction adds the menu item defined by the action parameter to the menu specified with the placement parameter.

The following example shows how you can add a custom menu item to Content Studio's View menu:

private void createActions() {
  Action action = new MyCustomAction(name, icon);    
  getDeclaredActions().addAction(DeclaredActions.Placement.VIEW_MENU, action);    
}

This method can be called from inside your plug-in's initialize() method. An Action class contains both code to execute some action and the information needed to display a menu item. You can create your own Action classes by extending AbstractAction (see Displaying Custom Dialogs for an example).