处用HandledToolItem创建工具栏。 按下按钮时,应用程序应该创建一个带有工具栏和一个HandledToolItem的新零件。问题是HandledToolItem总是呈灰色,我不知道为什么。也许你们有一个想法。RCP e4在我的MToolbar中遇到了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? –