Skip to content

Commit 6026123

Browse files
committed
Create disabled shared image in org.eclipse.jface on-the-fly
JFace uses a shared popup menu icon for which the disabled version is loaded as a pre-generated version from a specific file. This change replaces that with a programmatic on-the-fly disablement.
1 parent 769ddf9 commit 6026123

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/JFaceResources.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.eclipse.jface.wizard.Wizard;
3333
import org.eclipse.pde.api.tools.annotations.NoExtend;
3434
import org.eclipse.pde.api.tools.annotations.NoInstantiate;
35+
import org.eclipse.swt.SWT;
3536
import org.eclipse.swt.graphics.Font;
3637
import org.eclipse.swt.graphics.Image;
3738
import org.eclipse.swt.widgets.Control;
@@ -448,13 +449,9 @@ private static void initializeDefaultImages() {
448449
declareImage(
449450
bundle,
450451
PreferenceDialog.PREF_DLG_TITLE_IMG,
451-
ICONS_PATH + "pref_dialog_title.svg", PreferenceDialog.class, "images/pref_dialog_title.svg");//$NON-NLS-1$ //$NON-NLS-2$
452-
declareImage(bundle, PopupDialog.POPUP_IMG_MENU, ICONS_PATH
453-
+ "popup_menu.svg", PopupDialog.class, "images/popup_menu.svg");//$NON-NLS-1$ //$NON-NLS-2$
454-
declareImage(
455-
bundle,
456-
PopupDialog.POPUP_IMG_MENU_DISABLED,
457-
ICONS_PATH + "popup_menu_disabled.svg", PopupDialog.class, "images/popup_menu_disabled.svg");//$NON-NLS-1$ //$NON-NLS-2$
452+
ICONS_PATH + "pref_dialog_title.png", PreferenceDialog.class, "images/pref_dialog_title.png");//$NON-NLS-1$ //$NON-NLS-2$
453+
declareImage(bundle, PopupDialog.POPUP_IMG_MENU, PopupDialog.POPUP_IMG_MENU_DISABLED,
454+
ICONS_PATH + "popup_menu.svg", PopupDialog.class, "images/popup_menu.png");//$NON-NLS-1$ //$NON-NLS-2$
458455
}
459456

460457
/**
@@ -478,16 +475,27 @@ private static void initializeDefaultImages() {
478475
*/
479476
private static final void declareImage(Object bundle, String key, String path, Class<?> fallback,
480477
String fallbackPath) {
478+
declareImage(bundle, key, null, path, fallback, fallbackPath);
479+
}
480+
481+
private static final void declareImage(Object bundle, String key, String disabledKey, String path, Class<?> fallback,
482+
String fallbackPath) {
481483

482-
imageRegistry.put(key, ImageDescriptor.createFromURLSupplier(false, () -> {
484+
ImageDescriptor imageDescriptor = ImageDescriptor.createFromURLSupplier(false, () -> {
483485
if (bundle != null) {
484486
URL url = FileLocator.find((Bundle) bundle, IPath.fromOSString(path), null);
485487
if (url != null) {
486488
return url;
487489
}
488490
}
489491
return fallback.getResource(fallbackPath);
490-
}));
492+
});
493+
imageRegistry.put(key, imageDescriptor);
494+
if (disabledKey != null) {
495+
ImageDescriptor disabledImageDescriptor = ImageDescriptor.createWithFlags(imageDescriptor,
496+
SWT.IMAGE_DISABLE);
497+
imageRegistry.put(key, disabledImageDescriptor);
498+
}
491499
}
492500

493501
/**

0 commit comments

Comments
 (0)