/*******************************************************************************
* Copyright (c) 2010-2015 Henshin developers. 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:
* TU Berlin, University of Luxembourg, SES S.A.
*******************************************************************************/
package de.tub.tfs.henshin.tggeditor.views.graphview;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.jface.action.IMenuManager;
import de.tub.tfs.henshin.tggeditor.actions.AbstractTggActionFactory;
import de.tub.tfs.henshin.tggeditor.actions.EditAttributeAction;
import de.tub.tfs.henshin.tggeditor.actions.create.graph.CreateAttributeAction;
import de.tub.tfs.henshin.tggeditor.actions.create.rule.NewMarkerUnspecifiedAction;
import de.tub.tfs.muvitor.ui.ContextMenuProviderWithActionRegistry;
public class GraphicalContextMenuProvider extends
ContextMenuProviderWithActionRegistry {
public GraphicalContextMenuProvider(EditPartViewer viewer) {
super(viewer);
}
@Override
public void buildContextMenu(IMenuManager menu) {
String group = GEFActionConstants.GROUP_EDIT;
appendActions(menu, group);
IExtensionRegistry reg = Platform.getExtensionRegistry();
IExtensionPoint ep = reg.getExtensionPoint("de.tub.tfs.henshin.tgg.editor.graph.actions");
IExtension[] extensions = ep.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IExtension ext = extensions[i];
IConfigurationElement[] ce =
ext.getConfigurationElements();
for (int j = 0; j < ce.length; j++) {
try {
AbstractTggActionFactory obj = (AbstractTggActionFactory) ce[j].createExecutableExtension("class");
dynamicAppendActionToGroup(menu,obj.getActionID(),group);
} catch (CoreException e) {
}
}
}
}
/**
* @param menu
* @param group
*/
protected void appendActions(IMenuManager menu, String group) {
dynamicAppendActionToGroup(menu, CreateAttributeAction.ID, group);
dynamicAppendActionToGroup(menu, EditAttributeAction.ID, group);
}
}