Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ceb88f6015911a42f76370fdbf4ae01cad98cf84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (c) 2008, 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:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 */

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»

«DEFINE className FOR gmfgen::GenDiagram»DiagramEditorContextMenuProvider«ENDDEFINE»

«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»

«DEFINE DiagramEditorContextMenuProvider FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen-»
package «editorGen.editor.packageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «EXPAND className» extends org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider {

	«EXPAND xpt::Common::generatedMemberComment»
	private org.eclipse.ui.IWorkbenchPart part;

	«EXPAND xpt::Common::generatedMemberComment»
	private «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName» deleteAction;

	«EXPAND xpt::Common::generatedMemberComment»
	public DiagramEditorContextMenuProvider(org.eclipse.ui.IWorkbenchPart part, org.eclipse.gef.EditPartViewer viewer) {
		super(part, viewer);
		this.part = part;
		deleteAction = new «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName»(part);
		deleteAction.init();
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public void dispose() {
		if (deleteAction != null) {
			deleteAction.dispose();
			deleteAction = null;
		}
		super.dispose();
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public void buildContextMenu(final org.eclipse.jface.action.IMenuManager menu) {
		getViewer().flush();
		try {
			org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(
					(org.eclipse.emf.ecore.EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {

				public void run() {
					org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService.getInstance().contributeToPopupMenu(
							DiagramEditorContextMenuProvider.this, part);
					menu.remove(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.ACTION_DELETE_FROM_MODEL);
					menu.appendToGroup("editGroup", deleteAction);
				}
			});
		} catch (Exception e) {
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Error building context menu", e);
		}
	}
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»

Back to the top