`

eclipse rcp 不能切换工作空间 switch workspace fail

阅读更多

解决eclipse rcp 不能切换工作空间/switch workspace fail的问题。

 

今天,准备发布产品IDE的时候,发现一个棘手的问题。rcp程序居然不能切换工作空间。切换工作空间使用的commandid没有错,使用:org.eclipse.ui.file.openWorkspace。

 

最终在eclipse 官方论坛找到答案。解决方法如下:

 

public class Application implements IApplication

{

    private static final String PROP_EXIT_CODE = "eclipse.exitcode"; //$NON-NLS-1$

 

    /*

     * (non-Javadoc)

     * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.

     * IApplicationContext)

     */

    public Object start(IApplicationContext context)

    {

        Display display = PlatformUI.createDisplay();

        try

        {

// 注释的代码是在新建eclipse插件工程的时候生成。

// int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());

// if (returnCode == PlatformUI.RETURN_RESTART) {

// return IApplication.EXIT_RESTART;

// }

// return IApplication.EXIT_OK;

//                      上面的代码改为:

            int returnCode = PlatformUI.createAndRunWorkbench(display,

                    new ApplicationWorkbenchAdvisor());

            if (returnCode != PlatformUI.RETURN_RESTART)

                return EXIT_OK;

            return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE)) ? EXIT_RELAUNCH

                    : EXIT_RESTART;

        } finally

        {

            display.dispose();

        }

    }

 

    /*

     * (non-Javadoc)

     * @see org.eclipse.equinox.app.IApplication#stop()

     */

    public void stop()

    {

...

...

    }

}



PS: 切换工作空间只能在导出产品的时候使用。在eclipse下运行,是不能切换工作空间的。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics