|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2024 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials are made available under the |
5 | 5 | * terms of the Eclipse Public License 2.0 which is available at |
|
25 | 25 | import org.eclipse.swt.widgets.Display; |
26 | 26 |
|
27 | 27 | import org.eclipse.jface.resource.ImageDescriptor; |
| 28 | +import org.eclipse.jface.resource.ResourceManager; |
28 | 29 | import org.eclipse.ui.IMemento; |
29 | 30 |
|
30 | 31 | import org.eclipse.draw2d.Border; |
@@ -58,6 +59,11 @@ public abstract class PaletteEditPart extends AbstractGraphicalEditPart implemen |
58 | 59 | */ |
59 | 60 | public static final String XML_NAME = "entry"; //$NON-NLS-1$ |
60 | 61 | private static final Border TOOLTIP_BORDER = new MarginBorder(0, 2, 1, 0); |
| 62 | + /** |
| 63 | + * @deprecated Use {@code getViewer().getResourceManager()} instead. This field |
| 64 | + * will be removed after the 2025-12 release. |
| 65 | + */ |
| 66 | + @Deprecated(forRemoval = true, since = "2025-12") |
61 | 67 | private static ImageCache globalImageCache; |
62 | 68 | private AccessibleEditPart acc; |
63 | 69 | private final PropertyChangeListener childListener = evt -> { |
@@ -206,7 +212,10 @@ public DragTracker getDragTracker(Request request) { |
206 | 212 | * the same image in different palettes is only ever created once. |
207 | 213 | * |
208 | 214 | * @return the image cache. |
| 215 | + * @deprecated Use {@code getViewer().getResourceManager()} instead. This method |
| 216 | + * will be removed after the 2025-12 release. |
209 | 217 | */ |
| 218 | + @Deprecated(forRemoval = true, since = "2025-12") |
210 | 219 | protected static ImageCache getImageCache() { |
211 | 220 | ImageCache cache = globalImageCache; |
212 | 221 | if (cache == null) { |
@@ -419,8 +428,12 @@ protected void setImageDescriptor(ImageDescriptor desc) { |
419 | 428 | if (desc == imgDescriptor) { |
420 | 429 | return; |
421 | 430 | } |
| 431 | + ResourceManager resourceManager = getViewer().getResourceManager(); |
| 432 | + if (imgDescriptor != null) { |
| 433 | + resourceManager.destroy(imgDescriptor); |
| 434 | + } |
422 | 435 | imgDescriptor = desc; |
423 | | - setImageInFigure(getImageCache().getImage(imgDescriptor)); |
| 436 | + setImageInFigure(resourceManager.create(imgDescriptor)); |
424 | 437 | } |
425 | 438 |
|
426 | 439 | /** |
@@ -450,7 +463,11 @@ private void traverseChildren(List<? extends PaletteEntry> children, boolean add |
450 | 463 |
|
451 | 464 | /** |
452 | 465 | * The image cache for this edit part. |
| 466 | + * |
| 467 | + * @deprecated Use {@code getViewer().getResourceManager()} instead. This class |
| 468 | + * will be removed after the 2025-12 release. |
453 | 469 | */ |
| 470 | + @Deprecated(forRemoval = true, since = "2025-12") |
454 | 471 | protected static class ImageCache { |
455 | 472 | /** Map from ImageDescriptor to Image */ |
456 | 473 | private final Map<ImageDescriptor, Image> images = new HashMap<>(11); |
|
0 commit comments