问题
自4.x开始,Quick Access搜索框成为Toolbar的“标准装备”,一般删除Actionset的方式似乎不起作用,通过Quick Access,用户很容易访问到RCP程序本来想隐藏的功能。
解决方法
在WorkbenchWindowAdvisor的openIntro中加入以下代码
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。