Skip to content

Commit ce4d77d

Browse files
committed
Stop using Color constructors with Display
Simplifies the code and reduces chances for problems. Contributes to eclipse-platform/eclipse.platform.swt#3233 .
1 parent 98f8410 commit ce4d77d

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

org.eclipse.jdt.core.tests.model/workspace/Converter/src/test0501/JavaEditor.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2003 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Common Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -429,15 +429,14 @@ private void updateColor(ISourceViewer viewer) {
429429
if (text == null || text.isDisposed())
430430
return;
431431

432-
Display display= text.getDisplay();
433-
fColor= createColor(getPreferenceStore(), JavaEditor.LINK_COLOR, display);
432+
fColor= createColor(getPreferenceStore(), JavaEditor.LINK_COLOR);
434433
}
435434

436435
/**
437436
* Creates a color from the information stored in the given preference store.
438437
* Returns <code>null</code> if there is no such information available.
439438
*/
440-
private Color createColor(IPreferenceStore store, String key, Display display) {
439+
private Color createColor(IPreferenceStore store, String key) {
441440

442441
RGB rgb= null;
443442

@@ -449,7 +448,7 @@ private Color createColor(IPreferenceStore store, String key, Display display) {
449448
rgb= PreferenceConverter.getColor(store, key);
450449

451450
if (rgb != null)
452-
return new Color(display, rgb);
451+
return new Color(rgb);
453452
}
454453

455454
return null;

org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/X26.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* <code><pre>
1414
* Canvas canvas = new Canvas(shell, SWT.BORDER);
1515
* canvas.setBounds(10, 10, 300, 300);
16-
* Color color = new Color(null, 255, 0, 0);
16+
* Color color = new Color(255, 0, 0);
1717
* canvas.setBackground(color);
1818
* ControlEditor editor = new ControlEditor (canvas);
1919
* // The editor will be a button in the bottom right corner of the canvas.
@@ -28,7 +28,7 @@
2828
* RGB rgb = dialog.getRGB();
2929
* if (rgb != null) {
3030
* if (color != null) color.dispose();
31-
* color = new Color(null, rgb);
31+
* color = new Color(rgb);
3232
* canvas.setBackground(color);
3333
* }
3434
*

org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X26.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* <code><pre>
1515
* Canvas canvas = new Canvas(shell, SWT.BORDER);
1616
* canvas.setBounds(10, 10, 300, 300);
17-
* Color color = new Color(null, 255, 0, 0);
17+
* Color color = new Color(255, 0, 0);
1818
* canvas.setBackground(color);
1919
* ControlEditor editor = new ControlEditor (canvas);
2020
* // The editor will be a button in the bottom right corner of the canvas.
@@ -29,7 +29,7 @@
2929
* RGB rgb = dialog.getRGB();
3030
* if (rgb != null) {
3131
* if (color != null) color.dispose();
32-
* color = new Color(null, rgb);
32+
* color = new Color(rgb);
3333
* canvas.setBackground(color);
3434
* }
3535
*

0 commit comments

Comments
 (0)