Mercurial > projects > dwt-addons
diff dwtx/core/commands/AbstractHandlerWithState.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 | 6518c18a01f7 |
children |
line wrap: on
line diff
--- a/dwtx/core/commands/AbstractHandlerWithState.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/AbstractHandlerWithState.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,10 +19,7 @@ import dwtx.core.commands.State; import dwt.dwthelper.utils; - -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -45,7 +42,7 @@ * The map of states currently held by this handler. If this handler has no * state (generally, when inactive), then this will be <code>null</code>. */ - private Map!(String,State) states = null; + private Map states = null; /** * <p> @@ -70,15 +67,15 @@ } if (states is null) { - states = new HashMap!(String,State)(/+3+/); + states = new HashMap(3); } - states.add(stateId, state); + states.put(stateId, state); state.addListener(this); handleStateChange(state, null); } public final State getState(String stateId) { - if ((states is null) || (states.drained())) { + if ((states is null) || (states.isEmpty())) { return null; } @@ -86,15 +83,12 @@ } public final String[] getStateIds() { - if ((states is null) || (states.drained())) { + if ((states is null) || (states.isEmpty())) { return null; } - String[] res; - foreach( k, v; states.keys() ){ - res ~= k; - } - return res; + Set stateIds = states.keySet(); + return stringcast( stateIds.toArray()); } /** @@ -122,7 +116,7 @@ state.removeListener(this); if (states !is null) { states.remove(state); - if (states.drained()) { + if (states.isEmpty()) { states = null; } }