Search in sources :

Example 1 with ContextHelpAction

use of org.eclipse.mylyn.internal.wikitext.ui.editor.actions.ContextHelpAction in project mylyn.docs by eclipse.

the class ShowCheatSheetCommand method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    // $NON-NLS-1$
    Object activeFocusControl = HandlerUtil.getVariable(event, "activeFocusControl");
    if (activeFocusControl instanceof Control) {
        Control control = (Control) activeFocusControl;
        MarkupLanguage markupLanguage = (MarkupLanguage) control.getData(MarkupLanguage.class.getName());
        ISourceViewer viewer = (ISourceViewer) control.getData(ISourceViewer.class.getName());
        if (markupLanguage != null && viewer != null) {
            ToolBarManager toolBarManager = new ToolBarManager();
            toolBarManager.add(new ContextHelpAction());
            final InformationPresenter informationPresenter = InformationPresenterUtil.getHtmlInformationPresenter(viewer, new InformationPresenterUtil.SizeConstraint(50, 200, true, true), toolBarManager, computeCheatSheet(markupLanguage));
            // show information asynchronously since on Eclipse 3.4 it will disappear otherwise
            Display.getCurrent().asyncExec(new Runnable() {

                public void run() {
                    informationPresenter.showInformation();
                }
            });
        }
    }
    return null;
}
Also used : InformationPresenterUtil(org.eclipse.mylyn.internal.wikitext.ui.util.InformationPresenterUtil) Control(org.eclipse.swt.widgets.Control) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter) ToolBarManager(org.eclipse.jface.action.ToolBarManager) ContextHelpAction(org.eclipse.mylyn.internal.wikitext.ui.editor.actions.ContextHelpAction)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)1 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 ContextHelpAction (org.eclipse.mylyn.internal.wikitext.ui.editor.actions.ContextHelpAction)1 InformationPresenterUtil (org.eclipse.mylyn.internal.wikitext.ui.util.InformationPresenterUtil)1 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)1 Control (org.eclipse.swt.widgets.Control)1