Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2008-12-04 18:12:35 +0000
committerDarin Wright2008-12-04 18:12:35 +0000
commitd75ee633b04ab95b16a3ff29ebae7757732b4d14 (patch)
treeef6f5401fc54e26642f76f4ce176d9fe17472586 /org.eclipse.ui.console
parenta120f3ad6ab7f1e71180835b1750fe94ad39d40a (diff)
downloadeclipse.platform.debug-d75ee633b04ab95b16a3ff29ebae7757732b4d14.tar.gz
eclipse.platform.debug-d75ee633b04ab95b16a3ff29ebae7757732b4d14.tar.xz
eclipse.platform.debug-d75ee633b04ab95b16a3ff29ebae7757732b4d14.zip
Bug 246843 - Menu#setVisible(..) should show the menu while handling mouseDown event on button
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java30
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java33
2 files changed, 57 insertions, 6 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
index 1cd124c46..0c543dc64 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
@@ -18,13 +18,24 @@ import java.util.Map;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.SafeRunner;
+
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.swt.widgets.Composite;
+
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite;
@@ -461,6 +472,23 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
mgr.add(fDisplayConsoleAction);
if (fOpenConsoleAction != null) {
mgr.add(fOpenConsoleAction);
+ if (mgr instanceof ToolBarManager) {
+ ToolBarManager tbm= (ToolBarManager) mgr;
+ final ToolBar tb= tbm.getControl();
+ tb.addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent e) {
+ ToolItem ti= tb.getItem(new Point(e.x, e.y));
+ if (ti.getData() instanceof ActionContributionItem) {
+ ActionContributionItem actionContributionItem= (ActionContributionItem) ti.getData();
+ Event event= new Event();
+ event.widget= ti;
+ event.x= e.x;
+ event.y= e.y;
+ actionContributionItem.getAction().runWithEvent(event);
+ }
+ }
+ });
+ }
}
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
index 0064b921e..ab8d900a7 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* 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
@@ -11,13 +11,19 @@
package org.eclipse.ui.internal.console;
import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolItem;
+
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Menu;
+
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.eclipse.ui.console.ConsolePlugin;
@@ -46,7 +52,24 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
public void dispose() {
fFactoryExtensions = null;
}
-
+
+ /*
+ * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
+ * @since 3.5
+ */
+ public void runWithEvent(Event event) {
+ if (event.widget instanceof ToolItem) {
+ ToolItem toolItem= (ToolItem) event.widget;
+ Control control= toolItem.getParent();
+ Menu menu= getMenu(control);
+
+ Rectangle bounds= toolItem.getBounds();
+ Point topLeft= new Point(bounds.x, bounds.y + bounds.height);
+ menu.setLocation(control.toDisplay(topLeft));
+ menu.setVisible(true);
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
*/

Back to the top