[英]How to Remember the State in Eclipse e4
在Eclipse 3.x中,通过检查ApplicationWorkbenchAdvisor类中的restoreState()
方法,我们可以很容易地知道应用程序是第一次启动还是正在恢复状态,但是Eclipse 4.x中不提供此功能,所以任何人都可以帮助我我知道Eclipse 4中的Eclipse状态是否已恢复?
You could set a value in the 'persisted state' of the application and check that during start up. 您可以在应用程序的“持久状态”中设置一个值,并在启动过程中进行检查。
The earliest the application object is available is the @ProcessAdditions
step of the LifeCyle
class. 最早的应用程序对象是
LifeCyle
类的@ProcessAdditions
步骤。
@ProcessAdditions
void processAdditions(MApplication app)
{
String value = app.getPersistedState().get("myKey");
if (value == null) // Starting with nothing to restore
{
app.getPersistedState().put("myKey", "set");
...
}
else
{
... persisted state exists
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.