| /*=============================================================================# |
| # Copyright (c) 2005, 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.r.ui.preferences; |
| |
| import org.eclipse.core.filebuffers.IDocumentSetupParticipant; |
| import org.eclipse.jface.preference.IPreferenceStore; |
| 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.TextStyleManager; |
| |
| import org.eclipse.statet.internal.r.ui.RUIPlugin; |
| import org.eclipse.statet.ltk.ui.LTKUIPreferences; |
| import org.eclipse.statet.ltk.ui.sourceediting.SourceEditorViewerConfiguration; |
| import org.eclipse.statet.ltk.ui.util.CombinedPreferenceStore; |
| import org.eclipse.statet.r.core.RCore; |
| import org.eclipse.statet.r.ui.RUIPreferenceConstants; |
| import org.eclipse.statet.r.ui.editors.RdDocumentSetupParticipant; |
| import org.eclipse.statet.r.ui.editors.RdSourceViewerConfiguration; |
| |
| |
| public class RdSyntaxColoringPreferencePage extends ConfigurationBlockPreferencePage { |
| |
| |
| public RdSyntaxColoringPreferencePage() { |
| setPreferenceStore(RUIPlugin.getInstance().getPreferenceStore()); |
| } |
| |
| |
| @Override |
| protected ConfigurationBlock createConfigurationBlock() { |
| return new RdTextStylesBlock(); |
| } |
| |
| } |
| |
| |
| class RdTextStylesBlock extends AbstractTextStylesConfigurationBlock { |
| |
| |
| public RdTextStylesBlock() { |
| } |
| |
| |
| @Override |
| protected String getSettingsGroup() { |
| return RUIPreferenceConstants.Rd.TS_GROUP_ID; |
| } |
| |
| @Override |
| protected SyntaxNode[] createItems() { |
| return new SyntaxNode[] { |
| new CategoryNode(Messages.RdSyntaxColoring_CodeCategory_label, new SyntaxNode[] { |
| new StyleNode(Messages.RdSyntaxColoring_Default_label, Messages.RdSyntaxColoring_Default_description, |
| RUIPreferenceConstants.Rd.TS_DEFAULT_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| // new StyleNode(Messages.RdSyntaxColoring_Verbatim_label, Messages.RdSyntaxColoring_Verbatim_description, |
| // RUIPreferenceConstants.Rd.TS_VERBATIM_ROOT, false ), |
| new StyleNode(Messages.RdSyntaxColoring_SectionTag_label, Messages.RdSyntaxColoring_SectionTag_description, |
| RUIPreferenceConstants.Rd.TS_SECTION_TAG_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.RdSyntaxColoring_SubSectionTag_label, Messages.RdSyntaxColoring_SubSectionTag_description, |
| RUIPreferenceConstants.Rd.TS_SUBSECTION_TAG_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.RdSyntaxColoring_OtherTag_label, Messages.RdSyntaxColoring_OtherTag_description, |
| RUIPreferenceConstants.Rd.TS_OTHER_TAG_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.RdSyntaxColoring_UnlistedTag_label, Messages.RdSyntaxColoring_UnlistedTag_description, |
| RUIPreferenceConstants.Rd.TS_UNLISTED_TAG_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.RdSyntaxColoring_Brackets_label, Messages.RdSyntaxColoring_Brackets_description, |
| RUIPreferenceConstants.Rd.TS_BRACKETS_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| |
| new StyleNode(Messages.RdSyntaxColoring_PlatformSpecif_label, Messages.RdSyntaxColoring_PlatformSpecif_description, |
| RUIPreferenceConstants.Rd.TS_PLATFORM_SPECIF_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| }), |
| new CategoryNode(Messages.RdSyntaxColoring_CommentsCategory_label, new SyntaxNode[] { |
| new StyleNode(Messages.RdSyntaxColoring_Comment_label, Messages.RdSyntaxColoring_Comment_description, |
| RUIPreferenceConstants.Rd.TS_COMMENT_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| new StyleNode(Messages.RdSyntaxColoring_TaskTag_label, Messages.RdSyntaxColoring_TaskTag_description, |
| RUIPreferenceConstants.Rd.TS_TASK_TAG_ROOT, new SyntaxNode.UseStyle[] { |
| SyntaxNode.createUseCustomStyle() |
| }, null ), |
| }), |
| }; |
| } |
| |
| @Override |
| protected String getPreviewFileName() { |
| return "RdSyntaxColoringPreviewCode.txt"; //$NON-NLS-1$ |
| } |
| |
| @Override |
| protected IDocumentSetupParticipant getDocumentSetupParticipant() { |
| return new RdDocumentSetupParticipant(); |
| } |
| |
| @Override |
| protected SourceEditorViewerConfiguration getSourceEditorViewerConfiguration( |
| final IPreferenceStore preferenceStore, final TextStyleManager textStyles) { |
| return new RdSourceViewerConfiguration(0, null, RCore.getDefaultsAccess(), |
| CombinedPreferenceStore.createStore( |
| preferenceStore, |
| LTKUIPreferences.getPreferenceStore(), |
| EditorsUI.getPreferenceStore()), |
| textStyles ); |
| } |
| |
| } |