Eclipse restart using 'PlatformUI.getWorkbench().restart()' is not restarting the RCP product

杀马特。学长 韩版系。学妹 提交于 2019-12-07 22:34:47

问题


Upon invoking the method PlatformUI.getWorkbench().restart() the application is simply closing and refusing to restart the product.


回答1:


Your IApplication needs to check the return code from PlatformUI.createAndRunWorkbench in the start method:

The simplest is:

int returnCode = PlatformUI.createAndRunWorkbench(display, advisor);
if (returnCode == PlatformUI.RETURN_RESTART)
   return IApplication.EXIT_RESTART;

return IApplication.EXIT_OK;

More recent applications seem to use this:

private static final String SYSTEM_PROPERTY_EXIT_CODE = "eclipse.exitcode";

int returnCode = PlatformUI.createAndRunWorkbench(display, advisor);

if (returnCode == PlatformUI.RETURN_RESTART)
 {
   // eclipse.exitcode system property may be set to re-launch
   if (IApplication.EXIT_RELAUNCH.equals(Integer.getInteger(SYSTEM_PROPERTY_EXIT_CODE)))
      return IApplication.EXIT_RELAUNCH;

   return IApplication.EXIT_RESTART;
 }

return IApplication.EXIT_OK;


来源:https://stackoverflow.com/questions/24890851/eclipse-restart-using-platformui-getworkbench-restart-is-not-restarting-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!