不要在 Eclipse RCP 应用程序中保存 workbench 状态
Do not save workbench state in a eclipse RCP app
我正在使用 Eclipse RCP 开发一个应用程序。此应用程序在启动时应始终显示特定的视角。但是应用程序会保存它的 workbench 状态,并且在重新启动时它会显示与关闭时相同的视角。我试着添加
public void initialize(IWorkbenchConfigurer configurer){
configurer.setSaveAndRestore(false);
}
我的 ApplicationWorkbenchAdvisor
class,但它没有用。我也想到了selection the right perspective,但是不知道在哪里加这么一段代码
我的应用程序如何在启动时始终显示相同的视角?
我发现如果你总是想要相同的启动视角,你可以在启动时设置默认视角。
public class Application implements IApplication {
public Object start(IApplicationContext content){
PlatformUI.getWorkbench().getPerspectiveRegistry().setDefaultPerspective("youperspective here");
//other code...
}
//other code...
}
更新:
这仅在您在 运行 配置中启用 "Clear workspace" 时有效。我目前的解决方案是在程序启动时删除workbench文件。
对你来说太晚了,但可能对其他人有用。
正如@Aiden 所说,我们将 -clearPersistedState
添加到 运行 配置中的程序参数。
它在 e4 中与 Eclipse Neon 4.6 一起为我们工作。
我正在使用 Eclipse RCP 开发一个应用程序。此应用程序在启动时应始终显示特定的视角。但是应用程序会保存它的 workbench 状态,并且在重新启动时它会显示与关闭时相同的视角。我试着添加
public void initialize(IWorkbenchConfigurer configurer){
configurer.setSaveAndRestore(false);
}
我的 ApplicationWorkbenchAdvisor
class,但它没有用。我也想到了selection the right perspective,但是不知道在哪里加这么一段代码
我的应用程序如何在启动时始终显示相同的视角?
我发现如果你总是想要相同的启动视角,你可以在启动时设置默认视角。
public class Application implements IApplication {
public Object start(IApplicationContext content){
PlatformUI.getWorkbench().getPerspectiveRegistry().setDefaultPerspective("youperspective here");
//other code...
}
//other code...
}
更新: 这仅在您在 运行 配置中启用 "Clear workspace" 时有效。我目前的解决方案是在程序启动时删除workbench文件。
对你来说太晚了,但可能对其他人有用。
正如@Aiden 所说,我们将 -clearPersistedState
添加到 运行 配置中的程序参数。
它在 e4 中与 Eclipse Neon 4.6 一起为我们工作。