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