Mercurial > projects > dwt-addons
diff dwtx/jface/action/SubContributionManager.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 | 644f1334b451 |
children |
line wrap: on
line diff
--- a/dwtx/jface/action/SubContributionManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/SubContributionManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,11 +19,9 @@ import dwtx.jface.action.IContributionItem; import dwtx.jface.action.IContributionManagerOverrides; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; -import tango.util.collection.model.Iterator; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A <code>SubContributionManager</code> is used to define a set of contribution @@ -40,7 +38,7 @@ * Maps each item in the manager to a wrapper. The wrapper is used to * control the visibility of each item. */ - private Map!(Object,Object) mapItemToWrapper; + private Map mapItemToWrapper; /** * The visibility of the manager, @@ -55,7 +53,7 @@ * parent manager. */ public this(IContributionManager mgr) { - mapItemToWrapper = new HashMap!(Object,Object); + mapItemToWrapper = new HashMap(); //super(); parentMgr = mgr; } @@ -105,11 +103,12 @@ * @since 3.0 */ public void disposeManager() { + Iterator it = mapItemToWrapper.values().iterator(); // Dispose items in addition to removing them. // See bugs 64024 and 73715 for details. // Do not use getItems() here as subclasses can override that in bad ways. - foreach( k,v; mapItemToWrapper ){ - IContributionItem item = cast(IContributionItem) v; + while (it.hasNext()) { + IContributionItem item = cast(IContributionItem) it.next(); item.dispose(); } removeAll(); @@ -133,13 +132,7 @@ * Returns the items passed to us, not the wrappers. */ public IContributionItem[] getItems() { - IContributionItem[] result = new IContributionItem[mapItemToWrapper - .size()]; - int idx = 0; - foreach( k,v; mapItemToWrapper ){ - result[idx] = cast(IContributionItem)k; - idx++; - } + IContributionItem[] result = arraycast!(IContributionItem)(mapItemToWrapper.keySet().toArray()); return result; } @@ -231,7 +224,7 @@ * contributed by the client */ protected void itemAdded(IContributionItem item, SubContributionItem wrap) { - mapItemToWrapper.add(cast(Object)item, wrap); + mapItemToWrapper.put(cast(Object)item, wrap); } /** @@ -243,7 +236,7 @@ * @param item the item contributed by the client */ protected void itemRemoved(IContributionItem item) { - mapItemToWrapper.removeKey(cast(Object)item); + mapItemToWrapper.remove(cast(Object)item); } /** @@ -251,17 +244,17 @@ * @deprecated Use getItems(String value) instead. */ public Enumeration items() { - return new class(mapItemToWrapper.elements()) Enumeration { - Iterator!(Object) i; - this(Iterator!(Object) i__){ - i = i__; + return new class(mapItemToWrapper.values().iterator()) Enumeration { + Iterator i; + this(Iterator i_){ + i = i_; } public bool hasMoreElements() { - return i.more(); + return i.hasNext(); } public Object nextElement() { - return i.get(); + return i.next(); } }; } @@ -323,8 +316,9 @@ * Method declared on IContributionManager. */ public void removeAll() { - foreach( k, v; mapItemToWrapper ){ - IContributionItem item = cast(IContributionItem) v; + Iterator it = mapItemToWrapper.values().iterator(); + while (it.hasNext()) { + IContributionItem item = cast(IContributionItem) it.next(); parentMgr.remove(item); } mapItemToWrapper.clear(); @@ -340,8 +334,9 @@ public void setVisible(bool visible) { this.visible = visible; if (mapItemToWrapper.size() > 0) { - foreach( k, v; mapItemToWrapper ){ - IContributionItem item = cast(IContributionItem) v; + Iterator it = mapItemToWrapper.values().iterator(); + while (it.hasNext()) { + IContributionItem item = cast(IContributionItem) it.next(); item.setVisible(visible); } parentMgr.markDirty();