Skip to content

Commit c06713f

Browse files
fedejeanneiloveeclipse
authored andcommitted
Revert "Highlighting problem when using the dark theme on Windows
eclipse-platform/eclipse.platform.swt#811" This reverts commit cbda3bc. Bundle versions are not reverted.
1 parent 521543f commit c06713f

File tree

20 files changed

+34
-624
lines changed

20 files changed

+34
-624
lines changed

bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Export-Package:
1010
org.eclipse.jface.contentassist.images,
1111
org.eclipse.jface.internal.text;x-internal:=true,
1212
org.eclipse.jface.internal.text.codemining;x-internal:=true,
13-
org.eclipse.jface.internal.text.contentassist;x-internal:=true,
1413
org.eclipse.jface.internal.text.html;x-friends:="org.eclipse.ant.ui, org.eclipse.jdt.ui, org.eclipse.ltk.ui.refactoring, org.eclipse.pde.ui, org.eclipse.ui.editors, org.eclipse.xtext.ui",
1514
org.eclipse.jface.internal.text.link.contentassist;x-internal:=true,
1615
org.eclipse.jface.internal.text.revisions;x-internal:=true,

bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java

Lines changed: 6 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
import org.eclipse.swt.widgets.Table;
2626
import org.eclipse.swt.widgets.TableItem;
2727

28-
import org.eclipse.jface.resource.ColorRegistry;
29-
import org.eclipse.jface.resource.JFaceResources;
30-
3128

3229
/**
3330
* Adds owner draw support for tables.
@@ -45,10 +42,6 @@ public class TableOwnerDrawSupport implements Listener {
4542

4643
public static void install(Table table) {
4744
TableOwnerDrawSupport listener= new TableOwnerDrawSupport(table);
48-
installListener(table, listener);
49-
}
50-
51-
protected static void installListener(Table table, Listener listener) {
5245
table.addListener(SWT.Dispose, listener);
5346
table.addListener(SWT.MeasureItem, listener);
5447
table.addListener(SWT.EraseItem, listener);
@@ -77,7 +70,7 @@ private static StyleRange[] getStyledRanges(TableItem item, int column) {
7770
return (StyleRange[])item.getData(STYLED_RANGES_KEY + column);
7871
}
7972

80-
protected TableOwnerDrawSupport(Table table) {
73+
private TableOwnerDrawSupport(Table table) {
8174
int orientation= table.getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
8275
fSharedLayout= new TextLayout(table.getDisplay());
8376
fSharedLayout.setOrientation(orientation);
@@ -154,28 +147,7 @@ private void performPaint(Event event) {
154147
Color oldForeground= gc.getForeground();
155148
Color oldBackground= gc.getBackground();
156149

157-
if (isSelected) {
158-
Color background= item.getParent().isFocusControl()
159-
? getSelectedRowBackgroundColor()
160-
: getSelectedRowBackgroundColorNoFocus();
161-
Color foreground= item.getParent().isFocusControl()
162-
? getSelectedRowForegroundColor()
163-
: getSelectedRowForegroundColorNoFocus();
164-
165-
if (background == null) {
166-
background= item.getDisplay().getSystemColor(
167-
SWT.COLOR_LIST_SELECTION);
168-
}
169-
170-
if (foreground == null) {
171-
foreground= item.getDisplay().getSystemColor(
172-
SWT.COLOR_LIST_SELECTION_TEXT);
173-
}
174-
175-
gc.setBackground(background);
176-
gc.setForeground(foreground);
177-
gc.fillRectangle(0, event.y, item.getParent().getBounds().width, event.height);
178-
} else {
150+
if (!isSelected) {
179151
Color foreground= item.getForeground(index);
180152
gc.setForeground(foreground);
181153

@@ -206,54 +178,10 @@ private void performPaint(Event event) {
206178
gc.drawFocus(focusBounds.x, focusBounds.y, focusBounds.width + fDeltaOfLastMeasure, focusBounds.height);
207179
}
208180

209-
gc.setForeground(oldForeground);
210-
gc.setBackground(oldBackground);
211-
}
212-
213-
/**
214-
* The color to use when rendering the background of the selected row when the control has the
215-
* input focus
216-
*
217-
* @return the color or <code>null</code> to use the default
218-
*/
219-
protected Color getSelectedRowBackgroundColor() {
220-
ColorRegistry colorRegistry= JFaceResources.getColorRegistry();
221-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND"); //$NON-NLS-1$
222-
}
223-
224-
/**
225-
* The color to use when rendering the foreground (=text) of the selected row when the control
226-
* has the input focus
227-
*
228-
* @return the color or <code>null</code> to use the default
229-
*/
230-
protected Color getSelectedRowForegroundColor() {
231-
ColorRegistry colorRegistry= JFaceResources.getColorRegistry();
232-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND"); //$NON-NLS-1$
233-
}
234-
235-
/**
236-
* The color to use when rendering the foreground (=text) of the selected row when the control
237-
* has <b>no</b> input focus
238-
*
239-
* @return the color or <code>null</code> to use the same used when control has focus
240-
* @since 3.4
241-
*/
242-
protected Color getSelectedRowForegroundColorNoFocus() {
243-
ColorRegistry colorRegistry= JFaceResources.getColorRegistry();
244-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND_NO_FOCUS"); //$NON-NLS-1$
245-
}
246-
247-
/**
248-
* The color to use when rendering the background of the selected row when the control has
249-
* <b>no</b> input focus
250-
*
251-
* @return the color or <code>null</code> to use the same used when control has focus
252-
* @since 3.4
253-
*/
254-
protected Color getSelectedRowBackgroundColorNoFocus() {
255-
ColorRegistry colorRegistry= JFaceResources.getColorRegistry();
256-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND_NO_FOCUS"); //$NON-NLS-1$
181+
if (!isSelected) {
182+
gc.setForeground(oldForeground);
183+
gc.setBackground(oldBackground);
184+
}
257185
}
258186

259187
private void widgetDisposed() {

bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/contentassist/CompletionTableDrawSupport.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.eclipse.swt.widgets.Table;
4040
import org.eclipse.swt.widgets.TableItem;
4141

42-
import org.eclipse.jface.internal.text.contentassist.CompletionTableDrawSupport;
42+
import org.eclipse.jface.internal.text.TableOwnerDrawSupport;
4343
import org.eclipse.jface.preference.JFacePreferences;
4444
import org.eclipse.jface.resource.ColorRegistry;
4545
import org.eclipse.jface.resource.JFaceColors;
@@ -269,7 +269,7 @@ private void createProposalSelector() {
269269

270270
fIsColoredLabelsSupportEnabled= fContentAssistant.isColoredLabelsSupportEnabled();
271271
if (fIsColoredLabelsSupportEnabled)
272-
CompletionTableDrawSupport.install(fProposalTable);
272+
TableOwnerDrawSupport.install(fProposalTable);
273273

274274
fProposalTable.setLocation(0, 0);
275275
if (fAdditionalInfoController != null)
@@ -572,7 +572,7 @@ private void setProposals(ICompletionProposal[] proposals) {
572572

573573
item.setText(displayString);
574574
if (fIsColoredLabelsSupportEnabled)
575-
CompletionTableDrawSupport.storeStyleRanges(item, 0, styleRanges);
575+
TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges);
576576

577577
item.setData(p);
578578

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
import org.eclipse.jface.bindings.keys.SWTKeySupport;
7979
import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
8080
import org.eclipse.jface.internal.text.InformationControlReplacer;
81-
import org.eclipse.jface.internal.text.contentassist.CompletionTableDrawSupport;
81+
import org.eclipse.jface.internal.text.TableOwnerDrawSupport;
8282
import org.eclipse.jface.preference.JFacePreferences;
8383
import org.eclipse.jface.resource.JFaceColors;
8484
import org.eclipse.jface.resource.JFaceResources;
@@ -613,7 +613,7 @@ void createProposalSelector() {
613613

614614
fIsColoredLabelsSupportEnabled= fContentAssistant.isColoredLabelsSupportEnabled();
615615
if (fIsColoredLabelsSupportEnabled)
616-
CompletionTableDrawSupport.install(fProposalTable);
616+
TableOwnerDrawSupport.install(fProposalTable);
617617

618618
fProposalTable.setLocation(0, 0);
619619
if (fAdditionalInfoController != null)
@@ -904,7 +904,7 @@ private void handleSetData(Event event) {
904904

905905
item.setText(displayString);
906906
if (fIsColoredLabelsSupportEnabled)
907-
CompletionTableDrawSupport.storeStyleRanges(item, 0, styleRanges);
907+
TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges);
908908

909909
item.setImage(image);
910910
item.setData(current);

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import org.eclipse.core.runtime.Assert;
2020
import org.eclipse.jface.util.Util;
21-
import org.eclipse.jface.resource.ColorRegistry;
22-
import org.eclipse.jface.resource.JFaceResources;
2321
import org.eclipse.swt.SWT;
2422
import org.eclipse.swt.graphics.Color;
2523
import org.eclipse.swt.graphics.GC;
@@ -153,8 +151,8 @@ private void hookListener(final ColumnViewer viewer) {
153151
* @return the color or <code>null</code> to use the default
154152
*/
155153
protected Color getSelectedCellBackgroundColor(ViewerCell cell) {
156-
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
157-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND"); //$NON-NLS-1$
154+
return removeNonFocusedSelectionInformation ? null
155+
: cell.getItem().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
158156
}
159157

160158
/**
@@ -166,8 +164,7 @@ protected Color getSelectedCellBackgroundColor(ViewerCell cell) {
166164
* @return the color or <code>null</code> to use the default
167165
*/
168166
protected Color getSelectedCellForegroundColor(ViewerCell cell) {
169-
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
170-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND"); //$NON-NLS-1$
167+
return null;
171168
}
172169

173170
/**
@@ -181,8 +178,7 @@ protected Color getSelectedCellForegroundColor(ViewerCell cell) {
181178
* @since 3.4
182179
*/
183180
protected Color getSelectedCellForegroundColorNoFocus(ViewerCell cell) {
184-
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
185-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND_NO_FOCUS"); //$NON-NLS-1$
181+
return null;
186182
}
187183

188184
/**
@@ -196,8 +192,7 @@ protected Color getSelectedCellForegroundColorNoFocus(ViewerCell cell) {
196192
* @since 3.4
197193
*/
198194
protected Color getSelectedCellBackgroundColorNoFocus(ViewerCell cell) {
199-
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
200-
return colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND_NO_FOCUS"); //$NON-NLS-1$
195+
return null;
201196
}
202197

203198
/**

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/OwnerDrawLabelProvider.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import java.util.HashSet;
1818
import java.util.Set;
1919

20-
import org.eclipse.jface.resource.ColorRegistry;
21-
import org.eclipse.jface.resource.JFaceResources;
2220
import org.eclipse.swt.SWT;
2321
import org.eclipse.swt.graphics.Color;
2422
import org.eclipse.swt.graphics.Rectangle;
@@ -168,16 +166,20 @@ public void update(ViewerCell cell) {
168166
}
169167

170168
/**
171-
* Handle the erase event. The default implementation colors the background of
172-
* selected areas with "org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND" and
173-
* foregrounds with "org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND". Note
174-
* that this implementation causes non-native behavior on some platforms.
175-
* Subclasses should override this method and <b>not</b> call the super
169+
* Handle the erase event. The default implementation colors the background
170+
* of selected areas with {@link SWT#COLOR_LIST_SELECTION} and foregrounds
171+
* with {@link SWT#COLOR_LIST_SELECTION_TEXT}. Note that this
172+
* implementation causes non-native behavior on some platforms. Subclasses
173+
* should override this method and <b>not</b> call the super
176174
* implementation.
177175
*
178-
* @param event the erase event
179-
* @param element the model object
176+
* @param event
177+
* the erase event
178+
* @param element
179+
* the model object
180180
* @see SWT#EraseItem
181+
* @see SWT#COLOR_LIST_SELECTION
182+
* @see SWT#COLOR_LIST_SELECTION_TEXT
181183
*/
182184
protected void erase(Event event, Object element) {
183185

@@ -187,16 +189,11 @@ protected void erase(Event event, Object element) {
187189
Color oldForeground = event.gc.getForeground();
188190
Color oldBackground = event.gc.getBackground();
189191

190-
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
191-
if (event.widget instanceof Control control && control.isFocusControl()) {
192-
event.gc.setBackground(colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND")); //$NON-NLS-1$
193-
event.gc.setForeground(colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND")); //$NON-NLS-1$
194-
} else {
195-
event.gc.setBackground(colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND_NO_FOCUS")); //$NON-NLS-1$
196-
event.gc.setForeground(colorRegistry.get("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND_NO_FOCUS")); //$NON-NLS-1$
197-
}
192+
event.gc.setBackground(event.item.getDisplay().getSystemColor(
193+
SWT.COLOR_LIST_SELECTION));
194+
event.gc.setForeground(event.item.getDisplay().getSystemColor(
195+
SWT.COLOR_LIST_SELECTION_TEXT));
198196
event.gc.fillRectangle(bounds);
199-
200197
/* restore the old GC colors */
201198
event.gc.setForeground(oldForeground);
202199
event.gc.setBackground(oldBackground);

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ protected void erase(Event event, Object element) {
263263
// info has been set by 'update': announce that we paint ourselves
264264
event.detail &= ~SWT.FOREGROUND;
265265
}
266-
super.erase(event, element);
267266
}
268267

269268
@Override

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.eclipse.jface.viewers;
2121

2222
import org.eclipse.core.runtime.Assert;
23-
import org.eclipse.jface.viewers.internal.ColumnViewerSelectionColorListener;
2423
import org.eclipse.jface.viewers.internal.ExpandableNode;
2524
import org.eclipse.pde.api.tools.annotations.NoExtend;
2625
import org.eclipse.swt.SWT;
@@ -120,7 +119,6 @@ public TableViewer(Composite parent, int style) {
120119
public TableViewer(Table table) {
121120
this.table = table;
122121
hookControl(table);
123-
overwriteSelectionColor();
124122
}
125123

126124
@Override
@@ -509,13 +507,4 @@ void handleExpandableNodeClicked(Widget w) {
509507
}
510508
}
511509

512-
/**
513-
* The color of the selected item is drawn by the OS. On some OS the color might
514-
* be not accessible. To fix this issue the background color for selected items
515-
* is drawn in a custom method.
516-
*/
517-
private void overwriteSelectionColor() {
518-
ColumnViewerSelectionColorListener.addListenerToViewer(this);
519-
}
520-
521510
}

0 commit comments

Comments
 (0)