您的位置:首页 > 编程语言 > Java开发

定制Eclipse RCP编辑器右键菜单

2010-07-22 16:32 806 查看
这篇文章其实是《Eclipse RCP编辑器关闭按钮的屏蔽方法》的下半部分,之所以没放一起是因为原文很容易引起误解,所以拆开了。

在UnCloseableEditorPresentationFactory类createEditorPresentation()方法中,我们可以定制StandardViewSystemMenu类,从而去掉RCP中编辑器folder上的菜单中的close,closeall,new editor等菜单。

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;
public class MyStandardEditorSystemMenu extends StandardViewSystemMenu {
	public MyStandardEditorSystemMenu(IStackPresentationSite site) {
		super(site);
		// TODO Auto-generated constructor stub
	}
	String getMoveMenuText() {
		return WorkbenchMessages.EditorPane_moveEditor;
	}
	public void show(Control parent, Point displayCoordinates, IPresentablePart currentSelection) {
		super.show(parent, displayCoordinates, currentSelection);
	}
}


然后在createEditorPresentation()方法中,修改代码如下:

TabbedStackPresentation result = new TabbedStackPresentation(site, partFolder, new MyStandardEditorSystemMenu(site));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: