import org.simantics.h2d.event.IEvent;\r
import org.simantics.h2d.event.ReleaseEvent;\r
import org.simantics.h2d.event.handler.IEventHandler;\r
-import org.simantics.ui.action.GraphMenuManager;\r
\r
public class OpenContextMenu implements IEventHandler {\r
- \r
+\r
Control control;\r
IWorkbenchPartSite site;\r
String menuId;\r
- \r
+\r
MenuManager menuManager;\r
- \r
+\r
public OpenContextMenu(Control control, IWorkbenchPartSite site,\r
String menuId) {\r
super();\r
Menu menu = menuManager.createContextMenu(control);\r
control.setMenu(menu);\r
if (site != null) {\r
- site.registerContextMenu(menuManager.getId(), menuManager, \r
+ site.registerContextMenu(menuManager.getId(), menuManager,\r
site.getSelectionProvider());\r
}\r
}\r
}\r
\r
@Override\r
- public boolean handle(final IDiagramEditor editor, IEvent _event) {\r
+ public boolean handle(final IDiagramEditor editor, IEvent _event) {\r
final ReleaseEvent event = (ReleaseEvent)_event;\r
control.getDisplay().asyncExec(new Runnable() {\r
\r
new Point((int)event.dispPoint.getX(), (int)event.dispPoint.getY()));\r
menuManager.getMenu().setData(\r
new DiagramContextMenuData(editor, event)\r
- );\r
- menuManager.getMenu().setVisible(true); \r
+ );\r
+ menuManager.getMenu().setVisible(true);\r
}\r
- \r
- });\r
- return true;\r
- }\r
- \r
+\r
+ });\r
+ return true;\r
+ }\r
+\r
protected MenuManager createPopupMenu() {\r
- final MenuManager mm = new GraphMenuManager("Diagram Popup", menuId);\r
+ final MenuManager mm = new MenuManager("Diagram Popup", menuId);\r
mm.setRemoveAllWhenShown(true);\r
mm.addMenuListener(new IMenuListener() {\r
public void menuAboutToShow(IMenuManager manager) {\r