| 1 | /* |
| 2 | * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH) |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcm.gmf.composite.part; |
| 5 | |
| 6 | import org.eclipse.emf.ecore.EObject; |
| 7 | import org.eclipse.emf.transaction.util.TransactionUtil; |
| 8 | import org.eclipse.gef.EditPartViewer; |
| 9 | import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService; |
| 10 | import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds; |
| 11 | import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider; |
| 12 | import org.eclipse.jface.action.IMenuManager; |
| 13 | import org.eclipse.ui.IWorkbenchPart; |
| 14 | |
| 15 | /** |
| 16 | * @generated |
| 17 | */ |
| 18 | public class DiagramEditorContextMenuProvider extends |
| 19 | DiagramContextMenuProvider { |
| 20 | |
| 21 | /** |
| 22 | * @generated |
| 23 | */ |
| 24 | private IWorkbenchPart part; |
| 25 | |
| 26 | /** |
| 27 | * @generated |
| 28 | */ |
| 29 | private DeleteElementAction deleteAction; |
| 30 | |
| 31 | /** |
| 32 | * @generated |
| 33 | */ |
| 34 | public DiagramEditorContextMenuProvider(IWorkbenchPart part, |
| 35 | EditPartViewer viewer) { |
| 36 | super(part, viewer); |
| 37 | this.part = part; |
| 38 | deleteAction = new DeleteElementAction(part); |
| 39 | deleteAction.init(); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @generated |
| 44 | */ |
| 45 | public void dispose() { |
| 46 | if (deleteAction != null) { |
| 47 | deleteAction.dispose(); |
| 48 | deleteAction = null; |
| 49 | } |
| 50 | super.dispose(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @generated |
| 55 | */ |
| 56 | public void buildContextMenu(final IMenuManager menu) { |
| 57 | getViewer().flush(); |
| 58 | try { |
| 59 | TransactionUtil.getEditingDomain( |
| 60 | (EObject) getViewer().getContents().getModel()) |
| 61 | .runExclusive(new Runnable() { |
| 62 | |
| 63 | public void run() { |
| 64 | ContributionItemService |
| 65 | .getInstance() |
| 66 | .contributeToPopupMenu( |
| 67 | DiagramEditorContextMenuProvider.this, |
| 68 | part); |
| 69 | menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL); |
| 70 | menu.appendToGroup("editGroup", deleteAction); |
| 71 | } |
| 72 | }); |
| 73 | } catch (Exception e) { |
| 74 | PalladioComponentModelComposedStructureDiagramEditorPlugin |
| 75 | .getInstance().logError("Error building context menu", e); |
| 76 | } |
| 77 | } |
| 78 | } |