| /*=============================================================================# |
| # 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.ecommons.text.ui.settings; |
| |
| import org.eclipse.jface.text.contentassist.ContentAssistant; |
| import org.eclipse.jface.text.quickassist.IQuickAssistAssistant; |
| import org.eclipse.swt.graphics.Color; |
| |
| import org.eclipse.statet.ecommons.preferences.core.Preference.BooleanPref; |
| import org.eclipse.statet.ecommons.preferences.core.Preference.IntPref; |
| import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess; |
| import org.eclipse.statet.ecommons.preferences.core.util.PreferenceUtils; |
| import org.eclipse.statet.ecommons.preferences.ui.RGBPref; |
| import org.eclipse.statet.ecommons.ui.ColorManager; |
| import org.eclipse.statet.ecommons.ui.SharedUIResources; |
| |
| import org.eclipse.statet.ltk.ui.LTKUIPreferences; |
| |
| |
| /** |
| * Preferences for content and quick assist assistant. |
| */ |
| public class AssistPreferences { |
| |
| |
| private static final BooleanPref CONTENT_ASSIST_AUTO_ACTIVATION_ENABLED_PREF= new BooleanPref( |
| LTKUIPreferences.ASSIST_PREF_QUALIFIER, "ContentAssist.AutoActivation.enabled"); //$NON-NLS-1$); |
| |
| |
| private final String qualifier; |
| |
| /** |
| * Preference for content assist auto activation |
| */ |
| private final BooleanPref fAutoActivationEnabled; |
| |
| /** |
| * Preference for content assist auto activation delay |
| */ |
| private final IntPref fAutoActivationDelay; |
| |
| /** |
| * Preference for content assist auto insert |
| */ |
| private final BooleanPref fAutoInsertSingle; |
| |
| /** |
| * Preference for content assist auto insert |
| */ |
| private final BooleanPref fAutoInsertPrefix; |
| |
| /** |
| * Preference key for content assist parameters color. |
| */ |
| private final RGBPref fInformationBackground; |
| |
| /** |
| * Preference for content assist parameters color |
| */ |
| private final RGBPref fInformationForeground; |
| |
| // /** |
| // * A named preference that holds the background color used in the code |
| // * assist selection dialog to mark replaced code. |
| // */ |
| // private final RGBPref fReplacementBackground; |
| // |
| // /** |
| // * A named preference that holds the foreground color used in the code |
| // * assist selection dialog to mark replaced code. |
| // */ |
| // private final RGBPref fReplacementForeground; |
| |
| |
| public AssistPreferences(final String prefQualifier) { |
| this.qualifier= prefQualifier; |
| |
| this.fAutoActivationEnabled= CONTENT_ASSIST_AUTO_ACTIVATION_ENABLED_PREF; |
| this.fAutoActivationDelay= LTKUIPreferences.CONTENT_ASSIST_DELAY_PREF; |
| this.fAutoInsertSingle= new BooleanPref(prefQualifier, "AutoInsert.Single.enable"); //$NON-NLS-1$ |
| this.fAutoInsertPrefix= new BooleanPref(prefQualifier, "AutoInsert.Prefix.enable"); //$NON-NLS-1$ |
| |
| this.fInformationBackground= LTKUIPreferences.CONTEXT_INFO_BACKGROUND_COLOR_PREF; |
| this.fInformationForeground= LTKUIPreferences.CONTEXT_INFO_FOREGROUND_COLOR_PREF; |
| } |
| |
| |
| // /** Preference key for java content assist auto activation triggers */ |
| // private static final String AUTOACTIVATION_TRIGGERS_JAVA= PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA; |
| // /** Preference key for javadoc content assist auto activation triggers */ |
| // private static final String AUTOACTIVATION_TRIGGERS_JAVADOC= PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC; |
| |
| // /** Preference key for visibility of proposals */ |
| // private static final String SHOW_VISIBLE_PROPOSALS= PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS; |
| // /** Preference key for alphabetic ordering of proposals */ |
| // private static final String ORDER_PROPOSALS= PreferenceConstants.CODEASSIST_ORDER_PROPOSALS; |
| // /** Preference key for case sensitivity of proposals */ |
| // private static final String CASE_SENSITIVITY= PreferenceConstants.CODEASSIST_CASE_SENSITIVITY; |
| // /** Preference key for adding imports on code assist */ |
| // /** Preference key for filling argument names on method completion */ |
| // private static final String FILL_METHOD_ARGUMENTS= PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES; |
| // /** Preference key for prefix completion. */ |
| // private static final String PREFIX_COMPLETION= PreferenceConstants.CODEASSIST_PREFIX_COMPLETION; |
| |
| |
| public String getGroupId() { |
| return this.qualifier; |
| } |
| |
| public BooleanPref getAutoActivationEnabledPref() { |
| return this.fAutoActivationEnabled; |
| } |
| |
| public BooleanPref getAutoInsertSinglePref() { |
| return this.fAutoInsertSingle; |
| } |
| |
| public BooleanPref getAutoInsertPrefixPref() { |
| return this.fAutoInsertPrefix; |
| } |
| |
| |
| /** |
| * Configure the given content assistant according common StatET settings. |
| */ |
| public void configure(final ContentAssistant assistant) { |
| final ColorManager manager= SharedUIResources.getColors(); |
| final PreferenceAccess prefs= PreferenceUtils.getInstancePrefs(); |
| |
| assistant.enableAutoActivation(prefs.getPreferenceValue(this.fAutoActivationEnabled)); |
| assistant.setAutoActivationDelay(prefs.getPreferenceValue(this.fAutoActivationDelay)); |
| assistant.enableAutoInsert(prefs.getPreferenceValue(this.fAutoInsertSingle)); |
| assistant.enablePrefixCompletion(prefs.getPreferenceValue(this.fAutoInsertPrefix)); |
| { final Color c= manager.getColor(prefs.getPreferenceValue(this.fInformationForeground)); |
| assistant.setContextInformationPopupForeground(c); |
| assistant.setContextSelectorForeground(c); |
| } |
| { final Color c= manager.getColor(prefs.getPreferenceValue(this.fInformationBackground)); |
| assistant.setContextInformationPopupBackground(c); |
| assistant.setContextSelectorBackground(c); |
| } |
| |
| // assistant.enableColoredLabels(true); |
| } |
| |
| // public static void configureInformationProposalMode(final ContentAssist assistant, final boolean enable) { |
| // final ColorManager manager= StatetUIPlugin.getDefault().getColorManager(); |
| // final PreferenceAccess statet= PreferencesUtil.getInstancePrefs(); |
| // |
| // assistant.setProposalSelectorForeground(manager.getColor(statet.getPreferenceValue(enable ? |
| // PARAMETERS_FOREGROUND : PROPOSALS_FOREGROUND))); |
| // assistant.setProposalSelectorBackground(manager.getColor(statet.getPreferenceValue(enable ? |
| // PARAMETERS_BACKGROUND : PROPOSALS_BACKGROUND))); |
| // } |
| |
| /** |
| * Configure the given quick assistant according common StatET settings. |
| */ |
| public void configure(final IQuickAssistAssistant assistant) { |
| } |
| |
| } |