diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java deleted file mode 100644 index 01e9c8e8af4..00000000000 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2015 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.ui.internal.cheatsheets.composite.explorer; - -import org.eclipse.jface.resource.*; -import org.eclipse.swt.graphics.*; - -/** - * 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.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/OverlayIcon.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/OverlayIcon.java deleted file mode 100644 index a48b41f8ce8..00000000000 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/OverlayIcon.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 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.ui.internal.cheatsheets.composite.explorer; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.*; - -/** - * 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.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java index 270ca2cff4d..bdd48a20965 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2019 IBM Corporation and others. + * Copyright (c) 2005, 2026 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -22,6 +22,8 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.DecorationOverlayIcon; +import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; @@ -152,8 +154,8 @@ private ImageDescriptor getPredefinedImageDescriptor(String kind) { private void createImageWithOverlay(int state, String imagePath, ImageSet images, ImageDescriptor baseDescriptor) { ImageDescriptor descriptor = createImageDescriptor(imagePath); - OverlayIcon icon = new OverlayIcon(baseDescriptor, new ImageDescriptor[][] { - {}, { descriptor } }); + DecorationOverlayIcon icon = new DecorationOverlayIcon(baseDescriptor.createImage(), descriptor, + IDecoration.BOTTOM_RIGHT); images.put(state, icon.createImage()); }