Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Eclipse迁移和org.Eclipse.ui.internal API_Java_Eclipse_Eclipse Plugin_Eclipse Rcp - Fatal编程技术网

Java Eclipse迁移和org.Eclipse.ui.internal API

Java Eclipse迁移和org.Eclipse.ui.internal API,java,eclipse,eclipse-plugin,eclipse-rcp,Java,Eclipse,Eclipse Plugin,Eclipse Rcp,我目前正在将一段用EclipseHelios编写的非常古老的代码迁移到EclipseMars。代码使用了org.eclipse.ui.internal包中的某些API,如EditorSashContainer,EditorStack,PartStack,LayoutPart等。是否这些API在e4兼容层中不再可用?还是我需要再导入几个插件?迁移可能涉及最少代码更改的代码的最佳方法是什么。我们使用这些API基本上对编辑器进行了拆分,使其具有类似工作簿的外观 提前谢谢 您不应该使用内部API Ecl

我目前正在将一段用EclipseHelios编写的非常古老的代码迁移到EclipseMars。代码使用了
org.eclipse.ui.internal
包中的某些API,如
EditorSashContainer
EditorStack
PartStack
LayoutPart
等。是否这些API在e4兼容层中不再可用?还是我需要再导入几个插件?迁移可能涉及最少代码更改的代码的最佳方法是什么。我们使用这些API基本上对编辑器进行了拆分,使其具有类似工作簿的外观


提前谢谢

您不应该使用内部API

Eclipse的内部已经为Eclipse4完全重写,许多内部接口已经更改或删除。现在一切都基于表示GUI中对象的EMF模型。兼容性层提供旧式API,但只支持官方API

没有直接的方法来处理对内部API的更改。您必须了解Eclipse的新工作方式


您可以覆盖大多数组件(如零件堆栈)的“渲染器”,这可能是一种实现所需功能的方法。

以下是我如何在E4环境中拆分编辑器的代码片段

我就是这样执行的:
splitEditor(0.5f,3,currentEditor,newEditor)

@Override
public void splitEditor(float ratio, int where, IEditorPart containerEditor, IEditorPart editorToInsert) {
    MPart container = containerEditor.getSite().getService(MPart.class);
    if (container == null) {
        return;
    }
    MPart toInsert = editorToInsert.getSite().getService(MPart.class);
    if (toInsert == null) {
        return;
    }

    insertEditor(ratio, where, container, toInsert);
}

/**
 * Inserts the editor into the container editor.
 *
 * @param ratio the ratio
 * @param where where to insert ({@link EModelService#LEFT_OF}, {@link EModelService#RIGHT_OF}, {@link EModelService#ABOVE} or
 * {@link EModelService#BELOW})
 * @param containerEditor the container editor
 * @param editorToInsert the editor to insert
 */
public void insertEditor(float ratio, int where, MPart containerEditor, MPart editorToInsert) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    EModelService service = window.getService(EModelService.class);
    MPartStack toInsert = getPartStack(editorToInsert);

    MArea area = getArea(containerEditor);
    MPartSashContainerElement relToElement = area.getChildren().get(0);
    service.insert(toInsert, relToElement, where, ratio);
}

@SuppressWarnings("restriction")
private MPartStack getPartStack(MPart childPart) {
    MStackElement stackElement = childPart;
    MPartStack newStack = org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl.eINSTANCE.createPartStack();
    newStack.getChildren().add(stackElement);
    newStack.setSelectedElement(stackElement);
    return newStack;
}

private MArea getArea(MPart containerPart) {
    MUIElement targetParent = containerPart.getParent();
    while (!(targetParent instanceof MArea)) {
        targetParent = targetParent.getParent();
    }
    MArea area = (MArea) targetParent;
    return area;
}