1

我想做的事:

在我的 RCP 一个 E3/E4 混合体中,我有一个基于天狼星树的项目和库。用户可以将拖放项从库树拖到项目树中。这很好用,构建起来也不是什么大问题。所以现在我想让 UI 更有用。它应该看起来像这样的布局:

在此处输入图像描述 什么有效:

应用程序启动后,我使用 DialectUIManager 打开我的库演示文稿。

final DialectEditor editor = (DialectEditor) 
DialectUIManager.INSTANCE.openEditor(siriusSession, description, monitor);

好的,这行得通。但它在零件市场的编辑器中将其打开为 org.eclipse.ui.editorss。这不是我想要的

在此处输入图像描述

什么不起作用:

我想在“图书馆部分”中展示它。我可以在打开编辑器后用鼠标手动移动它,但是我怎样才能告诉 DialectUIManager 直接在那里打开它。或者我怎样才能以编程方式将它移到那里。

我做了很多谷歌研究,但我没有找到解决方案。我发现的唯一一件事是暗示 Pierre-Charles David https://www。eclipse.org/forums/index.php?t=msg&th=998476&goto=1631138&#msg_1631138

如果您只是需要在主编辑器区域之外显示编辑器,那么从 Eclipse 4.2 开始这是可能的(e4 并没有真正将主编辑器区域视为特殊的东西),因此您可以让您的编辑器“围绕”另一个编辑器其他视图的中间。

但在这一步我卡住了。我也在 Sirius 论坛上问过,但他们说这是 Eclipse E4 问题

感谢您的帮助、代码片段或链接以纠正手册的一部分。

4

1 回答 1

0

我找到了解决方案。这不是很好,但它有效。编辑器打开后,我在这里执行这些代码。

代码的作用:

他正在寻找 ID 为 org 的 MPlaceholder。蚀。ui。编辑。他在那里下降,直到他与零件在一起。这些处于兼容编辑器模式。然后他选择我们想要移出的部分并将它们附加到 MPartStack 目标。

  public static void movePart(MApplication application, 
            EModelService modelService) {

    MPart partToMove = null;
    MUIElement muiElement = 
            modelService.find("org.eclipse.ui.editorss", application);

    if (muiElement instanceof MPlaceholder) {
      MPlaceholder placeholder = (MPlaceholder) muiElement;
      MUIElement ref = placeholder.getRef();

      if (ref instanceof MArea) {
        MArea area = (MArea) ref;
        List<MPartSashContainerElement> children = area.getChildren();

        for (MPartSashContainerElement mPartSashContainerElement 
                                                       : children) {

          if (mPartSashContainerElement instanceof MPartStack) {
            MPartStack partStack = (MPartStack) mPartSashContainerElement;
            List<MStackElement> children2 = partStack.getChildren();
            for (MStackElement mStackElement : children2) {
              if (mStackElement instanceof MPart) {
                MPart part = (MPart) mStackElement;
                // Library is the Editor Name wiche I want to move
                if (part.getLabel().equals("Library")) {
                  partToMove = part;
                  break;
                }
              }
            }
          }
        }

      }
    }

    if (partToMove != null) {
      moveElement(modelService, application, partToMove);
    }
  }

  private static void moveElement(EModelService modelService, 
                    MApplication application, MPart part) {
    // target PartStack
    MUIElement find = modelService.find("de.bsg.onesps.rcp.
                               partstack.library", application);

    if (find instanceof MPartStack) {
      MPartStack mPartStack = (MPartStack) find;

      mPartStack.getChildren().add(part);
      mPartStack.setSelectedElement(part);
    }
  }
于 2017-09-06T13:03:31.100 回答