@@ -170,10 +170,11 @@ public void update(ViewerCell cell) {
170
170
/**
171
171
* Handle the erase event. The default implementation colors the background of
172
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
176
- * implementation.
173
+ * foregrounds with "org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND" if these
174
+ * colors are available, if not {@link SWT#COLOR_LIST_SELECTION} and
175
+ * {@link SWT#COLOR_LIST_SELECTION_TEXT} is used. Note that this implementation
176
+ * causes non-native behavior on some platforms. Subclasses should override this
177
+ * method and <b>not</b> call the super implementation.
177
178
*
178
179
* @param event the erase event
179
180
* @param element the model object
@@ -189,11 +190,27 @@ protected void erase(Event event, Object element) {
189
190
190
191
ColorRegistry colorRegistry = JFaceResources .getColorRegistry ();
191
192
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$
193
+ Color background = colorRegistry .get ("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND" ); //$NON-NLS-1$
194
+ if (background == null ) {
195
+ background = event .item .getDisplay ().getSystemColor (SWT .COLOR_LIST_SELECTION );
196
+ }
197
+ Color foreground = colorRegistry .get ("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND" ); //$NON-NLS-1$
198
+ if (foreground == null ) {
199
+ foreground = event .item .getDisplay ().getSystemColor (SWT .COLOR_LIST_SELECTION_TEXT );
200
+ }
201
+ event .gc .setBackground (background );
202
+ event .gc .setForeground (foreground );
194
203
} 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$
204
+ Color background = colorRegistry .get ("org.eclipse.ui.workbench.SELECTED_CELL_BACKGROUND_NO_FOCUS" ); //$NON-NLS-1$
205
+ if (background == null ) {
206
+ background = event .item .getDisplay ().getSystemColor (SWT .COLOR_LIST_SELECTION );
207
+ }
208
+ Color foreground = colorRegistry .get ("org.eclipse.ui.workbench.SELECTED_CELL_FOREGROUND_NO_FOCUS" ); //$NON-NLS-1$
209
+ if (foreground == null ) {
210
+ foreground = event .item .getDisplay ().getSystemColor (SWT .COLOR_LIST_SELECTION_TEXT );
211
+ }
212
+ event .gc .setBackground (background );
213
+ event .gc .setForeground (foreground );
197
214
}
198
215
event .gc .fillRectangle (bounds );
199
216
0 commit comments