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

本文介绍了解决Eclipse RCP程序无法切换工作空间的问题。通过修改Application类中的代码实现,确保了切换功能的正常运作。此解决方案适用于发布产品的场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决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下运行,是不能切换工作空间的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

在键盘上跳舞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值