简体   繁体   English

窗口标题是否可以在具有兼容性层的Eclipse 4应用程序中包含核心插件的版本号?

[英]Can the window title include the version number of the core plugin in an Eclipse 4 application with compatibility layer?

In a mixed mode Eclipse RCP application, I'd like to change the application window title to something like "Great App v1.3.22". 混合模式的 Eclipse RCP应用程序中,我想将应用程序窗口标题更改为“ Great App v1.3.22”。

I basically have application (3.x based) and product (4.5 (Mars) based) split up into two plugins (following a helpful blog post describing how to use 3.x views in Eclipse 4, I need the CNF). 基本上,我将应用程序(基于3.x)和产品(基于4.5(火星))分为两个插件(下面的博客文章描述了如何在Eclipse 4中使用3.x视图,我需要CNF)。

At the moment, the title is "got" from the org.eclipse.core.runtime.products extension point defined in the product plugin : 目前,标题是从产品插件中定义的org.eclipse.core.runtime.products扩展点“获得”的:

<extension
  id="my_product_id"
  point="org.eclipse.core.runtime.products">
  <product
    name="Great App"
    application="my.application">
  </product>
</extension>

Can I use a variable in the <product name> property? 我可以在<product name>属性中使用变量吗? If so, what variables are available? 如果可以,哪些变量可用? Or can this be achieved by "overriding" the window title via the Trimmed Window entry in Application.e4xmi , and again what variables would be available? 还是可以通过Application.e4xmiTrimmed Window条目“覆盖”窗口标题来实现,又可以使用哪些变量? Or do I have to resort to ancient ways and set the title programmatically in the old ApplicationWorkbenchWindowAdvisor (which, however, wouldn't be available if I was able to switch to a pure E4 app once the CNF is available as a native E4 plugin)? 还是我必须求助于古老的方法,并在旧的ApplicationWorkbenchWindowAdvisor中以编程方式设置标题(但是,一旦CNF可用作本机E4插件,如果我能够切换到纯E4应用程序,该标题将不可用) ?

There are no variables you can use. 没有可以使用的变量。

You can change the main window title in the LifeCycle class. 您可以在LifeCycle类中更改主窗口标题。 The @ProcessAdditions method is the earliest you can do this: @ProcessAdditions方法是最早可以执行此操作的方法:

@ProcessAdditions
public void processAdditions(MApplication app, EModelService modelService, IApplicationContext applicationContext)
{
  MWindow window = (MWindow)modelService.find("id of main trimmed window", app);

  window.setLabel("new text");
}

I am not sure where you want to get the version from. 我不确定您要从哪里获取版本。 One possibility is a property in the product definition: 一种可能性是产品定义中的属性:

<extension
  id="my_product_id"
  point="org.eclipse.core.runtime.products">
  <product
    name="Great App"
    application="my.application">
     <property
           name="version"
           value="1.3.22">
      </property>
   </product>
</extension>

You will have to maintain this property manually or do something in your build to set it. 您将必须手动维护此属性,或者在构建中进行一些设置。

You can access this using the IApplicationContext 您可以使用IApplicationContext访问它

applicationContext.getBrandingProperty("version")

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

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