Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Nepomuk Seiler is currently offline Nepomuk Seiler
Messages: 88
Registered: December 2010
Member
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
Marko Herchet is currently offline Marko Herchet
Messages: 11
Registered: May 2012
Junior Member
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]

Report message to a 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
Sopot Cela is currently offline Sopot Cela
Messages: 596
Registered: December 2010
Senior Member

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
Nepomuk Seiler is currently offline Nepomuk Seiler
Messages: 88
Registered: December 2010
Member
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: Tue Jul 29 20:59:10 EDT 2014

Powered by FUDForum. Page generated in 0.01682 seconds