Java Code Examples for org.eclipse.jface.text.source.SourceViewerConfiguration#getTabWidth()

The following examples show how to use org.eclipse.jface.text.source.SourceViewerConfiguration#getTabWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeScriptEditor.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer = getSourceViewer();
	SourceViewerConfiguration config = getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth = config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter = new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider = getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7) sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example 2
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer= getSourceViewer();
	SourceViewerConfiguration config= getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth= config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider= getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7)sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example 3
Source File: AbstractThemeableEditor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Added so we can set TM_TAB_SIZE for scripting.
 * 
 * @return
 */
public int getTabSize()
{
	SourceViewerConfiguration config = getSourceViewerConfiguration();
	if (config != null)
	{
		return config.getTabWidth(getSourceViewer());
	}
	return 4;
}