Search in sources :

Example 1 with SourceViewerConfiguration

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;
}
Also used : YEditSourceViewerConfiguration(org.dadacoalition.yedit.editor.YEditSourceViewerConfiguration) SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) ProjectionViewer(org.eclipse.jface.text.source.projection.ProjectionViewer) IFocusService(org.eclipse.ui.swt.IFocusService) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Aggregations

YEditSourceViewerConfiguration (org.dadacoalition.yedit.editor.YEditSourceViewerConfiguration)1 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)1 ProjectionViewer (org.eclipse.jface.text.source.projection.ProjectionViewer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 IFocusService (org.eclipse.ui.swt.IFocusService)1