Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » MMenuElement.setVisible not working?
MMenuElement.setVisible not working? [message #924959] Thu, 27 September 2012 09:12 Go to next message
Mike Shreek is currently offline Mike ShreekFriend
Messages: 16
Registered: September 2012
Junior Member
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 09:23 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 10:26 Go to previous messageGo to next message
Mike Shreek is currently offline Mike ShreekFriend
Messages: 16
Registered: September 2012
Junior Member
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 10:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 11:14 Go to previous messageGo to next message
Mike Shreek is currently offline Mike ShreekFriend
Messages: 16
Registered: September 2012
Junior Member
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 13:07 Go to previous messageGo to next message
Mike Shreek is currently offline Mike ShreekFriend
Messages: 16
Registered: September 2012
Junior Member
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 14:08 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 07:32 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
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: Fri Apr 19 18:55:25 GMT 2024

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

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

Back to the top