| /*=============================================================================# |
| # Copyright (c) 2013, 2019 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.internal.nico.ui.preferences; |
| |
| import org.eclipse.jface.preference.IPreferenceStore; |
| import org.eclipse.jface.text.source.ISourceViewer; |
| |
| import org.eclipse.statet.ecommons.text.core.sections.BasicDocContentSections; |
| import org.eclipse.statet.ecommons.text.core.sections.DocContentSections; |
| import org.eclipse.statet.ecommons.text.ui.presentation.SingleTokenScanner; |
| import org.eclipse.statet.ecommons.text.ui.settings.TextStyleManager; |
| |
| import org.eclipse.statet.ltk.ui.sourceediting.SourceEditorViewerConfiguration; |
| |
| |
| public class ConsolePreviewSourceViewerConfiguration extends SourceEditorViewerConfiguration { |
| |
| |
| private static final DocContentSections CONTENT_INFO= new BasicDocContentSections(ConsoleTextStylesPreviewPartitioner.PARTITIONING, |
| ConsoleTextStylesPreviewPartitioner.PARTITIONING) { |
| @Override |
| public String getTypeByPartition(final String contentType) { |
| return ConsoleTextStylesPreviewPartitioner.PARTITIONING; |
| } |
| }; |
| |
| |
| public ConsolePreviewSourceViewerConfiguration(final int flags, |
| final IPreferenceStore preferenceStore, final TextStyleManager textStyles) { |
| super(CONTENT_INFO, flags, null); |
| |
| setup(preferenceStore, null, null); |
| setTextStyles(textStyles); |
| } |
| |
| |
| @Override |
| protected void initScanners() { |
| final TextStyleManager textStyles= getTextStyles(); |
| |
| for (final String contentType : ConsoleTextStylesPreviewPartitioner.PARTITIONS) { |
| addScanner(contentType, |
| new SingleTokenScanner(textStyles, contentType) ); |
| } |
| } |
| |
| @Override |
| public String[] getConfiguredContentTypes(final ISourceViewer sourceViewer) { |
| return ConsoleTextStylesPreviewPartitioner.PARTITIONS; |
| } |
| |
| } |