aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2011-11-15 14:03:06 (EST)
committerPaul Webster2011-11-15 14:13:48 (EST)
commitdbb41d48c47a9c832f4fcc5a9b9a39a0d383dc84 (patch)
treead3a6eb049505b002ef03c73da147ac2a59819ce
parentf740fba07449fe293059dbb042e1e486cb6b6632 (diff)
downloadeclipse.platform.ui-dbb41d48c47a9c832f4fcc5a9b9a39a0d383dc84.zip
eclipse.platform.ui-dbb41d48c47a9c832f4fcc5a9b9a39a0d383dc84.tar.gz
eclipse.platform.ui-dbb41d48c47a9c832f4fcc5a9b9a39a0d383dc84.tar.bz2
Bug 357532 - "Open Context Menu" commandv20111115-1913
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.properties4
-rw-r--r--bundles/org.eclipse.ui/plugin.xml14
3 files changed, 70 insertions, 1 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 3692722..11c06a1 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
@@ -350,4 +352,4 @@ command.showIn.targetId.name = Show In Target Id
installationPage.main.name = About
installationPage.system.name = Configuration
-installationPage.plugins.name = Plug-ins \ No newline at end of file
+installationPage.plugins.name = Plug-ins
diff --git a/bundles/org.eclipse.ui/plugin.xml b/bundles/org.eclipse.ui/plugin.xml
index 9e77a30..976ccf5 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"/>
@@ -1921,6 +1931,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>