Community
Participate
Working Groups
Trying to update at runtime the icon of a part but it does not work. @PostConstruct public void postConstruct(Composite parent, EPartService partService, Branding currentBranding, IEclipseContext context) { ... MPart part = partService.findPart(PARTID); URI logoUri = currentBranding.getLogo(); if (null != logoUri) { part.setIconURI(logoUri.toString()); part.setLabel("blabla"); } ... } setLabel and setTooltip do their jobs however setIconURI does not change nothing. If there is already an iconURI in my Application.e4xmi, this icon is displayed but setIconURI does nothing even in this case: I can call it with any String, nothing happen. This bug now happen with Mars, the above code worked well with Luna.
Simon, can you have a look?
I'm guessing that your part has an overridden icon: it's added as a transient state element to the part. Try removing it and see if that helps: part.getTransientData().remove(IPresentationEngine.OVERRIDE_ICON_IMAGE_KEY); Perhaps the CleanupAddon should listen for ICON_URI changes and remove the override icon?
Thanks for your answer. Trying the suggested correction did not resolve the problem. However, by inspecting the Map retuned by getTransientData(), I have seen there is only on entry, with the key "IconUriForPart" and no value (there is no default icon in the application). So, with the following correction, my icon is displayed: part.getTransientData().remove("IconUriForPart"); I did not find a public constant for that String "IconUriForPart", there is a private static constant ICON_URI_FOR_PART in org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer Thanks for your help
Works via tip from Brian
This workaround, to remove an unpublished key, doesn't seem like a good thing. The key was brought in as part of bug 432785. I'll re-open that bug: there needs to be some discussion about it.
With my target at the latest Mars release I still cannot set the icon of an MPart dynamically without removing the "IconUriForPart" map entry. Brian states that removing a completely out-of-the blue tag from a map is not a good workaround, and I agree. Unfortunately, none of the two referenced bugs seems to actually fix the issue: bug 432785 which introduced the problem only references this one and bug 472658 which is supposed to be the one fixing the issue but only fixes issues with the spys as far as I can tell. I propose re-opening this bug.
Working with and targeting Neon.1 still shows this bug and the (not-so-pretty) workaround still works. Therefore I support Alexander's suggestion to re-open this bug. Thanks!
I see no comment *why* it was closed at all, and I agree the proposed workaround is dirty, so reopening.
Event registration for the icon change seems missing in StackRenderer Something like this: @Inject @Optional private void subscribeTopicIconChanged(@UIEventTopic(UIEvents.UILabel.TOPIC_ICONURI) Event event) { // TODO update the icon in the part, see updateClosableTab }
@Simon, can you take this one? This is similar to the close fix.
Mass move. Please move back to M6, if necessary
Please set a target milestone again when you plan to fix the bug.
Removing target milestone for all bugs that are not major or above.
> Removing target milestone for all bugs that are not major or above. Of course I meant "major or below". Sorry for the noise!
I think this would be necessary to allow changing icons via the CSS engine.
Mass change, please reset target if you still planning to fix this for 4.11.
Please set the target milestone back to 4.12 if you still intend to fix this for 4.12.
New Gerrit change created: https://git.eclipse.org/r/145457
New Gerrit change created: https://git.eclipse.org/r/145539
Created attachment 280391 [details] Test Application Test Project for testing the icon changes...
Gerrit change https://git.eclipse.org/r/145457 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a09e6e079531ba9ae423414d8ec6244434b4fa16
Thanks, Benedikt that is a nice feature. Please set target and assignee. Also please add to N&N.
New Gerrit change created: https://git.eclipse.org/r/151781
Gerrit change https://git.eclipse.org/r/151781 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=75103fe0cd7ccb4346f9d02d281d30f91b2a7405
Thanks, Benedikt. This development may allow to change the icons via CSS. I added the dependency to this bug.