| /*=============================================================================# |
| # Copyright (c) 2009, 2021 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.yaml.ui.config; |
| |
| import org.eclipse.core.filebuffers.IDocumentSetupParticipant; |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.jface.preference.IPreferenceStore; |
| import org.eclipse.jface.text.TextAttribute; |
| import org.eclipse.ui.editors.text.EditorsUI; |
| |
| import org.eclipse.statet.ecommons.preferences.ui.ConfigurationBlock; |
| import org.eclipse.statet.ecommons.preferences.ui.ConfigurationBlockPreferencePage; |
| import org.eclipse.statet.ecommons.text.ui.presentation.AbstractTextStylesConfigurationBlock; |
| import org.eclipse.statet.ecommons.text.ui.settings.PreferenceStoreTextStyleManager; |
| |
| import org.eclipse.statet.internal.yaml.ui.YamlUIPlugin; |
| import org.eclipse.statet.ltk.ui.sourceediting.SourceEditorViewerConfiguration; |
| import org.eclipse.statet.ltk.ui.util.CombinedPreferenceStore; |
| import org.eclipse.statet.yaml.core.YamlCore; |
| import org.eclipse.statet.yaml.core.source.YamlDocumentContentInfo; |
| import org.eclipse.statet.yaml.core.source.YamlDocumentSetupParticipant; |
| import org.eclipse.statet.yaml.ui.sourceediting.YamlSourceViewerConfiguration; |
| import org.eclipse.statet.yaml.ui.text.YamlTextStyles; |
| |
| |
| public class YamlTextStylesPreferencePage extends ConfigurationBlockPreferencePage { |
| |
| |
| public YamlTextStylesPreferencePage() { |
| setPreferenceStore(YamlUIPlugin.getInstance().getPreferenceStore()); |
| } |
| |
| |
| @Override |
| protected ConfigurationBlock createConfigurationBlock() throws CoreException { |
| return new YamlTextStylesBlock(); |
| } |
| |
| } |
| |
| |
| class YamlTextStylesBlock extends AbstractTextStylesConfigurationBlock { |
| |
| |
| public YamlTextStylesBlock() { |
| } |
| |
| |
| @Override |
| protected String getSettingsGroup() { |
| return YamlTextStyles.YAML_TEXTSTYLE_CONFIG_QUALIFIER; |
| } |
| |
| @Override |
| protected SyntaxNode[] createItems() { |
| return new SyntaxNode[] { |
| new CategoryNode(Messages.TextStyles_DefaultCodeCategory_label, new SyntaxNode[] { |
| new StyleNode(Messages.TextStyles_Default_label, Messages.TextStyles_Default_description, |
| YamlTextStyles.TS_DEFAULT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.TextStyles_Indicators_label, Messages.TextStyles_Indicators_description, |
| YamlTextStyles.TS_INDICATOR, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, new StyleNode[] { |
| new StyleNode(Messages.TextStyles_SeqMapBrackets_label, Messages.TextStyles_SeqMapBrackets_description, |
| YamlTextStyles.TS_BRACKET, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseNoExtraStyle(YamlTextStyles.TS_INDICATOR), |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| }), |
| new StyleNode(Messages.TextStyles_Keys_label, Messages.TextStyles_Keys_description, |
| YamlTextStyles.TS_KEY, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle(), |
| SyntaxNode.createUseOtherStyle(YamlTextStyles.TS_DEFAULT, Messages.TextStyles_Default_label), |
| }, null ), |
| new StyleNode(Messages.TextStyles_Tags_label, Messages.TextStyles_Tags_description, |
| YamlTextStyles.TS_TAG, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle(), |
| SyntaxNode.createUseOtherStyle(YamlTextStyles.TS_DEFAULT, Messages.TextStyles_Default_label), |
| }, null ), |
| }), |
| new CategoryNode(Messages.TextStyles_ProcessorCategory_label, new SyntaxNode[] { |
| new StyleNode(Messages.TextStyles_DocumentSeparators_label, Messages.TextStyles_DocumentSeparators_description, |
| YamlTextStyles.TS_DOCUMENT_SEPARATOR, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.TextStyles_Directives_label, Messages.TextStyles_Directives_description, |
| YamlTextStyles.TS_DIRECTIVE, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| }), |
| new CategoryNode(Messages.TextStyles_CommentCategory_label, new SyntaxNode[] { |
| new StyleNode(Messages.TextStyles_Comment_label, Messages.TextStyles_Comment_description, |
| YamlTextStyles.TS_COMMENT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| // new StyleNode(Messages.TextStyles_TaskTag_label, Messages.TextStyles_TaskTag_description, |
| // YamlTextStyles.TS_TASK_TAG, new SyntaxNode.UseStyle[] { |
| // SyntaxNode.createUseCustomStyle() |
| // }, null ), |
| }), |
| }; |
| } |
| |
| @Override |
| protected String getPreviewFileName() { |
| return "YamlTextStylesPreviewCode.txt"; //$NON-NLS-1$ |
| } |
| |
| @Override |
| protected IDocumentSetupParticipant getDocumentSetupParticipant() { |
| return new YamlDocumentSetupParticipant(); |
| } |
| |
| @Override |
| protected SourceEditorViewerConfiguration getSourceEditorViewerConfiguration( |
| final IPreferenceStore preferenceStore, |
| final PreferenceStoreTextStyleManager<TextAttribute> textStyles) { |
| return new YamlSourceViewerConfiguration(YamlDocumentContentInfo.INSTANCE, 0, |
| null, |
| YamlCore.getDefaultsAccess(), |
| CombinedPreferenceStore.createStore( |
| preferenceStore, |
| EditorsUI.getPreferenceStore() ), |
| textStyles ); |
| } |
| |
| } |