Community
Participate
Working Groups
Currently there seems to be no API to assign image to menu item that contains submenu, the only way is to override MenuManager.fill() methods. That seems to be inconsistent.
Consider as a post 2.0 enhancement
Reopen to investigate
Maybe someone from the community would be interested in coming up with a design for this? If so, please annotate this report and include a date when the design would be done and implementation could start.
how is the state of this enhancement? It would be nice to have this in Eclipse 3.0.
Moving Dougs bugs
Assigning to component owner PW
What kind of challenges are involved with implementing this?
You would potentially need to add it to the constructor, then include it in the update logic that is updating menuText. Using a local resource manager to keep track of the Image from the descriptor, and disposing the resource manager at the correct time. Then this could be considered for 3.4 PW
(In reply to comment #8) > You would potentially need to add it to the constructor, then include it in the > update logic that is updating menuText. What do you mean by "updating menuText"? That field in MenuManager seems to only ever get set once in the constructor. > Using a local resource manager to keep > track of the Image from the descriptor, and disposing the resource manager at > the correct time. This "local resource manager" makes it sound more complicated then just holding on to a reference to the Image from createImage() and then calling dispose() within MenuManager's dispose() implementation. Is there something inherently wrong with just doing this?
(In reply to comment #9) > > What do you mean by "updating menuText"? That field in MenuManager seems to > only ever get set once in the constructor. You would need the complimentory image code in update(String). > This "local resource manager" makes it sound more complicated then just holding > on to a reference to the Image from createImage() and then calling dispose() > within MenuManager's dispose() implementation. Is there something inherently > wrong with just doing this? You want the pattern similar to ActionContributionItem or CommandContributionItem. Use a LocalResourceManager to turn your ImageDescriptor into an Image. That way, if there same image is used mutliple times in your program, then it only gets instantiate once. disposing the local resource manager will remove that specific ref to the Image. PW
Created attachment 76186 [details] Patch to add two new constructors for instantiating a MenuManager with an ImageDescriptor. This patch implements the desired functionality based on Paul's comment #10 using some copy/paste magic from CommandContributionItem. The bug's summary's original request for a setImageDescriptor(ImageDescriptor) method is not implemented because there is currently no API for setting the text for the menu so I also chose not to expose any new API for setting the image for the menu. New API: -MenuManager(String, ImageDescriptor) -MenuManager(String, ImageDescriptor, String) -ImageDescriptor getImage() Paul, 7 out of the 674 JFace tests (via running org.eclipse.jface.tests.AllTests) failed both before and after I applied the patch. Running 3.4M1 on 32-bit Windows XP. Failures: SimpleVirtualLazyTreeViewerTest -testCreation -testRemoveAt VirtualLazyTreeViewerTest -testDeleteSibling -testInsertSibling -testInsertSiblings -testSomeChildrenChanged -testWorldChanged
Created attachment 76251 [details] MenuManager + ImageDescriptor v02 This is a few updates to Remy's patch. 1) Since the 2 arg constructor could be ambiguous with MenuManager(text, id), I've just removed it ... if you want an icon, we'll just say use the 3 arg constructor 2) I've added the disposeOldImages() to the dispose() call 3) I've added a small optimization that checks for image==null and doesn't create a LocalResourceManager if it is not necessary. All of the JFace and UI test pass for me with the patch. Remy, if these changes are fine I'll commit them. PW
(In reply to comment #12) > Remy, if these changes are fine I'll commit them. Hi Paul, the updated patch looks okay. I applied it locally and also reran my test plug-in and the image is getting displayed fine in my view's context menu. Thanks for the help! :)
Released into HEAD >20070816 Thanx, Remy. PW
In I20070918-0010 PW