| Update label of handled tool item [message #879072] |
Wed, 30 May 2012 09:20  |
Nepomuk Seiler Messages: 77 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   |
Marko Herchet Messages: 10 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01751 seconds