carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/editor/DiagramEditorContextMenuProvider.xpt
author cawthron
Fri, 04 Dec 2009 11:06:59 -0600
changeset 422 033392511bf7
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
422
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     1
/*
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2008 Borland Software Corporation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     3
 * 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     4
 * All rights reserved. This program and the accompanying materials
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     5
 * are made available under the terms of the Eclipse Public License v1.0
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     6
 * which accompanies this distribution, and is available at
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     7
 * http://www.eclipse.org/legal/epl-v10.html
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     8
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     9
 * Contributors:
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    10
 *    Dmitry Stadnik (Borland) - initial API and implementation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    11
 */
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    12
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    13
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    14
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    15
«DEFINE className FOR gmfgen::GenDiagram»DiagramEditorContextMenuProvider«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    16
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    17
«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    18
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    19
«DEFINE DiagramEditorContextMenuProvider FOR gmfgen::GenDiagram-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    20
«EXPAND xpt::Common::copyright FOR editorGen-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    21
package «editorGen.editor.packageName»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    22
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    23
«EXPAND xpt::Common::generatedClassComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    24
public class «EXPAND className» extends org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    25
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    26
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    27
	private org.eclipse.ui.IWorkbenchPart part;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    28
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    29
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    30
	private «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName» deleteAction;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    31
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    32
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    33
	public DiagramEditorContextMenuProvider(org.eclipse.ui.IWorkbenchPart part, org.eclipse.gef.EditPartViewer viewer) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    34
		super(part, viewer);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    35
		this.part = part;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    36
		deleteAction = new «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName»(part);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    37
		deleteAction.init();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    38
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    39
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    40
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    41
	public void dispose() {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    42
		if (deleteAction != null) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    43
			deleteAction.dispose();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    44
			deleteAction = null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    45
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    46
		super.dispose();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    47
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    48
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    49
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    50
	public void buildContextMenu(final org.eclipse.jface.action.IMenuManager menu) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    51
		getViewer().flush();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    52
		try {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    53
			org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    54
					(org.eclipse.emf.ecore.EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    55
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    56
				public void run() {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    57
					org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService.getInstance().contributeToPopupMenu(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    58
							DiagramEditorContextMenuProvider.this, part);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    59
					menu.remove(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.ACTION_DELETE_FROM_MODEL);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    60
					menu.appendToGroup("editGroup", deleteAction);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    61
				}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    62
			});
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    63
		} catch (Exception e) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    64
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Error building context menu", e);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    65
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    66
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    67
	«EXPAND additions-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    68
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    69
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    70
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    71
«DEFINE additions FOR gmfgen::GenDiagram-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    72
«ENDDEFINE»