From c6f20e1d0f937d299cfa4d6d67b3349a19584590 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Wed, 15 Apr 2026 09:40:00 +0200 Subject: [PATCH] Replace deprecated Color(Device, ...) constructors with display-free variants Replaces all usages of the deprecated new Color(Device/Display, ...) SWT constructors with the modern equivalents that do not require a Device parameter, as per eclipse-platform/eclipse.platform.swt#3233. Co-Authored-By: Claude Sonnet 4.6 --- .../org/eclipse/gef/cloudio/tests/ui/TestLabelProvider.java | 2 +- .../src/org/eclipse/gef/cloudio/internal/ui/TagCloud.java | 4 ++-- .../gef/cloudio/internal/ui/view/CloudOptionsComposite.java | 6 +++--- .../gef/cloudio/internal/ui/view/TypeLabelProvider.java | 2 +- .../dot/tests/DotHtmlLabelIndentationHighlightingTest.xtend | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/org.eclipse.gef.cloudio.tests.ui/src/org/eclipse/gef/cloudio/tests/ui/TestLabelProvider.java b/org.eclipse.gef.cloudio.tests.ui/src/org/eclipse/gef/cloudio/tests/ui/TestLabelProvider.java index f664f54791..fc1a1771ae 100644 --- a/org.eclipse.gef.cloudio.tests.ui/src/org/eclipse/gef/cloudio/tests/ui/TestLabelProvider.java +++ b/org.eclipse.gef.cloudio.tests.ui/src/org/eclipse/gef/cloudio/tests/ui/TestLabelProvider.java @@ -23,7 +23,7 @@ public class TestLabelProvider extends BaseLabelProvider implements ICloudLabelP public static final double WEIGHT = 0.987D; public static final float ANGLE = 12.34F; - public static Color COLOR = new Color(Display.getDefault(), new RGB(100, 100, 100)); + public static Color COLOR = new Color(new RGB(100, 100, 100)); public static FontData[] FONT_DATA = Display.getDefault().getShells()[0].getFont().getFontData(); public String getLabel(Object element) { diff --git a/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/TagCloud.java b/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/TagCloud.java index df34fbe371..6c45fae953 100644 --- a/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/TagCloud.java +++ b/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/TagCloud.java @@ -237,10 +237,10 @@ public TagCloud(Composite parent, int style, int accuracy, int maxSize) { this.accuracy = accuracy; this.maxSize = maxSize; cloudArea = new Rectangle(0, 0, maxSize, maxSize); - highlightColor = new Color(getDisplay(), Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB()); + highlightColor = new Color(Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB()); gc = new GC(this); layouter = new DefaultLayouter(accuracy, accuracy); - setBackground(new Color(getDisplay(), Display.getDefault().getSystemColor(SWT.COLOR_WHITE).getRGB())); + setBackground(new Color(Display.getDefault().getSystemColor(SWT.COLOR_WHITE).getRGB())); initListeners(); textLayerImage = new Image(getDisplay(), 100, 100); zoomFit(); diff --git a/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/CloudOptionsComposite.java b/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/CloudOptionsComposite.java index 4fd22eaa63..a4305b5e51 100644 --- a/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/CloudOptionsComposite.java +++ b/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/CloudOptionsComposite.java @@ -229,7 +229,7 @@ public void widgetDefaultSelected(SelectionEvent e) { protected Image createImageFromColor(RGB rgb, int size) { Image image; - Color color = new Color(Display.getDefault(), rgb); + Color color = new Color(rgb); image = new Image(Display.getDefault(), size, size); GC gc = new GC(image); gc.setBackground(color); @@ -355,7 +355,7 @@ public void widgetSelected(SelectionEvent e) { if (color == null) return; Color old = viewer.getCloud().getBackground(); - Color c = new Color(Display.getDefault(), color); + Color c = new Color(color); viewer.getCloud().setBackground(c); old.dispose(); viewer.getCloud().redrawTextLayerImage(); @@ -382,7 +382,7 @@ public void widgetSelected(SelectionEvent e) { if (color == null) return; Color old = viewer.getCloud().getSelectionColor(); - Color c = new Color(Display.getDefault(), color); + Color c = new Color(color); viewer.getCloud().setSelectionColor(c); old.dispose(); viewer.getCloud().redrawTextLayerImage(); diff --git a/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/TypeLabelProvider.java b/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/TypeLabelProvider.java index 75b9a53b2d..388328d43e 100644 --- a/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/TypeLabelProvider.java +++ b/org.eclipse.gef.cloudio.ui/src/org/eclipse/gef/cloudio/internal/ui/view/TypeLabelProvider.java @@ -135,7 +135,7 @@ public void setColors(List newColors) { colorList.clear(); colors.clear(); for (RGB color : newColors) { - Color c = new Color(Display.getDefault(), color); + Color c = new Color(color); colorList.add(c); } } diff --git a/org.eclipse.gef.dot.tests/src/org/eclipse/gef/dot/tests/DotHtmlLabelIndentationHighlightingTest.xtend b/org.eclipse.gef.dot.tests/src/org/eclipse/gef/dot/tests/DotHtmlLabelIndentationHighlightingTest.xtend index c5a6a9cce9..550fd0f65e 100644 --- a/org.eclipse.gef.dot.tests/src/org/eclipse/gef/dot/tests/DotHtmlLabelIndentationHighlightingTest.xtend +++ b/org.eclipse.gef.dot.tests/src/org/eclipse/gef/dot/tests/DotHtmlLabelIndentationHighlightingTest.xtend @@ -120,8 +120,8 @@ class DotHtmlLabelIndentationHighlightingTest extends AbstractHighlightingTest { int foregroundR, int foregroundG, int foregroundB, int backgroundR, int backgroundG, int backgroundB) { - val expectedForegroundColor = new Color(null, foregroundR, foregroundG, foregroundB) - val expectedBackgroundColor = new Color(null, backgroundR, backgroundG, backgroundB) + val expectedForegroundColor = new Color(foregroundR, foregroundG, foregroundB) + val expectedBackgroundColor = new Color(backgroundR, backgroundG, backgroundB) for(highlightingRegion : highlightingRegions) { val offset = highlightingRegion.offset