Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Inject the MMenu in a Handler
Inject the MMenu in a Handler [message #761368] Tue, 06 December 2011 11:13 Go to next message
Thomas Kölling is currently offline Thomas KöllingFriend
Messages: 45
Registered: December 2011
Location: Munich
Member
Hi!

Currently i try to inject my main menu in a handler. main reason for this is, to hide the main menu on a specific shortcut. the shortcut->command->handler mapping works fine, but only if I not try to inject the main menu. here is my handler implementation:

public class HideMenuHandler {
	@Inject
	@Named("menu:org.eclipse.ui.main.menu")
	private MMenu menu;
	
	@Execute
	public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
		System.out.println("menu");
	}
}


if i implement my handler like above, the execute method is not called. on some examples i've seen, this technique is only used in processor's. how i can get the mmenu (main menu) in to my handler?

thank you
Re: Inject the MMenu in a Handler [message #761378 is a reply to message #761368] Tue, 06 December 2011 11:30 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Do NOT use @Inject in Handlers put everything you need into the
execute()-method.

I'm not sure on the ID you are using but if it is not working I'd
suggest you let yourself inject the window instance and navigate to the
Menu from there.

Tom

Am 06.12.11 12:13, schrieb ThomasK:
> Hi!
>
> Currently i try to inject my main menu in a handler. main reason for
> this is, to hide the main menu on a specific shortcut. the
> shortcut->command->handler mapping works fine, but only if I not try to
> inject the main menu. here is my handler implementation:
>
>
> public class HideMenuHandler {
> @Inject
> @Named("menu:org.eclipse.ui.main.menu")
> private MMenu menu;
>
> @Execute
> public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell
> shell) {
> System.out.println("menu");
> }
> }
>
>
> if i implement my handler like above, the execute method is not called.
> on some examples i've seen, this technique is only used in processor's.
> how i can get the mmenu (main menu) in to my handler?
>
> thank you
Re: Inject the MMenu in a Handler [message #761399 is a reply to message #761378] Tue, 06 December 2011 12:31 Go to previous messageGo to next message
Thomas Kölling is currently offline Thomas KöllingFriend
Messages: 45
Registered: December 2011
Location: Munich
Member
Hi Tom,

ok, i've tried the following suggestion:

@Execute
	public void execute(MApplication application, EModelService service){
		//myTrimmedWindow
		List<MTrimmedWindow> findElements = service.findElements(application, "myTrimmedWindow",
				MTrimmedWindow.class, null);
		findElements.get(0).getMainMenu().setVisible(false);
		findElements.get(0).getMainMenu().setEnabled(false);
	}


the Window is there, the MainMenu too. but none of the both methods (setVisible & setEnable) works. do i miss something?

thank you for your help Smile
Re: Inject the MMenu in a Handler [message #761418 is a reply to message #761399] Tue, 06 December 2011 12:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Hm looking at the code I see that the renderer hooks itself up
visibility changes. Now my wild guess that the case for the Root-Menu
(==MenuBar on the Shell) is not implemented.

I'd suggest to file a bug for this so that we can track why your code is
not working.

Tom

Am 06.12.11 13:31, schrieb ThomasK:
> Hi Tom,
>
> ok, i've tried the following suggestion:
>
>
> @Execute
> public void execute(MApplication application, EModelService service){
> //myTrimmedWindow
> List<MTrimmedWindow> findElements =
> service.findElements(application, "myTrimmedWindow",
> MTrimmedWindow.class, null);
> findElements.get(0).getMainMenu().setVisible(false);
> findElements.get(0).getMainMenu().setEnabled(false);
> }
>
>
> the Window is there, the MainMenu too. but none of the both methods
> (setVisible & setEnable) works. do i miss something?
>
> thank you for your help :)
Re: Inject the MMenu in a Handler [message #761430 is a reply to message #761418] Tue, 06 December 2011 13:23 Go to previous message
Thomas Kölling is currently offline Thomas KöllingFriend
Messages: 45
Registered: December 2011
Location: Munich
Member
ok i created a new ticket with this id: 365724

(cannot create links < 5 messages Smile)
Previous Topic:external css file
Next Topic:How can I create toolbar icons with labels under them?
Goto Forum:
  


Current Time: Fri Apr 26 22:16:17 GMT 2024

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

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

Back to the top