summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMarkus Keller2011-11-15 14:03:06 (EST)
committer Paul Webster2011-11-15 14:03:54 (EST)
commitafca0df60f9dea9c9dd216baf0503f8b7eebcd1a (patch)
treec971e8a64d3c42a5014b2313f0f0e095e684882f
parent95d1f553b358670f6edd0db7aec66dc736fb3724 (diff)
downloadeclipse.platform.ui-afca0df60f9dea9c9dd216baf0503f8b7eebcd1a.zip
eclipse.platform.ui-afca0df60f9dea9c9dd216baf0503f8b7eebcd1a.tar.gz
eclipse.platform.ui-afca0df60f9dea9c9dd216baf0503f8b7eebcd1a.tar.bz2
Bug 357532 - "Open Context Menu" commandv20111115-1903
set to CTRL+SHIFT+F10
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ContextMenuHandler.java53
-rw-r--r--bundles/org.eclipse.ui/plugin.properties2
-rw-r--r--bundles/org.eclipse.ui/plugin.xml14
3 files changed, 69 insertions, 0 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ContextMenuHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ContextMenuHandler.java
new file mode 100644
index 0000000..d9199c6
--- /dev/null
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ContextMenuHandler.java
@@ -0,0 +1,53 @@
+package org.eclipse.ui.internal.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.util.Geometry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class ContextMenuHandler extends AbstractHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Shell shell = HandlerUtil.getActiveShell(event);
+ Display display = shell == null ? Display.getCurrent() : shell.getDisplay();
+ Control focusControl = display.getFocusControl();
+ if (focusControl != null) {
+ Menu menu = focusControl.getMenu();
+ if (menu != null) {
+ menu.setVisible(true);
+ } else {
+ Point size = focusControl.getSize();
+ Point center = focusControl.toDisplay(Geometry.divide(size, 2));
+
+ Point location = focusControl.toDisplay(0, 0);
+
+ Event mouseEvent = new Event();
+ mouseEvent.widget = focusControl;
+ mouseEvent.x = center.x;
+ mouseEvent.y = center.y;
+
+ Point cursorLoc = display.getCursorLocation();
+ if (cursorLoc.x < location.x || location.x + size.x <= cursorLoc.x
+ || cursorLoc.y < location.y || location.y + size.y <= cursorLoc.y) {
+ mouseEvent.type = SWT.MouseMove;
+ display.post(mouseEvent);
+ }
+
+ mouseEvent.button = 2;
+ mouseEvent.type = SWT.MouseDown;
+ display.post(mouseEvent);
+
+ mouseEvent.type = SWT.MouseUp;
+ display.post(mouseEvent);
+ }
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.ui/plugin.properties b/bundles/org.eclipse.ui/plugin.properties
index 0a1dae3..24e81d3 100644
--- a/bundles/org.eclipse.ui/plugin.properties
+++ b/bundles/org.eclipse.ui/plugin.properties
@@ -258,6 +258,8 @@ command.showSystemMenu.description = Show the system menu
command.showSystemMenu.name = Show System Menu
command.showViewMenu.description = Show the view menu
command.showViewMenu.name = Show View Menu
+command.showContextMenu.description = Show the context menu
+command.showContextMenu.name = Show Context Menu
command.showView.name = Show View
command.showView.description = Shows a particular view
command.showView.viewIdParameter = View
diff --git a/bundles/org.eclipse.ui/plugin.xml b/bundles/org.eclipse.ui/plugin.xml
index 29ccda1..a84c553 100644
--- a/bundles/org.eclipse.ui/plugin.xml
+++ b/bundles/org.eclipse.ui/plugin.xml
@@ -271,6 +271,11 @@
sequence="M1+M2+E"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
<key
+ commandId="org.eclipse.ui.window.showContextMenu"
+ sequence="CTRL+SHIFT+F10"
+ contextId="org.eclipse.ui.contexts.dialogAndWindow"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
+ <key
commandId="org.eclipse.ui.window.showSystemMenu"
sequence="M3+-"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
@@ -1040,6 +1045,11 @@
name="%command.showViewMenu.name"/>
<command
categoryId="org.eclipse.ui.category.window"
+ description="%command.showContextMenu.description"
+ id="org.eclipse.ui.window.showContextMenu"
+ name="%command.showContextMenu.name"/>
+ <command
+ categoryId="org.eclipse.ui.category.window"
description="%command.activateEditor.description"
id="org.eclipse.ui.window.activateEditor"
name="%command.activateEditor.name"/>
@@ -1927,6 +1937,10 @@
</enabledWhen>
</handler>
<handler
+ class="org.eclipse.ui.internal.handlers.ContextMenuHandler"
+ commandId="org.eclipse.ui.window.showContextMenu">
+ </handler>
+ <handler
class="org.eclipse.ui.internal.ShowPartPaneMenuHandler"
commandId="org.eclipse.ui.window.showSystemMenu">
<enabledWhen>