use of org.eclipse.jface.text.ITextOperationTarget 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;
}
Aggregations