Home » Eclipse Projects » Eclipse 4 » Removing Dynamic Menu Contributions
Removing Dynamic Menu Contributions [message #1037345] |
Tue, 09 April 2013 08:47  |
Eclipse User |
|
|
|
Hello,
I am using a DynamicMenuContribution to populate a menu.
The menu is filled nicely, it is however re-populated whenever selected
the next time.
Removing the items doesn't seem to have any effect?
protected MMenu createChildMenuManager;
protected MMenu createSiblingMenuManager;
@AboutToHide
public void aboutToHide(List<MMenuElement> items) {
// CB TODO, Doesn't clean.
items.remove(createChildMenuManager);
items.remove(createSiblingMenuManager);
}
Am I missing something here? Is this a bug?
thanks Christophe
|
|
| |
Re: Removing Dynamic Menu Contributions [message #1038335 is a reply to message #1038227] |
Wed, 10 April 2013 14:53   |
Eclipse User |
|
|
|
On 10-04-13 17:23, Jonas Helming wrote:
> Hi,
> could you paste the code you use to fill the menu?
> Regards
> Jonas
>
Hi Jonas,
Here it is, note it's bloated with calls to methods to fill up the menu,
but in essence it's creating to MMenu objects which are added to the
items collection.
Thanks, for helping. Christophe
@AboutToShow
public void aboutToShow(List<MMenuElement> items) {
createChildMenuManager = MMenuFactory.INSTANCE.createMenu();
createChildMenuManager.setLabel(EXTLibraryEditorPlugin.INSTANCE
.getString("_UI_CreateChild_menu_item"));//$NON-NLS-1$
createChildMenuManager.setElementId(CHILD_CREATE_ID);
populateManager(createChildMenuManager, createChildActionsMap, null);
items.add(createChildMenuManager);
createSiblingMenuManager = MMenuFactory.INSTANCE.createMenu();
createSiblingMenuManager.setLabel(EXTLibraryEditorPlugin.INSTANCE
.getString("_UI_CreateSibling_menu_item"));//$NON-NLS-1$
createSiblingMenuManager.setElementId(SIBLING_CREATE_ID);
populateManager(createSiblingMenuManager, createSiblingActionsMap, null);
items.add(createSiblingMenuManager);
}
> Am 09.04.2013 14:47, schrieb Christophe Bouhier:
>> Hello,
>>
>> I am using a DynamicMenuContribution to populate a menu.
>> The menu is filled nicely, it is however re-populated whenever selected
>> the next time.
>>
>> Removing the items doesn't seem to have any effect?
>>
>> protected MMenu createChildMenuManager;
>> protected MMenu createSiblingMenuManager;
>>
>> @AboutToHide
>> public void aboutToHide(List<MMenuElement> items) {
>>
>> // CB TODO, Doesn't clean.
>> items.remove(createChildMenuManager);
>> items.remove(createSiblingMenuManager);
>> }
>>
>>
>> Am I missing something here? Is this a bug?
>> thanks Christophe
>
|
|
| |
Re: Removing Dynamic Menu Contributions [message #1039577 is a reply to message #1039547] |
Fri, 12 April 2013 06:03   |
Eclipse User |
|
|
|
Thanks Marco, see inline response below.
On 12-04-13 11:29, Marco Descher wrote:> Hy there,
>
> @AboutToShow is called every time you open the menu containing the
> DynamicMenuContribution. So the list.clear() in @AboutToHide does not do
> anything useful to you.
>
OK, I suspected this. It wasn't clear to me how to use @AboutToHide
> What is the scenario you want to fix here??
I Simply want to add MMenu's to an MDynamicMenuContribution, which it
does. But the next time I click on the menu I get a duplicate entry for
the MMenu. Hence the 'experiment' to remove them in @aboutToHide. (So
that's a bad, and I won't do it again, promissed ;-)
I have attached two screenshots, notice that the second time the menu is
populated, the first MMenu entry is cleaned, but the MMenu itself is
still there.
So what could cause the orignal menu contribution not to be removed? I
wonder if it's the fact that I am contributing MMenu's and perhaps it's
only tested with MHandledMenuItem and MDirectMenuItem? (Just guessing
here).
I hope this is a better explanation.
Rgds Christophe
> If you want a conditional
> dynamic population of the menu, you have to realize this within
> @aboutToShow
>
> for example:
>
>
> @AboutToShow
> public void aboutToShow(List<MMenuElement> items) {
> if(condition) {
> populateMenu()
> }
> }
>
>
> I don't see any sense in removing elements in @AboutToHide, this already
> happens before the next @AboutToShow
|
|
|
Re: Removing Dynamic Menu Contributions [message #1039580 is a reply to message #1039547] |
Fri, 12 April 2013 06:03   |
Eclipse User |
|
|
|
Thanks Marco, see inline response below.
On 12-04-13 11:29, Marco Descher wrote:> Hy there,
>
> @AboutToShow is called every time you open the menu containing the
> DynamicMenuContribution. So the list.clear() in @AboutToHide does not do
> anything useful to you.
>
OK, I suspected this. It wasn't clear to me how to use @AboutToHide
> What is the scenario you want to fix here??
I Simply want to add MMenu's to an MDynamicMenuContribution, which it
does. But the next time I click on the menu I get a duplicate entry for
the MMenu. Hence the 'experiment' to remove them in @aboutToHide. (So
that's a bad, and I won't do it again, promissed ;-)
I have attached two screenshots, notice that the second time the menu is
populated, the first MMenu entry is cleaned, but the MMenu itself is
still there.
So what could cause the orignal menu contribution not to be removed? I
wonder if it's the fact that I am contributing MMenu's and perhaps it's
only tested with MHandledMenuItem and MDirectMenuItem? (Just guessing
here).
I hope this is a better explanation.
Rgds Christophe
> If you want a conditional
> dynamic population of the menu, you have to realize this within
> @aboutToShow
>
> for example:
>
>
> @AboutToShow
> public void aboutToShow(List<MMenuElement> items) {
> if(condition) {
> populateMenu()
> }
> }
>
>
> I don't see any sense in removing elements in @AboutToHide, this already
> happens before the next @AboutToShow
|
|
|
Re: Removing Dynamic Menu Contributions [message #1039584 is a reply to message #1039547] |
Fri, 12 April 2013 06:03   |
Eclipse User |
|
|
|
Thanks Marco, see inline response below.
On 12-04-13 11:29, Marco Descher wrote:> Hy there,
>
> @AboutToShow is called every time you open the menu containing the
> DynamicMenuContribution. So the list.clear() in @AboutToHide does not do
> anything useful to you.
>
OK, I suspected this. It wasn't clear to me how to use @AboutToHide
> What is the scenario you want to fix here??
I Simply want to add MMenu's to an MDynamicMenuContribution, which it
does. But the next time I click on the menu I get a duplicate entry for
the MMenu. Hence the 'experiment' to remove them in @aboutToHide. (So
that's a bad, and I won't do it again, promissed ;-)
I have attached two screenshots, notice that the second time the menu is
populated, the first MMenu entry is cleaned, but the MMenu itself is
still there.
So what could cause the orignal menu contribution not to be removed? I
wonder if it's the fact that I am contributing MMenu's and perhaps it's
only tested with MHandledMenuItem and MDirectMenuItem? (Just guessing
here).
I hope this is a better explanation.
Rgds Christophe
> If you want a conditional
> dynamic population of the menu, you have to realize this within
> @aboutToShow
>
> for example:
>
>
> @AboutToShow
> public void aboutToShow(List<MMenuElement> items) {
> if(condition) {
> populateMenu()
> }
> }
>
>
> I don't see any sense in removing elements in @AboutToHide, this already
> happens before the next @AboutToShow
|
|
|
Re: Removing Dynamic Menu Contributions [message #1039588 is a reply to message #1039547] |
Fri, 12 April 2013 06:03   |
Eclipse User |
|
|
|
Thanks Marco, see inline response below.
On 12-04-13 11:29, Marco Descher wrote:> Hy there,
>
> @AboutToShow is called every time you open the menu containing the
> DynamicMenuContribution. So the list.clear() in @AboutToHide does not do
> anything useful to you.
>
OK, I suspected this. It wasn't clear to me how to use @AboutToHide
> What is the scenario you want to fix here??
I Simply want to add MMenu's to an MDynamicMenuContribution, which it
does. But the next time I click on the menu I get a duplicate entry for
the MMenu. Hence the 'experiment' to remove them in @aboutToHide. (So
that's a bad, and I won't do it again, promissed ;-)
I have attached two screenshots, notice that the second time the menu is
populated, the first MMenu entry is cleaned, but the MMenu itself is
still there.
So what could cause the orignal menu contribution not to be removed? I
wonder if it's the fact that I am contributing MMenu's and perhaps it's
only tested with MHandledMenuItem and MDirectMenuItem? (Just guessing
here).
I hope this is a better explanation.
Rgds Christophe
> If you want a conditional
> dynamic population of the menu, you have to realize this within
> @aboutToShow
>
> for example:
>
>
> @AboutToShow
> public void aboutToShow(List<MMenuElement> items) {
> if(condition) {
> populateMenu()
> }
> }
>
>
> I don't see any sense in removing elements in @AboutToHide, this already
> happens before the next @AboutToShow
|
|
| | | | | |
Re: Removing Dynamic Menu Contributions [message #1107422 is a reply to message #1107028] |
Thu, 12 September 2013 07:21  |
Eclipse User |
|
|
|
On 12-09-13 00:09, Maarten Bezemer wrote:
> The bug your pointed to is slightly different. I do not populate with
> MMenu items but with MDirectMenuItem items.
> These are not growing each time the menu is opened, but are persisting
> when the application is restarted (and making the menu larger and larger)
> I tried to use @AboutToHide to throw the items away manually, but this
> does not help.
>
> Unfortunately, I am unable to debug the problem properly as I am using
> Linux and debugging it freezes X...
mmmh... stacked problems he? Solve them one by one is the solution :P
|
|
|
Goto Forum:
Current Time: Wed Jul 23 12:33:09 EDT 2025
Powered by FUDForum. Page generated in 0.39008 seconds
|