Mercurial > projects > dwt-addons
diff dwtx/jface/action/SubMenuManager.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 46a6e0e6ccd4 |
children |
line wrap: on
line diff
--- a/dwtx/jface/action/SubMenuManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/SubMenuManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,8 +19,6 @@ import dwtx.jface.action.IContributionManager; import dwtx.jface.action.SubContributionItem; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; import dwt.widgets.Composite; import dwt.widgets.CoolBar; @@ -30,6 +28,7 @@ import dwtx.core.runtime.ListenerList; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A <code>SubMenuManager</code> is used to define a set of contribution @@ -55,7 +54,7 @@ * monitor additions and removals. If the visibility of the manager is modified * the visibility of the submenus is also modified. */ - private Map!(Object,Object) mapMenuToWrapper; + private Map mapMenuToWrapper; /** * List of registered menu listeners (element type: <code>IMenuListener</code>). @@ -122,8 +121,9 @@ // otherwise super's call to removeAll will remove them // before they can be disposed if (mapMenuToWrapper !is null) { - foreach( v; mapMenuToWrapper.elements() ){ - SubMenuManager wrapper = cast(SubMenuManager) v; + Iterator iter = mapMenuToWrapper.values().iterator(); + while (iter.hasNext()) { + SubMenuManager wrapper = cast(SubMenuManager) iter.next(); wrapper.disposeManager(); } mapMenuToWrapper.clear(); @@ -264,12 +264,12 @@ */ protected IMenuManager getWrapper(IMenuManager mgr) { if (mapMenuToWrapper is null) { - mapMenuToWrapper = new HashMap!(Object,Object); + mapMenuToWrapper = new HashMap(4); } SubMenuManager wrapper = cast(SubMenuManager) mapMenuToWrapper.get(cast(Object)mgr); if (wrapper is null) { wrapper = wrapMenu(mgr); - mapMenuToWrapper.add(cast(Object)mgr, wrapper); + mapMenuToWrapper.put(cast(Object)mgr, wrapper); } return wrapper; } @@ -308,8 +308,9 @@ public override void removeAll() { super.removeAll(); if (mapMenuToWrapper !is null) { - foreach( v; mapMenuToWrapper.elements() ){ - SubMenuManager wrapper = cast(SubMenuManager) v; + Iterator iter = mapMenuToWrapper.values().iterator(); + while (iter.hasNext()) { + SubMenuManager wrapper = cast(SubMenuManager) iter.next(); wrapper.removeAll(); } mapMenuToWrapper.clear(); @@ -352,8 +353,9 @@ public override void setVisible(bool visible) { super.setVisible(visible); if (mapMenuToWrapper !is null) { - foreach( v; mapMenuToWrapper.elements() ){ - SubMenuManager wrapper = cast(SubMenuManager) v; + Iterator iter = mapMenuToWrapper.values().iterator(); + while (iter.hasNext()) { + SubMenuManager wrapper = cast(SubMenuManager) iter.next(); wrapper.setVisible(visible); } }