Navigation:  Application Architecture > Putting it All Together > Designing for Extensibility >

Integrating actions with the desktop

Previous pageReturn to chapter overviewNext page

TextEditorComponent has one more responsibility with respect to the tools that extend it:  it must decide how the actions provided by those tools will be integrated with the desktop.

The simplest (and usually the best) approach is to simply pass the actions up to the desktop using the IApplicationComponent.ExportedActions property.  Recall that the IToolSet.Actions property returns the set of all actions provided by all tools in the set.  All we need to do is override the ExportedActions property in the TextEditorComponent to return this set of actions:

 

public override IActionSet ExportedActions

{

   get { return _toolSet.Actions; }

}

 

How does the framework make use of the ExportedActions property?  It depends on the implementation of the individual host object, like Workspace. Workspace will return the ExportedActions property of the hosted component through the Workspace.Actions property, and hence these actions are able to appear in the global menus and toolbars when that workspace is the active workspace. Shelf, on the other hand, ignores the ExportedActions property, because shelves cannot contribute actions to the global menus and toolbars.  All is not lost however, because the component may still expose these actions on a context menu (we’ll come back to this idea later).

The important thing to note here is that for TextEditorToolExtensionPoint tools to contribute actions to the global menus and toolbars, three things must be in place:

1.The tool must provide an action with a site of “global-menus” or “global-toolbars”.
2.The component must “export” these actions through the IApplicationComponent.ExportedActions property.
3.The component must be hosted in a Workspace or other host that forwards the ExportedActions up to the desktop.

This may seem complicated; however the requirement of cooperation between 3 parties essentially creates a system of authority: a tool cannot contribute an action to the desktop without the agreement of the component, and the component cannot contribute actions without the agreement of the host.