Skip to content

Commit 94eabfd

Browse files
committed
Update Color constructors to modern signature
Follows eclipse-platform/eclipse.platform.swt#3232 by removing the Device/Display argument from Color constructors.
1 parent 0586f17 commit 94eabfd

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTColorHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class CSSSWTColorHelper {
5252

5353
/*--------------- SWT Color Helper -----------------*/
5454

55-
public static Color getSWTColor(RGBColor rgbColor, Display display) {
55+
public static Color getSWTColor(RGBColor rgbColor) {
5656
RGBA rgb = getRGBA(rgbColor);
5757
return new Color(rgb);
5858
}

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ColorRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public ColorRegistry(Display display, boolean cleanOnDisplayDisposal) {
124124
}
125125

126126
/**
127-
* Create a new <code>Color</code> on the receivers <code>Display</code>.
127+
* Create a new <code>Color</code> for the given RGB value.
128128
*
129129
* @param rgb the <code>RGB</code> data for the color.
130130
* @return the new <code>Color</code> object.

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/RGBColorDescriptor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ public int hashCode() {
6666

6767
@Override
6868
public Color createColor(Device device) {
69-
// If this descriptor is wrapping an existing color, then we can return the original color
70-
// if this is the same device.
71-
if (originalColor != null && originalColor.getDevice() == device) {
72-
// If we're allocating on the same device as the original color, return the original.
69+
// If this descriptor is wrapping an existing color, return the original.
70+
if (originalColor != null) {
7371
return originalColor;
7472
}
7573
return new Color(color);

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,8 +4222,6 @@ private void initializeFindScopeColor(ISourceViewer viewer) {
42224222
IPreferenceStore store = getPreferenceStore();
42234223
if (store != null) {
42244224

4225-
StyledText styledText = viewer.getTextWidget();
4226-
42274225
Color color = createColor(store, PREFERENCE_COLOR_FIND_SCOPE);
42284226

42294227
IFindReplaceTarget target = viewer.getFindReplaceTarget();

examples/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/sources/inlined/InlinedAnnotationDemo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.eclipse.jface.text.source.inlined.Positions;
4242
import org.eclipse.swt.SWT;
4343
import org.eclipse.swt.graphics.Color;
44-
import org.eclipse.swt.graphics.Device;
4544
import org.eclipse.swt.graphics.GC;
4645
import org.eclipse.swt.graphics.Rectangle;
4746
import org.eclipse.swt.layout.FillLayout;
@@ -195,7 +194,7 @@ private static Set<AbstractInlinedAnnotation> getInlinedAnnotation(ISourceViewer
195194
String rgb = line.substring(index + "color:".length()).trim();
196195
try {
197196
String status = "OK!";
198-
Color color = parse(rgb, viewer.getTextWidget().getDisplay());
197+
Color color = parse(rgb);
199198
if (color != null) {
200199
} else {
201200
status = "ERROR!";
@@ -282,7 +281,7 @@ private static int addRGBParamNameAnnotation(String paramName, String rgbContent
282281
* the rgb string color
283282
* @return the created color and null otherwise.
284283
*/
285-
private static Color parse(String input, Device device) {
284+
private static Color parse(String input) {
286285
Pattern c = Pattern.compile("rgb *\\( *([0-9]+), *([0-9]+), *([0-9]+) *\\)");
287286
Matcher m = c.matcher(input);
288287
if (m.matches()) {

0 commit comments

Comments
 (0)