Eclipse rcp 如果部分插入ICommandService,工具栏处理的项目图标将消失
我正在零件工具栏中添加工具栏处理项。部件堆栈有一个部件,其bundle类为DataBaseConnectPart。当我注入commandService和IHandlerService时。“零件”工具栏中的按钮将消失。我完全不知道如何在选择树项目时启动命令Eclipse rcp 如果部分插入ICommandService,工具栏处理的项目图标将消失,eclipse-rcp,eclipse-luna,eclipse-pde,Eclipse Rcp,Eclipse Luna,Eclipse Pde,我正在零件工具栏中添加工具栏处理项。部件堆栈有一个部件,其bundle类为DataBaseConnectPart。当我注入commandService和IHandlerService时。“零件”工具栏中的按钮将消失。我完全不知道如何在选择树项目时启动命令 public class DatabaseExplorerPart { @Inject private IEventBroker eventBroker; @Inject private EPartService partService;
public class DatabaseExplorerPart {
@Inject
private IEventBroker eventBroker;
@Inject
private EPartService partService;
@Inject private ICommandService commandService;
@Inject private IHandlerService service;
@Inject private IEvaluationService evaluationService;
@PostConstruct
public void createControls(Composite parent, EMenuService menuService, EclipseContext context ) {
createImages();
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent arg0) {
TreeSelection ts = (TreeSelection)arg0.getSelection();
Object o = ts.getFirstElement();
if (o instanceof Query){
context.set(Constants.KEY_SELECTED_OBJECT_TYPE, "query");
context.set(Constants.KEY_SELECTED_OBJECT, o);
String name = ((Query)o).getName();
if(name.equalsIgnoreCase("New Query")){
executeCommand();
}
}
}
}
});
viewer.setLabelProvider(new ViewLabelProvider());
}
private void executeCommand(){
try {
Command theCommand = commandService.getCommand("com.db.connect.command");
theCommand.executeWithChecks(new ExecutionEvent(theCommand, new HashMap(), null, evaluationService.getCurrentState()));
} catch (Exception exception) {
logger.error(exception.getMessage(), exception);
}
}
这是3.x还是e4?e4没有Ixxx服务,注入将在日志中失败。是的,谢谢greg,我将其更改为ECommandService,现在它正确执行。