Memran
Memran

Reputation: 405

Eclipse e4 RCP - setting titlebar text at runtime

I would like to be able to change the titlebar text at runtime. Typically I want to do this when my application opens a file, so that I will have Application Name - File Name in the titlebar.

I've read about people using an ApplicationWorkbenchWindowAdvisor to get hold of the IWorkbenchWindowConfigurer, and then using that to set the title, but I don't actually know where or how to get hold of the ApplicationWorkbenchWindowAdvisor, or even whether this is a class I need to write.

Currently, the title is set via the appName property in my plugin.xml only.

Can someone please show an example if its usage?

Upvotes: 2

Views: 836

Answers (2)

Nick J. R. T.
Nick J. R. T.

Reputation: 440

An alternative to using the EModelService to find the MWindow by ID, is to use injection. In this way, it'll find the parent (and active, though that might be redundant) Window in the Context of the Control that is performing the action (File-Chooser in your case):

@Inject
@Active
private MWindow window;

Upvotes: 0

greg-449
greg-449

Reputation: 111142

You can do this by setting the label on the top level MWindow of your app:

@Inject
MApplication application;
@Inject
EModelService modelService;

....

MWindow window = (MWindow)modelService.find("id of your top window", application);

window.setLabel("new label");

Upvotes: 2

Related Questions