Search code examples
eclipse-rcpe4

How to set the window title after startup of an RCP application


I am programming an e4 RCP application and would like to set it's window title once it has started. However I could not find any way to realise that.

Reason is, I would like to add some explicit info about the running program so the user can differ between multiple launches.

Any hints on that?


Solution

  • In e4 you can set the main window title by calling the setLabel method of the MWindow for the main window. Use the EModelService to find the main window.

    A suitable place to do this might be in an 'application startup complete' event in your RCP LifeCycle class

    @Optional
    @Inject
    public void appStartupComplete(@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, 
                                   EModelService modelService, MApplication application)
    {
      MWindow window = (MWindow)modelService.find("top window id", application);
    
      window.setLabel("new window title");
    }
    

    Note: Event is org.osgi.service.event.Event