-
Notifications
You must be signed in to change notification settings - Fork 251
Allow to ignore explicitly defined disabled icons #4002
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,12 @@ | |
| @NoExtend | ||
| public class ActionContributionItem extends ContributionItem { | ||
|
|
||
| /** | ||
| * System property for specifying whether custom disabled icons for actions | ||
| * shall be used or whether all disabled icons shall be generated on-the-fly. | ||
| */ | ||
| private static final String SYSTEM_PROPERTY_USE_DISABLED_ICONS = "org.eclipse.jface.action.useDisabledIcons"; //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * Mode bit: Show text on tool items or buttons, even if an image is | ||
| * present. If this mode bit is not set, text is only shown on tool items if | ||
|
|
@@ -96,6 +102,32 @@ public static void setUseColorIconsInToolbars(boolean useColorIcons) { | |
| USE_COLOR_ICONS = useColorIcons; | ||
| } | ||
|
|
||
| private static boolean USE_DISABLED_ICONS = Boolean.getBoolean(SYSTEM_PROPERTY_USE_DISABLED_ICONS); | ||
|
|
||
| /** | ||
| * Returns whether disabled icons assigned to actions shall be used or whether | ||
| * all such disabled icons shall be generated on-the-fly. | ||
| * | ||
| * @return <code>true</code> if disabled icons assigned to actions shall be | ||
| * used, <code>false</code> otherwise | ||
| * @since 3.40 | ||
| */ | ||
| public static boolean getUseDisabledIcons() { | ||
| return USE_DISABLED_ICONS; | ||
| } | ||
|
|
||
| /** | ||
| * Sets whether disabled icons assigned to actions shall be used or whether all | ||
| * such disabled icons shall be generated on-the-fly. | ||
| * | ||
| * @param useDisabledIcons <code>true</code> if disabled icons set to actions | ||
| * shall be used, <code>false</code> otherwise | ||
| * @since 3.40 | ||
| */ | ||
| public static void setUseDisabledIcons(boolean useDisabledIcons) { | ||
| USE_DISABLED_ICONS = useDisabledIcons; | ||
| } | ||
|
|
||
|
Comment on lines
+127
to
+130
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this just for testing or should this also be used by down-stream consumers?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently it's only used for testing, but it may also validly be used to programmatically configure the behavior instead of using the system property. I would be fine with only making it available for tests but properly doing it would not be that easy with our test setup. We could mark it as
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we definitively want to support that, then I think it makes sense to have this public. But if we don't or are not sure, then I suggest to not make it an 'API' and only elevate it when desired/necessary. I think it just should be a clear decision, but I'm not for one or the other.
Yes, in that case it we could do that or make it (package) private and just call it reflectively or set the field reflectively. But that's of course not very elegant. |
||
| /** | ||
| * The presentation mode. | ||
| */ | ||
|
|
@@ -988,7 +1020,10 @@ private boolean updateImages(boolean forceImage) { | |
| if (widget instanceof ToolItem) { | ||
| ImageDescriptor image = action.getImageDescriptor(); | ||
| ImageDescriptor hoverImage = action.getHoverImageDescriptor(); | ||
| ImageDescriptor disabledImage = action.getDisabledImageDescriptor(); | ||
| ImageDescriptor disabledImage = null; | ||
| if (getUseDisabledIcons()) { | ||
| disabledImage = action.getDisabledImageDescriptor(); | ||
| } | ||
| // Make sure there is a valid image in case images are forced. | ||
| if (image == null && forceImage) { | ||
| image = ImageDescriptor.getMissingImageDescriptor(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.