Skip to content

Commit f327f98

Browse files
Christopher-Hermannfedejeanne
authored andcommitted
Use system colors as default for selection color
The system selection/highlight color is set as default color for the viewer selection in Eclipse. This color setting can be overwritten by the user via the color preferences.
1 parent 9b5ce3d commit f327f98

File tree

3 files changed

+87
-14
lines changed

3 files changed

+87
-14
lines changed

bundles/org.eclipse.ui.themes/css/dark/e4-dark_preferencestyle.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ IEclipsePreferences#org-eclipse-ui-workbench:org-eclipse-ui-themes { /* pseudo a
6565
'org.eclipse.ui.workbench.FORM_HEADING_ERROR_COLOR=255,110,110'
6666
'org.eclipse.ui.workbench.FORM_HEADING_WARNING_COLOR=255,200,0'
6767
'org.eclipse.ui.workbench.FORM_HEADING_INFO_COLOR=170,170,170'
68-
'org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND=255,255,255'
69-
'org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND=0,90,210'
70-
'org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND_NO_FOCUS=227,227,227'
71-
'org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND_NO_FOCUS=70,70,70'
7268
'ERROR_COLOR=247,68,117'
7369
'HYPERLINK_COLOR=111,197,238'
7470
'INCOMING_COLOR=31,179,235'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.eclipse.ui.internal.themes;
2+
3+
import java.util.Hashtable;
4+
import org.eclipse.core.runtime.IConfigurationElement;
5+
import org.eclipse.core.runtime.IExecutableExtension;
6+
import org.eclipse.swt.SWT;
7+
import org.eclipse.swt.graphics.RGB;
8+
import org.eclipse.swt.widgets.Display;
9+
import org.eclipse.ui.themes.IColorFactory;
10+
11+
/**
12+
* The factory to provide the default colors for viewer selections. The default
13+
* color is based on the system color for the title, which is the actual
14+
* highlight color. The color can be overwritten via the color preferences.
15+
*
16+
* @since 3.5
17+
*
18+
*/
19+
public class ColumnViewerSelectionColorFactory implements IColorFactory, IExecutableExtension {
20+
21+
private String color = null;
22+
23+
@Override
24+
public RGB createColor() {
25+
if ("SELECTED_CELL_BACKGROUND".equals(color)) { //$NON-NLS-1$
26+
return Display.getDefault().getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB();
27+
28+
} else if ("SELECTED_CELL_FOREGROUND".equals(color)) { //$NON-NLS-1$
29+
return Display.getDefault().getSystemColor(SWT.COLOR_TITLE_FOREGROUND).getRGB();
30+
31+
} else if ("SELECTED_CELL_BACKGROUND_NO_FOCUS".equals(color)) { //$NON-NLS-1$
32+
return Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND).getRGB();
33+
34+
} else if ("SELECTED_CELL_FOREGROUND_NO_FOCUS".equals(color)) { //$NON-NLS-1$
35+
return Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND).getRGB();
36+
37+
} else {
38+
return null;
39+
}
40+
}
41+
42+
@Override
43+
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
44+
if (data instanceof Hashtable table) {
45+
this.color = (String) table.get("color"); //$NON-NLS-1$
46+
}
47+
}
48+
49+
}

bundles/org.eclipse.ui/plugin.xml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,44 +2055,72 @@
20552055
</description>
20562056
</colorDefinition>
20572057
<colorDefinition
2058+
categoryId="org.eclipse.ui.workbenchMisc"
20582059
id="org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND"
20592060
isEditable="true"
2060-
categoryId="org.eclipse.ui.workbenchMisc"
2061-
label="%Color.selectedCellForeground"
2062-
value="255,255,255">
2061+
label="%Color.selectedCellForeground">
20632062
<description>
20642063
%Color.selectedCellForegroundDesc
20652064
</description>
2065+
<colorFactory
2066+
class="org.eclipse.ui.internal.themes.ColumnViewerSelectionColorFactory"
2067+
plugin="org.eclipse.ui">
2068+
<parameter
2069+
name="color"
2070+
value="SELECTED_CELL_FOREGROUND">
2071+
</parameter>
2072+
</colorFactory>
20662073
</colorDefinition>
20672074
<colorDefinition
2075+
categoryId="org.eclipse.ui.workbenchMisc"
20682076
id="org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND"
20692077
isEditable="true"
2070-
categoryId="org.eclipse.ui.workbenchMisc"
2071-
label="%Color.selectedCellBackground"
2072-
value="0,90,210">
2078+
label="%Color.selectedCellBackground">
20732079
<description>
20742080
%Color.selectedCellBackgroundDesc
20752081
</description>
2082+
<colorFactory
2083+
class="org.eclipse.ui.internal.themes.ColumnViewerSelectionColorFactory"
2084+
plugin="org.eclipse.ui">
2085+
<parameter
2086+
name="color"
2087+
value="SELECTED_CELL_BACKGROUND">
2088+
</parameter>
2089+
</colorFactory>
20762090
</colorDefinition>
20772091
<colorDefinition
20782092
id="org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND_NO_FOCUS"
20792093
isEditable="true"
20802094
categoryId="org.eclipse.ui.workbenchMisc"
2081-
label="%Color.selectedCellForegroundNoFocus"
2082-
value="0,0,0">
2095+
label="%Color.selectedCellForegroundNoFocus">
20832096
<description>
20842097
%Color.selectedCellForegroundNoFocusDesc
20852098
</description>
2099+
<colorFactory
2100+
class="org.eclipse.ui.internal.themes.ColumnViewerSelectionColorFactory"
2101+
plugin="org.eclipse.ui">
2102+
<parameter
2103+
name="color"
2104+
value="SELECTED_CELL_FOREGROUND_NO_FOCUS">
2105+
</parameter>
2106+
</colorFactory>
20862107
</colorDefinition>
20872108
<colorDefinition
20882109
id="org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND_NO_FOCUS"
20892110
isEditable="true"
20902111
categoryId="org.eclipse.ui.workbenchMisc"
2091-
label="%Color.selectedCellBackgroundNoFocus"
2092-
value="220,220,220">
2112+
label="%Color.selectedCellBackgroundNoFocus">
20932113
<description>
20942114
%Color.selectedCellBackgroundNoFocusDesc
20952115
</description>
2116+
<colorFactory
2117+
class="org.eclipse.ui.internal.themes.ColumnViewerSelectionColorFactory"
2118+
plugin="org.eclipse.ui">
2119+
<parameter
2120+
name="color"
2121+
value="SELECTED_CELL_BACKGROUND_NO_FOCUS">
2122+
</parameter>
2123+
</colorFactory>
20962124
</colorDefinition>
20972125
</extension>
20982126
<extension

0 commit comments

Comments
 (0)