shapeseditoractionbarcontributor.java
来自「mywork是rcp开发的很好的例子」· Java 代码 · 共 97 行
JAVA
97 行
/******************************************************************************* * 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.ui.actions.ActionBarContributor;import org.eclipse.gef.ui.actions.GEFActionConstants;import org.eclipse.jface.action.IAction;import org.eclipse.jface.action.IToolBarManager;import org.eclipse.ui.IActionBars;import org.eclipse.ui.IEditorPart;import org.eclipse.ui.actions.ActionFactory;/** * Contributes actions to a toolbar. * This class is tied to the editor in the definition of editor-extension (see plugin.xml). * @author Elias Volanakis */public class ShapesEditorActionBarContributor extends ActionBarContributor {/** * Create actions managed by this contributor. * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() */protected void buildActions() {}/** * Add actions to the given toolbar. * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager) */public void contributeToToolBar(IToolBarManager toolBarManager) {// toolBarManager.add(new ZoomComboContributionItem(getPage()));}/* * (non-Javadoc) * @see org.eclipse.gef.ui.actions.ActionBarContributor#declareGlobalActionKeys() */protected void declareGlobalActionKeys() { addGlobalActionKey(ActionFactory.SAVE.getId()); addGlobalActionKey(ActionFactory.SAVE_AS.getId()); addGlobalActionKey(ActionFactory.SAVE_ALL.getId()); addGlobalActionKey(FreeNoteConstants.EXPORT_ACTION); addGlobalActionKey(ActionFactory.UNDO.getId()); addGlobalActionKey(ActionFactory.REDO.getId()); addGlobalActionKey(ActionFactory.DELETE.getId()); addGlobalActionKey(GEFActionConstants.ALIGN_LEFT); addGlobalActionKey(GEFActionConstants.ALIGN_CENTER); addGlobalActionKey(GEFActionConstants.ALIGN_RIGHT); addGlobalActionKey(GEFActionConstants.ALIGN_TOP); addGlobalActionKey(GEFActionConstants.ALIGN_MIDDLE); addGlobalActionKey(GEFActionConstants.ALIGN_BOTTOM); addGlobalActionKey(GEFActionConstants.MATCH_WIDTH); addGlobalActionKey(GEFActionConstants.MATCH_HEIGHT); addGlobalActionKey(FreeNoteConstants.CHANGE_CONNECTION_STYLE); addGlobalActionKey(FreeNoteConstants.PROPERTY_EDITOR); addGlobalActionKey(FreeNoteConstants.CHANGE_COLOR+"."+FreeNoteConstants.FORECOLOR); addGlobalActionKey(FreeNoteConstants.CHANGE_COLOR+"."+FreeNoteConstants.BACKCOLOR); addGlobalActionKey(GEFActionConstants.ZOOM_IN); addGlobalActionKey(GEFActionConstants.ZOOM_OUT); addGlobalActionKey(GEFActionConstants.ZOOM_TOOLBAR_WIDGET); addGlobalActionKey(FreeNoteConstants.CHANGE_LAYOUT_ACTION+"."+FreeNoteConstants.LAYOUT_NORMAL); addGlobalActionKey(FreeNoteConstants.CHANGE_LAYOUT_ACTION+"."+FreeNoteConstants.LAYOUT_HANGING); addGlobalActionKey(FreeNoteConstants.CHANGE_LAYOUT_ACTION+"."+FreeNoteConstants.LAYOUT_STAR);}@Overridepublic void setActiveEditor(IEditorPart editor) { super.setActiveEditor(editor); IActionBars actionBars=this.getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(editor,ActionFactory.SELECT_ALL.getId())); actionBars.updateActionBars(); }private IAction getAction(IEditorPart editor, String id) { if(editor instanceof ShapesEditor) return ((ShapesEditor)editor).getAction(id); return null;}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?