Trying to access the MApplication instance at startup: that is, before the user accesses the UI to generate events, via buttons, views etc.
尝试在启动时访问MApplication实例:即在用户访问UI以生成事件之前,通过按钮、视图等。
It appears that at startup, there are 2 access points:
在启动时,有两个存取点:
-
The app osgi bundle activator: via the .start() method.
app osgi捆绑激活器:通过.start()方法。
-
The E4LifeCycle instance: the .postContextCreate(workbenchContext, applicationContext) method.
E4LifeCycle实例:. postcontextcreate (workbenchContext, applicationContext)方法。
In checking the initial workbenchContext in my E4LifeCycle instance, it does not return an MApplication instance (or any instanceof MApplicationElement). The IApplicationContext instance (eclipse standard, not e4 apparently) doesn't seem to have any way to get to the e4 elements. The workbenchContext returns an instance of EModelService when queried but (for some reason I can't figure out), one can't access the root model element from that service: one already has to have access to an applicationElement (usually an MUIElement instance) to find other elements.
在我的E4LifeCycle实例中检查初始的workbenchContext时,它不会返回一个MApplication实例(或者任何instanceof MApplicationElement)。IApplicationContext实例(显然是eclipse标准,而不是e4)似乎没有办法到达e4元素。workbenchContext在查询时返回一个EModelService实例,但是(出于某些原因,我不能理解),不能从该服务访问根模型元素:一个已经必须访问applicationElement(通常是一个MUIElement实例)来查找其他元素。
So, perhaps I'm missing something, but there doesn't seem to be a way to get to the MApplication instance unless it is through the initial mPart view objects (via injection) that one's app provides. Is there no other way to access the app model before the ui/views are created?
所以,也许我遗漏了一些东西,但似乎没有办法到达MApplication实例,除非它通过一个应用程序提供的初始mPart视图对象(通过注入)。在创建ui/视图之前,没有其他方式访问app模型吗?
Is there some sort of EventBroker I need to register?
我需要注册一个EventBroker吗?
1 个解决方案
#1
1
The MApplication
has not yet been created when the life cycle @PostContextCreate
is called.
在调用生命周期@PostContextCreate时,还没有创建MApplication。
It is available when the @ProcessAdditions
life cycle method is called:
当@ processadd生命周期方法被调用时,它是可用的:
@ProcessAdditions
void processAdditions(MApplication app)
However you should note that this is still quite early in the application startup so other things may not be available. You may want to subscribe to the UIEvents.UILifeCycle.APP_STARTUP_COMPLETE
event in the event broker. This will be called when the application startup is complete.
但是,您应该注意到,在应用程序启动时,这仍然是相当早的,因此可能没有其他的东西可用。您可能想订阅UIEvents.UILifeCycle。事件代理中的APP_STARTUP_COMPLETE事件。这将在应用程序启动完成时调用。
#1
1
The MApplication
has not yet been created when the life cycle @PostContextCreate
is called.
在调用生命周期@PostContextCreate时,还没有创建MApplication。
It is available when the @ProcessAdditions
life cycle method is called:
当@ processadd生命周期方法被调用时,它是可用的:
@ProcessAdditions
void processAdditions(MApplication app)
However you should note that this is still quite early in the application startup so other things may not be available. You may want to subscribe to the UIEvents.UILifeCycle.APP_STARTUP_COMPLETE
event in the event broker. This will be called when the application startup is complete.
但是,您应该注意到,在应用程序启动时,这仍然是相当早的,因此可能没有其他的东西可用。您可能想订阅UIEvents.UILifeCycle。事件代理中的APP_STARTUP_COMPLETE事件。这将在应用程序启动完成时调用。