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