carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/editor/CreateShortcutAction.xpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/editor/CreateShortcutAction.xpt Fri Dec 04 11:06:59 2009 -0600
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2007 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/2008/GenModel"»
+«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
+«EXTENSION xpt::editor::i18n»
+«EXTENSION xpt::editor::Wizard»
+
+«DEFINE CreateShortcutAction FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «createShortcutActionClassName» «EXPAND supertypes» {
+ «EXPAND CREATE_SHORTCUT_ACTION-»
+ «EXPAND ctor-»
+ «EXPAND init-»
+ «EXPAND calculateEnabled-»
+ «EXPAND run-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE supertypes FOR gmfgen::GenDiagram»extends org.eclipse.gef.ui.actions.WorkbenchPartAction«ENDDEFINE»
+
+«DEFINE CREATE_SHORTCUT_ACTION FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public static final String CREATE_SHORTCUT_ACTION = "CreateShortcut"; «EXPAND xpt::Common::nonNLS»
+«ENDDEFINE»
+
+«DEFINE ctor FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public «createShortcutActionClassName»(org.eclipse.ui.IWorkbenchPart part) {
+ super(part);
+}
+«ENDDEFINE»
+
+«DEFINE init FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected void init() {
+ super.init();
+ setId(CREATE_SHORTCUT_ACTION);
+ setText(«EXPAND xpt::Externalizer::accessorCall(i18nForCreateShortcutActionLabel()) FOR editorGen»);
+ setToolTipText(«EXPAND xpt::Externalizer::accessorCall(i18nForCreateShortcutActionTooltip()) FOR editorGen»);
+}
+«ENDDEFINE»
+
+«DEFINE calculateEnabled FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected boolean calculateEnabled() {
+ org.eclipse.gef.GraphicalViewer graphicalViewer = (org.eclipse.gef.GraphicalViewer) getWorkbenchPart().getAdapter(org.eclipse.gef.GraphicalViewer.class);
+ if (graphicalViewer == null) {
+ return false;
+ }
+ return graphicalViewer.getContents().getModel() instanceof org.eclipse.gmf.runtime.notation.Diagram;
+}
+«ENDDEFINE»
+
+«DEFINE run FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public void run() {
+ org.eclipse.gef.GraphicalViewer graphicalViewer = (org.eclipse.gef.GraphicalViewer) getWorkbenchPart().getAdapter(org.eclipse.gef.GraphicalViewer.class);
+ org.eclipse.gmf.runtime.notation.Diagram diagram = (org.eclipse.gmf.runtime.notation.Diagram) graphicalViewer.getContents().getModel();
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(diagram.getElement());
+«IF isRichClientPlatform()-»
+ org.eclipse.jface.wizard.Wizard wizard = new «EXPAND xpt::editor::ShortcutCreationWizard::qualifiedClassName»(diagram, editingDomain, graphicalViewer);
+ «EXPAND xpt::editor::Common::wizardDialogSettings("wizard", "CreateShortcut")-»
+ wizard.setWindowTitle(«EXPAND xpt::Externalizer::accessorCall(i18nForCreateShortcutActionWizardWindowTitle()) FOR editorGen»);
+ org.eclipse.jface.wizard.WizardDialog dialog = new org.eclipse.jface.wizard.WizardDialog(«EXPAND getShell», wizard);
+ dialog.create();
+ «EXPAND xpt::editor::Common::setDefaultShellSize("dialog.getShell()")-»
+ dialog.open();
+«ELSE-»
+ «getElementChooserQualifiedClassName()» elementChooser = new «getElementChooserQualifiedClassName()»(«EXPAND getShell», diagram, graphicalViewer);
+ int result = elementChooser.open();
+ if (result != org.eclipse.jface.window.Window.OK) {
+ return;
+ }
+ org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand createShortcutCommand = elementChooser.getCreateShortcutCommand();
+ if (createShortcutCommand == null || !createShortcutCommand.canExecute()) {
+ return;
+ }
+ if (graphicalViewer.getEditDomain() != null && graphicalViewer.getEditDomain().getCommandStack() != null) {
+ graphicalViewer.getEditDomain().getCommandStack().execute(new org.eclipse.gmf.runtime.lite.commands.WrappingCommand(editingDomain, createShortcutCommand));
+ } else {
+ new org.eclipse.gmf.runtime.lite.commands.WrappingCommand(editingDomain, createShortcutCommand).execute();
+ }
+«ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE getShell FOR gmfgen::GenDiagram»getWorkbenchPart().getSite().getShell()«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«IF generateCreateShortcutAction()-»
+«EXPAND xpt::Externalizer::accessorField(i18nForCreateShortcutActionLabel())-»
+«EXPAND xpt::Externalizer::accessorField(i18nForCreateShortcutActionTooltip())-»
+«EXPAND xpt::Externalizer::accessorField(i18nForCreateShortcutActionWizardWindowTitle())-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«IF generateCreateShortcutAction()-»
+«EXPAND xpt::Externalizer::messageEntry(i18nForCreateShortcutActionLabel(), "Create sh&ortcut...")-»
+«EXPAND xpt::Externalizer::messageEntry(i18nForCreateShortcutActionTooltip(), "Creates a shortcut on the diagram")-»
+«EXPAND xpt::Externalizer::messageEntry(i18nForCreateShortcutActionWizardWindowTitle(), "Create shortcut")-»
+«ENDIF-»
+«ENDDEFINE»
+