use of org.eclipse.jface.text.source.projection.ProjectionViewer in project dbeaver by serge-rider.
the class SQLEditorBase method createPartControl.
@Override
public void createPartControl(Composite parent) {
setRangeIndicator(new DefaultRangeIndicator());
super.createPartControl(new SQLEditorControl(parent, this));
ProjectionViewer viewer = (ProjectionViewer) getSourceViewer();
projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors());
//$NON-NLS-1$
projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error");
//$NON-NLS-1$
projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning");
projectionSupport.install();
viewer.doOperation(ProjectionViewer.TOGGLE);
annotationModel = viewer.getProjectionAnnotationModel();
// Symbol inserter
{
SQLSymbolInserter symbolInserter = new SQLSymbolInserter(this);
DBPPreferenceStore preferenceStore = getActivePreferenceStore();
boolean closeSingleQuotes = preferenceStore.getBoolean(SQLPreferenceConstants.SQLEDITOR_CLOSE_SINGLE_QUOTES);
boolean closeDoubleQuotes = preferenceStore.getBoolean(SQLPreferenceConstants.SQLEDITOR_CLOSE_DOUBLE_QUOTES);
boolean closeBrackets = preferenceStore.getBoolean(SQLPreferenceConstants.SQLEDITOR_CLOSE_BRACKETS);
symbolInserter.setCloseSingleQuotesEnabled(closeSingleQuotes);
symbolInserter.setCloseDoubleQuotesEnabled(closeDoubleQuotes);
symbolInserter.setCloseBracketsEnabled(closeBrackets);
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension) {
((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(symbolInserter);
}
}
}
use of org.eclipse.jface.text.source.projection.ProjectionViewer in project dbeaver by serge-rider.
the class SQLEditorBase method reloadSyntaxRules.
public void reloadSyntaxRules() {
// Refresh syntax
SQLDialect dialect = getSQLDialect();
syntaxManager.init(dialect, getActivePreferenceStore());
ruleManager.refreshRules(getDataSource(), getEditorInput());
Document document = getDocument();
if (document != null) {
IDocumentPartitioner partitioner = new FastPartitioner(new SQLPartitionScanner(dialect), SQLPartitionScanner.SQL_CONTENT_TYPES);
partitioner.connect(document);
document.setDocumentPartitioner(SQLPartitionScanner.SQL_PARTITIONING, partitioner);
ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
if (projectionViewer != null && projectionViewer.getAnnotationModel() != null && document.getLength() > 0) {
//projectionViewer.getTextWidget().redraw();
try {
projectionViewer.reinitializeProjection();
} catch (Throwable ex) {
// We can catch OutOfMemory here for too big/complex documents
//$NON-NLS-1$
log.warn("Can't initialize SQL syntax projection", ex);
}
}
}
// Update configuration
if (getSourceViewerConfiguration() instanceof SQLEditorSourceViewerConfiguration) {
((SQLEditorSourceViewerConfiguration) getSourceViewerConfiguration()).onDataSourceChange();
}
final IVerticalRuler verticalRuler = getVerticalRuler();
if (verticalRuler != null) {
verticalRuler.update();
}
}
use of org.eclipse.jface.text.source.projection.ProjectionViewer in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
ProjectionViewer viewer = getProjectionViewer();
projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors());
projectionSupport.install();
// turn projection mode on
viewer.doOperation(ProjectionViewer.TOGGLE);
annotationModel = viewer.getProjectionAnnotationModel();
preferenceStore.addPropertyChangeListener(preferenceChangeListener);
}
use of org.eclipse.jface.text.source.projection.ProjectionViewer 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