⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapeseditorcontextmenuprovider.java

📁 mywork是rcp开发的很好的例子
💻 JAVA
字号:
/******************************************************************************* * Copyright (c) 2004, 2005 Elias Volanakis and others.�* All rights reserved. This program and the accompanying materials�* are made available under the terms of the Eclipse Public License v1.0�* which accompanies this distribution, and is available at�* http://www.eclipse.org/legal/epl-v10.html�*�* Contributors:�*����Elias Volanakis - initial API and implementation�*******************************************************************************/package net.sf.freenote;import org.eclipse.gef.ContextMenuProvider;import org.eclipse.gef.EditPartViewer;import org.eclipse.gef.ui.actions.ActionRegistry;import org.eclipse.gef.ui.actions.GEFActionConstants;import org.eclipse.jface.action.IAction;import org.eclipse.jface.action.IMenuManager;import org.eclipse.ui.actions.ActionFactory;/** * Provides context menu actions for the ShapesEditor. * @author Elias Volanakis */class ShapesEditorContextMenuProvider extends ContextMenuProvider {/** The editor's action registry. */private ActionRegistry actionRegistry;	/** * Instantiate a new menu context provider for the specified EditPartViewer  * and ActionRegistry. * @param viewer	the editor's graphical viewer * @param registry	the editor's action registry * @throws IllegalArgumentException if registry is <tt>null</tt>.  */public ShapesEditorContextMenuProvider(EditPartViewer viewer, ActionRegistry registry) {	super(viewer);	if (registry == null) {		throw new IllegalArgumentException();	}	actionRegistry = registry;}/** * Called when the context menu is about to show. Actions,  * whose state is enabled, will appear in the context menu. * @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager) */public void buildContextMenu(IMenuManager menu) {	// Add standard action groups to the menu	GEFActionConstants.addStandardActionGroups(menu);	// Add actions to the menu	menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(GEFActionConstants.DIRECT_EDIT));	menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(FreeNoteConstants.FILE_CHOOSE));	menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(FreeNoteConstants.FILE_SAVEAS));	menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(FreeNoteConstants.FIT_IMAGE));	menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(FreeNoteConstants.EXPAND_ACTION));		menu.appendToGroup(GEFActionConstants.GROUP_REST, getAction(ActionFactory.SELECT_ALL.getId()));	menu.appendToGroup(GEFActionConstants.GROUP_REST, getAction(FreeNoteConstants.SELECT_SAME));}private IAction getAction(String actionId) {	return actionRegistry.getAction(actionId);}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -