use of org.eclipse.jface.text.source.SourceViewerConfiguration in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonEditor method doCreateSourceViewer.
protected ISourceViewer doCreateSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
ProjectionViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles) {
private IInformationPresenter outlinePresenter;
@Override
public void doOperation(int operation) {
if (operation == OpenQuickOutlineHandler.QUICK_OUTLINE && outlinePresenter != null) {
outlinePresenter.showInformation();
return;
}
super.doOperation(operation);
}
@Override
public boolean canDoOperation(int operation) {
if (operation == OpenQuickOutlineHandler.QUICK_OUTLINE && outlinePresenter != null) {
return true;
}
return super.canDoOperation(operation);
}
@Override
public void configure(SourceViewerConfiguration configuration) {
super.configure(configuration);
if (configuration instanceof JsonSourceViewerConfiguration) {
JsonSourceViewerConfiguration c = (JsonSourceViewerConfiguration) configuration;
outlinePresenter = c.getOutlinePresenter(this);
if (outlinePresenter != null) {
outlinePresenter.install(this);
}
}
}
};
IFocusService focusService = (IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class);
if (focusService != null) {
focusService.addFocusTracker(viewer.getTextWidget(), "com.reprezen.swagedit.editor.sourceViewer");
}
viewer.getTextWidget().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// detectOutlineLocationChanged();
}
});
viewer.getTextWidget().setData(ISourceViewer.class.getName(), viewer);
getSourceViewerDecorationSupport(viewer);
return viewer;
}
Aggregations