Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » MMenuElement.setVisible not working?
MMenuElement.setVisible not working? [message #924959] Thu, 27 September 2012 05:12 Go to next message
Eclipse UserFriend
Hi, I've been using this code.

MMenuElement designMenu = application.getChildren().get(0).getMainMenu().getChildren().get(1);

designMenu.setVisible(false);

But nothing happens. No Error.

Am I missing something important here?
Re: MMenuElement.setVisible not working? [message #924975 is a reply to message #924959] Thu, 27 September 2012 05:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

First of all you most likely want toBeRenderer=false. Are you doing this
at runtime or when starting up?

Tom

Am 27.09.12 11:12, schrieb Mike Shreek:
> Hi, I've been using this code.
> MMenuElement designMenu =
> application.getChildren().get(0).getMainMenu().getChildren().get(1);
>
> designMenu.setVisible(false);
>
> But nothing happens. No Error.
> Am I missing something important here?
Re: MMenuElement.setVisible not working? [message #925042 is a reply to message #924975] Thu, 27 September 2012 06:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi Thomas!

I have tried what you said and still get the same result..

And I am doing this at runtime. I wanted to control the menu. The first approach was to add and delete menus. But I thought that I could just set the visibility whenever users trigger events.
Re: MMenuElement.setVisible not working? [message #925082 is a reply to message #925042] Thu, 27 September 2012 06:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I think this a problem in the Menu-Renderers I've already explained in
another answer. I gues the only possible solution is to attach
visible-when expression (i hope this one gets respected by the renderer).

The current menu code is extremely complex because the backwards stuff
got in there as well so fixing it your own is probably not very easy,
the best thing I could propose is that you write your custom menu
renderer (those are generally the easiest ones :-)

Tom

Am 27.09.12 12:26, schrieb Mike Shreek:
> Hi Thomas!
>
> I have tried what you said and still get the same result..
>
> And I am doing this at runtime. I wanted to control the menu. The first
> approach was to add and delete menus. But I thought that I could just
> set the visibility whenever users trigger events.
Re: MMenuElement.setVisible not working? [message #925091 is a reply to message #925082] Thu, 27 September 2012 07:14 Go to previous messageGo to next message
Eclipse UserFriend
Ohhh... That's sad Sad

Oh well, could you tell me how to inject visiblewhen expression? I was also considering that option
Re: MMenuElement.setVisible not working? [message #925178 is a reply to message #925091] Thu, 27 September 2012 09:07 Go to previous messageGo to next message
Eclipse UserFriend
Thomas, If you could pinpoint me on how to create my own custom menu renderer please. It would really help me with my quest
Re: MMenuElement.setVisible not working? [message #925230 is a reply to message #925178] Thu, 27 September 2012 10:08 Go to previous messageGo to next message
Eclipse UserFriend
Not sure there's documentation around and I'm out now for j1 so I can't
write up on it. You can take a look at the sources to see how things are
done - I have written a completely new rendering engine in the last
weeks but that one is for JavaFX so it won't help you.

Tom

Am 27.09.12 15:07, schrieb Mike Shreek:
> Thomas, If you could pinpoint me on how to create my own custom menu
> renderer please. It would really help me with my quest
Re: MMenuElement.setVisible not working? [message #925974 is a reply to message #924959] Fri, 28 September 2012 03:32 Go to previous message
Eclipse UserFriend
Hi Mike,

I have code which removes some menu and toolbar elements in the @ProcessRemovals of the life cycle manager based on configurable user rights (named "kompetenz" which is german for "authority"). If a user doesn't have the authority (kompetenz) for a specific command, all MUIElements that referenced by this command are set "not to be rendered".

This is the relevant part, mybe it will help you:
private void removeCommandUiElements(BenutzerKompetenzen kompetenzen) throws AsException {
	for (MCommand command : application.getCommands()) {
		if (command.getTags().contains(TAG_NO_CHECK))
			continue;
		
		String berechtigungId = command.getElementId();
		if (!kompetenzen.hasKompetenz(berechtigungId)) {
			Collection<Setting> collection = EcoreUtil.UsageCrossReferencer.find((EObject) command, (EObject) application);
			for (Setting setting : collection) {
				if (setting.getEObject() instanceof MUIElement) {
					MUIElement uiElement = (MUIElement) setting.getEObject();
					uiElement.setToBeRendered(false);
					uiElement.getTags().add(TAG_NO_KOMPETENZ);
				}
			}
			command.getTags().add(TAG_NO_KOMPETENZ);
		}
	}
}


Greetings
Christoph
Previous Topic:Tycho and OS X code signing
Next Topic:Abbort close operation on MPart
Goto Forum:
  


Current Time: Thu Jul 10 00:41:57 EDT 2025

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

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

Back to the top