Skip to content

Commit ce2f24c

Browse files
committed
Streamline ImageDescriptor implementations and avoid getImageData()
ImageDescriptor.getImageData() is deprecated and sub-classes are advised to stop re-implementing it and instead implement getImageData(int). The still existing implementations just replicate the default implementation and therefore can just be removed. Additionally the custom and internal 'ImageImageDescriptor' and '(Abstract)OverlayIcon' classes are replaced with implementations provided by standard JFace.
1 parent 30affe0 commit ce2f24c

File tree

6 files changed

+13
-234
lines changed

6 files changed

+13
-234
lines changed

ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/EditorImageDescriptor.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2005 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
77
* https://www.eclipse.org/legal/epl-2.0/
88
*
99
* SPDX-License-Identifier: EPL-2.0
10-
*
10+
*
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
1313
*******************************************************************************/
1414
package org.eclipse.ant.internal.ui.views.actions;
1515

1616
import org.eclipse.jface.resource.ImageDescriptor;
17-
import org.eclipse.swt.graphics.Image;
1817
import org.eclipse.swt.graphics.ImageData;
1918
import org.eclipse.swt.program.Program;
2019
import org.eclipse.ui.ISharedImages;
@@ -36,11 +35,9 @@ public EditorImageDescriptor(Program program) {
3635

3736
@Override
3837
public boolean equals(Object o) {
39-
if (!(o instanceof EditorImageDescriptor)) {
38+
if (!(o instanceof EditorImageDescriptor other)) {
4039
return false;
4140
}
42-
EditorImageDescriptor other = (EditorImageDescriptor) o;
43-
4441
// See if there is a name - compare it if so and compare the programs if not
4542
String otherName = other.program.getName();
4643
if (otherName == null) {
@@ -49,17 +46,9 @@ public boolean equals(Object o) {
4946
return otherName.equals(program.getName());
5047
}
5148

52-
/**
53-
* Returns an SWT Image that is described by the information in this descriptor. Each call returns a new Image.
54-
*/
55-
public Image getImage() {
56-
return createImage();
57-
}
58-
5949
@Override
60-
public ImageData getImageData() {
61-
62-
ImageData defaultImage = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE).getImageData();
50+
public ImageData getImageData(int zoom) {
51+
ImageData defaultImage = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE).getImageData(zoom);
6352
if (defaultImage == null) {
6453
return null;
6554
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2013 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -78,7 +78,7 @@ public static ImageDescriptor getImageDescriptor(Image image) {
7878
if (image != null) {
7979
ImageDescriptor descriptor = fgImages.get(image);
8080
if (descriptor == null) {
81-
descriptor = new ImageImageDescriptor(image);
81+
descriptor = ImageDescriptor.createFromImage(image);
8282
fgImages.put(image, descriptor);
8383
}
8484
return descriptor;

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java

Lines changed: 0 additions & 122 deletions
This file was deleted.

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/OverlayIcon.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,6 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.help.ui.internal.views;
1515

16+
import java.util.Arrays;
17+
1618
import org.eclipse.help.HelpSystem;
1719
import org.eclipse.help.IHelpResource;
1820
import org.eclipse.help.IToc;
@@ -22,9 +24,10 @@
2224
import org.eclipse.help.internal.toc.Toc;
2325
import org.eclipse.help.ui.internal.HelpUIResources;
2426
import org.eclipse.help.ui.internal.IHelpUIConstants;
25-
import org.eclipse.help.ui.internal.util.OverlayIcon;
2627
import org.eclipse.jface.action.IToolBarManager;
2728
import org.eclipse.jface.resource.ImageDescriptor;
29+
import org.eclipse.jface.viewers.DecorationOverlayIcon;
30+
import org.eclipse.jface.viewers.IDecoration;
2831
import org.eclipse.jface.viewers.ITreeContentProvider;
2932
import org.eclipse.jface.viewers.ITreeViewerListener;
3033
import org.eclipse.jface.viewers.LabelProvider;
@@ -205,8 +208,7 @@ private void initializeImages() {
205208
.getImageDescriptor(IHelpUIConstants.IMAGE_CONTAINER);
206209
ImageDescriptor ovr = HelpUIResources
207210
.getImageDescriptor(IHelpUIConstants.IMAGE_DOC_OVR);
208-
ImageDescriptor desc = new OverlayIcon(base,
209-
new ImageDescriptor[][] { { ovr } });
211+
ImageDescriptor desc = new DecorationOverlayIcon(base, ovr, IDecoration.BOTTOM_RIGHT);
210212
containerWithTopicImage = desc.createImage();
211213
}
212214

0 commit comments

Comments
 (0)