Eclipse 4 related

本文探讨了E4 RCP在Eclipse平台上的使用技巧,包括依赖注入、常见问题解答、上下文使用及EMF模型在SWT复合组件映射中的作用。详细介绍了如何查找和操作MToolBar元素,创建和激活MPart,以及如何将部分添加到MPartStack中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

List<MToolBar> toolbarElements = modelService.findElements(application,
                MToolBar.class,
                EModelService.ANYWHERE | EModelService.IN_PART, new Selector() {
                    @Override
                    public boolean select(MApplicationElement element) {
                        System.out.println(element);
                        return (element instanceof MToolBar);
                    }
                });
MToolBar viewMenu = (MToolBar)modelService.find(TOOLBAR_ID, application);

        MPart part = partService.createPart("your part id");

        //find your container
        List<MPartStack> stacks = modelService.findElements(application, STACK_ID, MPartStack.class, null);
        if (stacks.size() < 1) {
            MessageDialog.openError(shell, "Error ", 
                    "Part stack not found. Is the following ID correct?" + STACK_ID);
            return;
        } 

        //add your part into container
        stacks.get(0).getChildren().add(part);
        // activates the part
        partService.showPart(part, PartState.ACTIVATE);

E4:
http://wiki.eclipse.org/Eclipse4/RCP/Dependency_Injection
http://wiki.eclipse.org/E4/Snippets
http://wiki.eclipse.org/Eclipse4/RCP/FAQ
http://wiki.eclipse.org/E4/Contexts

org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer class is the parent of all e4 renderer
org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer is the renderer of MWindow
in one words, e4 is using EMF model to map the detail SWT composite, the EMF model is friend to xml
org.eclipse.e4.ui.model.application.ui.MUIElement class is the base class for e4 EMF model
TrimmedWindow is map to Shell, Window is also map to Shell, and use the same layout(TrimmedPartLayout)

AbstractPartRenderer.processContents method will map the config to real swt composite

TrimBar is just a composite with TrimBarLayout
MTrimBar is map to Composite, exchange information with Widget’s setData and getData, MTrimBar is set to Widget using setData

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值