Skip to content

Avoid implementations of ImageDescriptor.getImageData() #2907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.jface/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jface;singleton:=true
Bundle-Version: 3.36.100.qualifier
Bundle-Version: 3.37.0.qualifier
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow API-tools considers the removal of the (deprecated) overriden method from CompositeImageDescriptor as API addition and demands to minor version bump.

Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,6 @@ final protected void drawImage(ImageDataProvider srcProvider, int ox, int oy) {
}
}

/**
* @deprecated Use {@link #getImageData(int)} instead.
*/
@Deprecated
@Override
public ImageData getImageData() {
return getImageData(100);
}

@Override
public ImageData getImageData(int zoom) {
if (!supportsZoomLevel(zoom)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2024 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
Expand Down Expand Up @@ -434,12 +434,15 @@ public ImageData getImageData() {
return getImageData(100);
}

private static final ImageDescriptor MISSING_IMAGE = createFromImageDataProvider(
z -> z == 100 ? DEFAULT_IMAGE_DATA : null);

/**
* Returns the shared image descriptor for a missing image.
*
* @return the missing image descriptor
*/
public static ImageDescriptor getMissingImageDescriptor() {
return MissingImageDescriptor.getInstance();
return MISSING_IMAGE;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@
return ((URLImageDescriptor) o).url.equals(this.url);
}

@Deprecated
@Override
public ImageData getImageData() {
return getImageData(getURL(url), 100, 100);
}
Comment on lines -133 to -137
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Michael5601 FYI as this was a relevant point in our discussion at #2593. As before that change this implementation now just behaves as if getImageData(100) is called and therefore as the default implementation in the super-class. It can therefore just be removed.


@Override
public ImageData getImageData(int zoom) {
return getImageData(url, zoom);
Expand Down Expand Up @@ -187,7 +181,7 @@
return result;
}

@SuppressWarnings("restriction")

Check warning on line 184 in bundles/org.eclipse.jface/src/org/eclipse/jface/resource/URLImageDescriptor.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

Unnecessary Code

NORMAL: Unnecessary @SuppressWarnings("restriction")
private static ImageData loadImageFromStream(InputStream stream, int fileZoom, int targetZoom) {
return NativeImageLoader.load(new ElementAtZoom<>(stream, fileZoom), new ImageLoader(), targetZoom).get(0)
.element();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public int hashCode() {
}

@Override
public ImageData getImageData() {
public ImageData getImageData(int zoom) {
return null;
}

Expand Down Expand Up @@ -177,7 +177,7 @@ public int hashCode() {
}

@Override
public ImageData getImageData() {
public ImageData getImageData(int zoom) {
return null;
}

Expand Down Expand Up @@ -273,7 +273,7 @@ public int hashCode() {
}

@Override
public ImageData getImageData() {
public ImageData getImageData(int zoom) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.eclipse.ui.internal.misc;

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;
Expand All @@ -26,7 +25,7 @@
*/
public class ExternalProgramImageDescriptor extends ImageDescriptor {

public Program program;
private Program program;

/**
* Creates a new ImageDescriptor. The image is loaded from a file with the given
Expand All @@ -41,11 +40,9 @@ public ExternalProgramImageDescriptor(Program program) {
*/
@Override
public boolean equals(Object o) {
if (!(o instanceof ExternalProgramImageDescriptor)) {
if (!(o instanceof ExternalProgramImageDescriptor other)) {
return false;
}
ExternalProgramImageDescriptor other = (ExternalProgramImageDescriptor) 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) {
Expand All @@ -54,14 +51,6 @@ 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(int zoom) {
if (program != null) {
Expand Down
Loading