Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Removing Dynamic Menu Contributions
Removing Dynamic Menu Contributions [message #1037345] Tue, 09 April 2013 12:47 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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 #1038227 is a reply to message #1037345] Wed, 10 April 2013 15:23 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,
could you paste the code you use to fill the menu?
Regards
Jonas

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 #1038335 is a reply to message #1038227] Wed, 10 April 2013 18:53 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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 #1039547 is a reply to message #1037345] Fri, 12 April 2013 09:29 Go to previous messageGo to next message
Marco Descher is currently offline Marco DescherFriend
Messages: 197
Registered: October 2010
Location: Austria
Senior Member
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.

What is the scenario you want to fix here?? 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 #1039577 is a reply to message #1039547] Fri, 12 April 2013 10:03 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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 10:03 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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 10:03 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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 10:03 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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 #1039638 is a reply to message #1039577] Fri, 12 April 2013 11:41 Go to previous messageGo to next message
Marco Descher is currently offline Marco DescherFriend
Messages: 197
Registered: October 2010
Location: Austria
Senior Member
Now I see the problem. Thanks for reporting this bug, I will take care of it!
Re: Removing Dynamic Menu Contributions [message #1039650 is a reply to message #1039638] Fri, 12 April 2013 11:55 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 12-04-13 13:41, Marco Descher wrote:
> Now I see the problem. Thanks for reporting this bug, I will take care
> of it!
Great! Thanks.
Re: Removing Dynamic Menu Contributions [message #1104711 is a reply to message #1037345] Sun, 08 September 2013 21:23 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
I have the same problem.
Is there a solution/fix available?
Re: Removing Dynamic Menu Contributions [message #1106906 is a reply to message #1104711] Wed, 11 September 2013 18:04 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 08-09-13 23:23, Maarten Bezemer wrote:
> I have the same problem.
> Is there a solution/fix available?
Yes,see this;
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405471
Re: Removing Dynamic Menu Contributions [message #1107028 is a reply to message #1106906] Wed, 11 September 2013 22:09 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
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...
Re: Removing Dynamic Menu Contributions [message #1107422 is a reply to message #1107028] Thu, 12 September 2013 11:21 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
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
Previous Topic:Each Editor part to uniquely track navigator state
Next Topic:e4 how to contribute to the workbench main menu and toolbar.
Goto Forum:
  


Current Time: Fri Apr 19 21:55:44 GMT 2024

Powered by FUDForum. Page generated in 0.04528 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top