| /* |
| * Copyright (c) 2007, 2009 Borland Software Corporation |
| * |
| * 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: |
| * bblajer (Borland) - initial API and implementation |
| */ |
| |
| «IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'» |
| «EXTENSION xpt::editor::i18n» |
| |
| «DEFINE ActionBarContributor FOR gmfgen::GenEditorView-» |
| «EXPAND xpt::Common::copyright FOR editorGen» |
| package «editorGen.editor.packageName»; |
| |
| «EXPAND xpt::Common::generatedClassComment('The action bar contributor for the ' + editorGen.domainGenModel.modelName + ' editor.')» |
| public class «actionBarContributorClassName» «EXPAND supertypes» { |
| «EXPAND attributes-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void buildActions() { |
| «EXPAND fillActions-» |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void declareGlobalActionKeys() { |
| «EXPAND addGlobalActionKeys-» |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void contributeToMenu(org.eclipse.jface.action.IMenuManager menuManager) { |
| super.contributeToMenu(menuManager); |
| |
| «EXPAND menuContribution-» |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void contributeToToolBar(org.eclipse.jface.action.IToolBarManager toolBarManager) { |
| super.contributeToToolBar(toolBarManager); |
| |
| «EXPAND toolBarContribution-» |
| } |
| |
| «IF not eclipseEditor-» |
| «EXPAND viewSpecific-» |
| «ENDIF-» |
| «EXPAND additions-» |
| } |
| «ENDDEFINE» |
| |
| «DEFINE supertypes FOR gmfgen::GenEditorView»extends org.eclipse.gef.ui.actions.ActionBarContributor«ENDDEFINE» |
| |
| «DEFINE attributes FOR gmfgen::GenEditorView-» |
| «IF not eclipseEditor-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| private java.util.List globalActionKeys = new java.util.ArrayList(); |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| private org.eclipse.gef.ui.actions.ZoomComboContributionItem myZoomContributionItem; |
| «ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE fillActions FOR gmfgen::GenEditorView-» |
| addRetargetAction(new org.eclipse.gef.ui.actions.UndoRetargetAction()); |
| addRetargetAction(new org.eclipse.gef.ui.actions.RedoRetargetAction()); |
| addRetargetAction(new org.eclipse.gef.ui.actions.DeleteRetargetAction()); |
| |
| addRetargetAction(new org.eclipse.gef.ui.actions.ZoomInRetargetAction()); |
| addRetargetAction(new org.eclipse.gef.ui.actions.ZoomOutRetargetAction()); |
| «ENDDEFINE» |
| |
| «DEFINE addGlobalActionKeys FOR gmfgen::GenEditorView-» |
| addGlobalActionKey(org.eclipse.ui.actions.ActionFactory.PRINT.getId()); |
| addGlobalActionKey(org.eclipse.ui.actions.ActionFactory.DELETE.getId()); |
| «ENDDEFINE» |
| |
| «DEFINE viewSpecific FOR gmfgen::GenEditorView-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void addGlobalActionKey(String key) { |
| super.addGlobalActionKey(key); |
| globalActionKeys.add(key); |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void updateGlobalActions(org.eclipse.ui.IViewPart viewPart) { |
| org.eclipse.gef.ui.actions.ActionRegistry registry = viewPart == null ? null : (org.eclipse.gef.ui.actions.ActionRegistry) viewPart.getAdapter(org.eclipse.gef.ui.actions.ActionRegistry.class); |
| org.eclipse.ui.IActionBars bars = getActionBars(); |
| if (registry == null) { |
| bars.clearGlobalActionHandlers(); |
| } else { |
| for (int i = 0; i < globalActionKeys.size(); i++) { |
| String id = (String) globalActionKeys.get(i); |
| bars.setGlobalActionHandler(id, registry.getAction(id)); |
| } |
| } |
| org.eclipse.gef.editparts.ZoomManager zoomManager = viewPart == null ? null : (org.eclipse.gef.editparts.ZoomManager) viewPart.getAdapter(org.eclipse.gef.editparts.ZoomManager.class); |
| myZoomContributionItem.setZoomManager(zoomManager); |
| bars.updateActionBars(); |
| } |
| «ENDDEFINE» |
| |
| «DEFINE menuContribution FOR gmfgen::GenEditorView-» |
| «IF eclipseEditor-» |
| // add a "View" menu after "Edit" |
| org.eclipse.jface.action.MenuManager viewMenu = new org.eclipse.jface.action.MenuManager(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForActionBarContributorViewMenu(self)) FOR editorGen»); |
| viewMenu.add(getAction(org.eclipse.gef.ui.actions.GEFActionConstants.ZOOM_IN)); |
| viewMenu.add(getAction(org.eclipse.gef.ui.actions.GEFActionConstants.ZOOM_OUT)); |
| |
| menuManager.insertAfter(org.eclipse.ui.IWorkbenchActionConstants.M_EDIT, viewMenu); |
| «ELSE-» |
| menuManager.add(getAction(org.eclipse.gef.ui.actions.GEFActionConstants.ZOOM_IN)); |
| menuManager.add(getAction(org.eclipse.gef.ui.actions.GEFActionConstants.ZOOM_OUT)); |
| «ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE toolBarContribution FOR gmfgen::GenEditorView-» |
| toolBarManager.add(getAction(org.eclipse.ui.actions.ActionFactory.UNDO.getId())); |
| toolBarManager.add(getAction(org.eclipse.ui.actions.ActionFactory.REDO.getId())); |
| |
| toolBarManager.add(new org.eclipse.jface.action.Separator()); |
| «IF eclipseEditor-» |
| toolBarManager.add(new org.eclipse.gef.ui.actions.ZoomComboContributionItem(getPage())); |
| «ELSE-» |
| myZoomContributionItem = new org.eclipse.gef.ui.actions.ZoomComboContributionItem(getPage()); |
| toolBarManager.add(myZoomContributionItem); |
| «ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE additions FOR gmfgen::GenEditorView»«ENDDEFINE» |
| |
| «DEFINE i18nAccessors FOR gmfgen::GenEditorView-» |
| «EXPAND xpt::Externalizer::accessorField(i18nKeyForActionBarContributorViewMenu(self))-» |
| «ENDDEFINE» |
| |
| «DEFINE i18nValues FOR gmfgen::GenEditorView-» |
| «EXPAND xpt::Externalizer::messageEntry(i18nKeyForActionBarContributorViewMenu(self), 'View')-» |
| «ENDDEFINE» |