Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private Image createImage(String iconURI, LocalResourceManager resourceManager,
if (iconURI != null && iconURI.length() > 0) {
ImageDescriptor iconDescriptor = resUtils.imageDescriptorFromURI(URI.createURI(iconURI));
if (disabled) {
iconDescriptor = ImageDescriptor.createWithFlags(iconDescriptor, SWT.IMAGE_DISABLE);
iconDescriptor = iconDescriptor.asDisabledDescriptor();
}
if (iconDescriptor != null) {
try {
Expand Down
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.39.200.qualifier
Bundle-Version: 3.40.0.qualifier
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 @@ -1000,7 +1000,7 @@ private boolean updateImages(boolean forceImage) {
// If there is no disabled image, but there is a regular image generate a
// disabled one
if (disabledImage == null && image != null) {
disabledImage = ImageDescriptor.createWithFlags(image, SWT.IMAGE_DISABLE);
disabledImage = image.asDisabledDescriptor();
}
if (image != null && !USE_COLOR_ICONS) {
image = ImageDescriptor.createWithFlags(image, SWT.IMAGE_GRAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ public ImageData getImageData(int zoom) {
image.dispose();
return result;
}

@Override
public ImageDescriptor asDisabledDescriptor() {
if ((flags & SWT.IMAGE_DISABLE) != 0) {
return this;
}
return super.asDisabledDescriptor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.util.Policy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;
Expand Down Expand Up @@ -68,6 +69,8 @@ public abstract class ImageDescriptor extends DeviceResourceDescriptor<Image> {
*/
protected static final ImageData DEFAULT_IMAGE_DATA = new ImageData(6, 6, 1, new PaletteData(new RGB(255, 0, 0)));

private ImageDescriptor disabledImageDescriptor;

/**
* Constructs an image descriptor.
*/
Expand Down Expand Up @@ -151,13 +154,6 @@ public static ImageDescriptor createFromImage(Image img) {
* Creates an ImageDescriptor based on the given original descriptor, but with additional
* SWT flags.
*
* <p>
* Note that this sort of ImageDescriptor is slower and consumes more resources than
* a regular image descriptor. It will also never generate results that look as nice as
* a hand-drawn image. Clients are encouraged to supply their own disabled/grayed/etc. images
* rather than using a default image and transforming it.
* </p>
*
* @param originalImage image to transform
* @param swtFlags any flag that can be passed to the flags argument of Image#Image(Device, Image, int)
* @return an ImageDescriptor that creates new images by transforming the given image descriptor
Expand Down Expand Up @@ -351,6 +347,25 @@ public Image createImage(Device device) {
return createImage(true, device);
}

/**
* Returns an image descriptor representing a disabled version of the icon of
* this descriptor. The descriptor is shared, i.e., calling this method multiple
* times will return the same descriptor every time. In case the descriptor
* already represents a disabled version of the icon (created using
* {@link #createWithFlags(ImageDescriptor, int)} with the
* {@code SWT.IMAGE_DISABLE} flag), this method returns <code>this</code>.
*
* @since 3.40
* @return a shared image descriptor for a disabled version of the icon for this
* descriptor
*/
public ImageDescriptor asDisabledDescriptor() {
if (disabledImageDescriptor == null) {
disabledImageDescriptor = createWithFlags(this, SWT.IMAGE_DISABLE);
}
return disabledImageDescriptor;
}

/**
* Creates and returns a new SWT image for this image descriptor. The
* returned image must be explicitly disposed using the image's dispose
Expand Down
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: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.ide.application;singleton:=true
Bundle-Version: 1.6.100.qualifier
Bundle-Version: 1.6.200.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.21.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
if (disabledSymbolicName != null) {
ImageDescriptor disabledDescriptor = ImageDescriptor.createWithFlags(desc, SWT.IMAGE_DISABLE);
ImageDescriptor disabledDescriptor = desc.asDisabledDescriptor();
getWorkbenchConfigurer().declareImage(disabledSymbolicName, disabledDescriptor, shared);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.osgi.framework.Bundle;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;

import org.eclipse.core.runtime.FileLocator;
Expand Down Expand Up @@ -118,7 +117,7 @@ private final static void declareRegistryImage(String key, String disabledKey, S
}
fgImageRegistry.put(key, desc);
if (disabledKey != null) {
ImageDescriptor disabledDescriptor = ImageDescriptor.createWithFlags(desc, SWT.IMAGE_DISABLE);
ImageDescriptor disabledDescriptor = desc.asDisabledDescriptor();
fgImageRegistry.put(disabledKey, disabledDescriptor);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand Down Expand Up @@ -106,7 +105,7 @@ private static final void declareImage(String key, String disabledKey, String pa
() -> BundleUtility.find(PlatformUI.PLUGIN_ID, path));
declareImage(key, desc, shared);
if (disabledKey != null) {
ImageDescriptor disabledImageDescriptor = ImageDescriptor.createWithFlags(desc, SWT.IMAGE_DISABLE);
ImageDescriptor disabledImageDescriptor = desc.asDisabledDescriptor();
declareImage(disabledKey, disabledImageDescriptor, shared);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Image getImage(Object element) {
if (element instanceof DisplayItem item && actual != null) {
if (!CustomizePerspectiveDialog.isEffectivelyAvailable(item, filter)) {
ImageDescriptor original = ImageDescriptor.createFromImage(actual);
ImageDescriptor disable = ImageDescriptor.createWithFlags(original, SWT.IMAGE_DISABLE);
ImageDescriptor disable = original.asDisabledDescriptor();
Image newImage = disable.createImage();
toDispose.add(newImage);
return newImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ interface IndexListener {
static {
ImageDescriptor processStopDescriptor = WorkbenchImages.getWorkbenchImageDescriptor("elcl16/progress_stop.svg"); //$NON-NLS-1$
JFaceResources.getImageRegistry().put(STOP_IMAGE_KEY, processStopDescriptor);
ImageDescriptor disabledProcessStopDescriptor = ImageDescriptor.createWithFlags(processStopDescriptor,
SWT.IMAGE_DISABLE);
ImageDescriptor disabledProcessStopDescriptor = processStopDescriptor.asDisabledDescriptor();
JFaceResources.getImageRegistry().put(DISABLED_STOP_IMAGE_KEY, disabledProcessStopDescriptor);

JFaceResources.getImageRegistry().put(DEFAULT_JOB_KEY,
Expand Down
Loading