Search in sources :

Example 1 with JsonEditor

use of com.reprezen.swagedit.core.editor.JsonEditor in project KaiZen-OpenAPI-Editor by RepreZen.

the class OpenQuickOutlineHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISourceViewer viewer = null;
    //$NON-NLS-1$
    Object activeFocusControl = HandlerUtil.getVariable(event, "activeFocusControl");
    if (activeFocusControl instanceof Control) {
        Control control = (Control) activeFocusControl;
        if (!control.isDisposed()) {
            viewer = (ISourceViewer) control.getData(ISourceViewer.class.getName());
        }
    }
    if (viewer == null) {
        IEditorPart editor = HandlerUtil.getActiveEditor(event);
        if (editor instanceof JsonEditor) {
            viewer = ((JsonEditor) editor).getProjectionViewer();
        }
    }
    if (viewer != null) {
        ITextOperationTarget operationTarget = viewer.getTextOperationTarget();
        if (operationTarget.canDoOperation(QUICK_OUTLINE)) {
            operationTarget.doOperation(QUICK_OUTLINE);
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) ITextOperationTarget(org.eclipse.jface.text.ITextOperationTarget) IEditorPart(org.eclipse.ui.IEditorPart) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) JsonEditor(com.reprezen.swagedit.core.editor.JsonEditor)

Aggregations

JsonEditor (com.reprezen.swagedit.core.editor.JsonEditor)1 ITextOperationTarget (org.eclipse.jface.text.ITextOperationTarget)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 Control (org.eclipse.swt.widgets.Control)1 IEditorPart (org.eclipse.ui.IEditorPart)1