Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Update label of handled tool item
Update label of handled tool item [message #879072] Wed, 30 May 2012 09:20 Go to next message
Eclipse UserFriend
Hi,

I'm trying to implement a login button in the toolbar which
has a label called "login" and after pressing + successfull
login it shows the user name.

My implementation contains:
* Command
* Handler
* Window Trim -> Trimbar -> Toolbar -> Handled tool item -> Handler/Command

How do I access this tool item?

Note:
I tried "ToolControl", but the css isn't applied and it looks awefull.

thanks in advance,
Muki
Re: Update label of handled tool item [message #879567 is a reply to message #879072] Thu, 31 May 2012 08:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi Muki,
you can use the EModelService to get the MainToolbar.
Should look smth. like:
@Inject
private EModelService m_ModelService;
@Inject
private MWindow m_Window;

MApplication app = (MApplication)((EObject)m_Window).eContainer();
MToolBar mainToolbar = (MToolBar)m_ModelService.find("toolbar:org.eclipse.ui.main.toolbar", app);


mainToolbar.getChildren() should contain your login-item. The problem is that iam not sure if the Renderer will react on your MToolItem.setLabel("username") and updates the label of the Widget that was created for the MUIElement.
Bug 374568 for example shows that the Renderers do not react on every change yet.

The (imho) "bad" way would be to directly manipulate the widget which should work (already tried it for the MainMenu) and should look smth. like this:
((MenuItem)((Toolbar)mainToolbar.getWidget()).getItem(i)).setText("username")

[Updated on: Thu, 31 May 2012 09:05] by Moderator

Re: Update label of handled tool item [message #879633 is a reply to message #879567] Thu, 31 May 2012 11:00 Go to previous messageGo to next message
Eclipse UserFriend
You can also inject MApplication directly as the search root, it is not necessary to go through MWindow.

Also the update of the label should be autmatically done.
Re: Update label of handled tool item [message #879669 is a reply to message #879633] Thu, 31 May 2012 11:58 Go to previous message
Eclipse UserFriend
Thanks for the replies. So the "old" eclipse 3.x identifiers for toolbars and menus
are still valid.

cheers,
Muki
Previous Topic:What happens to the class HandlerUtil
Next Topic:e4 compatibility: PerspectiveRegistry.clonePerspective
Goto Forum:
  


Current Time: Wed Jul 23 06:37:27 EDT 2025

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

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

Back to the top