简体   繁体   English

如何在 RCP 应用程序启动后设置 window 标题

[英]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.我正在编写一个 e4 RCP 应用程序,并希望在它启动后将其设置为 window 标题。 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?有什么提示吗?

In e4 you can set the main window title by calling the setLabel method of the MWindow for the main window.在 e4 中,您可以通过调用主 window 的MWindowsetLabel方法来设置主 window 标题。 Use the EModelService to find the main window.使用EModelService找到主要的 window。

A suitable place to do this might be in an 'application startup complete' event in your RCP LifeCycle class执行此操作的合适位置可能是 RCP 生命周期 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注意: Eventorg.osgi.service.event.Event

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM