2016-07-22 回答
问题
自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