問題
自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。
