blob: c34466cf81aaa647a9241c13eb3f7ce17ef74c40 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2016 Fundación Tecnalia Research & Innovation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Huascar Espinoza - initial API and implementation
* Alejandra Ruíz - initial API and implementation
* Idoya Del Río - initial API and implementation
* Mari Carmen Palacios - initial API and implementation
* Angel López - initial API and implementation
*******************************************************************************/
/*
*
*/
package org.eclipse.opencert.pkm.refframework.refframework.diagram.part;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService;
import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.IWorkbenchPart;
/**
* @generated
*/
public class DiagramEditorContextMenuProvider extends
DiagramContextMenuProvider {
/**
* @generated
*/
private IWorkbenchPart part;
/**
* @generated
*/
private DeleteElementAction deleteAction;
/**
* @generated
*/
public DiagramEditorContextMenuProvider(IWorkbenchPart part,
EditPartViewer viewer) {
super(part, viewer);
this.part = part;
deleteAction = new DeleteElementAction(part);
deleteAction.init();
}
/**
* @generated
*/
public void dispose() {
if (deleteAction != null) {
deleteAction.dispose();
deleteAction = null;
}
super.dispose();
}
/**
* @generated
*/
public void buildContextMenu(final IMenuManager menu) {
getViewer().flush();
try {
TransactionUtil.getEditingDomain(
(EObject) getViewer().getContents().getModel())
.runExclusive(new Runnable() {
public void run() {
ContributionItemService
.getInstance()
.contributeToPopupMenu(
DiagramEditorContextMenuProvider.this,
part);
menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
menu.appendToGroup("editGroup", deleteAction);
}
});
} catch (Exception e) {
RefframeworkDiagramEditorPlugin.getInstance().logError(
"Error building context menu", e);
}
}
}