2017-08-30 33 views
0

我想做的事:打開DialectEditor編程主編輯器區域(E3/E4混合動力)之外

在我的RCP的E3/E4混合動力車我有一個基於天狼樹項目和圖書館。用戶可以從庫樹中拖放項目到項目樹。這工作正常,並沒有很大的問題,所以現在我想使UI更加可用。它應該看起來像這樣的佈局:

enter image description here 是什麼在起作用:

後,應用程序啓動時我打開與DialectUIManager庫演示。

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

好的,這個工程。但它在org.eclipse.ui.editorss的零件市場的編輯器中打開它。這是不是我想要

enter image description here

什麼行不通:

我想表明它在「庫部分」。打開編輯器後,我可以用鼠標手動移動它,但是如何告訴Di​​alectUIManager在那裏直接打開它。或者我如何以編程方式將它移到那裏。

我做了很多谷歌研究,但我沒有找到解決方案。我發現的唯一的事情就是個暗示皮埃爾 - 查爾斯·大衛https:// www. eclipse.org/forums/index.php?t=msg&th=998476&goto=1631138&#msg_1631138

如果您需要的是簡單的顯示主編輯器 區域以外的編輯,這是可能的,因爲Eclipse的4.2(E4並沒有真正治療 主編輯區域作爲特別的東西),所以你可以讓你的編輯器 「在其他視圖中間的另一個編輯器」周圍。

但在這一步我卡住了。我也在天狼星論壇上問過它,但他們說它的Eclipse E4問題

感謝您的幫助,代碼片段或鏈接以正確部分的手冊。

+0

我不知道'DialectUIManager'是什麼,但它可能是使用3.x API來打開編輯器 - 這些API沒有辦法說明編輯器在哪裏打開。 –

+0

'DialectUIManager'是Sirius API的一部分,你是對的,它使用3.x API。編輯器是'IEditorPart'類型的。 如果無法直接在另一部分中打開編輯器,是否可以通過編程方式將其移動到庫部件中? – Fry123

回答

0

我找到了解決方案。這不是很好,但它的工作原理。我在編輯打開後在這裏執行這些代碼。

的代碼做什麼:

他正在尋找它具有ID的MPlaceholder:組織。蝕。 UI。 editorss。在那裏,他下降,直到他與部分。這些處於兼容編輯模式。然後他選擇我們想移出的部分並將它們附加到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); 
    } 
    } 
相關問題