From 9623cdacb092231c546330199010079f994c4d67 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Fri, 11 Apr 2025 19:35:43 +0200 Subject: [PATCH 1/2] 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. --- .../views/actions/EditorImageDescriptor.java | 23 +--- .../ui/views/launch/DebugElementHelper.java | 9 +- .../ui/views/launch/ImageImageDescriptor.java | 48 ------- .../ui/internal/util/AbstractOverlayIcon.java | 122 ------------------ .../help/ui/internal/util/OverlayIcon.java | 42 ------ .../help/ui/internal/views/AllTopicsPart.java | 15 +-- 6 files changed, 15 insertions(+), 244 deletions(-) delete mode 100644 debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java delete mode 100644 ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java delete mode 100644 ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/OverlayIcon.java diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/EditorImageDescriptor.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/EditorImageDescriptor.java index 2e9eb6e456c..698b785d72d 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/EditorImageDescriptor.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/EditorImageDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,14 +7,13 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.ant.internal.ui.views.actions; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.program.Program; import org.eclipse.ui.ISharedImages; @@ -36,11 +35,9 @@ public EditorImageDescriptor(Program program) { @Override public boolean equals(Object o) { - if (!(o instanceof EditorImageDescriptor)) { + if (!(o instanceof EditorImageDescriptor other)) { return false; } - EditorImageDescriptor other = (EditorImageDescriptor) o; - // See if there is a name - compare it if so and compare the programs if not String otherName = other.program.getName(); if (otherName == null) { @@ -49,22 +46,14 @@ public boolean equals(Object o) { return otherName.equals(program.getName()); } - /** - * Returns an SWT Image that is described by the information in this descriptor. Each call returns a new Image. - */ - public Image getImage() { - return createImage(); - } - @Override - public ImageData getImageData() { - - ImageData defaultImage = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE).getImageData(); + public ImageData getImageData(int zoom) { + ImageData defaultImage = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE).getImageData(zoom); if (defaultImage == null) { return null; } ImageData data = null; - if (program == null || ((data = program.getImageData()) == null)) { + if (program == null || ((data = program.getImageData(zoom)) == null)) { return defaultImage; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java index f156fef4601..d10b0341ad2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -76,12 +76,7 @@ public static ImageDescriptor getImageDescriptor(Object object, IDebugModelPrese public static ImageDescriptor getImageDescriptor(Image image) { if (image != null) { - ImageDescriptor descriptor = fgImages.get(image); - if (descriptor == null) { - descriptor = new ImageImageDescriptor(image); - fgImages.put(image, descriptor); - } - return descriptor; + return fgImages.computeIfAbsent(image, ImageDescriptor::createFromImage); } return null; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java deleted file mode 100644 index 41bdc25f11e..00000000000 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.views.launch; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; - -/** - * Image descriptor for an image. - */ -public class ImageImageDescriptor extends ImageDescriptor { - private final Image fImage; - - /** - * Constructor for ImagImageDescriptor. - */ - public ImageImageDescriptor(Image image) { - super(); - fImage= image; - } - - @Override - public ImageData getImageData() { - return fImage.getImageData(); - } - - @Override - public boolean equals(Object obj) { - return (obj != null) && getClass().equals(obj.getClass()) && fImage.equals(((ImageImageDescriptor)obj).fImage); - } - - @Override - public int hashCode() { - return fImage.hashCode(); - } -} diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java deleted file mode 100644 index ad5ead991b8..00000000000 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.ui.internal.util; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; - -/** - * An OverlayIcon consists of a main icon and several adornments. - */ -public abstract class AbstractOverlayIcon extends CompositeImageDescriptor { - - static final int DEFAULT_WIDTH = 16; - static final int DEFAULT_HEIGHT = 16; - - private Point fSize = null; - - private final ImageDescriptor fOverlays[][]; - - public AbstractOverlayIcon(ImageDescriptor[][] overlays) { - this(overlays, null); - } - - public AbstractOverlayIcon(ImageDescriptor[][] overlays, Point size) { - fOverlays = overlays; - if (size != null) - fSize = size; - else - fSize = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT); - } - protected void drawBottomLeft(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = 0; - for (int i = 0; i < 3; i++) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - drawImage(id, x, getSize().y - id.height); - x += id.width; - } - } - } - protected void drawBottomRight(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = getSize().x; - for (int i = 2; i >= 0; i--) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - x -= id.width; - drawImage(id, x, getSize().y - id.height); - } - } - } - - protected abstract ImageData getBaseImageData(); - - @Override - protected void drawCompositeImage(int width, int height) { - ImageData base = getBaseImageData(); - drawImage(base, 0, 0); - if (fOverlays != null) { - if (fOverlays.length > 0) - drawTopRight(fOverlays[0]); - - if (fOverlays.length > 1) - drawBottomRight(fOverlays[1]); - - if (fOverlays.length > 2) - drawBottomLeft(fOverlays[2]); - - if (fOverlays.length > 3) - drawTopLeft(fOverlays[3]); - } - } - protected void drawTopLeft(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = 0; - for (int i = 0; i < 3; i++) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - drawImage(id, x, 0); - x += id.width; - } - } - } - protected void drawTopRight(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = getSize().x; - for (int i = 2; i >= 0; i--) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - x -= id.width; - drawImage(id, x, 0); - } - } - } - - @Override - protected Point getSize() { - return fSize; - } -} diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/OverlayIcon.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/OverlayIcon.java deleted file mode 100644 index ce341f5fc72..00000000000 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/OverlayIcon.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.ui.internal.util; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; - -/** - * An OverlayIcon consists of a main icon and several adornments. - */ -public class OverlayIcon extends AbstractOverlayIcon { - private ImageDescriptor fBase; - - public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays) { - this(base, overlays, null); - } - - public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays, - Point size) { - super(overlays, size); - fBase = base; - if (fBase == null) - fBase = ImageDescriptor.getMissingImageDescriptor(); - } - - @Override - protected ImageData getBaseImageData() { - return fBase.getImageData(); - } -} diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java index 46fa2a56175..d38279e5ca9 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -22,9 +22,10 @@ import org.eclipse.help.internal.toc.Toc; import org.eclipse.help.ui.internal.HelpUIResources; import org.eclipse.help.ui.internal.IHelpUIConstants; -import org.eclipse.help.ui.internal.util.OverlayIcon; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.DecorationOverlayIcon; +import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ITreeViewerListener; import org.eclipse.jface.viewers.LabelProvider; @@ -159,8 +160,8 @@ private boolean isNotEmpty(ITopic topic) { } private boolean isNotEmpty(ITopic[] topics) { - for (int i = 0; i < topics.length; i++) { - if (isNotEmpty(topics[i])) + for (ITopic topic : topics) { + if (isNotEmpty(topic)) return true; } return false; @@ -205,8 +206,7 @@ private void initializeImages() { .getImageDescriptor(IHelpUIConstants.IMAGE_CONTAINER); ImageDescriptor ovr = HelpUIResources .getImageDescriptor(IHelpUIConstants.IMAGE_DOC_OVR); - ImageDescriptor desc = new OverlayIcon(base, - new ImageDescriptor[][] { { ovr } }); + ImageDescriptor desc = new DecorationOverlayIcon(base, ovr, IDecoration.TOP_RIGHT); containerWithTopicImage = desc.createImage(); } @@ -239,8 +239,7 @@ protected String getHref(IHelpResource res) { public void selectReveal(String href) { IToc[] tocs = HelpSystem.getTocs(); - for (int i = 0; i < tocs.length; i++) { - IToc toc = tocs[i]; + for (IToc toc : tocs) { ITopic topic = toc.getTopic(href); if (topic != null) { selectReveal(topic); From 36a97e1b9e8543865d5f91756c2e0340a9a916a1 Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Fri, 11 Apr 2025 22:09:20 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.36 stream --- ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF | 2 +- ua/org.eclipse.help.ui/META-INF/MANIFEST.MF | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF index 14d67d91bc9..d9d8d92c9a7 100644 --- a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.ui; singleton:=true -Bundle-Version: 3.10.0.qualifier +Bundle-Version: 3.10.100.qualifier Bundle-Activator: org.eclipse.ant.internal.ui.AntUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF b/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF index aaac5dfae17..56ae7855043 100644 --- a/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %help_system_plugin_name Bundle-SymbolicName: org.eclipse.help.ui; singleton:=true -Bundle-Version: 4.8.0.qualifier +Bundle-Version: 4.8.100.qualifier Bundle-Activator: org.eclipse.help.ui.internal.HelpUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin