Shell shell = Display.getDefault().getActiveShell();
Object data = shell.getData();
// are we in a dialog that can show a cheat sheet?
if (!shell.isFocusControl() && data instanceof TrayDialog) {
TrayDialog dialog = (TrayDialog)data;
HelpTray tray = (HelpTray)dialog.getTray();
if (tray == null) {
tray = new HelpTray();
dialog.openTray(tray);
}
ReusableHelpPart helpPart = tray.getHelpPart();
IHelpPartPage page = helpPart.createPage(CheatSheetHelpPart.ID, null, null);
page.setVerticalSpacing(0);
page.setHorizontalMargin(0);
CheatSheetElement contentElement = CheatSheetRegistryReader.getInstance().findCheatSheet(id);
helpPart.addPart(CheatSheetHelpPart.ID, new CheatSheetHelpPart(helpPart.getForm().getForm().getBody(), helpPart.getForm().getToolkit(), page.getToolBarManager(), contentElement, new DefaultStateManager()));