Eclipse RCP:clonePerspective返回null [英] Eclipse RCP: clonePerspective returns null

查看:132
本文介绍了Eclipse RCP:clonePerspective返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想克隆一个透视图并保存克隆的透视图。但是,调用 PerspectiveRegistry.clonePerspective(...) 返回null,我的想法可能会消失我的参数值错误。

I want to clone a perspective and save that cloned one. However, the call to the PerspectiveRegistry.clonePerspective(...) returns null, and I'm running out of ideas what could possibly be wrong with my parameter values.

public void savePerspectiveAs(String label) {
    IWorkbenchPage page = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage();
    IPerspectiveDescriptor perspectiveDescriptor = perspectiveRegistry
            .findPerspectiveWithLabel(label);

    // if the perspective doesn't exist, create a new one 
    // by cloning the current perspective
    if (perspectiveDescriptor == null) {
        IPerspectiveDescriptor currentPerspectiveDescriptor = 
                perspectiveRegistry.findPerspectiveWithId(currentPerspective);
        // after this line, perspectiveDescriptor is still null
        perspectiveDescriptor = perspectiveRegistry
                .clonePerspective(currentPerspective + "." 
                         + label.replaceAll(" ", "_"), label, 
                         currentPerspectiveDescriptor);
        // hence I get a NullPointerException here...
        connectedPerspectives.add(perspectiveDescriptor.getId());
    }
    page.savePerspectiveAs(perspectiveDescriptor);

}

所有其他值似乎都很好。 currentPerspectiveDescriptor 是一个有效的对象,所以 perspectiveRegistry

All other values seem to be fine. currentPerspectiveDescriptor is a valid object, so is perspectiveRegistry.

标签类似于Connected Perspective 2 。而且它还不存在,我创建的透视ID也不是。

label is something like "Connected Perspective 2". And it does not exist yet, neither does my created perspective ID.

任何想法? c code返回null?

Any ideas? What could go wrong here for clonePerspective(...) to return null?

推荐答案

在Eclipse 4.x中不支持clonePerspective

这是 PerspectiveRegistry.clonePerspective

public IPerspectiveDescriptor clonePerspective(String id, String label,
        IPerspectiveDescriptor desc) throws IllegalArgumentException {
    // FIXME: compat clonePerspective. Not called in 3.8
    E4Util.unsupported("clonePerspective"); //$NON-NLS-1$
    return null;
}

Eclipse的这个错误是 382209

The Eclipse bug for this is 382209

这篇关于Eclipse RCP:clonePerspective返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆