【发布时间】:2019-01-16 19:12:39
【问题描述】:
我在 MToolbar 中遇到了有关 HandledToolItem 的问题。 当按下按钮时,应用程序应该创建一个带有工具栏和一个 HandledToolItem 的新部件。问题是 HandledToolItem 总是灰色的,我还不知道为什么。
final MPart mPart = modelService.createModelElement(MPart.class);
mPart.setLabel("Test");
mPart.setElementId("newid");
mPart.setContributionURI("bundleclass://something");
mPart.setCloseable(true);
// create Toolbar
final MToolBar mBar = modelService.createModelElement(MToolBar.class);
mPart.setToolbar(mBar);
// create HanledToolItem
final MHandledToolItem mItem = modelService.createModelElement(MHandledToolItem.class);
mBar.getChildren().add(mItem);
// create Handle and Command
final MHandler toolHandler = modelService.createModelElement(MHandler.class);
final MCommand toolCommand = modelService.createModelElement(MCommand.class);
toolCommand.setElementId("dsadsadsa");
toolHandler.setCommand(toolCommand);
toolHandler.setContributionURI("bundleclass://something");
mItem.setIconURI("platform:/plugin/RCPCAN/icons/icon_con_scroll_lock.png");
mItem.setTooltip("Lock Table Scrollbar");
mItem.setCommand(toolCommand);
mItem.setEnabled(true);
// show part
partService.showPart(mPart, PartState.ACTIVATE);
【问题讨论】:
-
您是否有理由不使用“PartDescriptor”来让您在 Application.e4xmi 中设计所有这些?