Home » Eclipse Projects » Eclipse 4 » Removing Dynamic Menu Contributions
| |
Re: Removing Dynamic Menu Contributions [message #1038335 is a reply to message #1038227] |
Wed, 10 April 2013 18:53 |
Christophe Bouhier 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 #1039577 is a reply to message #1039547] |
Fri, 12 April 2013 10:03 |
Christophe Bouhier 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 |
Christophe Bouhier 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 |
Christophe Bouhier 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 |
Christophe Bouhier 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
|
|
| | | | | | |
Goto Forum:
Current Time: Thu Apr 25 12:13:33 GMT 2024
Powered by FUDForum. Page generated in 0.05655 seconds
|