mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 194312: Hover Background Color
This commit is contained in:
parent
eff6754c12
commit
1d3da89cf0
8 changed files with 415 additions and 278 deletions
|
@ -572,8 +572,8 @@
|
|||
contentTypeId="org.eclipse.cdt.core.binaryFile">
|
||||
</contentTypeBinding>
|
||||
</editor>
|
||||
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.themes">
|
||||
<themeElementCategory label="%CPresentation.label" id="org.eclipse.cdt.ui.presentation"/>
|
||||
|
@ -614,8 +614,51 @@
|
|||
%asmCompareFontDefiniton.description
|
||||
</description>
|
||||
</fontDefinition>
|
||||
|
||||
<colorDefinition
|
||||
id="org.eclipse.cdt.ui.content_assist_proposals_background"
|
||||
isEditable="false"
|
||||
label="%Dummy.label"
|
||||
value="255,255,255">
|
||||
</colorDefinition>
|
||||
<colorDefinition
|
||||
id="org.eclipse.cdt.ui.content_assist_proposals_foreground"
|
||||
isEditable="false"
|
||||
label="%Dummy.label"
|
||||
value="0,0,0">
|
||||
</colorDefinition>
|
||||
<colorDefinition
|
||||
id="org.eclipse.cdt.ui.content_assist_parameters_background"
|
||||
isEditable="false"
|
||||
label="%Dummy.label"
|
||||
value="255,255,255">
|
||||
</colorDefinition>
|
||||
<colorDefinition
|
||||
id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
|
||||
isEditable="false"
|
||||
label="%Dummy.label"
|
||||
value="0,0,0">
|
||||
</colorDefinition>
|
||||
<theme
|
||||
id="org.eclipse.ui.ide.systemDefault">
|
||||
<colorOverride
|
||||
id="org.eclipse.cdt.ui.content_assist_proposals_background"
|
||||
value="COLOR_LIST_BACKGROUND">
|
||||
</colorOverride>
|
||||
<colorOverride
|
||||
id="org.eclipse.cdt.ui.content_assist_proposals_foreground"
|
||||
value="COLOR_LIST_FOREGROUND">
|
||||
</colorOverride>
|
||||
<colorOverride
|
||||
id="org.eclipse.cdt.ui.content_assist_parameters_background"
|
||||
value="COLOR_LIST_BACKGROUND">
|
||||
</colorOverride>
|
||||
<colorOverride
|
||||
id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
|
||||
value="COLOR_LIST_FOREGROUND">
|
||||
</colorOverride>
|
||||
</theme>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
|
|
|
@ -29,4 +29,15 @@ public interface ICThemeConstants {
|
|||
* A theme constant that holds the foreground color used in the code assist selection dialog.
|
||||
*/
|
||||
public final String CODEASSIST_PROPOSALS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
|
||||
|
||||
/**
|
||||
* A theme constant that holds the background color used for parameter hints.
|
||||
*/
|
||||
public final String CODEASSIST_PARAMETERS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
|
||||
|
||||
/**
|
||||
* A theme constant that holds the foreground color used for parameter hints.
|
||||
*/
|
||||
public final String CODEASSIST_PARAMETERS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
|
||||
|
||||
}
|
||||
|
|
|
@ -47,13 +47,14 @@ import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
|||
*/
|
||||
public class CEditorPreferencePage extends AbstractPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
protected final String[][] fAppearanceColorListModel = new String[][] {
|
||||
{PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor, ContentAssistPreference.PROPOSALS_BACKGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor, ContentAssistPreference.PROPOSALS_FOREGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor, ContentAssistPreference.PARAMETERS_BACKGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterForegroundColor, ContentAssistPreference.PARAMETERS_FOREGROUND, null },
|
||||
protected final String[][] fAppearanceColorListModel = new String[][] {
|
||||
{PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor, ContentAssistPreference.PROPOSALS_BACKGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor, ContentAssistPreference.PROPOSALS_FOREGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor, ContentAssistPreference.PARAMETERS_BACKGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterForegroundColor, ContentAssistPreference.PARAMETERS_FOREGROUND, null },
|
||||
{PreferencesMessages.CEditorPreferencePage_sourceHoverBackgroundColor, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT},
|
||||
};
|
||||
|
||||
private List fAppearanceColorList;
|
||||
|
@ -67,7 +68,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
|
||||
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||
ArrayList overlayKeys = new ArrayList();
|
||||
|
||||
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SUB_WORD_NAVIGATION));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
|
||||
|
@ -78,7 +79,9 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
|
||||
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT));
|
||||
|
||||
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
|
||||
overlayKeys.toArray(keys);
|
||||
return keys;
|
||||
|
@ -86,24 +89,19 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
|
||||
public static void initDefaults(IPreferenceStore store) {
|
||||
store.setDefault(CEditor.SUB_WORD_NAVIGATION, true);
|
||||
|
||||
|
||||
store.setDefault(CEditor.MATCHING_BRACKETS, true);
|
||||
PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, new RGB(170,170,170));
|
||||
|
||||
store.setDefault(CEditor.INACTIVE_CODE_ENABLE, true);
|
||||
PreferenceConverter.setDefault(store, CEditor.INACTIVE_CODE_COLOR, new RGB(224, 224, 224));
|
||||
|
||||
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
|
||||
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
|
||||
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
|
||||
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see PreferencePage#createControl(Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
super.createControl(parent);
|
||||
super.createControl(parent);
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_EDITOR_PREF_PAGE);
|
||||
}
|
||||
|
||||
|
@ -125,16 +123,16 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
layout.numColumns = 2;
|
||||
behaviorComposite.setLayout(layout);
|
||||
|
||||
String label= PreferencesMessages.CEditorPreferencePage_behaviorPage_subWordNavigation;
|
||||
String label= PreferencesMessages.CEditorPreferencePage_behaviorPage_subWordNavigation;
|
||||
addCheckBox(behaviorComposite, label, CEditor.SUB_WORD_NAVIGATION, 0);
|
||||
|
||||
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBrackets;
|
||||
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBrackets;
|
||||
addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS, 0);
|
||||
|
||||
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCode;
|
||||
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCode;
|
||||
addCheckBox(behaviorComposite, label, CEditor.INACTIVE_CODE_ENABLE, 0);
|
||||
|
||||
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_ensureNewline;
|
||||
label = PreferencesMessages.CEditorPreferencePage_behaviorPage_ensureNewline;
|
||||
addCheckBox(behaviorComposite, label, PreferenceConstants.ENSURE_NEWLINE_AT_EOF, 0);
|
||||
|
||||
Label l = new Label(behaviorComposite, SWT.LEFT);
|
||||
|
@ -144,7 +142,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
l.setLayoutData(gd);
|
||||
|
||||
l = new Label(behaviorComposite, SWT.LEFT);
|
||||
l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_appearanceColorOptions);
|
||||
l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_appearanceColorOptions);
|
||||
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||
gd.horizontalSpan = 2;
|
||||
l.setLayoutData(gd);
|
||||
|
@ -173,7 +171,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
l = new Label(stylesComposite, SWT.LEFT);
|
||||
l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_Color);
|
||||
l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_Color);
|
||||
gd = new GridData();
|
||||
gd.horizontalAlignment = GridData.BEGINNING;
|
||||
l.setLayoutData(gd);
|
||||
|
@ -188,16 +186,16 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
public void widgetSelected(SelectionEvent e) {
|
||||
boolean systemDefault= fAppearanceColorDefault.getSelection();
|
||||
fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
|
||||
|
||||
|
||||
int i= fAppearanceColorList.getSelectionIndex();
|
||||
String key= fAppearanceColorListModel[i][2];
|
||||
if (key != null)
|
||||
fOverlayStore.setValue(key, systemDefault);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
|
||||
fAppearanceColorDefault.setText(PreferencesMessages.CEditorPreferencePage_colorPage_systemDefault);
|
||||
fAppearanceColorDefault.setText(PreferencesMessages.CEditorPreferencePage_colorPage_systemDefault);
|
||||
gd= new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalAlignment= GridData.BEGINNING;
|
||||
gd.horizontalSpan= 2;
|
||||
|
@ -243,7 +241,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
}
|
||||
|
||||
private Control createHeader(Composite parent) {
|
||||
String text = PreferencesMessages.CEditorPreferencePage_link;
|
||||
String text = PreferencesMessages.CEditorPreferencePage_link;
|
||||
Link link = new Link(parent, SWT.NONE);
|
||||
link.setText(text);
|
||||
link.addListener (SWT.Selection, new Listener () {
|
||||
|
@ -254,7 +252,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
});
|
||||
// TODO replace by link-specific tooltips when
|
||||
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
|
||||
link.setToolTipText(PreferencesMessages.CEditorPreferencePage_link_tooltip);
|
||||
link.setToolTipText(PreferencesMessages.CEditorPreferencePage_link_tooltip);
|
||||
|
||||
GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
|
||||
gridData.widthHint= 150; // only expand further if anyone else requires it
|
||||
|
@ -266,7 +264,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
* @see PreferencePage#createContents(Composite)
|
||||
*/
|
||||
protected Control createContents(Composite parent) {
|
||||
|
||||
fOverlayStore.load();
|
||||
fOverlayStore.start();
|
||||
|
||||
|
@ -280,8 +277,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
}
|
||||
|
||||
private void initialize() {
|
||||
|
||||
initializeFields();
|
||||
initializeDefaultColors();
|
||||
|
||||
for (int i = 0; i < fAppearanceColorListModel.length; i++) {
|
||||
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
|
||||
|
@ -292,14 +289,16 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
handleAppearanceColorListSelection();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performOk()
|
||||
/**
|
||||
* Initializes the default colors.
|
||||
*/
|
||||
public boolean performOk() {
|
||||
return super.performOk();
|
||||
private void initializeDefaultColors() {
|
||||
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
|
||||
RGB rgb= fAppearanceColorList.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
|
||||
PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -307,15 +306,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
|||
*/
|
||||
protected void performDefaults() {
|
||||
super.performDefaults();
|
||||
|
||||
initializeDefaultColors();
|
||||
handleAppearanceColorListSelection();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String CEditorPreferencePage_ContentAssistPage_parameterForegroundColor;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_sortingSection_title;
|
||||
public static String CEditorPreferencePage_sourceHoverBackgroundColor;
|
||||
public static String CEditorColoringConfigurationBlock_MultiLine;
|
||||
public static String CEditorColoringConfigurationBlock_singleLine;
|
||||
public static String CEditorColoringConfigurationBlock_keywords;
|
||||
|
@ -195,7 +196,7 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String SmartTypingConfigurationBlock_strings_title;
|
||||
|
||||
public static String CodeFormatterPreferencePage_title;
|
||||
public static String CodeFormatterPreferencePage_description;
|
||||
public static String CodeFormatterPreferencePage_description;
|
||||
|
||||
public static String TodoTaskPreferencePage_title;
|
||||
public static String TodoTaskPreferencePage_description;
|
||||
|
@ -211,7 +212,7 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String TodoTaskConfigurationBlock_casesensitive_label;
|
||||
public static String TodoTaskConfigurationBlock_needsbuild_title;
|
||||
public static String TodoTaskConfigurationBlock_tasks_default;
|
||||
|
||||
|
||||
public static String TodoTaskInputDialog_new_title;
|
||||
public static String TodoTaskInputDialog_edit_title;
|
||||
public static String TodoTaskInputDialog_name_label;
|
||||
|
@ -255,11 +256,11 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String SpellingPreferencePage_variables;
|
||||
|
||||
public static String LanguageMappings_missingLanguageTitle;
|
||||
|
||||
|
||||
public static String WorkspaceLanguagesPreferencePage_description;
|
||||
public static String WorkspaceLanguagesPreferencePage_missingLanguage;
|
||||
public static String WorkspaceLanguagesPreferencePage_mappingTableTitle;
|
||||
|
||||
|
||||
public static String ProjectLanguagesPropertyPage_description;
|
||||
public static String ProjectLanguagesPropertyPage_configurationColumn;
|
||||
public static String ProjectLanguagesPropertyPage_contentTypeColumn;
|
||||
|
@ -270,13 +271,13 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String ProjectLanguagesPropertyPage_overriddenContentType;
|
||||
public static String ProjectLanguagesPropertyPage_missingLanguage;
|
||||
public static String ProjectLanguagesPropertyPage_mappingTableTitle;
|
||||
|
||||
|
||||
public static String ContentTypeMappingsDialog_title;
|
||||
public static String ContentTypeMappingsDialog_configuration;
|
||||
public static String ContentTypeMappingsDialog_contentType;
|
||||
public static String ContentTypeMappingsDialog_language;
|
||||
public static String ContentTypeMappingsDialog_allConfigurations;
|
||||
|
||||
|
||||
public static String FileLanguagesPropertyPage_languageLabel;
|
||||
public static String FileLanguagesPropertyPage_inheritedProjectMappingsGroup;
|
||||
public static String FileLanguagesPropertyPage_contentTypeLabel;
|
||||
|
@ -289,7 +290,7 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String FileLanguagesPropertyPage_defaultMapping;
|
||||
public static String FileLanguagesPropertyPage_missingLanguage;
|
||||
public static String FileLanguagesPropertyPage_mappingTableTitle;
|
||||
|
||||
|
||||
public static String CPluginPreferencePage_caption;
|
||||
public static String CPluginPreferencePage_structuralParseMode_label;
|
||||
public static String CPluginPreferencePage_note;
|
||||
|
|
|
@ -39,6 +39,7 @@ CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor=Parameter hint
|
|||
CEditorPreferencePage_ContentAssistPage_parameterForegroundColor=Parameter hint foreground
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigger
|
||||
CEditorPreferencePage_ContentAssistPage_sortingSection_title=Sorting and Filtering
|
||||
CEditorPreferencePage_sourceHoverBackgroundColor=Source hover background
|
||||
|
||||
# {0} will be replaced by the keyboard shortcut for the command (e.g. "Ctrl+Space", or "no shortcut")
|
||||
CodeAssistAdvancedConfigurationBlock_page_description=Configure the behavior of the content assist ({0}) command.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2002, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.jface.text.Document;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
@ -31,6 +32,7 @@ import org.eclipse.swt.graphics.Color;
|
|||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -41,6 +43,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.ui.text.ICPartitions;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
|
||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||
|
@ -48,12 +51,12 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
|
|||
|
||||
/**
|
||||
* SourceViewerInformationControl
|
||||
* Source viewer based implementation of <code>IInformationControl</code>.
|
||||
* Displays information in a source viewer.
|
||||
*
|
||||
* Source viewer based implementation of <code>IInformationControl</code>.
|
||||
* Displays information in a source viewer.
|
||||
*
|
||||
*/
|
||||
public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener {
|
||||
|
||||
|
||||
/** Border thickness in pixels. */
|
||||
private static final int BORDER= 1;
|
||||
/** The control's shell */
|
||||
|
@ -61,22 +64,22 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
/** The control's text widget */
|
||||
private StyledText fText;
|
||||
/** The control's source viewer */
|
||||
private SourceViewer fViewer;
|
||||
private SourceViewer fViewer;
|
||||
/**
|
||||
* The optional status field.
|
||||
*
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
private Label fStatusField;
|
||||
private Label fStatusField;
|
||||
/**
|
||||
* The separator for the optional status field.
|
||||
*
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
private Label fSeparator;
|
||||
private Label fSeparator;
|
||||
/**
|
||||
* The font of the optional status text label.
|
||||
*
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
private Font fStatusTextFont;
|
||||
|
@ -90,12 +93,15 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
* @since 4.0
|
||||
*/
|
||||
private int fMaxHeight= SWT.DEFAULT;
|
||||
|
||||
|
||||
private Color fBackgroundColor;
|
||||
private boolean fIsSystemBackgroundColor= true;
|
||||
|
||||
/**
|
||||
* Creates a default information control with the given shell as parent. The given
|
||||
* information presenter is used to process the information to be displayed. The given
|
||||
* styles are applied to the created styled text widget.
|
||||
*
|
||||
*
|
||||
* @param parent the parent shell
|
||||
* @param shellStyle the additional styles for the shell
|
||||
* @param style the additional styles for the styled text widget
|
||||
|
@ -103,12 +109,12 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
public SourceViewerInformationControl(Shell parent, int shellStyle, int style) {
|
||||
this(parent, shellStyle, style, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a default information control with the given shell as parent. The given
|
||||
* information presenter is used to process the information to be displayed. The given
|
||||
* styles are applied to the created styled text widget.
|
||||
*
|
||||
*
|
||||
* @param parent the parent shell
|
||||
* @param shellStyle the additional styles for the shell
|
||||
* @param style the additional styles for the styled text widget
|
||||
|
@ -121,9 +127,11 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
GridData gd;
|
||||
|
||||
fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
|
||||
Display display= fShell.getDisplay();
|
||||
Display display= fShell.getDisplay();
|
||||
fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
|
||||
|
||||
initializeColors();
|
||||
|
||||
Composite composite= fShell;
|
||||
layout= new GridLayout(1, false);
|
||||
int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
|
||||
|
@ -142,31 +150,31 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
gd= new GridData(GridData.FILL_BOTH);
|
||||
composite.setLayoutData(gd);
|
||||
composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
|
||||
composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
|
||||
}
|
||||
composite.setBackground(fBackgroundColor);
|
||||
}
|
||||
|
||||
// Source viewer
|
||||
IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
|
||||
fViewer= new CSourceViewer(composite, null, null, false, style, store);
|
||||
CTextTools tools= CUIPlugin.getDefault().getTextTools();
|
||||
fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning(), false));
|
||||
fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
|
||||
fViewer.setEditable(false);
|
||||
|
||||
|
||||
fText= fViewer.getTextWidget();
|
||||
gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
|
||||
fText.setLayoutData(gd);
|
||||
fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
|
||||
fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
|
||||
fText.setBackground(fBackgroundColor);
|
||||
|
||||
initializeFont();
|
||||
|
||||
fText.addKeyListener(new KeyListener() {
|
||||
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.character == 0x1B) // ESC
|
||||
fShell.dispose();
|
||||
}
|
||||
|
||||
|
||||
public void keyReleased(KeyEvent e) {}
|
||||
});
|
||||
|
||||
|
@ -191,45 +199,62 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
|
||||
// Regarding the color see bug 41128
|
||||
fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
|
||||
|
||||
fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
|
||||
fStatusField.setBackground(fBackgroundColor);
|
||||
}
|
||||
|
||||
|
||||
addDisposeListener(this);
|
||||
}
|
||||
|
||||
private void initializeColors() {
|
||||
RGB bgRGB= getHoverBackgroundColorRGB();
|
||||
if (bgRGB != null) {
|
||||
fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
|
||||
fIsSystemBackgroundColor= false;
|
||||
} else {
|
||||
fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
|
||||
fIsSystemBackgroundColor= true;
|
||||
}
|
||||
}
|
||||
|
||||
private RGB getHoverBackgroundColorRGB() {
|
||||
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
|
||||
return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)
|
||||
? null
|
||||
: PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default information control with the given shell as parent. The given
|
||||
* information presenter is used to process the information to be displayed. The given
|
||||
* styles are applied to the created styled text widget.
|
||||
*
|
||||
*
|
||||
* @param parent the parent shell
|
||||
* @param style the additional styles for the styled text widget
|
||||
*/
|
||||
*/
|
||||
public SourceViewerInformationControl(Shell parent,int style) {
|
||||
this(parent, SWT.NO_TRIM, style);
|
||||
this(parent, SWT.NO_TRIM | SWT.TOOL, style);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a default information control with the given shell as parent. The given
|
||||
* information presenter is used to process the information to be displayed. The given
|
||||
* styles are applied to the created styled text widget.
|
||||
*
|
||||
*
|
||||
* @param parent the parent shell
|
||||
* @param style the additional styles for the styled text widget
|
||||
* @param statusFieldText the text to be used in the optional status field
|
||||
* or <code>null</code> if the status field should be hidden
|
||||
* @since 3.0
|
||||
*/
|
||||
*/
|
||||
public SourceViewerInformationControl(Shell parent,int style, String statusFieldText) {
|
||||
this(parent, SWT.NO_TRIM, style, statusFieldText);
|
||||
this(parent, SWT.NO_TRIM | SWT.TOOL, style, statusFieldText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default information control with the given shell as parent.
|
||||
* No information presenter is used to process the information
|
||||
* to be displayed. No additional styles are applied to the styled text widget.
|
||||
*
|
||||
*
|
||||
* @param parent the parent shell
|
||||
*/
|
||||
public SourceViewerInformationControl(Shell parent) {
|
||||
|
@ -240,7 +265,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
* Creates a default information control with the given shell as parent.
|
||||
* No information presenter is used to process the information
|
||||
* to be displayed. No additional styles are applied to the styled text widget.
|
||||
*
|
||||
*
|
||||
* @param parent the parent shell
|
||||
* @param statusFieldText the text to be used in the optional status field
|
||||
* or <code>null</code> if the status field should be hidden
|
||||
|
@ -249,10 +274,10 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
public SourceViewerInformationControl(Shell parent, String statusFieldText) {
|
||||
this(parent, SWT.NONE, statusFieldText);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the font to the editor font.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
private void initializeFont() {
|
||||
|
@ -279,12 +304,12 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
fViewer.setInput(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
IDocument doc= new Document(content);
|
||||
CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
|
||||
fViewer.setInput(doc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setVisible(boolean)
|
||||
*/
|
||||
|
@ -299,27 +324,29 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
public void widgetDisposed(DisposeEvent event) {
|
||||
if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
|
||||
fStatusTextFont.dispose();
|
||||
|
||||
|
||||
fStatusTextFont= null;
|
||||
fShell= null;
|
||||
fText= null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public final void dispose() {
|
||||
if (!fIsSystemBackgroundColor)
|
||||
fBackgroundColor.dispose();
|
||||
if (fShell != null && !fShell.isDisposed())
|
||||
fShell.dispose();
|
||||
else
|
||||
widgetDisposed(null);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setSize(int, int)
|
||||
*/
|
||||
public void setSize(int width, int height) {
|
||||
|
||||
|
||||
if (fStatusField != null) {
|
||||
GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
|
||||
Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
|
||||
|
@ -327,22 +354,18 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
gd.heightHint= height - statusSize.y - separatorSize.y;
|
||||
}
|
||||
fShell.setSize(width, height);
|
||||
|
||||
|
||||
if (fStatusField != null)
|
||||
fShell.pack(true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setLocation(Point)
|
||||
*/
|
||||
public void setLocation(Point location) {
|
||||
Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
|
||||
Point textLocation= fText.getLocation();
|
||||
location.x += trim.x - textLocation.x;
|
||||
location.y += trim.y - textLocation.y;
|
||||
fShell.setLocation(location);
|
||||
fShell.setLocation(location);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setSizeConstraints(int, int)
|
||||
*/
|
||||
|
@ -350,7 +373,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
fMaxWidth= maxWidth;
|
||||
fMaxHeight= maxHeight;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#computeSizeHint()
|
||||
*/
|
||||
|
@ -370,42 +393,42 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#addDisposeListener(DisposeListener)
|
||||
*/
|
||||
public void addDisposeListener(DisposeListener listener) {
|
||||
fShell.addDisposeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#removeDisposeListener(DisposeListener)
|
||||
*/
|
||||
public void removeDisposeListener(DisposeListener listener) {
|
||||
fShell.removeDisposeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setForegroundColor(Color)
|
||||
*/
|
||||
public void setForegroundColor(Color foreground) {
|
||||
fText.setForeground(foreground);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setBackgroundColor(Color)
|
||||
*/
|
||||
public void setBackgroundColor(Color background) {
|
||||
fText.setBackground(background);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#isFocusControl()
|
||||
*/
|
||||
public boolean isFocusControl() {
|
||||
return fText.isFocusControl();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#setFocus()
|
||||
*/
|
||||
|
@ -413,28 +436,28 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
|||
fShell.forceFocus();
|
||||
fText.setFocus();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#addFocusListener(FocusListener)
|
||||
*/
|
||||
public void addFocusListener(FocusListener listener) {
|
||||
fText.addFocusListener(listener);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControl#removeFocusListener(FocusListener)
|
||||
*/
|
||||
public void removeFocusListener(FocusListener listener) {
|
||||
fText.removeFocusListener(listener);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IInformationControlExtension#hasContents()
|
||||
*/
|
||||
public boolean hasContents() {
|
||||
return fText.getCharCount() > 0;
|
||||
}
|
||||
|
||||
|
||||
protected ISourceViewer getViewer() {
|
||||
return fViewer;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import org.eclipse.swt.graphics.RGB;
|
|||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||
import org.eclipse.cdt.internal.ui.text.IColorManager;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
@ -35,13 +37,13 @@ public class ContentAssistPreference {
|
|||
/** Preference key for content assist timeout delay (unused) */
|
||||
public final static String TIMEOUT_DELAY= "content_assist_timeout_delay"; //$NON-NLS-1$
|
||||
/** Preference key for content assist proposal color */
|
||||
public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
|
||||
public final static String PROPOSALS_FOREGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
|
||||
/** Preference key for content assist proposal color */
|
||||
public final static String PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$
|
||||
public final static String PROPOSALS_BACKGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
|
||||
/** Preference key for content assist parameters color */
|
||||
public final static String PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$
|
||||
public final static String PARAMETERS_FOREGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
|
||||
/** Preference key for content assist parameters color */
|
||||
public final static String PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
|
||||
public final static String PARAMETERS_BACKGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
|
||||
/** Preference key for content assist auto insert */
|
||||
public final static String AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$
|
||||
/** Preference key for content assist to insert the common prefix */
|
||||
|
@ -104,7 +106,7 @@ public class ContentAssistPreference {
|
|||
// boolean enabled;
|
||||
// enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
|
||||
// ccp.restrictProposalsToVisibility(enabled);
|
||||
//
|
||||
//
|
||||
// enabled= store.getBoolean(CASE_SENSITIVITY);
|
||||
// ccp.restrictProposalsToMatchingCases(enabled);
|
||||
|
||||
|
@ -112,23 +114,23 @@ public class ContentAssistPreference {
|
|||
// ccp.orderProposalsAlphabetically(enabled);
|
||||
|
||||
// enabled= store.getBoolean(ADD_INCLUDE);
|
||||
// ccp.allowAddingIncludes(enabled);
|
||||
// ccp.allowAddingIncludes(enabled);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure the given content assistant from the given store.
|
||||
*/
|
||||
public static void configure(ContentAssistant assistant, IPreferenceStore store) {
|
||||
public static void configure(ContentAssistant assistant, IPreferenceStore store) {
|
||||
|
||||
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
|
||||
IColorManager manager= textTools.getColorManager();
|
||||
IColorManager manager= textTools.getColorManager();
|
||||
|
||||
boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ));
|
||||
assistant.enableAutoActivation(enabled);
|
||||
assistant.enableAutoActivation(enabled);
|
||||
|
||||
int delay= store.getInt(AUTOACTIVATION_DELAY);
|
||||
assistant.setAutoActivationDelay(delay);
|
||||
|
@ -162,7 +164,7 @@ public class ContentAssistPreference {
|
|||
if (ccp == null)
|
||||
return;
|
||||
|
||||
if ( (AUTOACTIVATION_TRIGGERS_DOT.equals(key))
|
||||
if ( (AUTOACTIVATION_TRIGGERS_DOT.equals(key))
|
||||
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) ){
|
||||
boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
|
@ -205,14 +207,14 @@ public class ContentAssistPreference {
|
|||
|
||||
String p= event.getProperty();
|
||||
|
||||
if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
|
||||
if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))){
|
||||
boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ));
|
||||
assistant.enableAutoActivation(enabled);
|
||||
assistant.enableAutoActivation(enabled);
|
||||
} else if (AUTOACTIVATION_DELAY.equals(p)) {
|
||||
int delay= store.getInt(AUTOACTIVATION_DELAY);
|
||||
assistant.setAutoActivationDelay(delay);
|
||||
|
@ -236,7 +238,7 @@ public class ContentAssistPreference {
|
|||
} else if (PREFIX_COMPLETION.equals(p)) {
|
||||
boolean enabled= store.getBoolean(PREFIX_COMPLETION);
|
||||
assistant.enablePrefixCompletion(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
changeCProcessor(assistant, store, p);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue