close

Filter

loading table of contents...

Site Manager Developer Manual / Version 2101

Table Of Contents

4.8.1 Register Commands

After you have written your command, you need to register it at the CommandManager, at the ListenerManager and at the manager of the chosen GUI element. This will make the command usable and visible. Optionally, you may associate your command with an activation model. These models activate or deactivate the command depending on a specific condition. See the field summary in the Javadoc of the DocumentView for the available activation models. To register your command proceed as follows:

Step Description
1.

Extend the view class.

 class MyView extends hox.corem.editor.generic.GenericDocumentView
2.

Get a CommandManager.

 CommandManager commandMgr = getCommandManager();
3.

Register your command at the CommandManager.

 commandMgr.registerCommand("my-first-command", new com.coremedia.extensions.MyFirstCommand());
4. If you want to associate your command with an activation model you have to call the associateActivationModel() method. See the field summary of the DocumentView class for the available activation models.
 commandMgr.associateActivationModel("my-first-command", approveModel);
5.

Get a manager for the GUI component in which you want to insert your command. Possible are:

 

ToolBarManager toolBarMgr = getToolBarManager();

MenuBarManager menuBarMgr = getMenuBarManager();

PopupMenuManager popupMenuMgr = getPopupMenuManager();

6.

Get a ListenerManager in order to make your command live.

 ListenerManager listenerMgr = getListenerManager();
7.

If you want to insert your command in the tool bar or in a pop-up menu you need to get one.

 JToolBar toolBar = toolBarMgr.getToolBar(); or JPopupMenu popUpMenu = popupMenuMgr.getPopupMenu();
8. Add your command to the ListenerManager and to the GUI component at once.
 

toolBarMgr.addIemBefore(toolBar, null, listenerMgr.createToolBarButton("my-first-command"));

or

menuBarMgr.addItemBefore("edit-menu", null, listenerMgr.createMenuItem("my-first-command"));

or

popupMenuMgr.addItemBefore("linklist-menu", moveBottomCommand, listenerMgr.createPopupMenuItem("my-first-command"));

Table 4.7. Register a new command


Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.