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);
ICheatSheetStateManager trayManager = new TrayStateManager();
preTrayManager = stateManager;
stateManager = trayManager;
saveCurrentSheet(); // Save the state into the tray manager
helpPart.addPart(CheatSheetHelpPart.ID, new CheatSheetHelpPart(helpPart.getForm().getForm().getBody(), helpPart.getForm().getToolkit(), page.getToolBarManager(), contentElement, trayManager));
page.addPart(CheatSheetHelpPart.ID, true);
helpPart.addPage(page);
helpPart.showPage(CheatSheetHelpPart.ID);
/*
* Disable the viewer until the tray is closed, then show it again.
*/
control.setVisible(false);
Display.getCurrent().removeFilter(SWT.Show, listener);
helpPart.getControl().addListener(SWT.Dispose, new Listener() {
public void handleEvent(Event event) {
control.setVisible(true);
Display.getCurrent().addFilter(SWT.Show, listener);
if (preTrayManager != null) {
loadState(); // Load from the tray manager