summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Dukadinov2012-03-27 11:22:21 (EDT)
committerJordan Dukadinov2012-04-04 09:01:24 (EDT)
commit98e00819c930ee5cac634c249eafdd18d5a4cd81 (patch)
tree6ed0d4cec83e032e0b5ab503b4adf09d2da040b0
parent95eee74687c56425cbeac2c8f148aa707ed155d7 (diff)
downloadorg.eclipse.riena-98e00819c930ee5cac634c249eafdd18d5a4cd81.zip
org.eclipse.riena-98e00819c930ee5cac634c249eafdd18d5a4cd81.tar.gz
org.eclipse.riena-98e00819c930ee5cac634c249eafdd18d5a4cd81.tar.bz2
Close open menu after clicking again - bug 299753
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarComposite.java175
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/ToolBarMenuListener.java160
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarCompositeTest.java32
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MenuManagerHelper.java53
4 files changed, 215 insertions, 205 deletions
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarComposite.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarComposite.java
index e6d740a..866d299 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarComposite.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarComposite.java
@@ -17,8 +17,6 @@ import java.util.List;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
@@ -39,12 +37,11 @@ import org.eclipse.riena.ui.swt.lnf.LnfKeyConstants;
import org.eclipse.riena.ui.swt.lnf.LnfManager;
/**
- * This composites has a list of the top-level menus of the Riena menu bar (a
- * cool bar with an item for every top-level menu).
+ * This composites has a list of the top-level menus of the Riena menu bar (a cool bar with an item for every top-level menu).
*/
public class MenuCoolBarComposite extends Composite {
- private static final String MENU_DATA_KEY = "Menu"; //$NON-NLS-1$
+ static final String MENU_DATA_KEY = "Menu"; //$NON-NLS-1$
private final IWorkbenchWindow window;
@@ -55,24 +52,20 @@ public class MenuCoolBarComposite extends Composite {
// private final Map<MenuManager, MenuManagerState> menuManagerOldState;
/**
- * Creates an new instance of {@code MenuCoolBarComposite} given its parent
- * and a style value describing its behavior and appearance.
+ * Creates an new instance of {@code MenuCoolBarComposite} given its parent and a style value describing its behavior and appearance.
*
* @param parent
- * a composite which will be the parent of the new instance
- * (cannot be null)
+ * a composite which will be the parent of the new instance (cannot be null)
* @param style
* the style of widget to construct
* @param window
- * an IWorkbenchWindow instance, used to determine the menu
- * entries. May be null.
+ * an IWorkbenchWindow instance, used to determine the menu entries. May be null.
* @since 3.0
*/
public MenuCoolBarComposite(final Composite parent, final int style, final IWorkbenchWindow window) {
super(parent, style);
setLayout(new FillLayout());
this.window = window;
- // menuManagerOldState = new HashMap<MenuManager, MenuManagerState>();
create();
}
@@ -81,6 +74,20 @@ public class MenuCoolBarComposite extends Composite {
return Arrays.asList(toolItems);
}
+ /**
+ * Disposes all menu items and re-creates them.
+ *
+ * @return an empty {@link List}
+ */
+ public List<ToolItem> updateMenuItems() {
+ if (menuCoolBar != null) {
+ menuCoolBar.dispose();
+ }
+ create();
+ layout();
+ return Collections.emptyList();
+ }
+
// helping methods
//////////////////
@@ -101,8 +108,9 @@ public class MenuCoolBarComposite extends Composite {
* Creates a top-level menu and adds it to the Riena menu bar.
*
* @param menuManager
+ * @param listener
*/
- private ToolItem createAndAddMenu(final MenuManager menuManager) {
+ private ToolItem createAndAddMenu(final MenuManager menuManager, final ToolBarMenuListener listener) {
if (menuManager.isVisible()) {
final ToolItem toolItem = new ToolItem(menuToolBar, SWT.CHECK);
toolItem.setText(menuManager.getMenuText());
@@ -110,29 +118,29 @@ public class MenuCoolBarComposite extends Composite {
final Menu menu = helper.createMenu(menuToolBar, toolItem, menuManager);
toolItem.setData(MENU_DATA_KEY, menu);
calcSize(menuCoolItem);
+ toolItem.addSelectionListener(listener);
return toolItem;
}
return null;
}
/**
- * Creates the cool and tool bar. These build the menu bar of the Riena
- * sub-application.
+ * Creates the cool and tool bar. These build the menu bar of the Riena sub-application.
*/
private void create() {
menuCoolBar = new CoolBar(this, SWT.FLAT);
menuCoolItem = CoolbarUtils.initCoolBar(menuCoolBar, getMenuBarFont());
menuToolBar = (ToolBar) menuCoolItem.getControl();
- SWTFacade.getDefault().addMouseMoveListener(menuToolBar, new ToolBarMouseListener());
- fillMenuBar();
+ final ToolBarMenuListener listener = new ToolBarMenuListener();
+ menuToolBar.addMouseListener(listener);
+ SWTFacade.getDefault().addMouseTrackListener(menuToolBar, listener);
+ fillMenuBar(listener);
}
- private void fillMenuBar() {
+ private void fillMenuBar(final ToolBarMenuListener listener) {
for (final IContributionItem contribItem : getTopLevelMenuEntries()) {
if (contribItem instanceof MenuManager) {
- final MenuManager topMenuManager = (MenuManager) contribItem;
- createAndAddMenu(topMenuManager);
- // menuManagerOldState.put(topMenuManager, new MenuManagerState(topMenuManager));
+ createAndAddMenu((MenuManager) contribItem, listener);
}
}
}
@@ -152,129 +160,4 @@ public class MenuCoolBarComposite extends Composite {
}
return new IContributionItem[0];
}
-
- // helping classes
- //////////////////
-
- /**
- * If the mouse moves over an unselected item of the tool bar and another
- * item was selected, deselect the other item and select the item below the
- * mouse pointer.<br>
- * <i>Does not work, if menu is visible.</i>
- */
- private static final class ToolBarMouseListener implements MouseMoveListener {
- public void mouseMove(final MouseEvent e) {
- if (e.getSource() instanceof ToolBar) {
- final ToolBar toolBar = (ToolBar) e.getSource();
-
- ToolItem selectedItem = null;
- final ToolItem[] items = toolBar.getItems();
- for (final ToolItem item : items) {
- if (item.getSelection()) {
- selectedItem = item;
- }
- }
-
- final ToolItem hoverItem = toolBar.getItem(new Point(e.x, e.y));
- if (hoverItem != null) {
- if (!hoverItem.getSelection() && (selectedItem != null)) {
- selectedItem.setSelection(false);
- hoverItem.setSelection(true);
- }
- }
- }
- }
- }
-
- public List<ToolItem> updateMenuItems() {
-
- if (menuCoolBar != null) {
- menuCoolBar.dispose();
- }
- create();
- layout();
- return Collections.emptyList();
-
- // final List<MenuManager> changedTopMenuManager = getChangedVisibilityItems();
- // final List<ToolItem> changedMenus = new ArrayList<ToolItem>();
- // if (!changedTopMenuManager.isEmpty()) {
- // if (menuCoolBar != null) {
- // menuCoolBar.dispose();
- // }
- // create();
- // layout();
- //
- // for (final ToolItem contribItem : getTopLevelItems()) {
- // for (final MenuManager manager : changedTopMenuManager) {
- // if (manager.getMenuText().equals(contribItem.getText())) {
- // changedMenus.add(contribItem);
- // }
- // }
- // }
- // }
- // return changedMenus;
- }
-
- // private List<MenuManager> getChangedVisibilityItems() {
- // final List<MenuManager> changedItems = new ArrayList<MenuManager>();
- // for (final IContributionItem contribItem : getTopLevelMenuEntries()) {
- // if (contribItem instanceof MenuManager) {
- // final MenuManager topMenuManager = (MenuManager) contribItem;
- // String oldToString = null;
- // final Menu menu = getMenu(topMenuManager);
- // if (!SwtUtilities.isDisposed(menu)) {
- // oldToString = getMenu(topMenuManager).toString();
- // }
- // topMenuManager.updateAll(true);
- // String newToString = null;
- // if (!SwtUtilities.isDisposed(getMenu(topMenuManager))) {
- // newToString = getMenu(topMenuManager).toString();
- // }
- // final MenuManagerState oldState = menuManagerOldState.get(topMenuManager);
- // if (oldState.isChanged(topMenuManager) || !StringUtils.equals(oldToString, newToString)) {
- // changedItems.add(topMenuManager);
- // }
- // }
- // }
- // return changedItems;
- // }
-
- // private Menu getMenu(final MenuManager topMenuManager) {
- //
- // if (SwtUtilities.isDisposed(menuCoolBar)) {
- // return null;
- // }
- // for (final Control menuBarChild : menuCoolBar.getChildren()) {
- // if (menuBarChild instanceof ToolBar) {
- // for (final ToolItem item : ((ToolBar) menuBarChild).getItems()) {
- // if (item.getData().equals(topMenuManager)) {
- // return (Menu) item.getData(MENU_DATA_KEY);
- // }
- // }
- // }
- // }
- //
- // return null;
- // }
- //
- // private class MenuManagerState {
- // private final String menuText;
- // private final boolean visible;
- // private final boolean enabled;
- // private final int itemCount;
- //
- // public MenuManagerState(final MenuManager menuManager) {
- // this.menuText = menuManager.getMenuText();
- // this.visible = menuManager.isVisible();
- // this.enabled = menuManager.isEnabled();
- // this.itemCount = menuManager.getMenu() != null ? menuManager.getMenu().getItemCount() : -1;
- // }
- //
- // private boolean isChanged(final MenuManager menuManager) {
- // return menuManager.getMenu() == null || //
- // itemCount == -1 || itemCount != menuManager.getMenu().getItemCount() || //
- // visible != menuManager.isVisible() || enabled != menuManager.isEnabled() || //
- // !menuManager.getMenuText().equals(menuText);
- // }
- // }
}
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/ToolBarMenuListener.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/ToolBarMenuListener.java
new file mode 100644
index 0000000..acbd179
--- /dev/null
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/navigation/ui/swt/component/ToolBarMenuListener.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2012 compeople AG 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.navigation.ui.swt.component;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+/**
+ * This class helps to reproduce a menu behavior using a ToolBar. It is only intended for usage by the {@link MenuCoolBarComposite}.
+ * <p>
+ * public for testing
+ */
+public class ToolBarMenuListener implements MouseListener, SelectionListener, MouseTrackListener {
+ /**
+ * The item, for which the menu is currently visible.
+ */
+ private ToolItem activeItem;
+
+ /**
+ * The selection state of the active item can change
+ */
+ private boolean activeItemSelectionState;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDown(final MouseEvent e) {
+ // because of timing issues, mouseDown(...) is used to handle item selections
+ final ToolItem toolItem = getItem(e);
+ if (toolItem != null && toolItem != activeItem) {
+ showMenu(toolItem);
+ } else {
+ if (activeItem != null) {
+ setActiveItemSelectionState(false);
+ }
+ activeItem = null;
+ }
+ }
+
+ private ToolItem getItem(final MouseEvent e) {
+ if (e.getSource() instanceof ToolBar) {
+ final ToolBar bar = (ToolBar) e.getSource();
+ return bar.getItem(new Point(e.x, e.y));
+ }
+ return null;
+ }
+
+ private void setActiveItemSelectionState(final boolean selectionState) {
+ activeItem.setSelection(selectionState);
+ activeItemSelectionState = selectionState;
+ }
+
+ /**
+ * Computes the position displays the {@link Menu}, attached to the given {@link ToolItem}. This method relies on the fact, that the tool item has a data
+ * field named {@link MenuCoolBarComposite}.MENU_DATA_KEY with the menu, which is already created. Also the menu must be already created.
+ * <p>
+ * See <tt>MenuCoolBarComposite.createAndAddMenu(...)</tt>
+ *
+ * @param toolItem
+ * the {@link ToolItem} for which the menu will be shown
+ */
+ private void showMenu(final ToolItem toolItem) {
+ final Rectangle itemBounds = toolItem.getBounds();
+ final Point loc = toolItem.getParent().toDisplay(itemBounds.x, itemBounds.height + itemBounds.y);
+ final Object data = toolItem.getData(MenuCoolBarComposite.MENU_DATA_KEY);
+ Assert.isTrue(data instanceof Menu, "Every tool item must know its associated menu object under the key: " + MenuCoolBarComposite.MENU_DATA_KEY); //$NON-NLS-1$
+ final Menu menu = (Menu) data;
+ menu.setLocation(loc);
+ activeItem = toolItem;
+ setActiveItemSelectionState(true);
+ menu.setVisible(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(final SelectionEvent e) {
+ if (e.getSource() instanceof ToolItem) {
+ // because of timing issues, mouseDown(...) is used to handle item selections
+ // here we only ensure that the item preserves its consistent selection state
+ ((ToolItem) e.getSource()).setSelection(activeItemSelectionState);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseEnter(final MouseEvent e) {
+ activeItem = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseUp(final MouseEvent e) {
+ // unused
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDoubleClick(final MouseEvent e) {
+ // unused
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // unused
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseExit(final MouseEvent e) {
+ // unused
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseHover(final MouseEvent e) {
+ // unused
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarCompositeTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarCompositeTest.java
index ae43c3d..74981c0 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarCompositeTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/ui/swt/component/MenuCoolBarCompositeTest.java
@@ -17,12 +17,14 @@ import junit.framework.TestCase;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarContributionItem;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.SWTEventListener;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.internal.core.test.collect.UITestCase;
@@ -48,16 +50,14 @@ public class MenuCoolBarCompositeTest extends TestCase {
}
/**
- * Tests the constructor of {@code MenuCoolBarComposite} and also the
- * <i>private</i> method {@code create()}.
+ * Tests the constructor of {@code MenuCoolBarComposite} and also the <i>private</i> method {@code create()}.
*/
public void testMenuCoolBarComposite() {
final MenuCoolBarComposite composite = new MenuCoolBarComposite(shell, SWT.NONE, null);
final ToolBar toolBar = ReflectionUtils.getHidden(composite, "menuToolBar");
- assertNotNull(toolBar);
- final Listener[] listeners = toolBar.getListeners(SWT.MouseMove);
- assertEquals(1, listeners.length);
+ checkListenerCountAndType(toolBar, SWT.MouseDown);
+ checkListenerCountAndType(toolBar, SWT.MouseEnter);
final CoolBar coolBar = (CoolBar) toolBar.getParent();
assertEquals(1, coolBar.getItemCount());
@@ -67,6 +67,22 @@ public class MenuCoolBarCompositeTest extends TestCase {
}
/**
+ * @param toolBar
+ * @param eventType
+ */
+ private void checkListenerCountAndType(final ToolBar toolBar, final int eventType) {
+ final Listener[] listeners = toolBar.getListeners(eventType);
+ assertEquals(1, listeners.length);
+ if (listeners[0] instanceof TypedListener) {
+ final TypedListener l = (TypedListener) listeners[0];
+ final SWTEventListener eventListener = l.getEventListener();
+ assertTrue(eventListener instanceof ToolBarMenuListener);
+ } else {
+ assertTrue(listeners[0] instanceof ToolBarMenuListener);
+ }
+ }
+
+ /**
* Tests the method {@code createAndAddMenu}.
*/
public void testCreateAndAddMenu() {
@@ -75,12 +91,12 @@ public class MenuCoolBarCompositeTest extends TestCase {
final MenuCoolBarComposite composite = new MenuCoolBarComposite(shell, SWT.NONE, null);
final MenuManager manager = getMenuManager("TestMenu", "0815");
- final ToolItem topItem = ReflectionUtils.invokeHidden(composite, "createAndAddMenu", manager);
+ final ToolItem topItem = ReflectionUtils.invokeHidden(composite, "createAndAddMenu", manager, new ToolBarMenuListener());
assertEquals("TestMenu", topItem.getText());
final MenuManager invisibleMenuManager = getMenuManager("TestMenu2", "4711");
invisibleMenuManager.setVisible(false);
- final ToolItem topItem2 = ReflectionUtils.invokeHidden(composite, "createAndAddMenu", invisibleMenuManager);
+ final ToolItem topItem2 = ReflectionUtils.invokeHidden(composite, "createAndAddMenu", invisibleMenuManager, new ToolBarMenuListener());
assertNull(locator.locateBindingProperty(topItem2));
assertNull(topItem2);
}
@@ -93,7 +109,7 @@ public class MenuCoolBarCompositeTest extends TestCase {
final MenuCoolBarComposite composite = new MenuCoolBarComposite(shell, SWT.NONE, null);
final MenuManager manager = getMenuManager("TestMenu", "0815");
- final ToolItem topItem = ReflectionUtils.invokeHidden(composite, "createAndAddMenu", manager);
+ final ToolItem topItem = ReflectionUtils.invokeHidden(composite, "createAndAddMenu", manager, new ToolBarMenuListener());
final List<ToolItem> items = composite.getTopLevelItems();
assertEquals(1, items.size());
assertTrue(items.contains(topItem));
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MenuManagerHelper.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MenuManagerHelper.java
index b6dcac3..d641666 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MenuManagerHelper.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/ui/ridgets/swt/MenuManagerHelper.java
@@ -14,10 +14,6 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
@@ -34,8 +30,7 @@ import org.eclipse.swt.widgets.TypedListener;
public class MenuManagerHelper {
/**
- * Creates with the help of the given menu manager a menu. If the given tool
- * item is selected, the menu is shown.
+ * Creates with the help of the given menu manager a menu. If the given tool item is selected, the menu is shown.
*
* @param parent
* @param toolItem
@@ -56,14 +51,11 @@ public class MenuManagerHelper {
}
public void addListeners(final ToolItem toolItem, final Menu menu) {
-
menu.addMenuListener(new TopMenuListener(menu, toolItem));
- toolItem.addSelectionListener(new TopItemListener(menu, toolItem));
}
public void removeListeners(final ToolItem toolItem, final Menu menu) {
-
- Listener[] listeners = menu.getListeners(SWT.Hide);
+ final Listener[] listeners = menu.getListeners(SWT.Hide);
for (final Listener listener : listeners) {
if (listener instanceof TypedListener) {
final TypedListener typedListener = (TypedListener) listener;
@@ -72,16 +64,6 @@ public class MenuManagerHelper {
}
}
}
- listeners = toolItem.getListeners(SWT.Selection);
- for (final Listener listener : listeners) {
- if (listener instanceof TypedListener) {
- final TypedListener typedListener = (TypedListener) listener;
- if (typedListener.getEventListener() instanceof TopItemListener) {
- toolItem.removeSelectionListener((TopItemListener) typedListener.getEventListener());
- }
- }
- }
-
}
private static class TopMenuListener implements MenuListener {
@@ -104,35 +86,4 @@ public class MenuManagerHelper {
}
}
-
- private static class TopItemListener implements SelectionListener {
-
- private final ToolItem toolItem;
- private final Menu menu;
-
- public TopItemListener(final Menu menu, final ToolItem toolItem) {
- this.menu = menu;
- this.toolItem = toolItem;
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(final SelectionEvent e) {
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(final SelectionEvent e) {
- if (e.getSource() == toolItem) {
- final Rectangle itemBounds = toolItem.getBounds();
- final Point loc = toolItem.getParent().toDisplay(itemBounds.x, itemBounds.height + itemBounds.y);
- menu.setLocation(loc);
- menu.setVisible(true);
- }
- }
-
- }
-
}