0
我有這個實用程序方法,它可以很容易地改變我的應用程序的特定位置顯示的內容。Eclipse 4 RCP - 如何從應用程序模型中刪除部分?
問題在於,它看起來更像是新零件位於舊零件的頂部(舊零件未被移除並且在新零件下仍然可見)。
package cz.vutbr.fit.xhriba01.bc.ui;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
public class UI {
public static final String PART_INSPECTOR_ID = "bc.part.inspector";
public static void changeInspectorView(String partDescriptorId, EPartService partService, EModelService modelService) {
MPart part = partService.createPart(partDescriptorId);
MPart oldPart = partService.findPart(UI.PART_INSPECTOR_ID);
MPartSashContainer parent = (MPartSashContainer) modelService.getContainer(oldPart);
parent.getChildren().remove(oldPart);
part.setElementId(UI.PART_INSPECTOR_ID);
parent.getChildren().add(0, part);
}
}
hidePart工作,thx – Krab 2014-10-28 09:24:01
如果我沒有記錯,hidePart使部分「隱形」。這可能會導致意想不到的行爲(例如,如果您在此部分中有觸發事件的方法)。 hidePart(oldPart,true)強制將其作爲孩子從零件堆棧中移除。只作爲提示;) – 2014-10-28 14:46:49
@MatthiasH零件在隱藏時被銷燬(只需運行測試以確認) – 2014-10-28 14:52:54