RCP:如何移除Toolbar中的Quick Access
问题
自4.x开始,Quick Access搜索框成为Toolbar的“标准装备”,一般删除Actionset的方式似乎不起作用,通过Quick Access,用户很容易访问到RCP程序本来想隐藏的功能。
解决方法
在WorkbenchWindowAdvisor的openIntro中加入以下代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | IWorkbenchWindow window = (IWorkbenchWindow) PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); if (window instanceof WorkbenchWindow) { MWindow model = ((WorkbenchWindow) window).getModel(); EModelService modelService = model.getContext().get( EModelService. class ); MToolControl searchField = (MToolControl) modelService.find( "SearchField" , model); if (searchField != null ) { searchField.setToBeRendered( false ); MTrimBar trimBar = modelService.getTrim((MTrimmedWindow) model, SideValue.TOP); trimBar.getChildren().remove(searchField); } } |
需要添加依赖:
org.eclipse.e4.ui.model.workbench org.eclipse.e4.ui.workbench org.eclipse.e4.core.contexts
参考
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362420 Comment66
Binhua Liu原创,写于2013/8/30。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步