CAB - Presentation Layer Toolset

The last week someone posted this question to the CAB messageboard

    ... there is any difficulty in combining other toolsets with CAB? where toolset = (DevExpress, Janus, ComponentOne, etc.)

This is a common question and I wanted to post the answer here as well so I could reference in the future.

CAB has many features: the EventBroker, the concept of a WorkItem, SmartParts, Services, and more. All of them could be used without implementing the toolset for CAB.
Besides, you have the UI or toolset-related part. I will separate it in 3 topics:
  • UI Elements/UI Extension Sites
  • Commands/CommandHandlers
  • Workspaces

UI Elements/UI Extension Sites

Another feature CAB has is abstracting the UI elements (like menus, toolbars, explorer bars, etc.). So you can treat them as just "sites" where you can add new elements from any module. Let me clarify this. Think about the Outlook Shell. When you switch between Mail, Calendars, Contacts you have different toolbars and different menu items. You need a mechanism to add/remove to these places.
That said, the Toolbar is an "extension site" in terms of CAB, the ToolStripMenu is another, the StatusBar is another, and so on. When the Mail "module" is activated, it will add/remove what it needs to the extension sites.
If you want to add UI elements to these sites using the CAB infrastructure you have to implement the "Adapters". These are very easy to implement. They are just small wrappers of your controls with Add/Remove methods.


So what happens when you click on a ToolsStripButton of the Toolbar? You need to handle that click and do something with it. The Commands defeat that purpose. If you are use to double click the toolstrip button in the designer surface to create the event handler, then in CAB you won't have that facility.
From a module developer point of view you will add invokers to a ui element like this:
Commands["Reply"].AddInvoker(replyButtonItem, "Click")
And then you will consume this event using a CommandHandler
public void ReplyHandler(object sender, EventArgs e) {
The way to integrate this with your toolset is by implementing the CommandAdapter. You will need one CommandAdapter for each specific UI element that raises a "Click" event (e.g. ToolStripButton, the ExplorerBarItem, etc.)


Finally you have workspaces. These are layout/containers. They will abstract the addition/remotion/hiding of smartparts. That means that you will add smartparts to a workspace and the workspace will wrap a layout container. Eg. Tab Control, Deck Panels, Dock Panels, Zones, etc.
Implementing this, will let you change the visual layout of a set of smartparts with a minumum effort.

Next steps

Finally, you can learn how to implement these 3 elements by:
- looking at the CompositeUI.Winforms project
- by downloading and looking over the CAB Extensibility kit of Infragistics
- by looking at this article Dockable CAB Workspace

Published: March 27 2006

blog comments powered by Disqus