Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: b60800bcc8b98357d3a75f067f9c96e189a809b7 (plain) (tree)







































































                                                                                                                                                                       
/*
 * Copyright (c) 2008 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/2008/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