Mercurial > projects > dwt-addons
changeset 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.
line wrap: on
line diff
--- a/dsss.conf Sun Aug 03 17:01:51 2008 +0200 +++ b/dsss.conf Thu Aug 07 15:01:33 2008 +0200 @@ -7,7 +7,6 @@ [dwtx] type=library -exclude=dwtx/draw2d buildflags+=-Jres preinstall = \ installdir res $LIB_PREFIX/res
--- 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; } }
--- a/dwtx/core/commands/Category.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/Category.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,14 +12,13 @@ *******************************************************************************/ module dwtx.core.commands.Category; -import tango.util.collection.ArraySeq; - import dwtx.core.commands.common.NamedHandleObject; import dwtx.core.internal.commands.util.Util; import dwtx.core.commands.ICategoryListener; import dwtx.core.commands.CategoryEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.convert.Format; /** @@ -37,7 +36,7 @@ * A collection of objects listening to changes to this category. This * collection is <code>null</code> if there are no listeners. */ - private ArraySeq!(ICategoryListener) categoryListeners; + private Collection categoryListeners; /** * Constructs a new instance of <code>Category</code> based on the given @@ -67,10 +66,10 @@ throw new NullPointerException(); } if (categoryListeners is null) { - categoryListeners = new ArraySeq!(ICategoryListener); + categoryListeners = new ArrayList(); } - if (!categoryListeners.contains(categoryListener)) { - categoryListeners.append(categoryListener); + if (!categoryListeners.contains(cast(Object)categoryListener)) { + categoryListeners.add(cast(Object)categoryListener); } } @@ -120,7 +119,10 @@ throw new NullPointerException(); } if (categoryListeners !is null) { - foreach( listener; categoryListeners ){ + Iterator listenerItr = categoryListeners.iterator(); + while (listenerItr.hasNext()) { + ICategoryListener listener = cast(ICategoryListener) listenerItr + .next(); listener.categoryChanged(categoryEvent); } } @@ -140,7 +142,7 @@ } if (categoryListeners !is null) { - categoryListeners.remove(categoryListener); + categoryListeners.remove(cast(Object)categoryListener); } }
--- a/dwtx/core/commands/CommandManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/CommandManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,21 +12,6 @@ *******************************************************************************/ module dwtx.core.commands.CommandManager; -// import java.util.ArrayList; -// import java.util.Collections; -// import java.util.HashMap; -// import java.util.HashSet; -// import java.util.Iterator; -// import java.util.Map; -// import java.util.Set; -// import java.util.WeakHashMap; -import tango.util.collection.HashMap; -import tango.util.collection.HashSet; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; -import tango.util.collection.model.SetView; - import dwtx.core.commands.common.HandleObjectManager; import dwtx.core.commands.common.NotDefinedException; import dwtx.core.runtime.ListenerList; @@ -56,6 +41,7 @@ import dwtx.core.commands.ExecutionEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; @@ -197,11 +183,11 @@ static const char PARAMETER_START_CHAR = '('; this(){ - categoriesById = new HashMap!(String,Category); - definedCategoryIds = new HashSet!(String); - definedParameterTypeIds = new HashSet!(String); - parameterTypesById = new HashMap!(String,ParameterType); + categoriesById = new HashMap(); + definedCategoryIds = new HashSet(); + definedParameterTypeIds = new HashSet(); helpContextIdsByHandler = new WeakHashMap(); + parameterTypesById = new HashMap(); } /** @@ -277,13 +263,13 @@ * <code>Category</code>). This collection may be empty, but it is never * <code>null</code>. */ - private const Map!(String,Category) categoriesById; + private const Map categoriesById; /** * The set of identifiers for those categories that are defined. This value * may be empty, but it is never <code>null</code>. */ - private const Set!(String) definedCategoryIds; + private const Set definedCategoryIds; /** * The set of identifiers for those command parameter types that are @@ -291,7 +277,7 @@ * * @since 3.2 */ - private const Set!(String) definedParameterTypeIds; + private const Set definedParameterTypeIds; /** * The execution listener for this command manager. This just forwards @@ -322,7 +308,7 @@ * * @since 3.2 */ - private const Map!(String,ParameterType) parameterTypesById; + private const Map parameterTypesById; /** * Adds a listener to this command manager. The listener will be notified @@ -356,8 +342,9 @@ // Add an execution listener to every command. executionListener = new ExecutionListener(); - foreach( k, v; handleObjectsById ){ - Command command = cast(Command) v; + Iterator commandItr = handleObjectsById.values().iterator(); + while (commandItr.hasNext()) { + Command command = cast(Command) commandItr.next(); command.addExecutionListener(executionListener); } @@ -533,14 +520,7 @@ * @since 3.2 */ public final Command[] getAllCommands() { - Command[] res; - res.length = handleObjectsById.size(); - int idx; - foreach( cmd; handleObjectsById.elements() ){ - res[idx] = cast(Command)cmd; - idx++; - } - return res; + return arraycast!(Command)( handleObjectsById.values().toArray()); } /** @@ -565,7 +545,7 @@ Category category = cast(Category) categoriesById.get(categoryId); if (category is null) { category = new Category(categoryId); - categoriesById.add(categoryId, category); + categoriesById.put(categoryId, category); category.addCategoryListener(this); } @@ -589,7 +569,7 @@ Command command = cast(Command) handleObjectsById.get(commandId); if (command is null) { command = new Command(commandId); - handleObjectsById.add(commandId, command); + handleObjectsById.put(commandId, command); command.addCommandListener(this); if (executionListener !is null) { @@ -609,11 +589,10 @@ */ public final Category[] getDefinedCategories() { Category[] categories = new Category[definedCategoryIds.size()]; -// Iterator categoryIdItr = definedCategoryIds.iterator(); + Iterator categoryIdItr = definedCategoryIds.iterator(); int i = 0; - foreach( categoryId; definedCategoryIds ){ -// while (categoryIdItr.hasNext()) { -// String categoryId = cast(String) categoryIdItr.next(); + while (categoryIdItr.hasNext()) { + String categoryId = stringcast( categoryIdItr.next()); categories[i++] = getCategory(categoryId); } return categories; @@ -625,8 +604,8 @@ * @return The set of defined category identifiers; this value may be empty, * but it is never <code>null</code>. */ - public final SetView!(String) getDefinedCategoryIds() { - return definedCategoryIds; + public final Set getDefinedCategoryIds() { + return Collections.unmodifiableSet(definedCategoryIds); } /** @@ -635,7 +614,7 @@ * @return The set of defined command identifiers; this value may be empty, * but it is never <code>null</code>. */ - public final SetView!(String) getDefinedCommandIds() { + public final Set getDefinedCommandIds() { return getDefinedHandleObjectIds(); } @@ -647,8 +626,8 @@ * @since 3.2 */ public final Command[] getDefinedCommands() { - return cast(Command[]) definedHandleObjects - .toArray(); + return arraycast!(Command)( definedHandleObjects + .toArray()); } /** @@ -659,8 +638,8 @@ * may be empty, but it is never <code>null</code>. * @since 3.2 */ - public final SetView!(String) getDefinedParameterTypeIds() { - return definedParameterTypeIds; + public final Set getDefinedParameterTypeIds() { + return Collections.unmodifiableSet(definedParameterTypeIds); } /** @@ -673,11 +652,10 @@ public final ParameterType[] getDefinedParameterTypes() { ParameterType[] parameterTypes = new ParameterType[definedParameterTypeIds .size()]; -// Iterator iterator = definedParameterTypeIds.iterator(); + Iterator iterator = definedParameterTypeIds.iterator(); int i = 0; - foreach( parameterTypeId; definedParameterTypeIds ){ -// while (iterator.hasNext()) { -// String parameterTypeId = cast(String) iterator.next(); + while (iterator.hasNext()) { + String parameterTypeId = stringcast( iterator.next()); parameterTypes[i++] = getParameterType(parameterTypeId); } return parameterTypes; @@ -747,7 +725,7 @@ return null; } - auto paramList = new ArraySeq!(Parameterization); + ArrayList paramList = new ArrayList(); int commaPosition; // split off each param by looking for ',' do { @@ -785,7 +763,7 @@ for (int i = 0; i < parameters.length; i++) { IParameter parameter = parameters[i]; if (parameter.getId().equals(parameterId)) { - paramList.append(new Parameterization(parameter, + paramList.add(new Parameterization(parameter, parameterValue)); break; } @@ -793,8 +771,8 @@ } while (commaPosition !is -1); - return cast(Parameterization[]) paramList - .toArray(); + return arraycast!(Parameterization)( paramList + .toArray()); } /** @@ -816,7 +794,7 @@ .get(parameterTypeId); if (parameterType is null) { parameterType = new ParameterType(parameterTypeId); - parameterTypesById.add(parameterTypeId, parameterType); + parameterTypesById.put(parameterTypeId, parameterType); parameterType.addListener(this); } @@ -878,10 +856,9 @@ executionListeners = null; // Remove the execution listener to every command. - foreach( k, v; handleObjectsById ){ -// Iterator commandItr = handleObjectsById.values().iterator(); -// while (commandItr.hasNext()) { - Command command = cast(Command) v; + Iterator commandItr = handleObjectsById.values().iterator(); + while (commandItr.hasNext()) { + Command command = cast(Command) commandItr.next(); command.removeExecutionListener(executionListener); } executionListener = null; @@ -902,23 +879,21 @@ * Similarly, if the map is empty, then all commands will become * unhandled. */ - public final void setHandlersByCommandId(Map!(String,Object) handlersByCommandId) { + public final void setHandlersByCommandId(Map handlersByCommandId) { // Make that all the reference commands are created. - foreach( k, v; handlersByCommandId ){ - //Iterator commandIdItr = handlersByCommandId.keySet().iterator(); - //while (commandIdItr.hasNext()) { - getCommand(k); + Iterator commandIdItr = handlersByCommandId.keySet().iterator(); + while (commandIdItr.hasNext()) { + getCommand(stringcast(commandIdItr.next())); } // Now, set-up the handlers on all of the existing commands. -// Iterator commandItr = handleObjectsById.values().iterator(); - foreach( k, v; handlersByCommandId ){ -// while (commandItr.hasNext()) { - Command command = cast(Command) v; + Iterator commandItr = handleObjectsById.values().iterator(); + while (commandItr.hasNext()) { + Command command = cast(Command) commandItr.next(); String commandId = command.getId(); Object value = handlersByCommandId.get(commandId); - if ( auto handler = cast(IHandler) value ) { - command.setHandler(handler); + if ( cast(IHandler)value ) { + command.setHandler(cast(IHandler) value); } else { command.setHandler(null); } @@ -943,9 +918,9 @@ throw new NullPointerException("The handler cannot be null"); //$NON-NLS-1$ } if (helpContextId is null) { - helpContextIdsByHandler.removeKey(cast(Object) handler); + helpContextIdsByHandler.remove(cast(Object) handler); } else { - helpContextIdsByHandler.add(cast(Object) handler, stringcast(helpContextId)); + helpContextIdsByHandler.put(cast(Object) handler, stringcast(helpContextId)); } } @@ -994,7 +969,7 @@ * <b>Note:</b> This supports bridging actions to the command framework, * and should not be used outside the framework. * </p> - * + * * @param commandId * The command id of the command about to execute, never * <code>null</code>. @@ -1007,7 +982,7 @@ executionListener.notEnabled(commandId, exception); } } - + /** * Fires the <code>notDefined</code> event for * <code>executionListeners</code>. @@ -1015,7 +990,7 @@ * <b>Note:</b> This supports bridging actions to the command framework, * and should not be used outside the framework. * </p> - * + * * @param commandId * The command id of the command about to execute, never * <code>null</code>. @@ -1028,7 +1003,7 @@ executionListener.notDefined(commandId, exception); } } - + /** * Fires the <code>preExecute</code> event for * <code>executionListeners</code>. @@ -1036,7 +1011,7 @@ * <b>Note:</b> This supports bridging actions to the command framework, * and should not be used outside the framework. * </p> - * + * * @param commandId * The command id of the command about to execute, never * <code>null</code>. @@ -1049,7 +1024,7 @@ executionListener.preExecute(commandId, event); } } - + /** * Fires the <code>postExecuteSuccess</code> event for * <code>executionListeners</code>. @@ -1057,7 +1032,7 @@ * <b>Note:</b> This supports bridging actions to the command framework, * and should not be used outside the framework. * </p> - * + * * @param commandId * The command id of the command executed, never * <code>null</code>. @@ -1070,7 +1045,7 @@ executionListener.postExecuteSuccess(commandId, returnValue); } } - + /** * Fires the <code>postExecuteFailure</code> event for * <code>executionListeners</code>. @@ -1078,7 +1053,7 @@ * <b>Note:</b> This supports bridging actions to the command framework, * and should not be used outside the framework. * </p> - * + * * @param commandId * The command id of the command executed, never * <code>null</code>. @@ -1086,7 +1061,7 @@ * The exception, never <code>null</code>. * @since 3.4 */ - public void firePostExecuteFailure(String commandId, + public void firePostExecuteFailure(String commandId, ExecutionException exception) { if (executionListener !is null) { executionListener.postExecuteFailure(commandId, exception);
--- a/dwtx/core/commands/ExecutionEvent.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/ExecutionEvent.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,8 +13,6 @@ module dwtx.core.commands.ExecutionEvent; // import java.util.Collections; -import tango.util.collection.model.Map; -import tango.util.collection.HashMap; import dwtx.core.commands.common.NotDefinedException; import dwtx.core.commands.ExecutionException; @@ -24,6 +22,7 @@ import dwtx.core.commands.ParameterValueConversionException; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.convert.Format; @@ -43,10 +42,6 @@ * @since 3.1 */ public final class ExecutionEvent { - private static const Map!(String,String) EMPTY_MAP; - static this(){ - EMPTY_MAP = new HashMap!(String,String); - } /** * The state of the application at the time the execution was triggered. In * the Eclipse workbench, this might contain information about the active @@ -65,7 +60,7 @@ * prompt for additional information, these can be used to avoid prompting. * This value may be empty, but it is never <code>null</code>. */ - private const Map!(String,String) parameters; + private const Map parameters; /** * The object that triggered the execution. In an event-driven architecture, @@ -82,7 +77,7 @@ * @since 3.2 */ public this() { - this(null, EMPTY_MAP, null, null); + this(null, Collections.EMPTY_MAP, null, null); } /** @@ -101,7 +96,7 @@ * @deprecated use * {@link ExecutionEvent#ExecutionEvent(Command, Map, Object, Object)} */ - public this(Map!(String,String) parameters, Object trigger, + public this(Map parameters, Object trigger, Object applicationContext) { this(null, parameters, trigger, applicationContext); } @@ -123,7 +118,7 @@ * triggered; may be <code>null</code>. * @since 3.2 */ - public this(Command command, Map!(String,String) parameters, + public this(Command command, Map parameters, Object trigger, Object applicationContext) { if (parameters is null) { throw new NullPointerException( @@ -213,7 +208,7 @@ * be found. */ public final String getParameter(String parameterId) { - return parameters.get(parameterId); + return stringcast(parameters.get(parameterId)); } /** @@ -221,7 +216,7 @@ * * @return The parameters; never <code>null</code>, but may be empty. */ - public final Map!(String,String) getParameters() { + public final Map getParameters() { return parameters; } @@ -243,7 +238,7 @@ public override final String toString() { String parm; foreach( k, v; parameters ){ - parm ~= "{"~k~","~v~"}"; + parm ~= "{"~stringcast(k)~","~stringcast(v)~"}"; } return Format( "ExecutionEvent({},{},{})", command, parm, trigger, applicationContext ); }
--- a/dwtx/core/commands/IParameterValues.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/IParameterValues.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,9 +13,8 @@ module dwtx.core.commands.IParameterValues; -import tango.util.collection.model.Map; - import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -36,5 +35,5 @@ * @return A map of the externalizable name of the parameter value (<code>String</code>) * to the actual value of the parameter (<code>String</code>). */ - public Map!(String,String) getParameterValues(); + public Map getParameterValues(); }
--- a/dwtx/core/commands/NamedHandleObjectWithState.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/NamedHandleObjectWithState.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,10 +13,6 @@ module dwtx.core.commands.NamedHandleObjectWithState; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; -// import tango.util.collection.model.Set; - import dwtx.core.commands.common.NamedHandleObject; import dwtx.core.commands.common.NotDefinedException; import dwtx.core.commands.IObjectWithState; @@ -24,6 +20,7 @@ import dwtx.core.commands.INamedHandleStateIds; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -49,7 +46,7 @@ * The map of states currently held by this command. If this command has no * state, then this will be <code>null</code>. */ - private Map!(String,State) states = null; + private Map states = null; /** * Constructs a new instance of <code>NamedHandleObject<WithState/code>. @@ -67,9 +64,9 @@ } if (states is null) { - states = new HashMap!(String,State)/+(3)+/; + states = new HashMap(3); } - states.add(stateId, state); + states.put(stateId, state); } public override final String getDescription() { @@ -101,23 +98,20 @@ } public final State getState(String stateId) { - if ((states is null) || (states.drained())) { + if ((states is null) || (states.isEmpty())) { return null; } - return states.get(stateId); + return cast(State) states.get(stateId); } public final String[] getStateIds() { - if ((states is null) || (states.drained())) { + if ((states is null) || (states.isEmpty())) { return NO_STATE; } - String[] res; - foreach( id, state; states){ - res ~= id; - } - return res; + Set stateIds = states.keySet(); + return stringcast( stateIds.toArray()); } public void removeState(String id) { @@ -126,8 +120,8 @@ } if (states !is null) { - states.removeKey(id); - if (states.drained()) { + states.remove(id); + if (states.isEmpty()) { states = null; } }
--- a/dwtx/core/commands/Parameterization.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/Parameterization.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,12 +13,11 @@ module dwtx.core.commands.Parameterization; -import tango.util.collection.model.Map; - import dwtx.core.commands.IParameter; import dwtx.core.internal.commands.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -136,14 +135,19 @@ * If the parameter needed to be initialized, but couldn't be. */ public final String getValueName() { - auto parameterValues = parameter.getValues().getParameterValues(); + Map parameterValues = parameter.getValues().getParameterValues(); + Iterator parameterValueItr = parameterValues.entrySet() + .iterator(); String returnValue = null; - foreach( k, v; parameterValues ){ - if (Util.equals(value, v)) { - returnValue = k; + while (parameterValueItr.hasNext()) { + Map.Entry entry = cast(Map.Entry) parameterValueItr.next(); + String currentValue = stringcast( entry.getValue()); + if (Util.equals(value, currentValue)) { + returnValue = stringcast( entry.getKey()); break; } } + if (returnValue is null) { return Util.ZERO_LENGTH_STRING; }
--- a/dwtx/core/commands/ParameterizedCommand.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/ParameterizedCommand.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,21 +14,6 @@ module dwtx.core.commands.ParameterizedCommand; -// import java.util.ArrayList; -// import java.util.Collection; -// import java.util.Collections; -// import java.util.HashMap; -// import java.util.Iterator; -// import java.util.List; -// import java.util.Map; - -import tango.util.collection.model.Seq; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashSet; -import tango.util.collection.HashMap; - import dwtx.core.commands.AbstractParameterValueConverter; import dwtx.core.commands.Command; import dwtx.core.commands.CommandManager; @@ -42,6 +27,7 @@ import dwtx.core.commands.common.NotDefinedException; import dwtx.core.internal.commands.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.convert.Format; static import tango.text.Text; @@ -58,7 +44,6 @@ * @since 3.1 */ public final class ParameterizedCommand : Comparable { - private static const Map!(String,String) EMPTY_MAP; /** * The constant integer hash code value meaning the hash code has not yet * been computed. @@ -77,7 +62,6 @@ static this(){ HASH_INITIAL = dwt.dwthelper.utils.toHash(ParameterizedCommand.classinfo.name ); - EMPTY_MAP = new HashMap!(String,String); } /** * The index of the parameter id in the parameter values. @@ -174,15 +158,15 @@ * @return A collection (<code>Collection</code>) of combinations (<code>List</code> * of <code>Parameterization</code>). */ - private static final Seq!(Object) expandParameters(int startIndex, + private static final Collection expandParameters(int startIndex, IParameter[] parameters) { int nextIndex = startIndex + 1; bool noMoreParameters = (nextIndex >= parameters.length); IParameter parameter = parameters[startIndex]; - auto parameterizations = new ArraySeq!(Object); + List parameterizations = new ArrayList(); if (parameter.isOptional()) { - parameterizations.append( cast(Object) null); + parameterizations.add( cast(Object) null); } IParameterValues values = null; @@ -197,21 +181,14 @@ return expandParameters(nextIndex, parameters); } -// Iterator parameterValueItr = parameterValues.entrySet() -// .iterator(); - auto parameterValues = values.getParameterValues(); - auto set = new HashSet!(String); - foreach( k,v; parameterValues ){ - set.add( v ); - } - - - //while (parameterValueItr.hasNext()) { - foreach( v; set ){ - //Map.Entry entry = (Map.Entry) parameterValueItr.next(); + Map parameterValues = values.getParameterValues(); + Iterator parameterValueItr = parameterValues.entrySet() + .iterator(); + while (parameterValueItr.hasNext()) { + Map.Entry entry = cast(Map.Entry) parameterValueItr.next(); Parameterization parameterization = new Parameterization( - parameter, v); - parameterizations.append(parameterization); + parameter, stringcast( entry.getValue())); + parameterizations.add(parameterization); } // Check if another iteration will produce any more names. @@ -221,44 +198,41 @@ for (int i = 0; i < parameterizationCount; i++) { Parameterization parameterization = cast(Parameterization) parameterizations .get(i); - auto combination = new ArraySeq!(Object); - combination.append(parameterization); - parameterizations.replaceAt(i, combination); + List combination = new ArrayList(); + combination.add(parameterization); + parameterizations.set(i, cast(Object)combination); } return parameterizations; } // Make recursive call - auto suffixes = expandParameters(nextIndex, parameters); - suffixes.removeAll(cast(Object)null); - if (suffixes.drained()) { + Collection suffixes = expandParameters(nextIndex, parameters); + while (suffixes.remove(cast(Object)null)) { + // just keep deleting the darn things. + } + if (suffixes.isEmpty()) { // This is it, so just return the current parameterizations. for (int i = 0; i < parameterizationCount; i++) { Parameterization parameterization = cast(Parameterization) parameterizations .get(i); - auto combination = new ArraySeq!(Object); - combination.append(parameterization); - parameterizations.replaceAt(i, combination); + List combination = new ArrayList(); + combination.add(parameterization); + parameterizations.set(i,cast(Object) combination); } return parameterizations; } - auto returnValue = new ArraySeq!(Object); -// Iterator suffixItr = suffixes.iterator(); -// while (suffixItr.hasNext()) { - foreach( v; suffixes ){ -// final List combination = (List) suffixItr.next(); - auto combination = cast(Seq!(Object)) v; + Collection returnValue = new ArrayList(); + Iterator suffixItr = suffixes.iterator(); + while (suffixItr.hasNext()) { + List combination = cast(List) suffixItr.next(); int combinationSize = combination.size(); for (int i = 0; i < parameterizationCount; i++) { Parameterization parameterization = cast(Parameterization) parameterizations .get(i); - auto newCombination = new ArraySeq!(Object); - newCombination.capacity(combinationSize + 1); - newCombination.append(parameterization); - foreach( c; combination ){ - newCombination.append(c); - } - returnValue.append(newCombination); + List newCombination = new ArrayList(combinationSize + 1); + newCombination.add(parameterization); + newCombination.addAll(combination); + returnValue.add(cast(Object)newCombination); } } @@ -286,31 +260,30 @@ * @throws NotDefinedException * If the command is not defined. */ - public static final Seq!(Object) generateCombinations(Command command) { + public static final Collection generateCombinations(Command command) { IParameter[] parameters = command.getParameters(); if (parameters is null) { - auto res = new ArraySeq!(Object); - res.append( new ParameterizedCommand(command, null) ); - return res; + return Collections + .singleton(new ParameterizedCommand(command, null)); } - auto expansion = expandParameters(0, parameters); - auto combinations = new ArraySeq!(Object); - combinations.capacity(expansion.size()); - foreach( v; expansion ){ -// Iterator expansionItr = expansion.iterator(); -// while (expansionItr.hasNext()) { - auto combination = cast(Seq!(Object)) v; + Collection expansion = expandParameters(0, parameters); + Collection combinations = new ArrayList(expansion.size()); + Iterator expansionItr = expansion.iterator(); + while (expansionItr.hasNext()) { + List combination = cast(List) expansionItr.next(); if (combination is null) { - combinations.append(new ParameterizedCommand(command, null)); + combinations.add(new ParameterizedCommand(command, null)); } else { - combination.removeAll(cast(Object)null); - if (combination.drained()) { - combinations.append(new ParameterizedCommand(command, null)); + while (combination.remove(cast(Object)null)) { + // Just keep removing while there are null entries left. + } + if (combination.isEmpty()) { + combinations.add(new ParameterizedCommand(command, null)); } else { - Parameterization[] parameterizations = cast(Parameterization[]) combination - .toArray(); - combinations.append(new ParameterizedCommand(command, + Parameterization[] parameterizations = arraycast!(Parameterization)( combination + .toArray()); + combinations.add(new ParameterizedCommand(command, parameterizations)); } } @@ -333,17 +306,19 @@ * @since 3.4 */ public static final ParameterizedCommand generateCommand(Command command, - Map!(String,Object) parameters) { + Map parameters) { // no parameters - if (parameters is null || parameters.drained()) { + if (parameters is null || parameters.isEmpty()) { return new ParameterizedCommand(command, null); } try { - Parameterization[] parms; + ArrayList parms = new ArrayList(); + Iterator i = parameters.keySet().iterator(); // iterate over given parameters - foreach( key, value; parameters ){ + while (i.hasNext()) { + String key = stringcast( i.next() ); IParameter parameter = null; // get the parameter from the command parameter = command.getParameter(key); @@ -354,24 +329,26 @@ } ParameterType parameterType = command.getParameterType(key); if (parameterType is null) { - parms ~= new Parameterization(parameter, - stringcast(value) ); + parms.add(new Parameterization(parameter, + stringcast( parameters.get(key)))); } else { AbstractParameterValueConverter valueConverter = parameterType .getValueConverter(); if (valueConverter !is null) { - String val = valueConverter.convertToString(value); - parms ~= new Parameterization(parameter, val); + String val = valueConverter.convertToString( parameters + .get(key)); + parms.add(new Parameterization(parameter, val)); } else { - parms ~= new Parameterization(parameter, - stringcast(value)); + parms.add(new Parameterization(parameter, + stringcast(parameters.get(key)))); } } } // convert the parameters to an Parameterization array and create // the command - return new ParameterizedCommand(command, parms ); + return new ParameterizedCommand(command, arraycast!(Parameterization)( parms + .toArray())); } catch (NotDefinedException e) { } catch (ParameterValueConversionException e) { } @@ -611,15 +588,15 @@ * values (<code>String</code>). This map is never * <code>null</code>, but may be empty. */ - public final Map!(String,String) getParameterMap() { + public final Map getParameterMap() { if ((parameterizations is null) || (parameterizations.length is 0)) { - return EMPTY_MAP; + return Collections.EMPTY_MAP; } - auto parameterMap = new HashMap!(String,String); + Map parameterMap = new HashMap(); for (int i = 0; i < parameterizations.length; i++) { Parameterization parameterization = parameterizations[i]; - parameterMap.add(parameterization.getParameter().getId(), + parameterMap.put(parameterization.getParameter().getId(), parameterization.getValue()); } return parameterMap;
--- a/dwtx/core/commands/common/HandleObjectManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/common/HandleObjectManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,11 +16,8 @@ import dwtx.core.commands.common.HandleObject; import dwtx.core.commands.common.EventManager; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; -import tango.util.collection.HashSet; -import tango.util.collection.HashMap; -import tango.util.collection.model.Set; -import tango.util.collection.model.Map; // import java.util.HashMap; // import java.util.HashSet; @@ -45,18 +42,18 @@ * The set of handle objects that are defined. This value may be empty, but * it is never <code>null</code>. */ - protected const Set!(Object) definedHandleObjects; + protected const Set definedHandleObjects; /** * The map of identifiers (<code>String</code>) to handle objects ( * <code>HandleObject</code>). This collection may be empty, but it is * never <code>null</code>. */ - protected const Map!( String, Object ) handleObjectsById; + protected const Map handleObjectsById; public this(){ - definedHandleObjects = new HashSet!(Object)(); - handleObjectsById = new HashMap!( String, Object )(); + definedHandleObjects = new HashSet(); + handleObjectsById = new HashMap(); } /** @@ -84,11 +81,13 @@ * @return The set of defined handle object identifiers; this value may be * empty, but it is never <code>null</code>. */ - protected final HashSet!(String) getDefinedHandleObjectIds() { - HashSet!(String) definedHandleObjectIds = new HashSet!(String)(/+definedHandleObjects - .size()+/); - foreach ( v; definedHandleObjects.elements() ) { - auto handleObject = cast(HandleObject)v; + protected final HashSet getDefinedHandleObjectIds() { + HashSet definedHandleObjectIds = new HashSet(definedHandleObjects + .size()); + Iterator handleObjectItr = definedHandleObjects.iterator(); + while (handleObjectItr.hasNext()) { + HandleObject handleObject = cast(HandleObject) handleObjectItr + .next(); String id = handleObject.getId(); definedHandleObjectIds.add(id); }
--- a/dwtx/core/commands/contexts/Context.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/contexts/Context.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,9 +12,6 @@ *******************************************************************************/ module dwtx.core.commands.contexts.Context; -import tango.util.collection.HashSet; -// import tango.util.Iterator; -import tango.util.collection.model.Set; import dwtx.core.commands.contexts.ContextEvent; import dwtx.core.commands.contexts.IContextListener; @@ -23,6 +20,7 @@ import dwtx.core.internal.commands.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; @@ -61,7 +59,7 @@ * The collection of all objects listening to changes on this context. This * value is <code>null</code> if there are no listeners. */ - private Set!(IContextListener) listeners = null; + private Set listeners = null; /** * The parent identifier for this context. The meaning of a parent is @@ -95,10 +93,10 @@ } if (listeners is null) { - listeners = new HashSet!(IContextListener); + listeners = new HashSet(); } - listeners.add(listener); + listeners.add(cast(Object)listener); } /* (non-Javadoc) @@ -184,7 +182,10 @@ return; } - foreach( listener; listeners){ + Iterator listenerItr = listeners.iterator(); + while (listenerItr.hasNext()) { + IContextListener listener = cast(IContextListener) listenerItr + .next(); listener.contextChanged(event); } } @@ -231,9 +232,9 @@ return; } - listeners.remove(contextListener); + listeners.remove(cast(Object)contextListener); - if (listeners.drained()) { + if (listeners.isEmpty()) { listeners = null; } }
--- a/dwtx/core/commands/contexts/ContextManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/contexts/ContextManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,10 +13,6 @@ module dwtx.core.commands.contexts.ContextManager; -import tango.util.collection.HashSet; -import tango.util.collection.model.Set; -import tango.util.collection.model.SetView; - import dwtx.core.commands.contexts.IContextListener; import dwtx.core.commands.contexts.IContextManagerListener; import dwtx.core.commands.contexts.ContextEvent; @@ -27,6 +23,7 @@ import dwtx.core.internal.commands.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -58,8 +55,8 @@ * The set of active context identifiers. This value may be empty, but it is * never <code>null</code>. */ - private Set!(String) activeContextIds; - private static Set!(String) EMPTY_SET; + private Set activeContextIds; + private static Set EMPTY_SET; // allow the ContextManager to send one event for a larger delta private bool caching = false; @@ -68,12 +65,12 @@ private bool activeContextsChange = false; - private Set!(String) oldIds = null; + private Set oldIds = null; public this(){ - activeContextIds = new HashSet!(String); + activeContextIds = new HashSet(); if( EMPTY_SET is null ){ - EMPTY_SET = new HashSet!(String); + EMPTY_SET = new HashSet(); } } @@ -107,7 +104,7 @@ if (caching) { activeContextIds.add(contextId); } else { - Set!(String) previouslyActiveContextIds = activeContextIds.duplicate(); + Set previouslyActiveContextIds = new HashSet(activeContextIds); activeContextIds.add(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, @@ -115,7 +112,7 @@ } if (DEBUG) { - Tracing.printTrace("CONTEXTS", SetToString(activeContextIds)); //$NON-NLS-1$ + Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } } @@ -178,8 +175,8 @@ * the set is not <code>null</code>, then it contains only * instances of <code>String</code>. */ - public final SetView!(String) getActiveContextIds() { - return /+Collections.unmodifiableSet(+/activeContextIds/+)+/; + public final Set getActiveContextIds() { + return Collections.unmodifiableSet(activeContextIds); } /** @@ -198,7 +195,7 @@ Context context = cast(Context) handleObjectsById.get(contextId); if (context is null) { context = new Context(contextId); - handleObjectsById.add(contextId, context); + handleObjectsById.put(contextId, context); context.addContextListener(this); } @@ -211,7 +208,7 @@ * @return The set of defined context identifiers; this value may be empty, * but it is never <code>null</code>. */ - public final Set!(String) getDefinedContextIds() { + public final Set getDefinedContextIds() { return getDefinedHandleObjectIds(); } @@ -223,8 +220,8 @@ * @since 3.2 */ public final Context[] getDefinedContexts() { - return cast(Context[]) definedHandleObjects - .toArray(/+new Context[definedHandleObjects.size()]+/); + return arraycast!(Context)( definedHandleObjects + .toArray(/+new Context[definedHandleObjects.size()]+/)); } /** @@ -243,7 +240,7 @@ if (caching) { activeContextIds.remove(contextId); } else { - auto previouslyActiveContextIds = activeContextIds.dup; + Set previouslyActiveContextIds = new HashSet(activeContextIds); activeContextIds.remove(contextId); fireContextManagerChanged(new ContextManagerEvent(this, null, @@ -251,18 +248,9 @@ } if (DEBUG) { - Tracing.printTrace("CONTEXTS", SetToString(activeContextIds)); //$NON-NLS-1$ + Tracing.printTrace("CONTEXTS", activeContextIds.toString()); //$NON-NLS-1$ } } - private String SetToString( Set!(String) set ){ - String s = "["; - foreach( id; set ){ - if( s.length > 1 ) s ~= ", "; - s ~= id; - } - s ~= "]"; - return s; - } /** * Removes a listener from this context manager. * @@ -283,23 +271,24 @@ * The new set of active context identifiers; may be * <code>null</code>. */ - public final void setActiveContextIds(Set!(String) activeContextIds) { - if (Util.equals(this.activeContextIds.toArray, activeContextIds.toArray)) { + public final void setActiveContextIds(Set activeContextIds) { + if (Util.equals(cast(Object)this.activeContextIds, cast(Object)activeContextIds)) { return; } activeContextsChange = true; - Set!(String) previouslyActiveContextIds = this.activeContextIds; + Set previouslyActiveContextIds = this.activeContextIds; if (activeContextIds !is null) { - this.activeContextIds = activeContextIds.duplicate; + this.activeContextIds = new HashSet(); + this.activeContextIds.addAll(activeContextIds); } else { this.activeContextIds = null; } if (DEBUG) { Tracing.printTrace("CONTEXTS", (activeContextIds is null) ? "none" //$NON-NLS-1$ //$NON-NLS-2$ - : SetToString(activeContextIds)); + : activeContextIds.toString()); } if (!caching) { @@ -322,10 +311,10 @@ } caching = cache; bool fireChange = activeContextsChange; - Set!(String) holdOldIds = (oldIds is null? EMPTY_SET : oldIds ); + Set holdOldIds = (oldIds is null?Collections.EMPTY_SET:oldIds); if (caching) { - oldIds = activeContextIds.duplicate; + oldIds = new HashSet(activeContextIds); } else { oldIds = null; }
--- a/dwtx/core/commands/contexts/ContextManagerEvent.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/contexts/ContextManagerEvent.d Thu Aug 07 15:01:33 2008 +0200 @@ -11,12 +11,12 @@ * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwtx.core.commands.contexts.ContextManagerEvent; -import tango.util.collection.model.Set; import dwtx.core.commands.contexts.ContextManager; import dwtx.core.commands.common.AbstractBitSetEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -55,7 +55,7 @@ * change occurred. If the active contexts did not changed, then this value * is <code>null</code>. */ - private const Set!(String) previouslyActiveContextIds; + private const Set previouslyActiveContextIds; /** * Creates a new instance of this class. @@ -82,7 +82,7 @@ public this(ContextManager contextManager, String contextId, bool contextIdAdded, bool activeContextsChanged, - Set!(String) previouslyActiveContextIds) { + Set previouslyActiveContextIds) { if (contextManager is null) { throw new NullPointerException(); } @@ -131,7 +131,7 @@ * guaranteed to not be <code>null</code> if * haveActiveContextsChanged() is <code>true</code>. */ - public final Set!(String) getPreviouslyActiveContextIds() { + public final Set getPreviouslyActiveContextIds() { return previouslyActiveContextIds; }
--- a/dwtx/core/commands/operations/AbstractOperation.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/operations/AbstractOperation.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,9 +12,6 @@ *******************************************************************************/ module dwtx.core.commands.operations.AbstractOperation; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; - import dwtx.core.commands.ExecutionException; import dwtx.core.runtime.Assert; import dwtx.core.runtime.IAdaptable; @@ -25,6 +22,7 @@ import dwtx.core.commands.operations.IUndoContext; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; @@ -43,7 +41,7 @@ * @since 3.1 */ public abstract class AbstractOperation : IUndoableOperation { - Seq!(IUndoContext) contexts; + List contexts; private String label = ""; //$NON-NLS-1$ @@ -57,7 +55,7 @@ public this(String label) { Assert.isNotNull(label); this.label = label; - contexts = new ArraySeq!(IUndoContext); + contexts = new ArrayList(); } /* @@ -68,8 +66,8 @@ * <p> Subclasses may override this method. </p> */ public void addContext(IUndoContext context) { - if (!contexts.contains(context)) { - contexts.append(context); + if (!contexts.contains(cast(Object)context)) { + contexts.add(cast(Object)context); } } @@ -127,7 +125,7 @@ public abstract IStatus execute(IProgressMonitor monitor, IAdaptable info); public final IUndoContext[] getContexts() { - return contexts.toArray(); + return arraycast!(IUndoContext)(contexts.toArray()); } /* @@ -160,7 +158,7 @@ public final bool hasContext(IUndoContext context) { Assert.isNotNull(cast(Object)context); for (int i = 0; i < contexts.size(); i++) { - IUndoContext otherContext = contexts.get(i); + IUndoContext otherContext = cast(IUndoContext)contexts.get(i); // have to check both ways because one context may be more general // in // its matching rules than another. @@ -188,7 +186,7 @@ */ public void removeContext(IUndoContext context) { - contexts.remove(context); + contexts.remove(cast(Object)context); } /*
--- a/dwtx/core/commands/operations/DefaultOperationHistory.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/operations/DefaultOperationHistory.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,11 +12,6 @@ *******************************************************************************/ module dwtx.core.commands.operations.DefaultOperationHistory; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; - import dwtx.core.commands.ExecutionException; import dwtx.core.commands.util.Tracing; import dwtx.core.runtime.Assert; @@ -40,6 +35,7 @@ import dwtx.core.commands.operations.IAdvancedUndoableOperation; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -129,7 +125,7 @@ /** * a map of undo limits per context */ - private Map!(IUndoContext,Integer) limits; + private Map limits; /** * the list of {@link IOperationHistoryListener}s @@ -139,12 +135,12 @@ /** * the list of operations available for redo, LIFO */ - private ArraySeq!(IUndoableOperation) redoList; + private List redoList; /** * the list of operations available for undo, LIFO */ - private ArraySeq!(IUndoableOperation) undoList; + private List undoList; /** * a lock that is used to synchronize access between the undo and redo @@ -172,10 +168,10 @@ openCompositeLock = new Object(); undoRedoHistoryLock = new Object(); approvers = new ListenerList(ListenerList.IDENTITY); - limits = new HashMap!(IUndoContext,Integer); + limits = Collections.synchronizedMap(new HashMap()); listeners = new ListenerList(ListenerList.IDENTITY); - redoList = new ArraySeq!(IUndoableOperation); - undoList = new ArraySeq!(IUndoableOperation); + redoList = Collections.synchronizedList(new ArrayList()); + undoList = Collections.synchronizedList(new ArrayList()); } /* @@ -203,7 +199,7 @@ if (checkUndoLimit(operation)) { synchronized (undoRedoHistoryLock) { - undoList.append(operation); + undoList.add(cast(Object)operation); } notifyAdd(operation); @@ -345,7 +341,7 @@ } flushUndo(context); flushRedo(context); - synchronized(limits) limits.removeKey(context); + limits.remove(cast(Object)context); return; } if (flushUndo_) { @@ -396,9 +392,9 @@ if (status.isOK()) { bool addedToUndo = true; synchronized (undoRedoHistoryLock) { - synchronized(redoList) redoList.remove(operation); + redoList.remove(cast(Object)operation); if (checkUndoLimit(operation)) { - undoList.append(operation); + undoList.add(cast(Object)operation); } else { addedToUndo = false; } @@ -455,9 +451,9 @@ if (status.isOK()) { bool addedToRedo = true; synchronized (undoRedoHistoryLock) { - undoList.remove(operation); + undoList.remove(cast(Object)operation); if (checkRedoLimit(operation)) { - synchronized(redoList) redoList.append(operation); + redoList.add(cast(Object)operation); } else { addedToRedo = false; } @@ -557,7 +553,7 @@ /* * Filter the specified list to include only the specified undo context. */ - private IUndoableOperation[] filter(Seq!(IUndoableOperation) list, IUndoContext context) { + private IUndoableOperation[] filter(List list, IUndoContext context) { /* * This method is used whenever there is a need to filter the undo or * redo history on a particular context. Currently there are no caches @@ -567,20 +563,19 @@ * the global history changes. */ - auto filtered = new ArraySeq!(IUndoableOperation); - filtered.capacity(list.size()); -// Iterator iterator = list.iterator(); + List filtered = new ArrayList(); + Iterator iterator = list.iterator(); synchronized (undoRedoHistoryLock) { - foreach( operation; list ){ -// while (iterator.hasNext()) { -// IUndoableOperation operation = (IUndoableOperation) iterator -// .next(); + while (iterator.hasNext()) { + IUndoableOperation operation = cast(IUndoableOperation) iterator + .next(); if (operation.hasContext(context)) { - filtered.append(operation); + filtered.add(cast(Object)operation); } } } - return filtered.toArray(); + return arraycast!(IUndoableOperation)( filtered + .toArray()); } /* @@ -594,12 +589,12 @@ IUndoableOperation[] filtered = filter(redoList, context); for (int i = 0; i < filtered.length; i++) { - IUndoableOperation operation = filtered[i]; + IUndoableOperation operation = cast(IUndoableOperation) filtered[i]; if (context is GLOBAL_UNDO_CONTEXT || operation.getContexts().length is 1) { // remove the operation if it only has the context or we are // flushing all - synchronized(redoList) redoList.remove(operation); + redoList.remove(cast(Object)operation); internalRemove(operation); } else { // remove the reference to the context. @@ -614,7 +609,7 @@ } } if (operation.getContexts().length is 0) { - synchronized(redoList) redoList.remove(operation); + redoList.remove(cast(Object)operation); internalRemove(operation); } } @@ -633,12 +628,12 @@ // Get all operations that have the context (or one that matches) IUndoableOperation[] filtered = filter(undoList, context); for (int i = 0; i < filtered.length; i++) { - IUndoableOperation operation = filtered[i]; + IUndoableOperation operation = cast(IUndoableOperation) filtered[i]; if (context is GLOBAL_UNDO_CONTEXT || operation.getContexts().length is 1) { // remove the operation if it only has the context or we are // flushing all - synchronized(undoList) undoList.remove(operation); + undoList.remove(cast(Object)operation); internalRemove(operation); } else { // remove the reference to the context. @@ -653,7 +648,7 @@ } } if (operation.getContexts().length is 0) { - synchronized(undoList) undoList.remove(operation); + undoList.remove(cast(Object)operation); internalRemove(operation); } } @@ -694,14 +689,14 @@ if (size > 0) { int index = 0; while (size > max) { - IUndoableOperation removed = filtered[index]; + IUndoableOperation removed = cast(IUndoableOperation)filtered[index]; if (context is GLOBAL_UNDO_CONTEXT || removed.getContexts().length is 1) { /* * remove the operation if we are enforcing a global limit * or if the operation only has the specified context */ - synchronized(redoList) redoList.remove(removed); + redoList.remove(cast(Object)removed); internalRemove(removed); } else { /* @@ -727,14 +722,14 @@ if (size > 0) { int index = 0; while (size > max) { - IUndoableOperation removed = filtered[index]; + IUndoableOperation removed = cast(IUndoableOperation)filtered[index]; if (context is GLOBAL_UNDO_CONTEXT || removed.getContexts().length is 1) { /* * remove the operation if we are enforcing a global limit * or if the operation only has the specified context */ - synchronized(undoList) undoList.remove(removed); + undoList.remove(cast(Object)removed); internalRemove(removed); } else { /* @@ -756,12 +751,10 @@ * @see dwtx.core.commands.operations.IOperationHistory#getLimit() */ public int getLimit(IUndoContext context) { - synchronized(limits) { - if (!limits.containsKey(context)) { - return DEFAULT_LIMIT; - } - return (cast(Integer) (limits.get(context))).intValue(); + if (!limits.containsKey(cast(Object)context)) { + return DEFAULT_LIMIT; } + return (cast(Integer) (limits.get(cast(Object)context))).intValue(); } /* @@ -808,8 +801,8 @@ Assert.isNotNull(cast(Object)context); synchronized (undoRedoHistoryLock) { for (int i = redoList.size() - 1; i >= 0; i--) { - IUndoableOperation operation; - synchronized(redoList) operation = cast(IUndoableOperation) redoList.get(i); + IUndoableOperation operation = cast(IUndoableOperation) redoList + .get(i); if (operation.hasContext(context)) { return operation; } @@ -862,8 +855,8 @@ Assert.isNotNull(cast(Object)context); synchronized (undoRedoHistoryLock) { for (int i = undoList.size() - 1; i >= 0; i--) { - IUndoableOperation operation; - synchronized(undoList) operation = cast(IUndoableOperation) undoList.get(i); + IUndoableOperation operation = cast(IUndoableOperation) undoList + .get(i); if (operation.hasContext(context)) { return operation; } @@ -1173,37 +1166,25 @@ // check the undo history first. bool inUndo = false; synchronized (undoRedoHistoryLock) { - int index = 0; - synchronized(undoList) { - foreach( o; undoList ){ - if( o == operation ){ - break; - } - index++; - } - if( index is undoList.size() ){ - index = -1; - } - } + int index = undoList.indexOf(cast(Object)operation); if (index > -1) { inUndo = true; - synchronized(undoList) undoList.remove(operation); + undoList.remove(cast(Object)operation); // notify listeners after the lock on undoList is released - auto allContexts = new ArraySeq!(IUndoContext); - allContexts.capacity(replacements.length); + ArrayList allContexts = new ArrayList(replacements.length); for (int i = 0; i < replacements.length; i++) { IUndoContext[] opContexts = replacements[i].getContexts(); for (int j = 0; j < opContexts.length; j++) { - allContexts.append(opContexts[j]); + allContexts.add(cast(Object)opContexts[j]); } - synchronized(undoList) undoList.addAt(index, replacements[i]); + undoList.add(index, cast(Object)replacements[i]); // notify listeners after the lock on the history is // released } // recheck all the limits. We do this at the end so the index // doesn't change during replacement for (int i = 0; i < allContexts.size(); i++) { - IUndoContext context = allContexts.get(i); + IUndoContext context = cast(IUndoContext) allContexts.get(i); forceUndoLimit(context, getLimit(context)); } } @@ -1220,31 +1201,19 @@ // operation was not in the undo history. Check the redo history. synchronized (undoRedoHistoryLock) { - int index = 0; - synchronized(redoList) { - foreach( o; redoList ){ - if( o == operation ){ - break; - } - index++; - } - if( index is redoList.size() ){ - index = -1; - } - } + int index = redoList.indexOf(cast(Object)operation); if (index is -1) { return; } - auto allContexts = new ArraySeq!(IUndoContext); - allContexts.capacity(replacements.length); - synchronized(redoList) redoList.remove(operation); + ArrayList allContexts = new ArrayList(replacements.length); + redoList.remove(cast(Object)operation); // notify listeners after we release the lock on redoList for (int i = 0; i < replacements.length; i++) { IUndoContext[] opContexts = replacements[i].getContexts(); for (int j = 0; j < opContexts.length; j++) { - allContexts.append(opContexts[j]); + allContexts.add(cast(Object)opContexts[j]); } - synchronized(redoList) redoList.addAt(index, replacements[i]); + redoList.add(index, cast(Object)replacements[i]); // notify listeners after we release the lock on redoList } // recheck all the limits. We do this at the end so the index @@ -1277,7 +1246,7 @@ * override this if a global limit is desired. */ Assert.isNotNull(cast(Object)context); - synchronized(limits) limits.add(context, new Integer(limit)); + limits.put(cast(Object)context, new Integer(limit)); forceUndoLimit(context, limit); forceRedoLimit(context, limit); @@ -1418,7 +1387,7 @@ * @see dwtx.core.commands.operations.IOperationHistory#operationChanged(dwtx.core.commands.operations.IUndoableOperation) */ public void operationChanged(IUndoableOperation operation) { - if (undoList.contains(operation) || redoList.contains(operation)) { + if (undoList.contains(cast(Object)operation) || redoList.contains(cast(Object)operation)) { notifyChanged(operation); } }
--- a/dwtx/core/commands/operations/ObjectUndoContext.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/operations/ObjectUndoContext.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,13 +12,11 @@ *******************************************************************************/ module dwtx.core.commands.operations.ObjectUndoContext; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; - import dwtx.core.commands.operations.UndoContext; import dwtx.core.commands.operations.IUndoContext; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -35,7 +33,7 @@ private String label; - private Seq!(IUndoContext) children; + private List children; /** * Construct an operation context that represents the given object. @@ -59,7 +57,7 @@ public this(Object object, String label) { this.object = object; this.label = label; - children = new ArraySeq!(IUndoContext); + children = new ArrayList(); } /* @@ -98,7 +96,7 @@ * the context to be added as a match of this context */ public void addMatch(IUndoContext context) { - children.append(context); + children.add(cast(Object)context); } /** @@ -112,7 +110,7 @@ * context */ public void removeMatch(IUndoContext context) { - children.remove(context); + children.remove(cast(Object)context); } /* @@ -123,7 +121,7 @@ */ public override bool matches(IUndoContext context) { // Check first for explicit matches that have been assigned. - if (children.contains(context)) { + if (children.contains(cast(Object)context)) { return true; } // Contexts for equal objects are considered matching
--- a/dwtx/core/commands/operations/TriggeredOperations.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/core/commands/operations/TriggeredOperations.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,9 +12,6 @@ *******************************************************************************/ module dwtx.core.commands.operations.TriggeredOperations; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; - import dwtx.core.commands.ExecutionException; import dwtx.core.runtime.IAdaptable; import dwtx.core.runtime.IProgressMonitor; @@ -32,6 +29,7 @@ import dwtx.core.commands.operations.OperationHistoryEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * Triggered operations are a specialized implementation of a composite @@ -56,7 +54,7 @@ private IOperationHistory history; - private Seq!(IUndoableOperation) children; + private List children; /** * Construct a composite triggered operations using the specified undoable @@ -71,7 +69,7 @@ public this(IUndoableOperation operation, IOperationHistory history) { super(operation.getLabel()); - children = new ArraySeq!(IUndoableOperation); + children = new ArrayList(); triggeringOperation = operation; recomputeContexts(); this.history = history; @@ -83,7 +81,7 @@ * @see dwtx.core.commands.operations.IUndoableOperation#add(dwtx.core.commands.operations.IUndoableOperation) */ public void add(IUndoableOperation operation) { - children.append(operation); + children.add(cast(Object)operation); recomputeContexts(); } @@ -101,14 +99,14 @@ // operation will be disposed as part of replacing it. We don't want // the children to be disposed since they are to replace this // operation. - Seq!(IUndoableOperation) childrenToRestore = children.dup; - children = new ArraySeq!(IUndoableOperation); + List childrenToRestore = new ArrayList(children); + children = new ArrayList(0); recomputeContexts(); operation.dispose(); // now replace the triggering operation - history.replaceOperation(this, childrenToRestore.toArray()); + history.replaceOperation(this, arraycast!(IUndoableOperation)(childrenToRestore.toArray())); } else { - children.remove(operation); + children.remove(cast(Object)operation); operation.dispose(); recomputeContexts(); } @@ -142,12 +140,12 @@ recompute = true; } // the triggering operation remains, check all the children - auto toBeRemoved = new ArraySeq!(IUndoableOperation); + auto toBeRemoved = new ArrayList(); for (int i = 0; i < children.size(); i++) { IUndoableOperation child = cast(IUndoableOperation) children.get(i); if (child.hasContext(context)) { if (child.getContexts().length is 1) { - toBeRemoved.append(child); + toBeRemoved.add(cast(Object)child); } else { child.removeContext(context); } @@ -197,7 +195,7 @@ public override IStatus redo(IProgressMonitor monitor, IAdaptable info) { if (triggeringOperation !is null) { history.openOperation(this, IOperationHistory.REDO); - Seq!(IUndoableOperation) childrenToRestore = children.dup; + List childrenToRestore = new ArrayList(children); try { removeAllChildren(); IStatus status = triggeringOperation.redo(monitor, info); @@ -229,7 +227,7 @@ public override IStatus undo(IProgressMonitor monitor, IAdaptable info) { if (triggeringOperation !is null) { history.openOperation(this, IOperationHistory.UNDO); - auto childrenToRestore = children.dup; + List childrenToRestore = new ArrayList(children); try { removeAllChildren(); IStatus status = triggeringOperation.undo(monitor, info); @@ -293,7 +291,7 @@ */ public override void dispose() { for (int i = 0; i < children.size(); i++) { - children.get(i).dispose(); + (cast(IUndoableOperation)children.get(i)).dispose(); } if (triggeringOperation !is null) { triggeringOperation.dispose(); @@ -304,18 +302,19 @@ * Recompute contexts in light of some change in the children */ private void recomputeContexts() { - auto allContexts = new ArraySeq!(IUndoContext); + ArrayList allContexts = new ArrayList(); if (triggeringOperation !is null) { IUndoContext[] contexts = triggeringOperation.getContexts(); for (int i = 0; i < contexts.length; i++) { - allContexts.append(contexts[i]); + allContexts.add(cast(Object)contexts[i]); } } for (int i = 0; i < children.size(); i++) { - IUndoContext[] contexts = children.get(i).getContexts(); + IUndoContext[] contexts = (cast(IUndoableOperation)children.get(i)) + .getContexts(); for (int j = 0; j < contexts.length; j++) { - if (!allContexts.contains(contexts[j])) { - allContexts.append(contexts[j]); + if (!allContexts.contains(cast(Object)contexts[j])) { + allContexts.add(cast(Object)contexts[j]); } } } @@ -327,9 +326,10 @@ * Remove all non-triggering children */ private void removeAllChildren() { - IUndoableOperation[] nonTriggers = children.toArray(); + IUndoableOperation[] nonTriggers = arraycast!(IUndoableOperation)(children + .toArray()); for (int i = 0; i < nonTriggers.length; i++) { - children.remove(nonTriggers[i]); + children.remove(cast(Object)nonTriggers[i]); nonTriggers[i].dispose(); } } @@ -431,7 +431,7 @@ } // Now check all the children for (int i = 0; i < children.size(); i++) { - IUndoableOperation child = children.get(i); + IUndoableOperation child = cast(IUndoableOperation)children.get(i); if (child.hasContext(original)) { if ( auto c = cast(IContextReplacingOperation)child ) { c.replaceContext(
--- a/dwtx/dwtxhelper/Collection.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/dwtxhelper/Collection.d Thu Aug 07 15:01:33 2008 +0200 @@ -2,20 +2,60 @@ import dwt.dwthelper.utils; +static import tango.core.Exception; static import tango.util.container.CircularList; static import tango.util.container.HashMap; static import tango.util.container.HashSet; static import tango.util.container.SortedMap; static import tango.util.container.more.Vector; -interface Iterator{ +// class AListIterator { +// +// ArraySeq!(Object) c; +// int i; +// +// this( ArraySeq!(Object) c ){ +// this.c = c; +// } +// +// Object next(){ +// return c.get(++i); +// } +// Object previous(){ +// return c.get(--i); +// } +// +// bool hasNext(){ +// return i+1 < c.size(); +// } +// bool hasPrevious(){ +// return i > 0; +// } +// +// void remove(){ +// c.removeAt(i); +// if( i is c.size() ) i--; +// } +// int nextIndex(){ +// return i+1; +// } +// } + + +interface Iterator { public bool hasNext(); public Object next(); public void remove(); } +interface Enumeration { + public bool hasMoreElements(); + public Object nextElement(); +} + interface Collection { public bool add(Object o); + public bool add(String o); public bool addAll(Collection c); public void clear(); public bool contains(Object o); @@ -25,26 +65,43 @@ public bool isEmpty(); public Iterator iterator(); public bool remove(Object o); + public bool remove(String o); public bool removeAll(Collection c); public bool retainAll(Collection c); public int size(); public Object[] toArray(); public Object[] toArray(Object[] a); + + // only for D + public int opApply (int delegate(ref Object value) dg); } interface Map { + interface Entry { + int opEquals(Object o); + Object getKey(); + Object getValue(); + hash_t toHash(); + Object setValue(Object value); + } public void clear(); public bool containsKey(Object key); + public bool containsKey(String key); public bool containsValue(Object value); public Set entrySet(); public int opEquals(Object o); public Object get(Object key); + public Object get(String key); public hash_t toHash(); public bool isEmpty(); public Set keySet(); public Object put(Object key, Object value); + public Object put(String key, Object value); + public Object put(Object key, String value); + public Object put(String key, String value); public void putAll(Map t); public Object remove(Object key); + public Object remove(String key); public int size(); public Collection values(); @@ -56,6 +113,7 @@ interface List : Collection { public void add(int index, Object element); public bool add(Object o); + public bool add(String o); public bool addAll(Collection c); public bool addAll(int index, Collection c); public void clear(); @@ -72,6 +130,7 @@ public ListIterator listIterator(int index); public Object remove(int index); public bool remove(Object o); + public bool remove(String o); public bool removeAll(Collection c); public bool retainAll(Collection c); public Object set(int index, Object element); @@ -83,23 +142,50 @@ interface Set : Collection { public bool add(Object o); + public bool add(String o); public bool addAll(Collection c); public void clear(); public bool contains(Object o); + public bool contains(String o); public bool containsAll(Collection c); public int opEquals(Object o); public hash_t toHash(); public bool isEmpty(); public Iterator iterator(); public bool remove(Object o); + public bool remove(String o); public bool removeAll(Collection c); public bool retainAll(Collection c); public int size(); public Object[] toArray(); public Object[] toArray(Object[] a); + public String toString(); + + // only for D + public int opApply (int delegate(ref Object value) dg); } -interface ListIterator { + +interface SortedSet : Set { + Comparator comparator(); + Object first(); + SortedSet headSet(Object toElement); + Object last(); + SortedSet subSet(Object fromElement, Object toElement); + SortedSet tailSet(Object fromElement); +} + +interface SortedMap : Map { + Comparator comparator(); + Object firstKey(); + SortedMap headMap(Object toKey); + Object lastKey(); + SortedMap subMap(Object fromKey, Object toKey); + SortedMap tailMap(Object fromKey); +} + +interface ListIterator : Iterator { public void add(Object o); + public bool add(String o); public bool hasNext(); public bool hasPrevious(); public Object next(); @@ -109,32 +195,45 @@ public void remove(); public void set(Object o); } -class Collections { + +/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////// + class MapEntry : Map.Entry { + Map map; + Object key; + private this( Map map, Object key){ + this.map = map; + this.key = key; + } + public override int opEquals(Object o){ + if( auto other = cast(MapEntry)o){ - private static List EMPTY_LIST_; - public static List EMPTY_LIST(){ - if( EMPTY_LIST_ is null ){ - synchronized(Collections.classinfo ){ - if( EMPTY_LIST_ is null ){ - EMPTY_LIST_ = new ArrayList(0); + if(( getKey() is null ? other.getKey() is null : getKey() == other.getKey() ) && + ( getValue() is null ? other.getValue() is null : getValue() == other.getValue() )){ + return true; } + return false; } + return false; + } + public Object getKey(){ + return key; } - return EMPTY_LIST_; + public Object getValue(){ + return map.get(key); + } + public override hash_t toHash(){ + return ( getKey() is null ? 0 : getKey().toHash() ) ^ + ( getValue() is null ? 0 : getValue().toHash() ); + } + public Object setValue(Object value){ + return map.put( key, value ); + } + } - public static List unmodifiableList( List list ){ - return null; - } - public static void sort(List list){ - } - public static void sort(List list, Comparator c){ - } - static void reverse(List list) { - } -} - class HashMap : Map { + // The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. alias tango.util.container.HashMap.HashMap!(Object,Object) MapType; private MapType map; @@ -142,13 +241,14 @@ map = new MapType(); } public this(int initialCapacity){ - implMissing( __FILE__, __LINE__ ); + this(); } public this(int initialCapacity, float loadFactor){ - implMissing( __FILE__, __LINE__ ); + map = new MapType(loadFactor); } public this(Map m){ - implMissing( __FILE__, __LINE__ ); + this(); + putAll(m); } public void clear(){ map.clear(); @@ -157,12 +257,18 @@ Object v; return map.get(key, v ); } + public bool containsKey(String key){ + return containsKey(stringcast(key)); + } public bool containsValue(Object value){ return map.contains(value); } public Set entrySet(){ - implMissing( __FILE__, __LINE__ ); - return null; + HashSet res = new HashSet(); + foreach( k, v; map ){ + res.add( new MapEntry(this,k)); + } + return res; } public override int opEquals(Object o){ if( auto other = cast(HashMap) o ){ @@ -185,6 +291,9 @@ } return null; } + public Object get(String key){ + return get(stringcast(key)); + } public override hash_t toHash(){ return super.toHash(); } @@ -206,16 +315,34 @@ map[ key ] = value; return res; } + public Object put(String key, Object value){ + return put( stringcast(key), value ); + } + public Object put(Object key, String value){ + return put( key, stringcast(value) ); + } + public Object put(String key, String value){ + return put( stringcast(key), stringcast(value) ); + } public void putAll(Map t){ - implMissing( __FILE__, __LINE__ ); + foreach( k, v; t ){ + map[k] = v; + } } public Object remove(Object key){ - implMissing( __FILE__, __LINE__ ); + if( auto v = key in map ){ + Object res = *v; + map.remove(key); + return res; + } + map.remove(key); return null; } + public Object remove(String key){ + return remove(stringcast(key)); + } public int size(){ - implMissing( __FILE__, __LINE__ ); - return 0; + return map.size(); } public Collection values(){ ArrayList res = new ArrayList( size() ); @@ -234,7 +361,218 @@ } -class TreeMap : Map { +class Dictionary { + public this(){ + } + abstract Enumeration elements(); + abstract Object get(Object key); + Object get(String key){ + return get(stringcast(key)); + } + abstract bool isEmpty(); + abstract Enumeration keys(); + abstract Object put(Object key, Object value); + public Object put(String key, Object value){ + return put(stringcast(key), value); + } + public Object put(Object key, String value){ + return put(key, stringcast(value)); + } + public Object put(String key, String value){ + return put(stringcast(key), stringcast(value)); + } + abstract Object remove(Object key); + public Object remove(String key){ + return remove(stringcast(key)); + } + abstract int size(); +} + +class Hashtable : Dictionary, Map { + + public Object get(String key){ + return super.get(key); + } + public Object put(String key, Object value){ + return super.put(key, value); + } + public Object put(Object key, String value){ + return super.put(key, value); + } + public Object put(String key, String value){ + return super.put(key, value); + } + public Object remove(String key){ + return super.remove(key); + } + + // The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. + public this(){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity, float loadFactor){ + implMissing( __FILE__, __LINE__ ); + } + public this(Map t){ + implMissing( __FILE__, __LINE__ ); + } + + Enumeration elements(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Enumeration keys() { + implMissing( __FILE__, __LINE__ ); + return null; + } + public void clear(){ + implMissing( __FILE__, __LINE__ ); + } + public bool containsKey(Object key){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool containsKey(String key){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool containsValue(Object value){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public Set entrySet(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public Object get(Object key){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public bool isEmpty(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public Set keySet(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object put(Object key, Object value){ + implMissing( __FILE__, __LINE__ ); + return null; + } +// public Object put(String key, Object value) +// public Object put(Object key, String value) +// public Object put(String key, String value) + public void putAll(Map t){ + implMissing( __FILE__, __LINE__ ); + } + public Object remove(Object key){ + implMissing( __FILE__, __LINE__ ); + return null; + } +// public Object remove(String key) + public int size(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public Collection values(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public int opApply (int delegate(ref Object key, ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + +} + +abstract class AbstractMap : Map { + public this(){ + implMissing( __FILE__, __LINE__ ); + } + void clear(){ + implMissing( __FILE__, __LINE__ ); + } + protected Object clone(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + bool containsKey(Object key){ + implMissing( __FILE__, __LINE__ ); + return false; + } + bool containsValue(Object value){ + implMissing( __FILE__, __LINE__ ); + return false; + } + abstract Set entrySet(); + + public override int opEquals(Object o){ + if( Map other = cast(Map)o){ + return entrySet().opEquals( cast(Object) other.entrySet() ); + } + return false; + } + + Object get(Object key){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public override hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + bool isEmpty(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + Set keySet(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object put(Object key, Object value){ + implMissing( __FILE__, __LINE__ ); + return null; + } + void putAll(Map t){ + implMissing( __FILE__, __LINE__ ); + } + Object remove(Object key){ + implMissing( __FILE__, __LINE__ ); + return null; + } + int size(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Collection values(){ + implMissing( __FILE__, __LINE__ ); + return null; + } +} + +class TreeMap : Map, SortedMap { alias tango.util.container.SortedMap.SortedMap!(Object,Object) MapType; private MapType map; @@ -247,22 +585,32 @@ public this(Map m){ implMissing( __FILE__, __LINE__ ); } -// public this(SortedMap m){ -// implMissing( __FILE__, __LINE__ ); -// } + public this(SortedMap m){ + implMissing( __FILE__, __LINE__ ); + } public void clear(){ map.clear(); } + Comparator comparator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } public bool containsKey(Object key){ Object v; return map.get(key, v ); } + public bool containsKey(String key){ + return containsKey(stringcast(key)); + } public bool containsValue(Object value){ return map.contains(value); } public Set entrySet(){ - implMissing( __FILE__, __LINE__ ); - return null; + TreeSet res = new TreeSet(); + foreach( k, v; map ){ + res.add( new MapEntry(this,k) ); + } + return res; } public override int opEquals(Object o){ if( auto other = cast(HashMap) o ){ @@ -279,36 +627,91 @@ } return false; } + Object firstKey(){ + foreach( k; map ){ + return k; + } + throw new tango.core.Exception.NoSuchElementException( "TreeMap.firstKey" ); + } public Object get(Object key){ implMissing( __FILE__, __LINE__ ); return null; } + public Object get(String key){ + return get(stringcast(key)); + } public override hash_t toHash(){ - return super.toHash(); + // http://java.sun.com/j2se/1.4.2/docs/api/java/util/AbstractMap.html#hashCode() + hash_t res = 0; + foreach( e; entrySet() ){ + res += e.toHash(); + } + return res; + } + SortedMap headMap(Object toKey){ + implMissing( __FILE__, __LINE__ ); + return null; } public bool isEmpty(){ return map.isEmpty(); } - public Set keySet(){ + public Set keySet(){ + TreeSet res = new TreeSet(); + foreach( k; map ){ + res.add( k ); + } + return res; + } + Object lastKey(){ + Object res; + foreach( k; map ){ + res = k; + } + if( map.size() ) return res; + throw new tango.core.Exception.NoSuchElementException( "TreeMap.lastKey" ); + } + public Object put(Object key, Object value){ + if( map.contains(key) ){ // TODO if tango has opIn_r, then use the "in" operator + Object res = map[key]; + map[key] = value; + return res; + } + map[key] = value; + return null; + } + public Object put(String key, Object value){ + return put(stringcast(key), value); + } + public Object put(Object key, String value){ + return put(key, stringcast(value)); + } + public Object put(String key, String value){ + return put(stringcast(key), stringcast(value)); + } + public void putAll(Map t){ + foreach( k, v; t ){ + put( k, v ); + } + } + public Object remove(Object key){ + Object res; + map.take(key,res); + return res; + } + public Object remove(String key){ + return remove(stringcast(key)); + } + public int size(){ + return map.size(); + } + SortedMap subMap(Object fromKey, Object toKey){ implMissing( __FILE__, __LINE__ ); return null; } - public Object put(Object key, Object value){ - Object res = null; - implMissing( __FILE__, __LINE__ ); - return res; - } - public void putAll(Map t){ - implMissing( __FILE__, __LINE__ ); - } - public Object remove(Object key){ + SortedMap tailMap(Object fromKey){ implMissing( __FILE__, __LINE__ ); return null; } - public int size(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } public Collection values(){ ArrayList res = new ArrayList( size() ); foreach( k, v; map ){ @@ -344,6 +747,9 @@ public bool add(Object o){ return set.add(o); } + public bool add(String o){ + return add(stringcast(o)); + } public bool addAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -354,6 +760,9 @@ public bool contains(Object o){ return set.contains(o); } + public bool contains(String o){ + return contains(stringcast(o)); + } public bool containsAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -391,6 +800,9 @@ public bool remove(Object o){ return set.remove(o); } + public bool remove(String key){ + return remove(stringcast(key)); + } public bool removeAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -410,23 +822,500 @@ implMissing( __FILE__, __LINE__ ); return null; } + public override String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + // only for D + public int opApply (int delegate(ref Object value) dg){ + return set.opApply(dg); + } + +} + +abstract class AbstractCollection : Collection { + this(){ + } + bool add(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + bool addAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + void clear(){ + implMissing( __FILE__, __LINE__ ); + } + bool contains(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + bool containsAll(Collection c){ + if( c is null ) throw new NullPointerException(); + foreach( o; c ){ + if( !contains(o) ) return false; + } + return true; + } + override int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + bool isEmpty(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + abstract Iterator iterator(); + override hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + bool remove(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + bool remove(String o){ + return remove(stringcast(o)); + } + bool removeAll(Collection c){ + if( c is null ) throw new NullPointerException(); + bool res = false; + foreach( o; c ){ + res |= remove(o); + } + return res; + } + bool retainAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + abstract int size(); + Object[] toArray(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object[] toArray(Object[] a){ + implMissing( __FILE__, __LINE__ ); + return null; + } + String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } +} + +abstract class AbstractSet : AbstractCollection, Set { + this(){ + } + int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + bool removeAll(Collection c){ + return super.removeAll(c); + } + public abstract bool add(Object o); + public abstract bool add(String o); + public abstract bool addAll(Collection c); + public abstract void clear(); + public abstract bool contains(Object o); + public abstract bool contains(String o); + public abstract bool containsAll(Collection c); + + + public abstract bool isEmpty(); + public abstract Iterator iterator(); + public abstract bool remove(Object o); + public abstract bool remove(String o); + public abstract bool removeAll(Collection c); + public abstract bool retainAll(Collection c); + public abstract int size(); + public abstract Object[] toArray(); + public abstract Object[] toArray(Object[] a); + public abstract String toString(){ + return super.toString(); + } + + // only for D + public abstract int opApply (int delegate(ref Object value) dg); +} + +abstract class AbstractList : AbstractCollection, List { + this(){ + } + + public abstract void add(int index, Object element); + public abstract bool add(Object o); + public abstract bool addAll(Collection c); + public abstract bool addAll(int index, Collection c); + public abstract void clear(); + public abstract bool contains(Object o); + public abstract bool containsAll(Collection c); + public abstract int opEquals(Object o); + public abstract Object get(int index); + + public hash_t toHash(){ + // http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html#hashCode() + hash_t hashCode = 1; + Iterator i = iterator(); + while (i.hasNext()) { + Object obj = i.next(); + hashCode = 31 * hashCode + (obj is null ? 0 : obj.toHash()); + } + return hashCode; + } + + public abstract int indexOf(Object o); + public abstract bool isEmpty(); + public abstract Iterator iterator(); + public abstract int lastIndexOf(Object o); + public abstract ListIterator listIterator(); + public abstract ListIterator listIterator(int index); + public abstract Object remove(int index); + protected abstract void removeRange(int fromIndex, int toIndex); + public abstract bool remove(Object o); + public abstract bool remove(String o); + public abstract bool removeAll(Collection c); + public abstract bool retainAll(Collection c); + public abstract Object set(int index, Object element); + public abstract List subList(int fromIndex, int toIndex); + public abstract Object[] toArray(); + public abstract Object[] toArray(Object[] a); } +class TreeSet : AbstractSet, SortedSet { -class Vector : List { - this(){ + alias tango.util.container.SortedMap.SortedMap!(Object,int) SetType; + private SetType set; + + public this(){ + set = new SetType(); + } + public this(Collection c){ + implMissing( __FILE__, __LINE__ ); + } + public this(Comparator c){ + implMissing( __FILE__, __LINE__ ); + } + public this(SortedSet){ + implMissing( __FILE__, __LINE__ ); + } + + public bool add(Object o){ + return set.add(o, 0); + } + public bool add(String o){ + return add(stringcast(o)); + } + public bool addAll(Collection c){ + foreach( o; c ){ + add(o); + } + return true; + } + public void clear(){ + set.clear(); + } + public bool contains(Object o){ + return set.containsKey(o); + } + public bool contains(String o){ + return contains(stringcast(o)); + } + public bool containsAll(Collection c){ + foreach( o; c ){ + if( !contains(o) ){ + return false; + } + } + return true; + } + public Comparator comparator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public override int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public Object first(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public override hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public SortedSet headSet(Object toElement){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public bool isEmpty(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public Iterator iterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object last(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public bool remove(Object o){ + return false; + } + public bool remove(String key){ + return remove(stringcast(key)); + } + public bool removeAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool retainAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public int size(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public SortedSet subSet(Object fromElement, Object toElement){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public SortedSet tailSet(Object fromElement){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object[] toArray(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object[] toArray(Object[] a){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public override String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + + // only for D + public int opApply (int delegate(ref Object value) dg){ + int localDg( ref Object key, ref int value ){ + return dg( key ); + } + return set.opApply(&localDg); + } +} + +class Vector : AbstractList, List { + public this(){ + implMissing( __FILE__, __LINE__ ); + } + public this(Collection c){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity, int capacityIncrement){ + implMissing( __FILE__, __LINE__ ); + } + public void add(int index, Object element){ + implMissing( __FILE__, __LINE__ ); + } + public bool add(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool add(String o){ + return add(stringcast(o)); + } + public bool addAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool addAll(int index, Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public void addElement(Object obj){ implMissing( __FILE__, __LINE__ ); } - this(Collection c){ + public int capacity(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public void clear(){ + implMissing( __FILE__, __LINE__ ); + } + public Object clone(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public bool contains(Object elem){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool containsAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public void copyInto(Object[] anArray){ + implMissing( __FILE__, __LINE__ ); + } + public Object elementAt(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Enumeration elements(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public void ensureCapacity(int minCapacity){ + implMissing( __FILE__, __LINE__ ); + } + public int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public Object firstElement(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object get(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public int indexOf(Object elem){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public int indexOf(Object elem, int index){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public void insertElementAt(Object obj, int index){ implMissing( __FILE__, __LINE__ ); } - this(int initialCapacity){ + public bool isEmpty(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public Iterator iterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object lastElement(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public int lastIndexOf(Object elem){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public int lastIndexOf(Object elem, int index){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public ListIterator listIterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public ListIterator listIterator(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object remove(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public bool remove(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool remove(String key){ + return remove(stringcast(key)); + } + public bool removeAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public void removeAllElements(){ implMissing( __FILE__, __LINE__ ); } - this(int initialCapacity, int capacityIncrement){ + public bool removeElement(Object obj){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public void removeElementAt(int index){ + implMissing( __FILE__, __LINE__ ); + } + protected void removeRange(int fromIndex, int toIndex){ + implMissing( __FILE__, __LINE__ ); + } + public bool retainAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public Object set(int index, Object element){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public void setElementAt(Object obj, int index){ + implMissing( __FILE__, __LINE__ ); + } + public void setSize(int newSize){ + implMissing( __FILE__, __LINE__ ); + } + public int size(){ implMissing( __FILE__, __LINE__ ); + return 0; + } + public List subList(int fromIndex, int toIndex){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object[] toArray(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object[] toArray(Object[] a){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public void trimToSize(){ + implMissing( __FILE__, __LINE__ ); + } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + +} + +class Stack : Vector { + this(){ } void add(int index, Object element){ implMissing( __FILE__, __LINE__ ); @@ -435,6 +1324,9 @@ implMissing( __FILE__, __LINE__ ); return false; } + public bool add(String o){ + return add(stringcast(o)); + } bool addAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -542,177 +1434,8 @@ implMissing( __FILE__, __LINE__ ); return false; } - bool removeAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; - } - void removeAllElements(){ - implMissing( __FILE__, __LINE__ ); - } - bool removeElement(Object obj){ - implMissing( __FILE__, __LINE__ ); - return false; - } - void removeElementAt(int index){ - implMissing( __FILE__, __LINE__ ); - } - protected void removeRange(int fromIndex, int toIndex){ - implMissing( __FILE__, __LINE__ ); - } - bool retainAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; - } - Object set(int index, Object element){ - implMissing( __FILE__, __LINE__ ); - return null; - } - void setElementAt(Object obj, int index){ - implMissing( __FILE__, __LINE__ ); - } - void setSize(int newSize){ - implMissing( __FILE__, __LINE__ ); - } - int size(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - List subList(int fromIndex, int toIndex){ - implMissing( __FILE__, __LINE__ ); - return null; - } - Object[] toArray(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - Object[] toArray(Object[] a){ - implMissing( __FILE__, __LINE__ ); - return null; - } - String toString(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - void trimToSize(){ - implMissing( __FILE__, __LINE__ ); - } -} -class Stack : Vector { - this(){ - } - void add(int index, Object element){ - implMissing( __FILE__, __LINE__ ); - } - bool add(Object o){ - implMissing( __FILE__, __LINE__ ); - return false; - } - bool addAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; - } - bool addAll(int index, Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; - } - void addElement(Object obj){ - implMissing( __FILE__, __LINE__ ); - } - int capacity(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - void clear(){ - implMissing( __FILE__, __LINE__ ); - } - Object clone(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - bool contains(Object elem){ - implMissing( __FILE__, __LINE__ ); - return false; - } - bool containsAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; - } - void copyInto(Object[] anArray){ - implMissing( __FILE__, __LINE__ ); - } - Object elementAt(int index){ - implMissing( __FILE__, __LINE__ ); - return null; - } -// Enumeration elements(){ -// implMissing( __FILE__, __LINE__ ); -// return null; -// } - void ensureCapacity(int minCapacity){ - implMissing( __FILE__, __LINE__ ); - } - int opEquals(Object o){ - implMissing( __FILE__, __LINE__ ); - return false; - } - Object firstElement(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - Object get(int index){ - implMissing( __FILE__, __LINE__ ); - return null; - } - hash_t toHash(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - int indexOf(Object elem){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - int indexOf(Object elem, int index){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - void insertElementAt(Object obj, int index){ - implMissing( __FILE__, __LINE__ ); - } - bool isEmpty(){ - implMissing( __FILE__, __LINE__ ); - return false; - } - Iterator iterator(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - Object lastElement(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - int lastIndexOf(Object elem){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - int lastIndexOf(Object elem, int index){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - ListIterator listIterator(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - ListIterator listIterator(int index){ - implMissing( __FILE__, __LINE__ ); - return null; - } - Object remove(int index){ - implMissing( __FILE__, __LINE__ ); - return null; - } - bool remove(Object o){ - implMissing( __FILE__, __LINE__ ); - return false; + public bool remove(String key){ + return remove(stringcast(key)); } bool removeAll(Collection c){ implMissing( __FILE__, __LINE__ ); @@ -790,52 +1513,83 @@ implMissing( __FILE__, __LINE__ ); return 0; } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + } class LinkedList : List { + alias tango.util.container.CircularList.CircularList!(Object) ListType; + private ListType list; + + this(){ + list = new ListType(); + } + this( Collection c ){ + this(); + addAll(c); + } void add(int index, Object element){ - implMissing( __FILE__, __LINE__ ); + list.addAt(index,element); + return true; } bool add(Object o){ - implMissing( __FILE__, __LINE__ ); - return false; + list.add(o); + return true; + } + public bool add(String o){ + return add(stringcast(o)); } bool addAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; + if( c is null ) throw new NullPointerException(); + bool res = false; + foreach( o; c ){ + res |= add( o ); + } + return res; } bool addAll(int index, Collection c){ implMissing( __FILE__, __LINE__ ); return false; } - void addElement(Object obj){ - implMissing( __FILE__, __LINE__ ); + void addFirst(Object o){ + list.prepend( o ); } + void addLast(Object o){ + list.append( o ); + } +// void addElement(Object obj){ +// implMissing( __FILE__, __LINE__ ); +// } int capacity(){ implMissing( __FILE__, __LINE__ ); return 0; } void clear(){ - implMissing( __FILE__, __LINE__ ); + list.clear(); } Object clone(){ implMissing( __FILE__, __LINE__ ); return null; } bool contains(Object elem){ - implMissing( __FILE__, __LINE__ ); - return false; + return list.contains(elem); } bool containsAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; + foreach(o; c){ + if( !list.contains(o)) return false; + } + return true; } void copyInto(Object[] anArray){ implMissing( __FILE__, __LINE__ ); } Object elementAt(int index){ - implMissing( __FILE__, __LINE__ ); - return null; + return list.get(index); } // Enumeration elements(){ // implMissing( __FILE__, __LINE__ ); @@ -907,6 +1661,9 @@ implMissing( __FILE__, __LINE__ ); return false; } + public bool remove(String key){ + return remove(stringcast(key)); + } bool removeAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -914,6 +1671,14 @@ void removeAllElements(){ implMissing( __FILE__, __LINE__ ); } + Object removeFirst(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object removeLast(){ + implMissing( __FILE__, __LINE__ ); + return null; + } bool removeElement(Object obj){ implMissing( __FILE__, __LINE__ ); return false; @@ -947,12 +1712,10 @@ return null; } Object[] toArray(){ - implMissing( __FILE__, __LINE__ ); - return null; + return list.toArray(); } Object[] toArray(Object[] a){ - implMissing( __FILE__, __LINE__ ); - return null; + return list.toArray( a ); } String toString(){ implMissing( __FILE__, __LINE__ ); @@ -961,9 +1724,16 @@ void trimToSize(){ implMissing( __FILE__, __LINE__ ); } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + } -class ArrayList : List { +class ArrayList : AbstractList, List { private Object[] data; this(){ @@ -984,6 +1754,9 @@ data ~= o; return true; } + public bool add(String o){ + return add(stringcast(o)); + } bool addAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -995,6 +1768,10 @@ void clear(){ data.length = 0; } + ArrayList clone(){ + implMissing( __FILE__, __LINE__ ); + return null; + } bool contains(Object o){ foreach( v; data ){ if( o is v ){ @@ -1111,6 +1888,9 @@ implMissing( __FILE__, __LINE__ ); return false; } + public bool remove(String key){ + return remove(stringcast(key)); + } bool removeAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -1119,6 +1899,9 @@ implMissing( __FILE__, __LINE__ ); return false; } + protected void removeRange(int fromIndex, int toIndex){ + implMissing( __FILE__, __LINE__ ); + } Object set(int index, Object element){ Object res = data[index]; data[index] = element; @@ -1132,10 +1915,127 @@ return null; } Object[] toArray(){ + return data.dup; + } + Object[] toArray(Object[] a){ + if( data.length <= a.length ){ + a[ 0 .. data.length ] = data; + } + else{ + return data.dup; + } + if( data.length < a.length ){ + a[data.length] = null; + } + return a; + } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } +} + +class Arrays { + public static bool equals(Object[] a, Object[] b){ + if( a.length !is b.length ){ + return false; + } + for( int i = 0; i < a.length; i++ ){ + if( a[i] is null && b[i] is null ){ + continue; + } + if( a[i] !is null && b[i] !is null && a[i] == b[i] ){ + continue; + } + return false; + } + return true; + } + static List asList(Object[] a) { + if( a.length is 0 ) return Collections.EMPTY_LIST; + ArrayList res = new ArrayList( a.length ); + foreach( o; a ){ + res.add(o); + } + return res; + } +} + +class Collections { + + private static List EMPTY_LIST_; + public static List EMPTY_LIST(){ + if( EMPTY_LIST_ is null ){ + synchronized(Collections.classinfo ){ + if( EMPTY_LIST_ is null ){ + EMPTY_LIST_ = new ArrayList(0); + } + } + } + return EMPTY_LIST_; + } + public static Map EMPTY_MAP(){ implMissing( __FILE__, __LINE__ ); return null; } - Object[] toArray(Object[] a){ + public static Set EMPTY_SET(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static List unmodifiableList( List list ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public static Map unmodifiableMap( Map list ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public static Set unmodifiableSet( Set list ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public static Set singleton( Object o ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public static void sort(List list){ + implMissing( __FILE__, __LINE__ ); + } + public static void sort(List list, Comparator c){ + implMissing( __FILE__, __LINE__ ); + } + + static Collection synchronizedCollection(Collection c){ + implMissing( __FILE__, __LINE__ ); + return null; + } + static List synchronizedList(List list){ + implMissing( __FILE__, __LINE__ ); + return null; + } + static Map synchronizedMap(Map m){ + implMissing( __FILE__, __LINE__ ); + return null; + } + static Set synchronizedSet(Set s){ + implMissing( __FILE__, __LINE__ ); + return null; + } +// static SortedMap synchronizedSortedMap(SortedMap m){ +// implMissing( __FILE__, __LINE__ ); +// return null; +// } +// static SortedSet synchronizedSortedSet(SortedSet s){ +// implMissing( __FILE__, __LINE__ ); +// return null; +// } + static void reverse(List list) { + implMissing( __FILE__, __LINE__ ); + } + static Enumeration enumeration(Collection c){ implMissing( __FILE__, __LINE__ ); return null; }
--- a/dwtx/jface/action/ContributionManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/ContributionManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,13 +19,12 @@ import dwtx.jface.action.IContributionManagerOverrides; import dwtx.jface.action.IAction; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwtx.core.runtime.Assert; import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.io.Stdout; import tango.core.Exception; import tango.text.convert.Format; @@ -57,7 +56,7 @@ /** * The list of contribution items. */ - private Seq!(IContributionItem) contributions; + private List contributions; /** * Indicates whether the widgets are in sync with the contributions. @@ -78,7 +77,7 @@ * Creates a new contribution manager. */ protected this() { - contributions = new ArraySeq!(IContributionItem); + contributions = new ArrayList(); // Do nothing. } @@ -96,7 +95,7 @@ public void add(IContributionItem item) { Assert.isNotNull( cast(Object)item, "Item must not be null"); //$NON-NLS-1$ if (allowItem(item)) { - contributions.append(item); + contributions.add(cast(Object)item); itemAdded(item); } } @@ -118,25 +117,24 @@ private void addToGroup(String groupName, IContributionItem item, bool append) { int i; - auto items = contributions.elements(); - for (i = 0; items.more(); i++) { - IContributionItem o = cast(IContributionItem) items.get(); + auto items = contributions.iterator(); + for (i = 0; items.hasNext(); i++) { + IContributionItem o = cast(IContributionItem) items.next(); if (o.isGroupMarker()) { String id = o.getId(); if (id !is null && id.equalsIgnoreCase(groupName)) { i++; if (append) { - for (; items.more(); i++) { + for (; items.hasNext(); i++) { IContributionItem ci = cast(IContributionItem) items - .get(); + .next(); if (ci.isGroupMarker()) { break; } } } if (allowItem(item)) { - //TODO: does this corrupt the iterator? - contributions.addAt(i, item); + contributions.add(i, cast(Object)item); itemAdded(item); } return; @@ -204,9 +202,9 @@ * (non-Javadoc) Method declared on IContributionManager. */ public IContributionItem find(String id) { - auto e = contributions.elements(); - while (e.more()) { - IContributionItem item = cast(IContributionItem) e.get(); + auto e = contributions.iterator(); + while (e.hasNext()) { + IContributionItem item = cast(IContributionItem) e.next(); String itemId = item.getId(); if (itemId !is null && itemId.equalsIgnoreCase(id)) { return item; @@ -219,7 +217,8 @@ * (non-Javadoc) Method declared on IContributionManager. */ public IContributionItem[] getItems() { - return contributions.toArray(); + IContributionItem[] items = arraycast!(IContributionItem)(contributions.toArray()); + return items; } /** @@ -247,7 +246,7 @@ return null; } - public ValueWrapperInt getAccelerator(IContributionItem item) { + public Integer getAccelerator(IContributionItem item) { return null; } @@ -305,16 +304,7 @@ * @since 3.0 */ protected int indexOf(IContributionItem item) { - int res = -1; - int idx = 0; - foreach( e; contributions ){ - if( e == item ) { - res = idx; - break; - } - idx++; - } - return res; + return contributions.indexOf(cast(Object)item); } /** @@ -331,7 +321,7 @@ "inserting {} at {}", item.getId(), index)); //$NON-NLS-1$ //$NON-NLS-2$ } if (allowItem(item)) { - contributions.addAt(index, item); + contributions.add(index, cast(Object)item); itemAdded(item); } } @@ -351,11 +341,11 @@ if (ci is null) { throw new IllegalArgumentException(Format("can't find ID{}", ID));//$NON-NLS-1$ } - int ix = SeqIndexOf!(IContributionItem)( contributions, ci ); + int ix = contributions.indexOf(cast(Object)ci); if (ix >= 0) { // System.out.println("insert after: " + ix); if (allowItem(item)) { - contributions.addAt(ix + 1, item); + contributions.add(ix + 1,cast(Object) item); itemAdded(item); } } @@ -376,11 +366,11 @@ if (ci is null) { throw new IllegalArgumentException(Format("can't find ID {}", ID));//$NON-NLS-1$ } - int ix = SeqIndexOf!(IContributionItem)(contributions,ci); + int ix = contributions.indexOf(cast(Object)ci); if (ix >= 0) { // System.out.println("insert before: " + ix); if (allowItem(item)) { - contributions.addAt(ix, item); + contributions.add(ix, cast(Object)item); itemAdded(item); } } @@ -394,8 +384,8 @@ return true; } if (hasDynamicItems()) { - foreach( e; contributions ){ - IContributionItem item = cast(IContributionItem) e; + for (Iterator iter = contributions.iterator(); iter.hasNext();) { + IContributionItem item = cast(IContributionItem) iter.next(); if (item.isDirty()) { return true; } @@ -408,7 +398,7 @@ * (non-Javadoc) Method declared on IContributionManager. */ public bool isEmpty() { - return contributions.drained(); + return contributions.isEmpty(); } /** @@ -478,9 +468,7 @@ * (non-Javadoc) Method declared on IContributionManager. */ public IContributionItem remove(IContributionItem item) { - bool contained = contributions.contains(item); - contributions.remove(item); - if (contained) { + if (contributions.remove(cast(Object)item)) { itemRemoved(item); return item; } @@ -537,7 +525,7 @@ itemRemoved(oldItem); // Add the new item. - contributions.replaceAt(index, replacementItem); + contributions.set(index, cast(Object)replacementItem); itemAdded(replacementItem); // throws NPE if (replacementItem is null) // Go through and remove duplicates. @@ -547,7 +535,7 @@ if (Policy.TRACE_TOOLBAR) { Stdout.formatln("Removing duplicate on replace: {}", identifier); //$NON-NLS-1$ } - contributions.removeAt(i); + contributions.remove(i); itemRemoved(item); } } @@ -589,7 +577,7 @@ contributions.clear(); for (int i = 0; i < items.length; i++) { if (allowItem(items[i])) { - contributions.append(items[i]); + contributions.add(cast(Object)items[i]); } } }
--- a/dwtx/jface/action/CoolBarManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/CoolBarManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -23,14 +23,6 @@ import dwtx.jface.action.IMenuManager; import dwtx.jface.action.MenuManager; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; -import tango.util.collection.model.Iterator; -// import java.util.HashMap; -// import java.util.Iterator; -// import java.util.List; -// import java.util.ListIterator; - import dwt.DWT; import dwt.widgets.Composite; import dwt.widgets.Control; @@ -41,6 +33,7 @@ import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.io.Stdout; /** @@ -56,38 +49,6 @@ ICoolBarManager { alias ContributionManager.add add; - class ListIterator { - - ArraySeq!(Object) c; - int i; - - this( ArraySeq!(Object) c ){ - this.c = c; - } - - Object next(){ - return c.get(++i); - } - Object previous(){ - return c.get(--i); - } - - bool hasNext(){ - return i+1 < c.size(); - } - bool hasPrevious(){ - return i > 0; - } - - void remove(){ - c.removeAt(i); - if( i is c.size() ) i--; - } - int nextIndex(){ - return i+1; - } - } - /** * A separator created by the end user. */ @@ -96,7 +57,7 @@ /** * The original creation order of the contribution items. */ - private ArraySeq!(Object) cbItemsCreationOrder; + private ArrayList cbItemsCreationOrder; /** * MenuManager for cool bar pop-up menu, or null if none. @@ -119,7 +80,7 @@ * <code>CoolBarManager(DWT.NONE)</code>. */ public this() { - cbItemsCreationOrder = new ArraySeq!(Object); + cbItemsCreationOrder = new ArrayList(); // do nothing } @@ -148,7 +109,7 @@ * style bits */ public this(int style) { - cbItemsCreationOrder = new ArraySeq!(Object); + cbItemsCreationOrder = new ArrayList(); itemStyle = style; } @@ -172,16 +133,16 @@ * removed; this value is never <code>null</code>, but may be * empty. */ - private ArraySeq!(Object) adjustContributionList(ArraySeq!(Object) contributionList) { + private ArrayList adjustContributionList(ArrayList contributionList) { IContributionItem item; // Fist remove a separator if it is the first element of the list if (contributionList.size() !is 0) { item = cast(IContributionItem) contributionList.get(0); if (item.isSeparator()) { - contributionList.removeAt(0); + contributionList.remove(0); } - auto iterator = new ListIterator( contributionList ); + auto iterator = contributionList.listIterator(); // collapse consecutive separators while (iterator.hasNext()) { item = cast(IContributionItem) iterator.next(); @@ -201,7 +162,7 @@ item = cast(IContributionItem) contributionList.get(contributionList .size() - 1); if (item.isSeparator()) { - contributionList.removeAt(contributionList.size() - 1); + contributionList.remove(contributionList.size() - 1); } } return contributionList; @@ -443,12 +404,11 @@ * * @return an array list of contribution items. */ - private ArraySeq!(Object) getItemList() { + private ArrayList getItemList() { IContributionItem[] cbItems = getItems(); - ArraySeq!(Object) list = new ArraySeq!(Object); - list.capacity(cbItems.length); + ArrayList list = new ArrayList(cbItems.length); for (int i = 0; i < cbItems.length; i++) { - list.append( cast(Object) cbItems[i]); + list.add( cast(Object) cbItems[i]); } return list; } @@ -513,14 +473,14 @@ IContributionItem created = cast(IContributionItem) cbItemsCreationOrder .get(i); if (created.getId() !is null && created.getId().equals(item.getId())) { - cbItemsCreationOrder.replaceAt(i, cast(Object) item); + cbItemsCreationOrder.set(i, cast(Object) item); replaced = true; break; } } if (!replaced) { - cbItemsCreationOrder.addAt(Math.min(Math.max(insertedAt, 0), + cbItemsCreationOrder.add(Math.min(Math.max(insertedAt, 0), cbItemsCreationOrder.size()), cast(Object) item); } } @@ -630,12 +590,11 @@ // Traverse through all cool items in the coolbar add them to a new // data structure // in the correct order - auto displayedItems = new ArraySeq!(Object); - displayedItems.capacity(coolBar.getItemCount()); + auto displayedItems = new ArrayList(coolBar.getItemCount()); for (int i = 0; i < coolItems.length; i++) { CoolItem coolItem = coolItems[i]; if ( auto cbItem = cast(IContributionItem) coolItem.getData() ) { - displayedItems.addAt(Math.min(i, displayedItems.size()), cast(Object) cbItem); + displayedItems.add(Math.min(i, displayedItems.size()), cast(Object) cbItem); } } @@ -643,14 +602,13 @@ int offset = 0; for (int i = 1; i < wrapIndicies.length; i++) { int insertAt = wrapIndicies[i] + offset; - displayedItems.addAt(insertAt, new Separator(USER_SEPARATOR)); + displayedItems.add(insertAt, new Separator(USER_SEPARATOR)); offset++; } // Determine which rows are invisible - auto existingVisibleRows = new ArraySeq!(Object); - existingVisibleRows.capacity(4); - ListIterator rowIterator = new ListIterator( contributionList ); + auto existingVisibleRows = new ArrayList(4); + ListIterator rowIterator = contributionList.listIterator(); collapseSeparators(rowIterator); int numRow = 0; while (rowIterator.hasNext()) { @@ -659,7 +617,7 @@ IContributionItem cbItem = cast(IContributionItem) rowIterator .next(); if (displayedItems.contains(cast(Object) cbItem)) { - existingVisibleRows.append(new Integer(numRow)); + existingVisibleRows.add(new Integer(numRow)); break; } if (cbItem.isSeparator()) { @@ -670,15 +628,17 @@ numRow++; } - auto existingRows = new ListIterator( existingVisibleRows ); + auto existingRows = existingVisibleRows.iterator(); // Adjust row number to the first visible if (existingRows.hasNext()) { row = (cast(Integer) existingRows.next()).intValue(); } - auto itemLocation = new HashMap!(Object,Object); - foreach( key; displayedItems ){ - IContributionItem item = cast(IContributionItem)key; + auto itemLocation = new HashMap(); + for (ListIterator locationIterator = displayedItems.listIterator(); locationIterator + .hasNext();) { + IContributionItem item = cast(IContributionItem) locationIterator + .next(); if (item.isSeparator()) { if (existingRows.hasNext()) { Integer value = cast(Integer) existingRows.next(); @@ -687,14 +647,15 @@ row++; } } else { - itemLocation.add(cast(Object)item, new Integer(row)); + itemLocation.put(cast(Object)item, new Integer(row)); } } // Insert the contribution items in their correct location - foreach( key; displayedItems ){ - IContributionItem cbItem = cast(IContributionItem) key; + for (ListIterator iterator = displayedItems.listIterator(); iterator + .hasNext();) { + IContributionItem cbItem = cast(IContributionItem) iterator.next(); if (cbItem.isSeparator()) { coolItemIndex = 0; } else { @@ -706,7 +667,7 @@ if (contributionList.size() !is 0) { contributionList = adjustContributionList(contributionList); - auto array = arraycast!(IContributionItem)( contributionList.toArray() ); + IContributionItem[] array = arraycast!(IContributionItem)( contributionList.toArray()); internalSetItems(array); } @@ -724,26 +685,19 @@ * @param itemLocation */ private void relocate(IContributionItem cbItem, int index, - ArraySeq!(Object) contributionList, HashMap!(Object,Object) itemLocation) { + ArrayList contributionList, HashMap itemLocation) { if (!(cast(Integer)itemLocation.get(cast(Object)cbItem) )) { return; } int targetRow = (cast(Integer) itemLocation.get(cast(Object)cbItem)).intValue(); - int cbInternalIndex = -1; int idx; - foreach( el; contributionList ){ - if( el == cast(Object)cbItem){ - cbInternalIndex = idx; - break; - } - idx++; - } + int cbInternalIndex = contributionList.indexOf(cast(Object)cbItem); // by default add to end of list int insertAt = contributionList.size(); // Find the row to place this item in. - auto iterator = new ListIterator( contributionList ); + ListIterator iterator = contributionList.listIterator(); // bypass any separators at the begining collapseSeparators(iterator); int currentRow = -1; @@ -792,11 +746,11 @@ // if we didn't find the row then add a new row if (currentRow !is targetRow) { - contributionList.append(new Separator(USER_SEPARATOR)); + contributionList.add(new Separator(USER_SEPARATOR)); insertAt = contributionList.size(); } insertAt = Math.min(insertAt, contributionList.size()); - contributionList.addAt(insertAt, cast(Object) cbItem); + contributionList.add(insertAt, cast(Object) cbItem); } @@ -805,15 +759,16 @@ * order is the order in which the contribution items where added. */ public void resetItemOrder() { - auto iterator = new ListIterator( cbItemsCreationOrder ); - while( iterator.hasNext() ){ + for (ListIterator iterator = cbItemsCreationOrder.listIterator(); iterator + .hasNext();) { IContributionItem item = cast(IContributionItem) iterator.next(); // if its a user separator then do not include in original order. if ((item.getId() !is null) && (item.getId().equals(USER_SEPARATOR))) { iterator.remove(); } } - setItems( arraycast!(IContributionItem)(cbItemsCreationOrder.toArray)); + IContributionItem[] itemsToSet = arraycast!(IContributionItem)(cbItemsCreationOrder.toArray()); + setItems(itemsToSet); } /* @@ -891,12 +846,11 @@ * a cool bar. */ IContributionItem[] items = getItems(); - auto visibleItems = new ArraySeq!(Object); - visibleItems.capacity(items.length); + List visibleItems = new ArrayList(items.length); for (int i = 0; i < items.length; i++) { IContributionItem item = items[i]; if (item.isVisible()) { - visibleItems.append(cast(Object)item); + visibleItems.add(cast(Object)item); } } @@ -906,15 +860,14 @@ * to be disposed. Dynamic items are also removed. */ CoolItem[] coolItems = coolBar.getItems(); - auto coolItemsToRemove = new ArraySeq!(Object); - coolItemsToRemove.capacity(coolItems.length); + ArrayList coolItemsToRemove = new ArrayList(coolItems.length); for (int i = 0; i < coolItems.length; i++) { Object data = coolItems[i].getData(); if ((data is null) || (!visibleItems.contains(data)) || ((cast(IContributionItem)data ) && (cast(IContributionItem) data) .isDynamic())) { - coolItemsToRemove.append(coolItems[i]); + coolItemsToRemove.add(coolItems[i]); } } @@ -937,7 +890,7 @@ IContributionItem destinationItem; int sourceIndex = 0; int destinationIndex = 0; - auto visibleItemItr = new ListIterator( visibleItems ); + Iterator visibleItemItr = visibleItems.iterator(); while (visibleItemItr.hasNext()) { sourceItem = cast(IContributionItem) visibleItemItr.next(); @@ -1025,12 +978,11 @@ if (coolBar !is null) { CoolItem[] items = coolBar.getItems(); if (items !is null) { - auto children = new ArraySeq!(Object); - children.capacity(items.length); + ArrayList children = new ArrayList(items.length); for (int i = 0; i < items.length; i++) { if ((items[i].getControl() !is null) && (!items[i].getControl().isDisposed())) { - children.append(items[i].getControl()); + children.add(items[i].getControl()); } } // Convert array
--- a/dwtx/jface/action/ExternalActionManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/ExternalActionManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,10 +15,6 @@ import dwtx.jface.action.IAction; -import tango.util.collection.HashMap; -import tango.util.collection.HashSet; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; import dwt.widgets.Event; import dwtx.core.commands.Command; @@ -47,6 +43,7 @@ import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.ResourceBundle; import tango.text.convert.Format; @@ -73,11 +70,6 @@ */ public final class ExternalActionManager { - private static HashMap!(String,String) EMPTY_MAP; - static this(){ - EMPTY_MAP = new HashMap!(String,String); - } - /** * A simple implementation of the <code>ICallback</code> mechanism that * simply takes a <code>BindingManager</code> and a @@ -130,7 +122,7 @@ * will be removed from this set and the listener removed. This value * may be empty, but never <code>null</code>. */ - private const Set!(String) loggedCommandIds; + private const Set loggedCommandIds; /** * The list of listeners that have registered for property change @@ -138,7 +130,7 @@ * to listeners (<code>IPropertyChangeListener</code> or * <code>ListenerList</code> of <code>IPropertyChangeListener</code>). */ - private const Map!(String,IPropertyChangeListener) registeredListeners; + private const Map registeredListeners; static this(){ RESOURCE_BUNDLE = ResourceBundle.getBundle( @@ -219,8 +211,8 @@ CommandManager commandManager, IActiveChecker activeChecker, IExecuteApplicable checker) { - loggedCommandIds = new HashSet!(String); - registeredListeners = new HashMap!(String,IPropertyChangeListener); + loggedCommandIds = new HashSet(); + registeredListeners = new HashMap(); if (bindingManager is null) { throw new NullPointerException( "The callback needs a binding manager"); //$NON-NLS-1$ @@ -260,7 +252,7 @@ listeners.add(existing); listeners.add(cast(Object)listener); } else { - registeredListeners.add(commandId, listener); + registeredListeners.put(commandId, cast(Object)listener); } if (!bindingManagerListenerAttached) { bindingManager.addBindingManagerListener(this); @@ -270,17 +262,17 @@ public final void bindingManagerChanged(BindingManagerEvent event) { if (event.isActiveBindingsChanged()) { - foreach( k,v; registeredListeners ){ -// Iterator listenerItr = registeredListeners.entrySet() -// .iterator(); -// while (listenerItr.hasNext()) { -// Map.Entry entry = cast(Map.Entry) listenerItr.next(); - String commandId = k;//stringcast(k);// entry.getKey(); - Command command = commandManager.getCommand(commandId); + final Iterator listenerItr = registeredListeners.entrySet() + .iterator(); + while (listenerItr.hasNext()) { + Map.Entry entry = cast(Map.Entry) listenerItr.next(); + String commandId = stringcast( entry.getKey()); + Command command = commandManager + .getCommand(commandId); ParameterizedCommand parameterizedCommand = new ParameterizedCommand( command, null); if (event.isActiveBindingsChangedFor(parameterizedCommand)) { - Object value = cast(Object) v; + Object value = entry.getValue(); PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(event .getManager(), IAction.TEXT, null, null); if (null !is cast(ListenerList)value ) { @@ -301,7 +293,7 @@ /** * @see dwtx.jface.action.ExternalActionManager.ICallback#getAccelerator(String) */ - public ValueWrapperInt getAccelerator(String commandId) { + public Integer getAccelerator(String commandId) { TriggerSequence triggerSequence = bindingManager .getBestActiveBindingFor(commandId); if (triggerSequence !is null) { @@ -311,7 +303,7 @@ if ( auto keyStroke = cast(KeyStroke) trigger ) { int accelerator = SWTKeySupport .convertKeyStrokeToAccelerator(keyStroke); - return new ValueWrapperInt(accelerator); + return new Integer(accelerator); } } } @@ -422,8 +414,8 @@ IPropertyChangeListener listener) { Object existing = cast(Object) registeredListeners.get(commandId); if (existing is cast(Object)listener) { - registeredListeners.removeKey(commandId); - if (registeredListeners.drained()) { + registeredListeners.remove(commandId); + if (registeredListeners.isEmpty()) { bindingManager.removeBindingManagerListener(this); bindingManagerListenerAttached = false; } @@ -431,7 +423,7 @@ ListenerList existingList = cast(ListenerList) existing; existingList.remove(cast(Object)listener); if (existingList.size() is 1) { - registeredListeners.add(commandId, cast(IPropertyChangeListener)existingList.getListeners()[0]); + registeredListeners.put(commandId, existingList.getListeners()[0]); } } } @@ -447,7 +439,7 @@ } Command command = commandManager.getCommand(actionDefinitionId); ExecutionEvent executionEvent = new ExecutionEvent(command, - EMPTY_MAP, event, null); + Collections.EMPTY_MAP, event, null); commandManager.firePreExecute(actionDefinitionId, executionEvent); }
--- a/dwtx/jface/action/LegacyActionTools.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/LegacyActionTools.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,13 +13,12 @@ module dwtx.jface.action.LegacyActionTools; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; import dwt.DWT; import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; @@ -42,7 +41,7 @@ * * @see #findKeyCode */ - private static Map!(String,Object) keyCodes = null; + private static Map keyCodes = null; /** * Table of string representations of keys (key type: <code>Integer</code>, @@ -51,7 +50,7 @@ * * @see #findKeyString */ - private static Map!(Object,String) keyStrings = null; + private static Map keyStrings = null; /** * The localized uppercase version of ALT @@ -75,7 +74,7 @@ * * @see #findLocalizedKeyCode */ - private static Map!(String,Object) localizedKeyCodes = null; + private static Map localizedKeyCodes = null; /** * The localized uppercase version of SHIFT @@ -310,7 +309,7 @@ } int i = keyCode & ~(DWT.CTRL | DWT.ALT | DWT.SHIFT | DWT.COMMAND); Integer integer = new Integer(i); - String result = keyStrings.get(integer); + String result = stringcast(keyStrings.get(integer)); if (result !is null) { return result; } @@ -483,178 +482,178 @@ * Initializes the internal key code table. */ private static final void initKeyCodes() { - keyCodes = new HashMap!(String,Object); + keyCodes = new HashMap(); - keyCodes.add("BACKSPACE", new Integer(8)); //$NON-NLS-1$ - keyCodes.add("TAB", new Integer(9)); //$NON-NLS-1$ - keyCodes.add("RETURN", new Integer(13)); //$NON-NLS-1$ - keyCodes.add("ENTER", new Integer(13)); //$NON-NLS-1$ - keyCodes.add("ESCAPE", new Integer(27)); //$NON-NLS-1$ - keyCodes.add("ESC", new Integer(27)); //$NON-NLS-1$ - keyCodes.add("DELETE", new Integer(127)); //$NON-NLS-1$ + keyCodes.put(stringcast("BACKSPACE"), new Integer(8)); //$NON-NLS-1$ + keyCodes.put(stringcast("TAB"), new Integer(9)); //$NON-NLS-1$ + keyCodes.put(stringcast("RETURN"), new Integer(13)); //$NON-NLS-1$ + keyCodes.put(stringcast("ENTER"), new Integer(13)); //$NON-NLS-1$ + keyCodes.put(stringcast("ESCAPE"), new Integer(27)); //$NON-NLS-1$ + keyCodes.put(stringcast("ESC"), new Integer(27)); //$NON-NLS-1$ + keyCodes.put(stringcast("DELETE"), new Integer(127)); //$NON-NLS-1$ - keyCodes.add("SPACE", new Integer(' ')); //$NON-NLS-1$ - keyCodes.add("ARROW_UP", new Integer(DWT.ARROW_UP)); //$NON-NLS-1$ - keyCodes.add("ARROW_DOWN", new Integer(DWT.ARROW_DOWN)); //$NON-NLS-1$ - keyCodes.add("ARROW_LEFT", new Integer(DWT.ARROW_LEFT)); //$NON-NLS-1$ - keyCodes.add("ARROW_RIGHT", new Integer(DWT.ARROW_RIGHT)); //$NON-NLS-1$ - keyCodes.add("PAGE_UP", new Integer(DWT.PAGE_UP)); //$NON-NLS-1$ - keyCodes.add("PAGE_DOWN", new Integer(DWT.PAGE_DOWN)); //$NON-NLS-1$ - keyCodes.add("HOME", new Integer(DWT.HOME)); //$NON-NLS-1$ - keyCodes.add("END", new Integer(DWT.END)); //$NON-NLS-1$ - keyCodes.add("INSERT", new Integer(DWT.INSERT)); //$NON-NLS-1$ - keyCodes.add("F1", new Integer(DWT.F1)); //$NON-NLS-1$ - keyCodes.add("F2", new Integer(DWT.F2)); //$NON-NLS-1$ - keyCodes.add("F3", new Integer(DWT.F3)); //$NON-NLS-1$ - keyCodes.add("F4", new Integer(DWT.F4)); //$NON-NLS-1$ - keyCodes.add("F5", new Integer(DWT.F5)); //$NON-NLS-1$ - keyCodes.add("F6", new Integer(DWT.F6)); //$NON-NLS-1$ - keyCodes.add("F7", new Integer(DWT.F7)); //$NON-NLS-1$ - keyCodes.add("F8", new Integer(DWT.F8)); //$NON-NLS-1$ - keyCodes.add("F9", new Integer(DWT.F9)); //$NON-NLS-1$ - keyCodes.add("F10", new Integer(DWT.F10)); //$NON-NLS-1$ - keyCodes.add("F11", new Integer(DWT.F11)); //$NON-NLS-1$ - keyCodes.add("F12", new Integer(DWT.F12)); //$NON-NLS-1$ + keyCodes.put(stringcast("SPACE"), new Integer(' ')); //$NON-NLS-1$ + keyCodes.put(stringcast("ARROW_UP"), new Integer(DWT.ARROW_UP)); //$NON-NLS-1$ + keyCodes.put(stringcast("ARROW_DOWN"), new Integer(DWT.ARROW_DOWN)); //$NON-NLS-1$ + keyCodes.put(stringcast("ARROW_LEFT"), new Integer(DWT.ARROW_LEFT)); //$NON-NLS-1$ + keyCodes.put(stringcast("ARROW_RIGHT"), new Integer(DWT.ARROW_RIGHT)); //$NON-NLS-1$ + keyCodes.put(stringcast("PAGE_UP"), new Integer(DWT.PAGE_UP)); //$NON-NLS-1$ + keyCodes.put(stringcast("PAGE_DOWN"), new Integer(DWT.PAGE_DOWN)); //$NON-NLS-1$ + keyCodes.put(stringcast("HOME"), new Integer(DWT.HOME)); //$NON-NLS-1$ + keyCodes.put(stringcast("END"), new Integer(DWT.END)); //$NON-NLS-1$ + keyCodes.put(stringcast("INSERT"), new Integer(DWT.INSERT)); //$NON-NLS-1$ + keyCodes.put(stringcast("F1"), new Integer(DWT.F1)); //$NON-NLS-1$ + keyCodes.put(stringcast("F2"), new Integer(DWT.F2)); //$NON-NLS-1$ + keyCodes.put(stringcast("F3"), new Integer(DWT.F3)); //$NON-NLS-1$ + keyCodes.put(stringcast("F4"), new Integer(DWT.F4)); //$NON-NLS-1$ + keyCodes.put(stringcast("F5"), new Integer(DWT.F5)); //$NON-NLS-1$ + keyCodes.put(stringcast("F6"), new Integer(DWT.F6)); //$NON-NLS-1$ + keyCodes.put(stringcast("F7"), new Integer(DWT.F7)); //$NON-NLS-1$ + keyCodes.put(stringcast("F8"), new Integer(DWT.F8)); //$NON-NLS-1$ + keyCodes.put(stringcast("F9"), new Integer(DWT.F9)); //$NON-NLS-1$ + keyCodes.put(stringcast("F10"), new Integer(DWT.F10)); //$NON-NLS-1$ + keyCodes.put(stringcast("F11"), new Integer(DWT.F11)); //$NON-NLS-1$ + keyCodes.put(stringcast("F12"), new Integer(DWT.F12)); //$NON-NLS-1$ } /** * Initializes the internal key string table. */ private static void initKeyStrings() { - keyStrings = new HashMap!(Object,String); + keyStrings = new HashMap(); - keyStrings.add(new Integer(8), JFaceResources.getString("Backspace")); //$NON-NLS-1$ - keyStrings.add(new Integer(9), JFaceResources.getString("Tab")); //$NON-NLS-1$ - keyStrings.add(new Integer(13), JFaceResources.getString("Return")); //$NON-NLS-1$ - keyStrings.add(new Integer(13), JFaceResources.getString("Enter")); //$NON-NLS-1$ - keyStrings.add(new Integer(27), JFaceResources.getString("Escape")); //$NON-NLS-1$ - keyStrings.add(new Integer(27), JFaceResources.getString("Esc")); //$NON-NLS-1$ - keyStrings.add(new Integer(127), JFaceResources.getString("Delete")); //$NON-NLS-1$ + keyStrings.put(new Integer(8), stringcast(JFaceResources.getString("Backspace"))); //$NON-NLS-1$ + keyStrings.put(new Integer(9), stringcast(JFaceResources.getString("Tab"))); //$NON-NLS-1$ + keyStrings.put(new Integer(13), stringcast(JFaceResources.getString("Return"))); //$NON-NLS-1$ + keyStrings.put(new Integer(13), stringcast(JFaceResources.getString("Enter"))); //$NON-NLS-1$ + keyStrings.put(new Integer(27), stringcast(JFaceResources.getString("Escape"))); //$NON-NLS-1$ + keyStrings.put(new Integer(27), stringcast(JFaceResources.getString("Esc"))); //$NON-NLS-1$ + keyStrings.put(new Integer(127), stringcast(JFaceResources.getString("Delete"))); //$NON-NLS-1$ - keyStrings.add(new Integer(' '), JFaceResources.getString("Space")); //$NON-NLS-1$ + keyStrings.put(new Integer(cast(int)' '), stringcast(JFaceResources.getString("Space"))); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.ARROW_UP), JFaceResources - .getString("Arrow_Up")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.ARROW_DOWN), JFaceResources - .getString("Arrow_Down")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.ARROW_LEFT), JFaceResources - .getString("Arrow_Left")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.ARROW_RIGHT), JFaceResources - .getString("Arrow_Right")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.PAGE_UP), JFaceResources - .getString("Page_Up")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.PAGE_DOWN), JFaceResources - .getString("Page_Down")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.HOME), JFaceResources.getString("Home")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.END), JFaceResources.getString("End")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.INSERT), JFaceResources - .getString("Insert")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F1), JFaceResources.getString("F1")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F2), JFaceResources.getString("F2")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F3), JFaceResources.getString("F3")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F4), JFaceResources.getString("F4")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F5), JFaceResources.getString("F5")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F6), JFaceResources.getString("F6")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F7), JFaceResources.getString("F7")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F8), JFaceResources.getString("F8")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F9), JFaceResources.getString("F9")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F10), JFaceResources.getString("F10")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F11), JFaceResources.getString("F11")); //$NON-NLS-1$ - keyStrings.add(new Integer(DWT.F12), JFaceResources.getString("F12")); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.ARROW_UP), stringcast(JFaceResources + .getString("Arrow_Up"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.ARROW_DOWN), stringcast(JFaceResources + .getString("Arrow_Down"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.ARROW_LEFT), stringcast(JFaceResources + .getString("Arrow_Left"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.ARROW_RIGHT), stringcast(JFaceResources + .getString("Arrow_Right"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.PAGE_UP), stringcast(JFaceResources + .getString("Page_Up"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.PAGE_DOWN), stringcast(JFaceResources + .getString("Page_Down"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.HOME), stringcast(JFaceResources.getString("Home"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.END), stringcast(JFaceResources.getString("End"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.INSERT), stringcast(JFaceResources + .getString("Insert"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F1), stringcast(JFaceResources.getString("F1"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F2), stringcast(JFaceResources.getString("F2"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F3), stringcast(JFaceResources.getString("F3"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F4), stringcast(JFaceResources.getString("F4"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F5), stringcast(JFaceResources.getString("F5"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F6), stringcast(JFaceResources.getString("F6"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F7), stringcast(JFaceResources.getString("F7"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F8), stringcast(JFaceResources.getString("F8"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F9), stringcast(JFaceResources.getString("F9"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F10), stringcast(JFaceResources.getString("F10"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F11), stringcast(JFaceResources.getString("F11"))); //$NON-NLS-1$ + keyStrings.put(new Integer(DWT.F12), stringcast(JFaceResources.getString("F12"))); //$NON-NLS-1$ } /** * Initializes the localized internal key code table. */ private static void initLocalizedKeyCodes() { - localizedKeyCodes = new HashMap!(String,Object); + localizedKeyCodes = new HashMap(); - localizedKeyCodes.add(JFaceResources - .getString("Backspace").toUpperCase(), new Integer(8)); //$NON-NLS-1$ - localizedKeyCodes.add( - JFaceResources.getString("Tab").toUpperCase(), new Integer(9)); //$NON-NLS-1$ + localizedKeyCodes.put(stringcast(JFaceResources + .getString("Backspace").toUpperCase()), new Integer(8)); //$NON-NLS-1$ + localizedKeyCodes.put( + stringcast(JFaceResources.getString("Tab").toUpperCase()), new Integer(9)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Return").toUpperCase(), new Integer(13)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Return").toUpperCase()), new Integer(13)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Enter").toUpperCase(), new Integer(13)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Enter").toUpperCase()), new Integer(13)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Escape").toUpperCase(), new Integer(27)); //$NON-NLS-1$ - localizedKeyCodes.add( - JFaceResources.getString("Esc").toUpperCase(), new Integer(27)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Escape").toUpperCase()), new Integer(27)); //$NON-NLS-1$ + localizedKeyCodes.put( + stringcast(JFaceResources.getString("Esc").toUpperCase()), new Integer(27)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Delete").toUpperCase(), new Integer(127)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Delete").toUpperCase()), new Integer(127)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Space").toUpperCase(), new Integer(' ')); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Space").toUpperCase()), new Integer(' ')); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Arrow_Up").toUpperCase(), new Integer(DWT.ARROW_UP)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Arrow_Up").toUpperCase()), new Integer(DWT.ARROW_UP)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Arrow_Down").toUpperCase(), new Integer(DWT.ARROW_DOWN)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Arrow_Down").toUpperCase()), new Integer(DWT.ARROW_DOWN)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Arrow_Left").toUpperCase(), new Integer(DWT.ARROW_LEFT)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Arrow_Left").toUpperCase()), new Integer(DWT.ARROW_LEFT)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Arrow_Right").toUpperCase(), new Integer(DWT.ARROW_RIGHT)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Arrow_Right").toUpperCase()), new Integer(DWT.ARROW_RIGHT)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Page_Up").toUpperCase(), new Integer(DWT.PAGE_UP)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Page_Up").toUpperCase()), new Integer(DWT.PAGE_UP)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Page_Down").toUpperCase(), new Integer(DWT.PAGE_DOWN)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Page_Down").toUpperCase()), new Integer(DWT.PAGE_DOWN)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Home").toUpperCase(), new Integer(DWT.HOME)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Home").toUpperCase()), new Integer(DWT.HOME)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("End").toUpperCase(), new Integer(DWT.END)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("End").toUpperCase()), new Integer(DWT.END)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("Insert").toUpperCase(), new Integer(DWT.INSERT)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("Insert").toUpperCase()), new Integer(DWT.INSERT)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F1").toUpperCase(), new Integer(DWT.F1)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F1").toUpperCase()), new Integer(DWT.F1)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F2").toUpperCase(), new Integer(DWT.F2)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F2").toUpperCase()), new Integer(DWT.F2)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F3").toUpperCase(), new Integer(DWT.F3)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F3").toUpperCase()), new Integer(DWT.F3)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F4").toUpperCase(), new Integer(DWT.F4)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F4").toUpperCase()), new Integer(DWT.F4)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F5").toUpperCase(), new Integer(DWT.F5)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F5").toUpperCase()), new Integer(DWT.F5)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F6").toUpperCase(), new Integer(DWT.F6)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F6").toUpperCase()), new Integer(DWT.F6)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F7").toUpperCase(), new Integer(DWT.F7)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F7").toUpperCase()), new Integer(DWT.F7)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F8").toUpperCase(), new Integer(DWT.F8)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F8").toUpperCase()), new Integer(DWT.F8)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F9").toUpperCase(), new Integer(DWT.F9)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F9").toUpperCase()), new Integer(DWT.F9)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F10").toUpperCase(), new Integer(DWT.F10)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F10").toUpperCase()), new Integer(DWT.F10)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F11").toUpperCase(), new Integer(DWT.F11)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F11").toUpperCase()), new Integer(DWT.F11)); //$NON-NLS-1$ localizedKeyCodes - .add( - JFaceResources.getString("F12").toUpperCase(), new Integer(DWT.F12)); //$NON-NLS-1$ + .put( + stringcast(JFaceResources.getString("F12").toUpperCase()), new Integer(DWT.F12)); //$NON-NLS-1$ } /**
--- a/dwtx/jface/action/MenuManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/MenuManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,8 +24,6 @@ import dwtx.jface.action.IAction; import dwtx.jface.action.ExternalActionManager; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwt.DWT; import dwt.events.MenuAdapter; @@ -45,6 +43,7 @@ import dwtx.jface.resource.LocalResourceManager; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** @@ -334,8 +333,8 @@ } IContributionItem item = super.find(id); - if (auto mm = cast(IMenuManager)item ) { - return mm.findUsingPath(rest); + if (auto manager = cast(IMenuManager)item ) { + return manager.findUsingPath(rest); } return null; } @@ -430,7 +429,7 @@ if (overrides is null) { if (parent is null) { overrides = new class IContributionManagerOverrides { - public ValueWrapperInt getAccelerator(IContributionItem item) { + public Integer getAccelerator(IContributionItem item) { return null; } @@ -764,8 +763,7 @@ if (menuExist()) { // clean contains all active items without double separators IContributionItem[] items = getItems(); - auto clean = new ArraySeq!(IContributionItem); - clean.capacity(items.length); + List clean = new ArrayList(items.length); IContributionItem separator = null; for (int i = 0; i < items.length; ++i) { IContributionItem ci = items[i]; @@ -779,11 +777,11 @@ } else { if (separator !is null) { if (clean.size() > 0) { - clean.append(separator); + clean.add(cast(Object)separator); } separator = null; } - clean.append(ci); + clean.add(cast(Object)ci); } } @@ -793,11 +791,7 @@ for (int i = 0; i < mi.length; i++) { Object data = mi[i].getData(); - bool clean_contains = false; - foreach( ci; clean ){ - if( cast(Object)ci == data ) clean_contains = true; - } - if (data is null || !clean_contains) { + if (data is null || !clean.contains(data)) { mi[i].dispose(); } else if (cast(IContributionItem)data && (cast(IContributionItem) data).isDynamic() @@ -811,7 +805,8 @@ int srcIx = 0; int destIx = 0; - foreach( src; clean ){ + for (Iterator e = clean.iterator(); e.hasNext();) { + IContributionItem src = cast(IContributionItem) e.next(); IContributionItem dest; // get corresponding item in DWT widget @@ -904,11 +899,12 @@ .getInstance().getCallback(); if (callback !is null) { - int index = dwt.dwthelper.utils.indexOf( text, '&' ); + int index = .indexOf( text, '&' ); // DWT collision with local indexOf - if (index >= 0 && index < text.length - 1) { - char character = CharacterToUpper(text - .charAt(index + 1)); + if (index >= 0 && index < text.length - 1) { + + dchar character = CharacterToUpper(text + [index + 1 .. $].firstCodePoint()); if (callback.isAcceleratorInUse(DWT.ALT | character)) { if (index is 0) {
--- 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();
--- 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); } }
--- a/dwtx/jface/action/ToolBarContributionItem.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/ToolBarContributionItem.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,7 +24,6 @@ import dwtx.jface.action.Separator; import dwtx.jface.action.IContributionManager; -import tango.util.collection.ArraySeq; // import java.util.Iterator; import dwt.DWT; @@ -47,6 +46,7 @@ import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.io.Stdout; /** @@ -375,12 +375,12 @@ ToolBar toolBar = cast(ToolBar) control; Rectangle toolBarBounds = toolBar.getBounds(); ToolItem[] items = toolBar.getItems(); - auto hidden = new ArraySeq!(Object); + ArrayList hidden = new ArrayList(); for (int i = 0; i < items.length; ++i) { Rectangle itemBounds = items[i].getBounds(); if (!((itemBounds.x + itemBounds.width <= toolBarBounds.width) && (itemBounds.y + itemBounds.height <= toolBarBounds.height))) { - hidden.append(items[i]); + hidden.add(items[i]); } } @@ -389,8 +389,8 @@ chevronMenuManager.dispose(); } chevronMenuManager = new MenuManager(); - foreach( it; hidden ){ - ToolItem toolItem = cast(ToolItem) it; + for (Iterator i = hidden.iterator(); i.hasNext();) { + ToolItem toolItem = cast(ToolItem) i.next(); IContributionItem data = cast(IContributionItem) toolItem.getData(); if (cast(ActionContributionItem)data ) { ActionContributionItem contribution = new ActionContributionItem(
--- a/dwtx/jface/action/ToolBarManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/action/ToolBarManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,7 +17,6 @@ import dwtx.jface.action.MenuManager; import dwtx.jface.action.IContributionItem; -import tango.util.collection.ArraySeq; // import java.util.Iterator; import dwt.DWT; @@ -35,6 +34,7 @@ import dwt.widgets.ToolItem; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A tool bar manager is a contribution manager which realizes itself and its @@ -254,8 +254,7 @@ // clean contains all active items without double separators IContributionItem[] items = getItems(); - auto clean = new ArraySeq!(Object); - clean.capacity(items.length); + ArrayList clean = new ArrayList(items.length); IContributionItem separator = null; // long cleanStartTime= 0; // if (DEBUG) { @@ -274,11 +273,11 @@ } else { if (separator !is null) { if (clean.size() > 0) { - clean.append(cast(Object)separator); + clean.add(cast(Object)separator); } separator = null; } - clean.append(cast(Object)ci); + clean.add(cast(Object)ci); } } // if (DEBUG) { @@ -288,15 +287,14 @@ // determine obsolete items (removed or non active) ToolItem[] mi = toolBar.getItems(); - auto toRemove = new ArraySeq!(Object); - toRemove.capacity(mi.length); + ArrayList toRemove = new ArrayList(mi.length); for (int i = 0; i < mi.length; i++) { Object data = mi[i].getData(); if (data is null || !clean.contains(data) || (cast(IContributionItem) data && (cast(IContributionItem) data) .isDynamic())) { - toRemove.append(mi[i]); + toRemove.add(mi[i]); } } @@ -331,8 +329,9 @@ mi = toolBar.getItems(); int srcIx = 0; int destIx = 0; - foreach( e; clean ){ - src = cast(IContributionItem) e; + for (Iterator e = clean.iterator(); e.hasNext();) { + src = cast(IContributionItem) e.next(); + // get corresponding item in DWT widget if (srcIx < mi.length) {
--- a/dwtx/jface/bindings/BindingManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/BindingManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -25,14 +25,6 @@ // import java.io.BufferedWriter; // import java.io.IOException; // import java.io.StringWriter; -import tango.util.collection.HashMap; -import tango.util.collection.HashSet; -import tango.util.collection.ArraySeq; -import tango.util.collection.LinkSeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; -import tango.util.collection.model.View; import dwt.DWT; import dwtx.core.commands.CommandManager; @@ -56,6 +48,7 @@ import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; import tango.text.convert.Format; @@ -83,7 +76,6 @@ public final class BindingManager : HandleObjectManager, IContextManagerListener, ISchemeListener { - private static Map!(Object,Object) EMPTY_MAP; /** * This flag can be set to <code>true</code> if the binding manager should * print information to <code>System.out</code> when certain boundary @@ -105,7 +97,7 @@ * </p> * A utility method for adding entries to a map. The map is checked for * entries at the key. If such an entry exists, it is expected to be a - * <code>Seq!(Object)</code>. The value is then appended to the collection. + * <code>Collection</code>. The value is then appended to the collection. * If no such entry exists, then a collection is created, and the value * added to the collection. * </p> @@ -118,7 +110,7 @@ * @param value * The value to look up in the map; may be <code>null</code>. */ - private static final void addReverseLookup(Map!(Object,Object) map, Object key, + private static final void addReverseLookup(Map map, Object key, Object value) { if (map is null) { return; @@ -126,12 +118,12 @@ Object currentValue = map.get(key); if (currentValue !is null) { - auto values = cast(Seq!(Object)) currentValue; - values.append(value); + Collection values = cast(Collection) currentValue; + values.add(value); } else { // currentValue is null - auto values = new ArraySeq!(Object); - values.append(value); - map.add(key, values); + auto values = new ArrayList(1); + values.add(value); + map.put(key, values); } } @@ -161,8 +153,8 @@ return new String[0]; } - auto strings = new LinkSeq!(String); - auto stringBuffer = new StringBuffer(); + List strings = new ArrayList(); + StringBuffer stringBuffer = new StringBuffer(); string = string.trim(); // remove whitespace if (string.length > 0) { @@ -172,12 +164,13 @@ stringBuffer.append(separator); } stringBuffer.append(tok.trim()); - strings.prepend(stringBuffer.toString()); + strings.add(stringBuffer.toString()); } } - strings.append(Util.ZERO_LENGTH_STRING); - strings.append(cast(char[])null); - return strings.toArray(); + Collections.reverse(strings); + strings.add(Util.ZERO_LENGTH_STRING); + strings.add(""); + return stringcast(strings.toArray()); } /** @@ -186,7 +179,7 @@ * This value will only be <code>null</code> if the active bindings have * not yet been computed. Otherwise, this value may be empty. */ - private Map!(Object,Object) activeBindings = null; + private Map activeBindings = null; /** * The active bindings indexed by fully-parameterized commands. This is a @@ -195,9 +188,9 @@ * <code>null</code> if the active bindings have not yet been computed. * Otherwise, this value may be empty. */ - private Map!(Object,Object) activeBindingsByParameterizedCommand = null; + private Map activeBindingsByParameterizedCommand = null; - private Set!(Object) triggerConflicts; + private Set triggerConflicts; /** * The scheme that is currently active. An active scheme is the one that is @@ -223,7 +216,7 @@ /** * A cache of context IDs that weren't defined. */ - private Set!(Object) bindingErrors; + private Set bindingErrors; /** * The array of all bindings currently handled by this manager. This array @@ -238,7 +231,7 @@ * may be empty, but it is never <code>null</code>. This is a map of * <code>CachedBindingSet</code> to <code>CachedBindingSet</code>. */ - private Map!(Object,Object) cachedBindings; + private Map cachedBindings; /** * The command manager for this binding manager. This manager is only needed @@ -287,7 +280,7 @@ * to bindings (<code>Binding</code>). This value may be * <code>null</code> if there is no existing solution. */ - private Map!(Object,Object) prefixTable = null; + private Map prefixTable = null; /** * <p> @@ -306,9 +299,9 @@ */ public this(ContextManager contextManager, CommandManager commandManager) { - triggerConflicts = new HashSet!(Object); - bindingErrors = new HashSet!(Object); - cachedBindings = new HashMap!(Object,Object); + triggerConflicts = new HashSet(); + bindingErrors = new HashSet(); + cachedBindings = new HashMap(); locale = tango.text.Util.replace( Culture.current().toString().dup, '-', '_' ); locales = expand(locale, LOCALE_SEPARATOR); @@ -398,14 +391,17 @@ * trigger (<code>TriggerSequence</code>) to command identifier (<code>String</code>). * This value will never be <code>null</code>, but may be empty. */ - private final Map!(Object,Object) buildPrefixTable(Map!(Object,Object) activeBindings) { - auto prefixTable = new HashMap!(Object,Object); - foreach( k, v; activeBindings ){ - TriggerSequence triggerSequence = cast(TriggerSequence)k; + private final Map buildPrefixTable(Map activeBindings) { + Map prefixTable = new HashMap; + Iterator bindingItr = activeBindings.entrySet().iterator(); + while (bindingItr.hasNext()) { + Map.Entry entry = cast(Map.Entry) bindingItr.next(); + TriggerSequence triggerSequence = cast(TriggerSequence) entry + .getKey(); // Add the perfect match. if (!prefixTable.containsKey(triggerSequence)) { - prefixTable.add(triggerSequence, null); + prefixTable.put(triggerSequence, cast(Object)null); } TriggerSequence[] prefixes = triggerSequence.getPrefixes(); @@ -415,16 +411,16 @@ } // Break apart the trigger sequence. - Binding binding = cast(Binding) v; + Binding binding = cast(Binding) entry.getValue(); for (int i = 0; i < prefixesLength; i++) { TriggerSequence prefix = prefixes[i]; Object value = prefixTable.get(prefix); - if ((prefixTable.containsKey(prefix)) && (cast(Map!(Object,Object))value )) { - (cast(Map!(Object,Object)) value).add(triggerSequence, binding); + if ((prefixTable.containsKey(prefix)) && (cast(Map)value )) { + (cast(Map) value).put(triggerSequence, binding); } else { - auto map = new HashMap!(Object,Object); - prefixTable.add(prefix, map); - map.add(triggerSequence, binding); + Map map = new HashMap(); + prefixTable.put(prefix, cast(Object)map); + map.put(triggerSequence, binding); } } } @@ -529,9 +525,9 @@ * needed), or empty (indicating that this map should be * computed). */ - private final void computeBindings(Map!(Object,Object) activeContextTree, - Map!(Object,Object) bindingsByTrigger, Map!(Object,Object) triggersByCommandId, - Map!(Object,Object) conflictsByTrigger) { + private final void computeBindings(Map activeContextTree, + Map bindingsByTrigger, Map triggersByCommandId, + Map conflictsByTrigger) { /* * FIRST PASS: Remove all of the bindings that are marking deletions. */ @@ -541,7 +537,7 @@ * SECOND PASS: Just throw in bindings that match the current state. If * there is more than one match for a binding, then create a list. */ - auto possibleBindings = new HashMap!(Object,Object); + Map possibleBindings = new HashMap(); int length = trimmedBindings.length; for (int i = 0; i < length; i++) { Binding binding = trimmedBindings[i]; @@ -550,7 +546,7 @@ // Check the context. String contextId = binding.getContextId(); if ((activeContextTree !is null) - && (!activeContextTree.containsKey( new ArrayWrapperString(contextId)))) { + && (!activeContextTree.containsKey( stringcast(contextId)))) { continue; } @@ -584,17 +580,17 @@ Object existingMatch = possibleBindings.get(trigger); if (cast(Binding)existingMatch ) { possibleBindings.remove(trigger); - auto matches = new ArraySeq!(Object); - matches.append(existingMatch); - matches.append(binding); - possibleBindings.add(trigger, matches); + Collection matches = new ArrayList; + matches.add(existingMatch); + matches.add(binding); + possibleBindings.put(trigger, cast(Object)matches); - } else if (cast(Seq!(Object))existingMatch ) { - auto matches = cast(Seq!(Object)) existingMatch; - matches.append(binding); + } else if (cast(Collection)existingMatch ) { + auto matches = cast(Collection) existingMatch; + matches.add(binding); } else { - possibleBindings.add(trigger, binding); + possibleBindings.put(trigger, binding); } } @@ -607,13 +603,12 @@ * further logic to try to resolve them. If the conflict can't be * resolved, then we log the problem. */ - foreach( k,v; possibleBindings ){ -// Iterator possibleBindingItr = possibleBindings.entrySet() -// .iterator(); -// while (possibleBindingItr.hasNext()) { -// Map.Entry entry = cast(Map.Entry) possibleBindingItr.next(); - TriggerSequence trigger = cast(TriggerSequence) k;//entry.getKey(); - Object match = v;//entry.getValue(); + Iterator possibleBindingItr = possibleBindings.entrySet() + .iterator(); + while (possibleBindingItr.hasNext()) { + Map.Entry entry = cast(Map.Entry) possibleBindingItr.next(); + TriggerSequence trigger = cast(TriggerSequence) entry.getKey(); + Object match = entry.getValue(); /* * What we do depends slightly on whether we are trying to build a * list of all possible bindings (disregarding context), or a flat @@ -621,22 +616,21 @@ */ if (activeContextTree is null) { // We are building the list of all possible bindings. - auto bindings = new ArraySeq!(Object); + Collection bindings = new ArrayList; if (cast(Binding)match ) { - bindings.append(match); - bindingsByTrigger.add(trigger, bindings); + bindings.add(match); + bindingsByTrigger.put(trigger, cast(Object)bindings); addReverseLookup(triggersByCommandId, (cast(Binding) match) .getParameterizedCommand(), trigger); - } else if (cast(View!(Object))match ) { - bindings.append( (cast(View!(Object)) match).elements ); - bindingsByTrigger.add(trigger, bindings); + } else if (cast(Collection)match ) { + bindings.addAll( cast(Collection) match); + bindingsByTrigger.put(trigger, cast(Object)bindings); - foreach( e; bindings ){ -// Iterator matchItr = bindings.iterator(); -// while (matchItr.hasNext()) { + Iterator matchItr = bindings.iterator(); + while (matchItr.hasNext()) { addReverseLookup(triggersByCommandId, - (cast(Binding) e) + (cast(Binding) matchItr.next()) .getParameterizedCommand(), trigger); } } @@ -645,18 +639,17 @@ // We are building the flat map of trigger to commands. if (cast(Binding)match ) { Binding binding = cast(Binding) match; - bindingsByTrigger.add(trigger, binding); + bindingsByTrigger.put(trigger, binding); addReverseLookup(triggersByCommandId, binding .getParameterizedCommand(), trigger); - } else if (cast(Seq!(Object))match ) { - Binding winner = resolveConflicts(cast(Seq!(Object)) match, + } else if (cast(Collection)match ) { + Binding winner = resolveConflicts(cast(Collection) match, activeContextTree); if (winner is null) { // warn once ... so as not to flood the logs - conflictsByTrigger.add(trigger, match); - if (!triggerConflicts.contains(trigger)) { - triggerConflicts.add(trigger); + conflictsByTrigger.put(trigger, match); + if (!triggerConflicts.add(trigger)) { // StringWriter sw = new StringWriter(); // BufferedWriter buffer = new BufferedWriter(sw); StringBuffer sb = new StringBuffer(); @@ -664,11 +657,10 @@ sb.append("A conflict occurred for "); //$NON-NLS-1$ sb.append(trigger.toString()); sb.append(':'); - foreach( e; cast(Seq!(Object)) match){ -// Iterator i = (cast(Seq!(Object)) match).iterator(); -// while (i.hasNext()) { + Iterator i = (cast(Collection) match).iterator(); + while (i.hasNext()) { sb.append('\n'); - sb.append( e.toString() ); + sb.append( i.next().toString() ); } } catch (IOException e) { // we should not get this @@ -683,7 +675,7 @@ Tracing.printTrace("BINDINGS", " " ~ match.toString); //$NON-NLS-1$ //$NON-NLS-2$ } } else { - bindingsByTrigger.add(trigger, winner); + bindingsByTrigger.put(trigger, winner); addReverseLookup(triggersByCommandId, winner .getParameterizedCommand(), trigger); } @@ -769,14 +761,17 @@ * @return The tree of contexts to use; may be empty, but never * <code>null</code>. The keys and values are both strings. */ - private final Map!(Object,Object) createContextTreeFor(Set!(Object) contextIds) { - auto contextTree = new HashMap!(Object,Object); + private final Map createContextTreeFor(Set contextIds) { + Map contextTree = new HashMap; - foreach( e; contextIds ){ - auto childContextId = (cast(ArrayWrapperString)e).array; + final Iterator contextIdItr = contextIds.iterator(); + while (contextIdItr.hasNext()) { + Object childContextIdObj = contextIdItr.next(); + String childContextId = stringcast (childContextIdObj); + while (childContextId !is null) { // Check if we've already got the part of the tree from here up. - if (contextTree.containsKey(/+childContextId+/e)) { + if (contextTree.containsKey(childContextIdObj)) { break; } @@ -787,7 +782,7 @@ // Add the child-parent pair to the tree. try { String parentContextId = childContext.getParentId(); - contextTree.add(new ArrayWrapperString(childContextId), new ArrayWrapperString(parentContextId)); + contextTree.put(childContextIdObj, stringcast(parentContextId)); childContextId = parentContextId; } catch (NotDefinedException e) { break; // stop ascending @@ -816,12 +811,13 @@ * @return The tree of contexts to use; may be empty, but never * <code>null</code>. The keys and values are both strings. */ - private final Map!(Object,Object) createFilteredContextTreeFor(Set!(Object) contextIds) { + private final Map createFilteredContextTreeFor(Set contextIds) { // Check to see whether a dialog or window is active. bool dialog = false; bool window = false; - foreach( e; contextIds ){ - String contextId = (cast(ArrayWrapperString) e).array; + Iterator contextIdItr = contextIds.iterator(); + while (contextIdItr.hasNext()) { + String contextId = stringcast(contextIdItr.next()); if (IContextIds.CONTEXT_ID_DIALOG.equals(contextId)) { dialog = true; continue; @@ -837,31 +833,29 @@ * or window, and the corresponding dialog or window context is not * active. */ - foreach( e; contextIds.dup ){ - String contextId = (cast(ArrayWrapperString) e).array; + contextIdItr = contextIds.iterator(); + while (contextIdItr.hasNext()) { + String contextId = stringcast( contextIdItr.next()); Context context = contextManager.getContext(contextId); try { String parentId = context.getParentId(); while (parentId !is null) { if (IContextIds.CONTEXT_ID_DIALOG.equals(parentId)) { if (!dialog) { - contextIds.remove(e); -// contextIdItr.remove(); + contextIdItr.remove(); } break; } if (IContextIds.CONTEXT_ID_WINDOW.equals(parentId)) { if (!window) { - contextIds.remove(e); -// contextIdItr.remove(); + contextIdItr.remove(); } break; } if (IContextIds.CONTEXT_ID_DIALOG_AND_WINDOW .equals(parentId)) { if ((!window) && (!dialog)) { - contextIds.remove(e); -// contextIdItr.remove(); + contextIdItr.remove(); } break; } @@ -872,13 +866,12 @@ } catch (NotDefinedException e) { // since this context was part of an undefined hierarchy, // I'm going to yank it out as a bad bet - contextIds.remove(e); -// contextIdItr.remove(); + contextIdItr.remove(); // This is a logging optimization, only log the error once. - if (context is null || !bindingErrors.contains(new ArrayWrapperString(context.getId()))) { + if (context is null || !bindingErrors.contains(stringcast(context.getId()))) { if (context !is null) { - bindingErrors.add(new ArrayWrapperString(context.getId())); + bindingErrors.add(stringcast(context.getId())); } // now log like you've never logged before! @@ -933,7 +926,7 @@ * This value may be <code>null</code> if there are no active * bindings, and it may be empty. */ - private final Map!(Object,Object) getActiveBindings() { + private final Map getActiveBindings() { if (activeBindings is null) { recomputeBindings(); } @@ -957,7 +950,7 @@ * currently active. This value may be <code>null</code> if there * are no active bindings, and it may be empty. */ - private final Map!(Object,Object) getActiveBindingsByParameterizedCommand() { + private final Map getActiveBindingsByParameterizedCommand() { if (activeBindingsByParameterizedCommand is null) { recomputeBindings(); } @@ -977,14 +970,13 @@ * </p> * * @return A map of trigger (<code>TriggerSequence</code>) to bindings ( - * <code>Seq!(Object)</code> containing <code>Binding</code>). + * <code>Collection</code> containing <code>Binding</code>). * This map may be empty, but it is never <code>null</code>. */ - public final Map!(Object,Object) getActiveBindingsDisregardingContext() { + public final Map getActiveBindingsDisregardingContext() { if (bindings is null) { // Not yet initialized. This is happening too early. Do nothing. - if( EMPTY_MAP is null ) EMPTY_MAP = new HashMap!(Object,Object); - return EMPTY_MAP; + return Collections.EMPTY_MAP; } // Build a cached binding set for that state. @@ -999,15 +991,15 @@ .get(bindingCache); if (existingCache is null) { existingCache = bindingCache; - cachedBindings.add(existingCache, existingCache); + cachedBindings.put(existingCache, existingCache); } - auto commandIdsByTrigger = existingCache.getBindingsByTrigger(); + Map commandIdsByTrigger = existingCache.getBindingsByTrigger(); if (commandIdsByTrigger !is null) { if (DEBUG) { Tracing.printTrace("BINDINGS", "Cache hit"); //$NON-NLS-1$ //$NON-NLS-2$ } - return commandIdsByTrigger; + return Collections.unmodifiableMap(commandIdsByTrigger); } // There is no cached entry for this. @@ -1016,15 +1008,15 @@ } // Compute the active bindings. - commandIdsByTrigger = new HashMap!(Object,Object); - auto triggersByParameterizedCommand = new HashMap!(Object,Object); - auto conflictsByTrigger = new HashMap!(Object,Object); + commandIdsByTrigger = new HashMap(); + Map triggersByParameterizedCommand = new HashMap(); + Map conflictsByTrigger = new HashMap(); computeBindings(null, commandIdsByTrigger, triggersByParameterizedCommand, conflictsByTrigger); existingCache.setBindingsByTrigger(commandIdsByTrigger); existingCache.setTriggersByCommandId(triggersByParameterizedCommand); existingCache.setConflictsByTrigger(conflictsByTrigger); - return /+Collections.unmodifiableMap(+/commandIdsByTrigger; + return Collections.unmodifiableMap(commandIdsByTrigger); } /** @@ -1039,15 +1031,14 @@ * </p> * * @return A map of trigger (<code>TriggerSequence</code>) to bindings ( - * <code>Seq!(Object)</code> containing <code>Binding</code>). + * <code>Collection</code> containing <code>Binding</code>). * This map may be empty, but it is never <code>null</code>. * @since 3.2 */ - private final Map!(Object,Object) getActiveBindingsDisregardingContextByParameterizedCommand() { + private final Map getActiveBindingsDisregardingContextByParameterizedCommand() { if (bindings is null) { // Not yet initialized. This is happening too early. Do nothing. - if( EMPTY_MAP is null ) EMPTY_MAP = new HashMap!(Object,Object); - return EMPTY_MAP; + return Collections.EMPTY_MAP; } // Build a cached binding set for that state. @@ -1062,9 +1053,9 @@ .get(bindingCache); if (existingCache is null) { existingCache = bindingCache; - cachedBindings.add(existingCache, existingCache); + cachedBindings.put(existingCache, existingCache); } - auto triggersByParameterizedCommand = existingCache + Map triggersByParameterizedCommand = existingCache .getTriggersByCommandId(); if (triggersByParameterizedCommand !is null) { if (DEBUG) { @@ -1080,16 +1071,16 @@ } // Compute the active bindings. - auto commandIdsByTrigger = new HashMap!(Object,Object); - auto conflictsByTrigger = new HashMap!(Object,Object); - triggersByParameterizedCommand = new HashMap!(Object,Object); + Map commandIdsByTrigger = new HashMap(); + Map conflictsByTrigger = new HashMap(); + triggersByParameterizedCommand = new HashMap(); computeBindings(null, commandIdsByTrigger, triggersByParameterizedCommand, conflictsByTrigger); existingCache.setBindingsByTrigger(commandIdsByTrigger); existingCache.setTriggersByCommandId(triggersByParameterizedCommand); existingCache.setConflictsByTrigger(conflictsByTrigger); - return /+Collections.unmodifiableMap(+/triggersByParameterizedCommand; + return Collections.unmodifiableMap(triggersByParameterizedCommand); } /** @@ -1107,15 +1098,16 @@ * in any fashion. This collection may be empty, but it is never * <code>null</code>. */ - public final View!(Object) getActiveBindingsDisregardingContextFlat() { - auto mergedBindings = new ArraySeq!(Object); - - foreach( k,v; getActiveBindingsDisregardingContext() ){ - auto bindingCollection = cast(View!(Object))v; - if ((bindingCollection !is null) && (!bindingCollection.drained())) { - foreach( e; bindingCollection ){ - mergedBindings.append(e); - } + public final Collection getActiveBindingsDisregardingContextFlat() { + Collection bindingCollections = getActiveBindingsDisregardingContext() + .values(); + Collection mergedBindings = new ArrayList(); + Iterator bindingCollectionItr = bindingCollections.iterator(); + while (bindingCollectionItr.hasNext()) { + Collection bindingCollection = cast(Collection) bindingCollectionItr + .next(); + if ((bindingCollection !is null) && (!bindingCollection.isEmpty())) { + mergedBindings.addAll(bindingCollection); } } @@ -1146,10 +1138,10 @@ ParameterizedCommand parameterizedCommand) { Object object = getActiveBindingsDisregardingContextByParameterizedCommand() .get(parameterizedCommand); - if (auto collection = cast(Seq!(Object))object ) { - return arraycast!(TriggerSequence)(collection.toArray()); + if (auto collection = cast(Collection)object ) { + return arraycast!(TriggerSequence)( collection + .toArray()); } - return EMPTY_TRIGGER_SEQUENCE; } @@ -1175,8 +1167,9 @@ ParameterizedCommand parameterizedCommand) { Object object = getActiveBindingsByParameterizedCommand().get( parameterizedCommand); - if ( auto collection = cast(Seq!(Object))object ) { - return arraycast!(TriggerSequence)(collection.toArray()); + if ( auto collection = cast(Collection)object ) { + return arraycast!(TriggerSequence)(collection + .toArray(new TriggerSequence[collection.size()])); } return EMPTY_TRIGGER_SEQUENCE; @@ -1225,7 +1218,7 @@ return null; } - auto activeBindings = getActiveBindings(); + Map activeBindings = getActiveBindings(); if (activeBindings !is null) { Binding[] bindings = new Binding[triggers.length]; for (int i = 0; i < triggers.length; i++) { @@ -1434,7 +1427,8 @@ * <code>null</code>. */ public final Scheme[] getDefinedSchemes() { - return arraycast!(Scheme)(definedHandleObjects.toArray()); + return arraycast!(Scheme)(definedHandleObjects + .toArray(new Scheme[definedHandleObjects.size()])); } /** @@ -1468,11 +1462,10 @@ * @return A map of triggers (<code>TriggerSequence</code>) to bindings (<code>Binding</code>). * This map may be empty, but it is never <code>null</code>. */ - public final Map!(Object,Object) getPartialMatches(TriggerSequence trigger) { - auto partialMatches = cast(Map!(Object,Object)) getPrefixTable().get(trigger); + public final Map getPartialMatches(TriggerSequence trigger) { + Map partialMatches = cast(Map) getPrefixTable().get(trigger); if (partialMatches is null) { - if( EMPTY_MAP is null ) EMPTY_MAP = new HashMap!(Object,Object); - return EMPTY_MAP; + return Collections.EMPTY_MAP; } return partialMatches; @@ -1528,7 +1521,7 @@ * trigger (<code>TriggerSequence</code>) to binding (<code>Binding</code>). * This value will never be <code>null</code> but may be empty. */ - private final Map!(Object,Object) getPrefixTable() { + private final Map getPrefixTable() { if (prefixTable is null) { recomputeBindings(); } @@ -1557,7 +1550,7 @@ Scheme scheme = cast(Scheme) handleObjectsById.get(schemeId); if (scheme is null) { scheme = new Scheme(schemeId); - handleObjectsById.add(schemeId, scheme); + handleObjectsById.put(schemeId, scheme); scheme.addSchemeListener(this); } @@ -1580,9 +1573,9 @@ * <code>schemeId</code> and then ascending through its ancestors. */ private final String[] getSchemeIds(String schemeId) { - auto strings = new ArraySeq!(Object); + List strings = new ArrayList(); while (schemeId !is null) { - strings.append( stringcast(schemeId)); + strings.add( stringcast(schemeId)); try { schemeId = getScheme(schemeId).getParentId(); } catch (NotDefinedException e) { @@ -1724,18 +1717,15 @@ private final void recomputeBindings() { if (bindings is null) { // Not yet initialized. This is happening too early. Do nothing. - if( EMPTY_MAP is null ) EMPTY_MAP = new HashMap!(Object,Object); - setActiveBindings(EMPTY_MAP, EMPTY_MAP, - EMPTY_MAP, EMPTY_MAP); + setActiveBindings(Collections.EMPTY_MAP, Collections.EMPTY_MAP, + Collections.EMPTY_MAP, Collections.EMPTY_MAP); return; } // Figure out the current state. - auto activeContextIds = new HashSet!(Object); - foreach( e; contextManager.getActiveContextIds()){ - activeContextIds.add(stringcast(e)); - } - auto activeContextTree = createFilteredContextTreeFor(activeContextIds); + Set activeContextIds = new HashSet(contextManager + .getActiveContextIds()); + Map activeContextTree = createFilteredContextTreeFor(activeContextIds); // Build a cached binding set for that state. CachedBindingSet bindingCache = new CachedBindingSet( @@ -1749,9 +1739,9 @@ .get(bindingCache); if (existingCache is null) { existingCache = bindingCache; - cachedBindings.add(existingCache, existingCache); + cachedBindings.put(existingCache, existingCache); } - auto commandIdsByTrigger = existingCache.getBindingsByTrigger(); + Map commandIdsByTrigger = existingCache.getBindingsByTrigger(); if (commandIdsByTrigger !is null) { if (DEBUG) { Tracing.printTrace("BINDINGS", "Cache hit"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1768,9 +1758,9 @@ } // Compute the active bindings. - commandIdsByTrigger = new HashMap!(Object,Object); - auto triggersByParameterizedCommand = new HashMap!(Object,Object); - auto conflictsByTrigger = new HashMap!(Object,Object); + commandIdsByTrigger = new HashMap(); + Map triggersByParameterizedCommand = new HashMap(); + Map conflictsByTrigger = new HashMap(); computeBindings(activeContextTree, commandIdsByTrigger, triggersByParameterizedCommand, conflictsByTrigger); existingCache.setBindingsByTrigger(commandIdsByTrigger); @@ -1914,7 +1904,7 @@ * of <code>Binding</code>. */ private final Binding[] removeDeletions(Binding[] bindings) { - auto deletions = new HashMap!(Object,Object); + auto deletions = new HashMap; Binding[] bindingsCopy = new Binding[bindingCount]; System.arraycopy(bindings, 0, bindingsCopy, 0, bindingCount); int deletedCount = 0; @@ -1927,14 +1917,14 @@ TriggerSequence sequence = binding.getTriggerSequence(); Object currentValue = deletions.get(sequence); if (cast(Binding)currentValue ) { - auto collection = new ArraySeq!(Object); - collection.append(currentValue); - collection.append(binding); - deletions.add(sequence, collection); - } else if ( auto collection = cast(Seq!(Object))currentValue ) { - collection.append(binding); + Collection collection = new ArrayList; + collection.add(currentValue); + collection.add(binding); + deletions.put(sequence, cast(Object)collection); + } else if ( auto collection = cast(Collection)currentValue ) { + collection.add(binding); } else { - deletions.add(sequence, binding); + deletions.put(sequence, binding); } bindingsCopy[i] = null; deletedCount++; @@ -1958,12 +1948,11 @@ deletedCount++; } - } else if (cast(Seq!(Object))deletion ) { - Seq!(Object) collection = cast(Seq!(Object)) deletion; - foreach( e; collection){ -// Iterator iterator = collection.iterator(); -// while (iterator.hasNext()) { - Object deletionBinding = e;//iterator.next(); + } else if (cast(Collection)deletion ) { + Collection collection = cast(Collection) deletion; + Iterator iterator = collection.iterator(); + while (iterator.hasNext()) { + Object deletionBinding = iterator.next(); if (cast(Binding)deletionBinding ) { if ((cast(Binding) deletionBinding).deletes(binding)) { bindingsCopy[i] = null; @@ -2014,8 +2003,8 @@ * @return The binding which best matches the current state. If there is a * tie, then return <code>null</code>. */ - private final Binding resolveConflicts(View!(Object) bindings, - Map!(Object,Object) activeContextTree) { + private final Binding resolveConflicts(Collection bindings, + Map activeContextTree) { /* * This flag is used to indicate when the bestMatch binding conflicts * with another binding. We keep the best match binding so that we know @@ -2024,15 +2013,8 @@ */ bool conflict = false; -// Iterator bindingItr = bindings.iterator(); - Binding bestMatch; - bool first = true; - foreach( b; bindings ){ - if( first ){ - first = false; - bestMatch = cast(Binding) b;//bindingItr.next(); - continue; - } + Iterator bindingItr = bindings.iterator(); + Binding bestMatch = cast(Binding) bindingItr.next(); /* * Iterate over each binding and compare it with the best match. If a @@ -2040,8 +2022,8 @@ * conflict flag to false. If a conflict is found, then leave the best * match and set the conflict flag. Otherwise, just continue. */ -// while (bindingItr.hasNext()) { - Binding current = cast(Binding) b;//bindingItr.next(); + while (bindingItr.hasNext()) { + Binding current = cast(Binding) bindingItr.next(); /* * SCHEME: Test whether the current is in a child scheme. Bindings @@ -2188,11 +2170,11 @@ * This value may be <code>null</code> if there is no existing * solution. */ - private final void setActiveBindings(Map!(Object,Object) activeBindings, - Map!(Object,Object) activeBindingsByCommandId, Map!(Object,Object) prefixTable, - Map!(Object,Object) conflicts) { + private final void setActiveBindings(Map activeBindings, + Map activeBindingsByCommandId, Map prefixTable, + Map conflicts) { this.activeBindings = activeBindings; - Map!(Object,Object) previousBindingsByParameterizedCommand = this.activeBindingsByParameterizedCommand; + Map previousBindingsByParameterizedCommand = this.activeBindingsByParameterizedCommand; this.activeBindingsByParameterizedCommand = activeBindingsByCommandId; this.prefixTable = prefixTable; InternalPolicy.currentConflicts = conflicts;
--- a/dwtx/jface/bindings/BindingManagerEvent.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/BindingManagerEvent.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,15 +17,13 @@ import dwtx.jface.bindings.Scheme; import dwtx.jface.bindings.TriggerSequence; -// import tango.util.collection.Seq!(Object); -import tango.util.collection.model.Map; -import tango.util.collection.model.Seq; import dwtx.core.commands.ParameterizedCommand; import dwtx.core.commands.common.AbstractBitSetEvent; import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * An instance of this class describes changes to an instance of @@ -71,12 +69,12 @@ private const BindingManager manager; /** - * The map of triggers (<code>Seq!(Object)</code> of + * The map of triggers (<code>Collection</code> of * <code>TriggerSequence</code>) by parameterized command (<code>ParameterizedCommand</code>) * before the change occurred. This map may be empty and it may be * <code>null</code>. */ - private const Map!(Object,Object) previousTriggersByParameterizedCommand; + private const Map previousTriggersByParameterizedCommand; /** * The scheme that became defined or undefined. This value may be @@ -112,7 +110,7 @@ */ public this(BindingManager manager, bool activeBindingsChanged, - Map!(Object,Object) previousTriggersByParameterizedCommand, + Map previousTriggersByParameterizedCommand, bool activeSchemeChanged, Scheme scheme, bool schemeDefined, bool localeChanged, bool platformChanged) { @@ -192,7 +190,7 @@ .getActiveBindingsFor(parameterizedCommand); TriggerSequence[] previousBindings; if (previousTriggersByParameterizedCommand !is null) { - Seq!(Object) previousBindingCollection = cast(Seq!(Object)) previousTriggersByParameterizedCommand + Collection previousBindingCollection = cast(Collection) previousTriggersByParameterizedCommand .get(parameterizedCommand); if (previousBindingCollection is null) { previousBindings = null;
--- a/dwtx/jface/bindings/CachedBindingSet.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/CachedBindingSet.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,11 +15,11 @@ import dwtx.jface.bindings.TriggerSequence; import dwtx.jface.bindings.Binding; -import tango.util.collection.model.Map; import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -54,14 +54,14 @@ * (i.e., no parent). * </p> */ - private const Map!(Object,Object) activeContextTree; + private const Map activeContextTree; /** * The map representing the resolved state of the bindings. This is a map of * a trigger (<code>TriggerSequence</code>) to binding (<code>Binding</code>). * This value may be <code>null</code> if it has not yet been initialized. */ - private Map!(Object,Object) bindingsByTrigger = null; + private Map bindingsByTrigger = null; /** * A map of triggers to collections of bindings. If this binding set @@ -69,7 +69,7 @@ * * @since 3.3 */ - private Map!(Object,Object) conflictsByTrigger = null; + private Map conflictsByTrigger = null; /** * The hash code for this object. This value is computed lazily, and marked @@ -119,7 +119,7 @@ * to command identifier (<code>String</code>). This value is * <code>null</code> if it has not yet been initialized. */ - private Map!(Object,Object) prefixTable = null; + private Map prefixTable = null; /** * <p> @@ -142,7 +142,7 @@ * of <code>TriggerSequence</code>). This value may be <code>null</code> * if it has not yet been initialized. */ - private Map!(Object,Object) triggersByCommandId = null; + private Map triggersByCommandId = null; /** * Constructs a new instance of <code>CachedBindingSet</code>. @@ -174,7 +174,7 @@ * <code>null</code or empty. The * elements cannot be <code>null</code>. */ - this(Map!(Object,Object) activeContextTree, String[] locales, + this(Map activeContextTree, String[] locales, String[] platforms, String[] schemeIds) { if (locales is null) { throw new NullPointerException("The locales cannot be null."); //$NON-NLS-1$ @@ -235,7 +235,7 @@ * This value may be <code>null</code> if this was not yet * initialized. */ - final Map!(Object,Object) getBindingsByTrigger() { + final Map getBindingsByTrigger() { return bindingsByTrigger; } @@ -246,7 +246,7 @@ * <code>null</code>. * @since 3.3 */ - final Map!(Object,Object) getConflictsByTrigger() { + final Map getConflictsByTrigger() { return conflictsByTrigger; } @@ -261,7 +261,7 @@ * This value may be <code>null</code> if it has not yet been * initialized. */ - final Map!(Object,Object) getPrefixTable() { + final Map getPrefixTable() { return prefixTable; } @@ -273,7 +273,7 @@ * <code>TriggerSequence</code>). This value may be * <code>null</code> if this was not yet initialized. */ - final Map!(Object,Object) getTriggersByCommandId() { + final Map getTriggersByCommandId() { return triggersByCommandId; } @@ -308,7 +308,7 @@ * The map to set; must not be <code>null</code>. This is a * map of triggers (<code>TriggerSequence</code>) to binding (<code>Binding</code>). */ - final void setBindingsByTrigger(Map!(Object,Object) commandIdsByTrigger) { + final void setBindingsByTrigger(Map commandIdsByTrigger) { if (commandIdsByTrigger is null) { throw new NullPointerException( "Cannot set a null binding resolution"); //$NON-NLS-1$ @@ -324,7 +324,7 @@ * The map to set; must not be <code>null</code>. * @since 3.3 */ - final void setConflictsByTrigger(Map!(Object,Object) conflicts) { + final void setConflictsByTrigger(Map conflicts) { if (conflicts is null) { throw new NullPointerException( "Cannot set a null binding conflicts"); //$NON-NLS-1$ @@ -344,7 +344,7 @@ * identifier (<code>String</code>). Must not be * <code>null</code>. */ - final void setPrefixTable(Map!(Object,Object) prefixTable) { + final void setPrefixTable(Map prefixTable) { if (prefixTable is null) { throw new NullPointerException("Cannot set a null prefix table"); //$NON-NLS-1$ } @@ -361,7 +361,7 @@ * triggers (<code>Collection</code> of * <code>TriggerSequence</code>). */ - final void setTriggersByCommandId(Map!(Object,Object) triggersByCommandId) { + final void setTriggersByCommandId(Map triggersByCommandId) { if (triggersByCommandId is null) { throw new NullPointerException( "Cannot set a null binding resolution"); //$NON-NLS-1$
--- a/dwtx/jface/bindings/Scheme.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/Scheme.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,14 +16,13 @@ import dwtx.jface.bindings.ISchemeListener; import dwtx.jface.bindings.SchemeEvent; -import tango.util.collection.HashSet; -import tango.util.collection.model.Set; import dwtx.core.commands.common.NamedHandleObject; import dwtx.core.commands.common.NotDefinedException; import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.convert.Format; /** @@ -59,7 +58,7 @@ * The collection of all objects listening to changes on this scheme. This * value is <code>null</code> if there are no listeners. */ - private Set!(ISchemeListener) listeners = null; + private Set listeners = null; /** * The parent identifier for this scheme. This is the identifier of the @@ -95,10 +94,10 @@ } if (listeners is null) { - listeners = new HashSet!(ISchemeListener); + listeners = new HashSet(); } - listeners.add(schemeListener); + listeners.add(cast(Object)schemeListener); } /* @@ -185,8 +184,11 @@ if (listeners is null) { return; } - foreach( e; listeners ){ - ISchemeListener listener = cast(ISchemeListener)e; + + Iterator listenerItr = listeners.iterator(); + while (listenerItr.hasNext()) { + final ISchemeListener listener = cast(ISchemeListener) listenerItr + .next(); listener.schemeChanged(event); } } @@ -236,9 +238,9 @@ return; } - listeners.remove(schemeListener); + listeners.remove(cast(Object)schemeListener); - if (listeners.drained()) { + if (listeners.isEmpty()) { listeners = null; } }
--- a/dwtx/jface/bindings/keys/KeySequence.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/keys/KeySequence.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,9 +15,6 @@ import dwtx.jface.bindings.keys.KeyStroke; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwtx.jface.bindings.TriggerSequence; import dwtx.jface.bindings.keys.formatting.KeyFormatterFactory; @@ -25,6 +22,7 @@ import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import tango.text.Util; /** * <p> @@ -150,8 +148,8 @@ * must only contain instances of <code>KeyStroke</code>. * @return a key sequence. Guaranteed not to be <code>null</code>. */ - public static final KeySequence getInstance(SeqView!(KeyStroke) keyStrokes) { - return new KeySequence(keyStrokes.toArray()); + public static final KeySequence getInstance(List keyStrokes) { + return new KeySequence(arraycast!(KeyStroke)(keyStrokes.toArray())); } /** @@ -170,8 +168,6 @@ throw new NullPointerException(); } - auto keyStrokes = new ArraySeq!(KeyStroke); - try { auto tokens = tango.text.Util.delimit( string, KEY_STROKE_DELIMITERS ); KeyStroke[] keyStrokeArray = new KeyStroke[ tokens.length ];
--- a/dwtx/jface/bindings/keys/KeySequenceText.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/keys/KeySequenceText.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,11 +17,6 @@ import dwtx.jface.bindings.keys.SWTKeySupport; import dwtx.jface.bindings.keys.KeySequence; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashSet; -import tango.util.collection.model.Seq; -import tango.util.collection.model.View; -import tango.util.collection.TreeMap; import dwt.DWT; import dwt.events.DisposeEvent; @@ -41,6 +36,7 @@ import dwtx.jface.util.PropertyChangeEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -480,13 +476,13 @@ } static this(){ - HashSet!(KeyStroke) trappedKeys = new HashSet!(KeyStroke); + TreeSet trappedKeys = new TreeSet(); trappedKeys.add(SWTKeySupport.convertAcceleratorToKeyStroke(DWT.TAB)); trappedKeys.add(SWTKeySupport.convertAcceleratorToKeyStroke(DWT.TAB | DWT.SHIFT)); trappedKeys.add(SWTKeySupport.convertAcceleratorToKeyStroke(DWT.BS)); - //List trappedKeyList = new ArrayList(trappedKeys); - TRAPPED_KEYS = trappedKeys;// Collections.unmodifiableList(trappedKeyList); + List trappedKeyList = new ArrayList(trappedKeys); + TRAPPED_KEYS = Collections.unmodifiableList(trappedKeyList); } /** An empty string instance for use in clearing text values. */ @@ -511,7 +507,7 @@ * accurate. Perfection is not possible, as DWT does not export traversal * keys as constants. */ - public static const View!(KeyStroke) TRAPPED_KEYS; + public static const List TRAPPED_KEYS; /** * The key filter attached to the underlying widget that traps key events. @@ -527,7 +523,7 @@ * Those listening to changes to the key sequence in this widget. This value * may be <code>null</code> if there are no listeners. */ - private ArraySeq!(IPropertyChangeListener) listeners = null; + private Collection listeners = null; /** The maximum number of key strokes permitted in the sequence. */ private int maxStrokes = INFINITE; @@ -610,10 +606,10 @@ } if (listeners is null) { - listeners = new ArraySeq!(IPropertyChangeListener); + listeners = new ArrayList(1); } - listeners.append(listener); + listeners.add(cast(Object)listener); } /** @@ -662,13 +658,13 @@ * startTextIndex->string.length() is the first selected stroke). */ String string; - auto currentStrokes = new ArraySeq!(KeyStroke); + auto currentStrokes = new ArrayList(); int startTextIndex = 0; // keeps track of the start of the stroke int keyStrokesLength = keyStrokes.length; int i; for (i = 0; (i < keyStrokesLength) && (string.length < start); i++) { startTextIndex = string.length; - currentStrokes.append(keyStrokes[i]); + currentStrokes.add(keyStrokes[i]); string = KeySequence.getInstance(currentStrokes).format(); } @@ -696,7 +692,7 @@ } for (; (i < keyStrokesLength) && (string.length < end); i++) { - currentStrokes.append(keyStrokes[i]); + currentStrokes.add(keyStrokes[i]); string = KeySequence.getInstance(currentStrokes).format(); } endStrokeIndex = currentStrokes.size() - 1; @@ -751,9 +747,12 @@ protected final void firePropertyChangeEvent( KeySequence oldKeySequence) { if (listeners !is null) { + Iterator listenerItr = listeners.iterator(); PropertyChangeEvent event = new PropertyChangeEvent(this, P_KEY_SEQUENCE, oldKeySequence, getKeySequence()); - foreach( listener; listeners ){ + while (listenerItr.hasNext()) { + IPropertyChangeListener listener = cast(IPropertyChangeListener) listenerItr + .next(); listener.propertyChange(event); } } @@ -897,7 +896,7 @@ return; } - listeners.remove(listener); + listeners.remove(cast(Object)listener); } /** @@ -921,9 +920,9 @@ if (newKeySequence is null) { text.setText(""); //$NON-NLS-1$ } else { - keySequence = newKeySequence; + keySequence = newKeySequence; } - + // Trim any extra strokes. if (maxStrokes !is INFINITE) { KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes();
--- a/dwtx/jface/bindings/keys/SWTKeyLookup.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/keys/SWTKeyLookup.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,13 +14,12 @@ import dwtx.jface.bindings.keys.IKeyLookup; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; import dwt.DWT; import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -40,19 +39,19 @@ * The look-up table for modifier keys. This is a map of formal name (<code>String</code>) * to integer value (<code>Integer</code>). */ - private const Map!(String,Integer) modifierKeyTable; + private const Map modifierKeyTable; /** * The look-up table for formal names. This is a map of integer value (<code>Integer</code>) * to formal name (<code>String</code>). */ - private const Map!(Integer,String) nameTable; + private const Map nameTable; /** * The look-up table for natural keys. This is a map of formal name (<code>String</code>) * to integer value (<code>Integer</code>). */ - private const Map!(String,Integer) naturalKeyTable; + private const Map naturalKeyTable; /** * Constructs a new look-up class. This should only be done by the look-up @@ -61,204 +60,204 @@ * @see KeyLookupFactory */ this() { - modifierKeyTable = new HashMap!(String,Integer); - nameTable = new HashMap!(Integer,String); - naturalKeyTable = new HashMap!(String,Integer); + modifierKeyTable = new HashMap(); + nameTable = new HashMap(); + naturalKeyTable = new HashMap(); Integer alt = new Integer(DWT.ALT); Integer command = new Integer(DWT.COMMAND); Integer ctrl = new Integer(DWT.CTRL); Integer shift = new Integer(DWT.SHIFT); - modifierKeyTable.add(ALT_NAME, alt); - nameTable.add(alt, ALT_NAME); - modifierKeyTable.add(COMMAND_NAME, command); - nameTable.add(command, COMMAND_NAME); - modifierKeyTable.add(CTRL_NAME, ctrl); - nameTable.add(ctrl, CTRL_NAME); - modifierKeyTable.add(SHIFT_NAME, shift); - nameTable.add(shift, SHIFT_NAME); - modifierKeyTable.add(M1_NAME, + modifierKeyTable.put(ALT_NAME, alt); + nameTable.put(alt, ALT_NAME); + modifierKeyTable.put(COMMAND_NAME, command); + nameTable.put(command, COMMAND_NAME); + modifierKeyTable.put(CTRL_NAME, ctrl); + nameTable.put(ctrl, CTRL_NAME); + modifierKeyTable.put(SHIFT_NAME, shift); + nameTable.put(shift, SHIFT_NAME); + modifierKeyTable.put(M1_NAME, "carbon".equals(DWT.getPlatform()) ? command : ctrl); //$NON-NLS-1$ - modifierKeyTable.add(M2_NAME, shift); - modifierKeyTable.add(M3_NAME, alt); - modifierKeyTable.add(M4_NAME, "carbon".equals(DWT.getPlatform()) ? ctrl //$NON-NLS-1$ + modifierKeyTable.put(M2_NAME, shift); + modifierKeyTable.put(M3_NAME, alt); + modifierKeyTable.put(M4_NAME, "carbon".equals(DWT.getPlatform()) ? ctrl //$NON-NLS-1$ : command); Integer arrowDown = new Integer(DWT.ARROW_DOWN); - naturalKeyTable.add(ARROW_DOWN_NAME, arrowDown); - nameTable.add(arrowDown, ARROW_DOWN_NAME); + naturalKeyTable.put(ARROW_DOWN_NAME, arrowDown); + nameTable.put(arrowDown, ARROW_DOWN_NAME); Integer arrowLeft = new Integer(DWT.ARROW_LEFT); - naturalKeyTable.add(ARROW_LEFT_NAME, arrowLeft); - nameTable.add(arrowLeft, ARROW_LEFT_NAME); + naturalKeyTable.put(ARROW_LEFT_NAME, arrowLeft); + nameTable.put(arrowLeft, ARROW_LEFT_NAME); Integer arrowRight = new Integer(DWT.ARROW_RIGHT); - naturalKeyTable.add(ARROW_RIGHT_NAME, arrowRight); - nameTable.add(arrowRight, ARROW_RIGHT_NAME); + naturalKeyTable.put(ARROW_RIGHT_NAME, arrowRight); + nameTable.put(arrowRight, ARROW_RIGHT_NAME); Integer arrowUp = new Integer(DWT.ARROW_UP); - naturalKeyTable.add(ARROW_UP_NAME, arrowUp); - nameTable.add(arrowUp, ARROW_UP_NAME); + naturalKeyTable.put(ARROW_UP_NAME, arrowUp); + nameTable.put(arrowUp, ARROW_UP_NAME); Integer breakKey = new Integer(DWT.BREAK); - naturalKeyTable.add(BREAK_NAME, breakKey); - nameTable.add(breakKey, BREAK_NAME); + naturalKeyTable.put(BREAK_NAME, breakKey); + nameTable.put(breakKey, BREAK_NAME); Integer bs = new Integer(DWT.BS); - naturalKeyTable.add(BS_NAME, bs); - nameTable.add(bs, BS_NAME); - naturalKeyTable.add(BACKSPACE_NAME, bs); + naturalKeyTable.put(BS_NAME, bs); + nameTable.put(bs, BS_NAME); + naturalKeyTable.put(BACKSPACE_NAME, bs); Integer capsLock = new Integer(DWT.CAPS_LOCK); - naturalKeyTable.add(CAPS_LOCK_NAME, capsLock); - nameTable.add(capsLock, CAPS_LOCK_NAME); + naturalKeyTable.put(CAPS_LOCK_NAME, capsLock); + nameTable.put(capsLock, CAPS_LOCK_NAME); Integer cr = new Integer(DWT.CR); - naturalKeyTable.add(CR_NAME, cr); - nameTable.add(cr, CR_NAME); - naturalKeyTable.add(ENTER_NAME, cr); - naturalKeyTable.add(RETURN_NAME, cr); + naturalKeyTable.put(CR_NAME, cr); + nameTable.put(cr, CR_NAME); + naturalKeyTable.put(ENTER_NAME, cr); + naturalKeyTable.put(RETURN_NAME, cr); Integer del = new Integer(DWT.DEL); - naturalKeyTable.add(DEL_NAME, del); - nameTable.add(del, DEL_NAME); - naturalKeyTable.add(DELETE_NAME, del); + naturalKeyTable.put(DEL_NAME, del); + nameTable.put(del, DEL_NAME); + naturalKeyTable.put(DELETE_NAME, del); Integer end = new Integer(DWT.END); - naturalKeyTable.add(END_NAME, end); - nameTable.add(end, END_NAME); + naturalKeyTable.put(END_NAME, end); + nameTable.put(end, END_NAME); Integer esc = new Integer(DWT.ESC); - naturalKeyTable.add(ESC_NAME, esc); - nameTable.add(esc, ESC_NAME); - naturalKeyTable.add(ESCAPE_NAME, esc); + naturalKeyTable.put(ESC_NAME, esc); + nameTable.put(esc, ESC_NAME); + naturalKeyTable.put(ESCAPE_NAME, esc); Integer f1 = new Integer(DWT.F1); - naturalKeyTable.add(F1_NAME, f1); - nameTable.add(f1, F1_NAME); + naturalKeyTable.put(F1_NAME, f1); + nameTable.put(f1, F1_NAME); Integer f2 = new Integer(DWT.F2); - naturalKeyTable.add(F2_NAME, new Integer(DWT.F2)); - nameTable.add(f2, F2_NAME); + naturalKeyTable.put(F2_NAME, new Integer(DWT.F2)); + nameTable.put(f2, F2_NAME); Integer f3 = new Integer(DWT.F3); - naturalKeyTable.add(F3_NAME, new Integer(DWT.F3)); - nameTable.add(f3, F3_NAME); + naturalKeyTable.put(F3_NAME, new Integer(DWT.F3)); + nameTable.put(f3, F3_NAME); Integer f4 = new Integer(DWT.F4); - naturalKeyTable.add(F4_NAME, new Integer(DWT.F4)); - nameTable.add(f4, F4_NAME); + naturalKeyTable.put(F4_NAME, new Integer(DWT.F4)); + nameTable.put(f4, F4_NAME); Integer f5 = new Integer(DWT.F5); - naturalKeyTable.add(F5_NAME, new Integer(DWT.F5)); - nameTable.add(f5, F5_NAME); + naturalKeyTable.put(F5_NAME, new Integer(DWT.F5)); + nameTable.put(f5, F5_NAME); Integer f6 = new Integer(DWT.F6); - naturalKeyTable.add(F6_NAME, new Integer(DWT.F6)); - nameTable.add(f6, F6_NAME); + naturalKeyTable.put(F6_NAME, new Integer(DWT.F6)); + nameTable.put(f6, F6_NAME); Integer f7 = new Integer(DWT.F7); - naturalKeyTable.add(F7_NAME, new Integer(DWT.F7)); - nameTable.add(f7, F7_NAME); + naturalKeyTable.put(F7_NAME, new Integer(DWT.F7)); + nameTable.put(f7, F7_NAME); Integer f8 = new Integer(DWT.F8); - naturalKeyTable.add(F8_NAME, new Integer(DWT.F8)); - nameTable.add(f8, F8_NAME); + naturalKeyTable.put(F8_NAME, new Integer(DWT.F8)); + nameTable.put(f8, F8_NAME); Integer f9 = new Integer(DWT.F9); - naturalKeyTable.add(F9_NAME, new Integer(DWT.F9)); - nameTable.add(f9, F9_NAME); + naturalKeyTable.put(F9_NAME, new Integer(DWT.F9)); + nameTable.put(f9, F9_NAME); Integer f10 = new Integer(DWT.F10); - naturalKeyTable.add(F10_NAME, new Integer(DWT.F10)); - nameTable.add(f10, F10_NAME); + naturalKeyTable.put(F10_NAME, new Integer(DWT.F10)); + nameTable.put(f10, F10_NAME); Integer f11 = new Integer(DWT.F11); - naturalKeyTable.add(F11_NAME, new Integer(DWT.F11)); - nameTable.add(f11, F11_NAME); + naturalKeyTable.put(F11_NAME, new Integer(DWT.F11)); + nameTable.put(f11, F11_NAME); Integer f12 = new Integer(DWT.F12); - naturalKeyTable.add(F12_NAME, new Integer(DWT.F12)); - nameTable.add(f12, F12_NAME); + naturalKeyTable.put(F12_NAME, new Integer(DWT.F12)); + nameTable.put(f12, F12_NAME); Integer f13 = new Integer(DWT.F13); - naturalKeyTable.add(F13_NAME, new Integer(DWT.F13)); - nameTable.add(f13, F13_NAME); + naturalKeyTable.put(F13_NAME, new Integer(DWT.F13)); + nameTable.put(f13, F13_NAME); Integer f14 = new Integer(DWT.F14); - naturalKeyTable.add(F14_NAME, new Integer(DWT.F14)); - nameTable.add(f14, F14_NAME); + naturalKeyTable.put(F14_NAME, new Integer(DWT.F14)); + nameTable.put(f14, F14_NAME); Integer f15 = new Integer(DWT.F15); - naturalKeyTable.add(F15_NAME, new Integer(DWT.F15)); - nameTable.add(f15, F15_NAME); + naturalKeyTable.put(F15_NAME, new Integer(DWT.F15)); + nameTable.put(f15, F15_NAME); Integer ff = new Integer(12); // ASCII 0x0C - naturalKeyTable.add(FF_NAME, ff); - nameTable.add(ff, FF_NAME); + naturalKeyTable.put(FF_NAME, ff); + nameTable.put(ff, FF_NAME); Integer home = new Integer(DWT.HOME); - naturalKeyTable.add(HOME_NAME, home); - nameTable.add(home, HOME_NAME); + naturalKeyTable.put(HOME_NAME, home); + nameTable.put(home, HOME_NAME); Integer insert = new Integer(DWT.INSERT); - naturalKeyTable.add(INSERT_NAME, insert); - nameTable.add(insert, INSERT_NAME); + naturalKeyTable.put(INSERT_NAME, insert); + nameTable.put(insert, INSERT_NAME); Integer lf = new Integer(DWT.LF); - naturalKeyTable.add(LF_NAME, lf); - nameTable.add(lf, LF_NAME); + naturalKeyTable.put(LF_NAME, lf); + nameTable.put(lf, LF_NAME); Integer nul = new Integer(DWT.NULL); - naturalKeyTable.add(NUL_NAME, nul); - nameTable.add(nul, NUL_NAME); + naturalKeyTable.put(NUL_NAME, nul); + nameTable.put(nul, NUL_NAME); Integer numLock = new Integer(DWT.NUM_LOCK); - naturalKeyTable.add(NUM_LOCK_NAME, numLock); - nameTable.add(numLock, NUM_LOCK_NAME); + naturalKeyTable.put(NUM_LOCK_NAME, numLock); + nameTable.put(numLock, NUM_LOCK_NAME); Integer keypad0 = new Integer(DWT.KEYPAD_0); - naturalKeyTable.add(NUMPAD_0_NAME, keypad0); - nameTable.add(keypad0, NUMPAD_0_NAME); + naturalKeyTable.put(NUMPAD_0_NAME, keypad0); + nameTable.put(keypad0, NUMPAD_0_NAME); Integer keypad1 = new Integer(DWT.KEYPAD_1); - naturalKeyTable.add(NUMPAD_1_NAME, keypad1); - nameTable.add(keypad1, NUMPAD_1_NAME); + naturalKeyTable.put(NUMPAD_1_NAME, keypad1); + nameTable.put(keypad1, NUMPAD_1_NAME); Integer keypad2 = new Integer(DWT.KEYPAD_2); - naturalKeyTable.add(NUMPAD_2_NAME, keypad2); - nameTable.add(keypad2, NUMPAD_2_NAME); + naturalKeyTable.put(NUMPAD_2_NAME, keypad2); + nameTable.put(keypad2, NUMPAD_2_NAME); Integer keypad3 = new Integer(DWT.KEYPAD_3); - naturalKeyTable.add(NUMPAD_3_NAME, keypad3); - nameTable.add(keypad3, NUMPAD_3_NAME); + naturalKeyTable.put(NUMPAD_3_NAME, keypad3); + nameTable.put(keypad3, NUMPAD_3_NAME); Integer keypad4 = new Integer(DWT.KEYPAD_4); - naturalKeyTable.add(NUMPAD_4_NAME, keypad4); - nameTable.add(keypad4, NUMPAD_4_NAME); + naturalKeyTable.put(NUMPAD_4_NAME, keypad4); + nameTable.put(keypad4, NUMPAD_4_NAME); Integer keypad5 = new Integer(DWT.KEYPAD_5); - naturalKeyTable.add(NUMPAD_5_NAME, keypad5); - nameTable.add(keypad5, NUMPAD_5_NAME); + naturalKeyTable.put(NUMPAD_5_NAME, keypad5); + nameTable.put(keypad5, NUMPAD_5_NAME); Integer keypad6 = new Integer(DWT.KEYPAD_6); - naturalKeyTable.add(NUMPAD_6_NAME, keypad6); - nameTable.add(keypad6, NUMPAD_6_NAME); + naturalKeyTable.put(NUMPAD_6_NAME, keypad6); + nameTable.put(keypad6, NUMPAD_6_NAME); Integer keypad7 = new Integer(DWT.KEYPAD_7); - naturalKeyTable.add(NUMPAD_7_NAME, keypad7); - nameTable.add(keypad7, NUMPAD_7_NAME); + naturalKeyTable.put(NUMPAD_7_NAME, keypad7); + nameTable.put(keypad7, NUMPAD_7_NAME); Integer keypad8 = new Integer(DWT.KEYPAD_8); - naturalKeyTable.add(NUMPAD_8_NAME, keypad8); - nameTable.add(keypad8, NUMPAD_8_NAME); + naturalKeyTable.put(NUMPAD_8_NAME, keypad8); + nameTable.put(keypad8, NUMPAD_8_NAME); Integer keypad9 = new Integer(DWT.KEYPAD_9); - naturalKeyTable.add(NUMPAD_9_NAME, keypad9); - nameTable.add(keypad9, NUMPAD_9_NAME); + naturalKeyTable.put(NUMPAD_9_NAME, keypad9); + nameTable.put(keypad9, NUMPAD_9_NAME); Integer keypadAdd = new Integer(DWT.KEYPAD_ADD); - naturalKeyTable.add(NUMPAD_ADD_NAME, keypadAdd); - nameTable.add(keypadAdd, NUMPAD_ADD_NAME); + naturalKeyTable.put(NUMPAD_ADD_NAME, keypadAdd); + nameTable.put(keypadAdd, NUMPAD_ADD_NAME); Integer keypadDecimal = new Integer(DWT.KEYPAD_DECIMAL); - naturalKeyTable.add(NUMPAD_DECIMAL_NAME, keypadDecimal); - nameTable.add(keypadDecimal, NUMPAD_DECIMAL_NAME); + naturalKeyTable.put(NUMPAD_DECIMAL_NAME, keypadDecimal); + nameTable.put(keypadDecimal, NUMPAD_DECIMAL_NAME); Integer keypadDivide = new Integer(DWT.KEYPAD_DIVIDE); - naturalKeyTable.add(NUMPAD_DIVIDE_NAME, keypadDivide); - nameTable.add(keypadDivide, NUMPAD_DIVIDE_NAME); + naturalKeyTable.put(NUMPAD_DIVIDE_NAME, keypadDivide); + nameTable.put(keypadDivide, NUMPAD_DIVIDE_NAME); Integer keypadCr = new Integer(DWT.KEYPAD_CR); - naturalKeyTable.add(NUMPAD_ENTER_NAME, keypadCr); - nameTable.add(keypadCr, NUMPAD_ENTER_NAME); + naturalKeyTable.put(NUMPAD_ENTER_NAME, keypadCr); + nameTable.put(keypadCr, NUMPAD_ENTER_NAME); Integer keypadEqual = new Integer(DWT.KEYPAD_EQUAL); - naturalKeyTable.add(NUMPAD_EQUAL_NAME, keypadEqual); - nameTable.add(keypadEqual, NUMPAD_EQUAL_NAME); + naturalKeyTable.put(NUMPAD_EQUAL_NAME, keypadEqual); + nameTable.put(keypadEqual, NUMPAD_EQUAL_NAME); Integer keypadMultiply = new Integer(DWT.KEYPAD_MULTIPLY); - naturalKeyTable.add(NUMPAD_MULTIPLY_NAME, keypadMultiply); - nameTable.add(keypadMultiply, NUMPAD_MULTIPLY_NAME); + naturalKeyTable.put(NUMPAD_MULTIPLY_NAME, keypadMultiply); + nameTable.put(keypadMultiply, NUMPAD_MULTIPLY_NAME); Integer keypadSubtract = new Integer(DWT.KEYPAD_SUBTRACT); - naturalKeyTable.add(NUMPAD_SUBTRACT_NAME, keypadSubtract); - nameTable.add(keypadSubtract, NUMPAD_SUBTRACT_NAME); + naturalKeyTable.put(NUMPAD_SUBTRACT_NAME, keypadSubtract); + nameTable.put(keypadSubtract, NUMPAD_SUBTRACT_NAME); Integer pageDown = new Integer(DWT.PAGE_DOWN); - naturalKeyTable.add(PAGE_DOWN_NAME, pageDown); - nameTable.add(pageDown, PAGE_DOWN_NAME); + naturalKeyTable.put(PAGE_DOWN_NAME, pageDown); + nameTable.put(pageDown, PAGE_DOWN_NAME); Integer pageUp = new Integer(DWT.PAGE_UP); - naturalKeyTable.add(PAGE_UP_NAME, pageUp); - nameTable.add(pageUp, PAGE_UP_NAME); + naturalKeyTable.put(PAGE_UP_NAME, pageUp); + nameTable.put(pageUp, PAGE_UP_NAME); Integer pause = new Integer(DWT.PAUSE); - naturalKeyTable.add(PAUSE_NAME, pause); - nameTable.add(pause, PAUSE_NAME); + naturalKeyTable.put(PAUSE_NAME, pause); + nameTable.put(pause, PAUSE_NAME); Integer printScreen = new Integer(DWT.PRINT_SCREEN); - naturalKeyTable.add(PRINT_SCREEN_NAME, printScreen); - nameTable.add(printScreen, PRINT_SCREEN_NAME); + naturalKeyTable.put(PRINT_SCREEN_NAME, printScreen); + nameTable.put(printScreen, PRINT_SCREEN_NAME); Integer scrollLock = new Integer(DWT.SCROLL_LOCK); - naturalKeyTable.add(SCROLL_LOCK_NAME, scrollLock); - nameTable.add(scrollLock, SCROLL_LOCK_NAME); + naturalKeyTable.put(SCROLL_LOCK_NAME, scrollLock); + nameTable.put(scrollLock, SCROLL_LOCK_NAME); Integer space = new Integer(' '); - naturalKeyTable.add(SPACE_NAME, space); - nameTable.add(space, SPACE_NAME); + naturalKeyTable.put(SPACE_NAME, space); + nameTable.put(space, SPACE_NAME); Integer tab = new Integer(DWT.TAB); - naturalKeyTable.add(TAB_NAME, tab); - nameTable.add(tab, TAB_NAME); + naturalKeyTable.put(TAB_NAME, tab); + nameTable.put(tab, TAB_NAME); Integer vt = new Integer(11); // ASCII 0x0B - naturalKeyTable.add(VT_NAME, vt); - nameTable.add(vt, VT_NAME); + naturalKeyTable.put(VT_NAME, vt); + nameTable.put(vt, VT_NAME); } /* @@ -320,7 +319,7 @@ public final String formalNameLookup(int key) { Integer keyObject = new Integer(key); if (nameTable.containsKey(keyObject) ) { - return nameTable.get(keyObject); + return stringcast(nameTable.get(keyObject)); } return dcharToString( cast(dchar) key );
--- a/dwtx/jface/bindings/keys/formatting/AbstractKeyFormatter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/keys/formatting/AbstractKeyFormatter.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,8 +15,6 @@ import dwtx.jface.bindings.keys.formatting.IKeyFormatter; -import tango.util.collection.HashSet; -import tango.util.collection.model.Set; import dwtx.jface.bindings.keys.IKeyLookup; import dwtx.jface.bindings.keys.KeyLookupFactory; @@ -25,6 +23,7 @@ import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.ResourceBundle; /** @@ -69,14 +68,14 @@ * The keys in the resource bundle. This is used to avoid missing resource * exceptions when they aren't necessary. */ - private static const Set!(String) resourceBundleKeys; + private static const Set resourceBundleKeys; static this() { RESOURCE_BUNDLE = ResourceBundle.getBundle( getImportData!("dwtx.jface.bindings.keys.formatting.AbstractKeyFormatter.properties")); - resourceBundleKeys = new HashSet!(String); - foreach( key; RESOURCE_BUNDLE.getKeys()){ - resourceBundleKeys.add(key); + resourceBundleKeys = new HashSet(); + foreach( element; RESOURCE_BUNDLE.getKeys()){ + resourceBundleKeys.add(stringcast(element)); } }
--- a/dwtx/jface/bindings/keys/formatting/NativeKeyFormatter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/bindings/keys/formatting/NativeKeyFormatter.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,7 +15,6 @@ import dwtx.jface.bindings.keys.formatting.AbstractKeyFormatter; -import tango.util.collection.HashMap; import dwt.DWT; import dwtx.jface.bindings.keys.IKeyLookup; @@ -25,6 +24,7 @@ import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.ResourceBundle; /** @@ -48,7 +48,7 @@ /** * A look-up table for the string representations of various carbon keys. */ - private const static HashMap!(String,String) CARBON_KEY_LOOK_UP; + private const static HashMap CARBON_KEY_LOOK_UP; /** * The resource bundle used by <code>format()</code> to translate formal @@ -63,31 +63,31 @@ private const static String WIN32_KEY_STROKE_DELIMITER_KEY = "WIN32_KEY_STROKE_DELIMITER"; //$NON-NLS-1$ static this() { - CARBON_KEY_LOOK_UP = new HashMap!(String,String); + CARBON_KEY_LOOK_UP = new HashMap(); RESOURCE_BUNDLE = ResourceBundle.getBundle( getImportData!("dwtx.jface.bindings.keys.formatting.NativeKeyFormatter.properties")); - String carbonBackspace = "\u232B"; //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.BS_NAME, carbonBackspace); - CARBON_KEY_LOOK_UP.add(IKeyLookup.BACKSPACE_NAME, carbonBackspace); - CARBON_KEY_LOOK_UP.add(IKeyLookup.CR_NAME, "\u21A9"); //$NON-NLS-1$ - String carbonDelete = "\u2326"; //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.DEL_NAME, carbonDelete); - CARBON_KEY_LOOK_UP.add(IKeyLookup.DELETE_NAME, carbonDelete); - CARBON_KEY_LOOK_UP.add(IKeyLookup.SPACE_NAME, "\u2423"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.ALT_NAME, "\u2325"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.COMMAND_NAME, "\u2318"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.CTRL_NAME, "\u2303"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.SHIFT_NAME, "\u21E7"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.ARROW_DOWN_NAME, "\u2193"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.ARROW_LEFT_NAME, "\u2190"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.ARROW_RIGHT_NAME, "\u2192"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.ARROW_UP_NAME, "\u2191"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.END_NAME, "\u2198"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.NUMPAD_ENTER_NAME, "\u2324"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.HOME_NAME, "\u2196"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.PAGE_DOWN_NAME, "\u21DF"); //$NON-NLS-1$ - CARBON_KEY_LOOK_UP.add(IKeyLookup.PAGE_UP_NAME, "\u21DE"); //$NON-NLS-1$ + Object carbonBackspace = stringcast("\u232B"); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.BS_NAME), carbonBackspace); + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.BACKSPACE_NAME), carbonBackspace); + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.CR_NAME), stringcast("\u21A9")); //$NON-NLS-1$ + Object carbonDelete = stringcast("\u2326"); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.DEL_NAME), carbonDelete); + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.DELETE_NAME), carbonDelete); + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.SPACE_NAME), stringcast("\u2423")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.ALT_NAME), stringcast("\u2325")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.COMMAND_NAME), stringcast("\u2318")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.CTRL_NAME), stringcast("\u2303")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.SHIFT_NAME), stringcast("\u21E7")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.ARROW_DOWN_NAME), stringcast("\u2193")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.ARROW_LEFT_NAME), stringcast("\u2190")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.ARROW_RIGHT_NAME), stringcast("\u2192")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.ARROW_UP_NAME), stringcast("\u2191")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.END_NAME), stringcast("\u2198")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.NUMPAD_ENTER_NAME), stringcast("\u2324")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.HOME_NAME), stringcast("\u2196")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.PAGE_DOWN_NAME), stringcast("\u21DF")); //$NON-NLS-1$ + CARBON_KEY_LOOK_UP.put(stringcast(IKeyLookup.PAGE_UP_NAME), stringcast("\u21DE")); //$NON-NLS-1$ } /** @@ -105,7 +105,7 @@ // TODO consider platform-specific resource bundles if ("carbon".equals(DWT.getPlatform())) { //$NON-NLS-1$ - String formattedName = cast(String) CARBON_KEY_LOOK_UP.get(name); + String formattedName = stringcast( CARBON_KEY_LOOK_UP.get(name)); if (formattedName !is null) { return formattedName; }
--- a/dwtx/jface/commands/RadioState.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/commands/RadioState.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,10 +13,6 @@ module dwtx.jface.commands.RadioState; -import tango.util.collection.HashMap; -import tango.util.collection.HashSet; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; import dwtx.core.commands.IStateListener; import dwtx.core.commands.State; @@ -25,6 +21,7 @@ import dwtx.jface.commands.ToggleState; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * <p> @@ -67,7 +64,7 @@ * The current members in this group. If there are no members, then * this value is <code>nlistenerull</code>. */ - private Set!(RadioState) members = null; + private Set members = null; /** * Activates a memeber. This checks to see if there are any other @@ -94,7 +91,7 @@ */ private final void addMember(RadioState state) { if (members is null) { - members = new HashSet!(RadioState); + members = new HashSet(); } members.add(state); @@ -144,7 +141,7 @@ * instance or a <code>Collection</code> of <code>RadioState</code> * instances. */ - private static Map!(String,RadioState) radioStatesById = null; + private static Map radioStatesById = null; /** * Activates a particular state within a given group. @@ -180,7 +177,7 @@ private static final void registerState(String identifier, RadioState state) { if (radioStatesById is null) { - radioStatesById = new HashMap!(String,RadioState); + radioStatesById = new HashMap(); } auto currentValue = radioStatesById.get(identifier);
--- a/dwtx/jface/dialogs/ControlEnableState.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/dialogs/ControlEnableState.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,13 +12,12 @@ *******************************************************************************/ module dwtx.jface.dialogs.ControlEnableState; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwt.widgets.Composite; import dwt.widgets.Control; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * Helper class to save the enable/disable state of a control including all its @@ -29,12 +28,12 @@ * List of exception controls (element type: <code>Control</code>); * <code>null</code> if none. */ - private Seq!(Control) exceptions = null; + private List exceptions = null; /** * List of saved states (element type: <code>ItemState</code>). */ - private Seq!(Object) states; + private List states; /** * Internal class for recording the enable/disable state of a single @@ -93,9 +92,9 @@ * the list of controls to not disable (element type: * <code>Control</code>), or <code>null</code> if none */ - protected this(Control w, Seq!(Control) exceptions) { + protected this(Control w, List exceptions) { // super(); - states = new ArraySeq!(Object); + states = new ArrayList(); this.exceptions = exceptions; readStateForAndDisable(w); } @@ -124,7 +123,7 @@ * <code>Control</code>) * @return an object capturing the enable/disable state */ - public static ControlEnableState disable(Control w, Seq!(Control) exceptions) { + public static ControlEnableState disable(Control w, List exceptions) { return new ControlEnableState(w, exceptions); } @@ -145,7 +144,7 @@ } // XXX: Workaround for 1G2Q8SS: ITPUI:Linux - Combo box is not enabled // in "File->New->Solution" - states.append(new ItemState(control, control.getEnabled())); + states.add(new ItemState(control, control.getEnabled())); control.setEnabled(false); }
--- a/dwtx/jface/dialogs/DialogSettings.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/dialogs/DialogSettings.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,10 +14,6 @@ import dwtx.jface.dialogs.IDialogSettings; -import tango.util.collection.model.Map; -import tango.util.collection.model.Seq; -import tango.util.collection.HashMap; -import tango.util.collection.ArraySeq; static import tango.text.xml.Document; static import tango.text.xml.SaxParser; @@ -26,6 +22,7 @@ import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; static import dwt.dwthelper.OutputStream; static import tango.text.convert.Integer; static import tango.text.convert.Float; @@ -75,14 +72,14 @@ /* A Map of DialogSettings representing each sections in a DialogSettings. It maps the DialogSettings' name to the DialogSettings */ - private Map!(String,IDialogSettings) sections; + private Map sections; /* A Map with all the keys and values of this sections. Either the keys an values are restricted to strings. */ - private Map!(String,String) items; + private Map items; // A Map with all the keys mapped to array of strings. - private Map!(String,String[]) arrayItems; + private Map arrayItems; private static const String TAG_SECTION = "section";//$NON-NLS-1$ @@ -106,9 +103,9 @@ */ public this(String sectionName) { name = sectionName; - items = new HashMap!(String,String); - arrayItems = new HashMap!(String,String[]); - sections = new HashMap!(String,IDialogSettings); + items = new HashMap(); + arrayItems = new HashMap(); + sections = new HashMap(); } /* (non-Javadoc) @@ -124,35 +121,35 @@ * Method declared on IDialogSettings. */ public void addSection(IDialogSettings section) { - sections.add(section.getName(), section); + sections.put(stringcast(section.getName()), cast(Object)section); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public String get(String key) { - return items.get(key); + return stringcast(items.get(stringcast(key))); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public String[] getArray(String key) { - return arrayItems.get(key); + return stringArrayFromObject(arrayItems.get(stringcast(key))); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public bool getBoolean(String key) { - return items.get(key) == "true"; + return stringcast(items.get(stringcast(key))) == "true"; } /* (non-Javadoc) * Method declared on IDialogSettings. */ public double getDouble(String key) { - String setting = items.get(key); + String setting = stringcast(items.get(stringcast(key))); if (setting is null) { throw new NumberFormatException( "There is no setting associated with the key \"" ~ key ~ "\"");//$NON-NLS-1$ //$NON-NLS-2$ @@ -165,7 +162,7 @@ * Method declared on IDialogSettings. */ public float getFloat(String key) { - String setting = items.get(key); + String setting = stringcast(items.get(stringcast(key))); if (setting is null) { throw new NumberFormatException( "There is no setting associated with the key \"" ~ key ~ "\"");//$NON-NLS-1$ //$NON-NLS-2$ @@ -178,7 +175,7 @@ * Method declared on IDialogSettings. */ public int getInt(String key) { - String setting = items.get(key); + String setting = stringcast(items.get(stringcast(key))); if (setting is null) { //new Integer(null) will throw a NumberFormatException and meet our spec, but this message //is clearer. @@ -193,7 +190,7 @@ * Method declared on IDialogSettings. */ public long getLong(String key) { - String setting = items.get(key); + String setting = stringcast(items.get(stringcast(key))); if (setting is null) { //new Long(null) will throw a NumberFormatException and meet our spec, but this message //is clearer. @@ -215,14 +212,16 @@ * Method declared on IDialogSettings. */ public IDialogSettings getSection(String sectionName) { - return sections.get(sectionName); + return cast(IDialogSettings) sections.get(stringcast(sectionName)); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public IDialogSettings[] getSections() { - return sections.toArray(); + Collection values = sections.values(); + IDialogSettings[] result = arraycast!(IDialogSettings)( values.toArray() ); + return result; } /* (non-Javadoc) @@ -275,7 +274,7 @@ if( root is n.parent() ){ String key = n.getAttribute(TAG_KEY).value().dup; String value = n.getAttribute(TAG_VALUE).value().dup; - items.add(key, value); + items.put(stringcast(key), stringcast(value)); } } foreach( n; root.query[TAG_LIST].dup ){ @@ -288,7 +287,7 @@ valueList ~= node.getAttribute(TAG_VALUE).value().dup; } } - arrayItems.add(key, valueList ); + arrayItems.put(stringcast(key), new ArrayWrapperString2(valueList) ); } } foreach( n; root.query[TAG_SECTION].dup ){ @@ -304,7 +303,7 @@ * Method declared on IDialogSettings. */ public void put(String key, String[] value) { - arrayItems.add(key, value); + arrayItems.put(stringcast(key), new ArrayWrapperString2(value)); } /* (non-Javadoc) @@ -339,7 +338,7 @@ * Method declared on IDialogSettings. */ public void put(String key, String value) { - items.add(key, value); + items.put(stringcast(key), stringcast(value)); } /* (non-Javadoc) @@ -371,35 +370,37 @@ * Save the settings in the <code>document</code>. */ private void save(XMLWriter out_) { - HashMap!(String,String) attributes = new HashMap!(String,String); - attributes.add(TAG_NAME, name is null ? "" : name); //$NON-NLS-1$ + HashMap attributes = new HashMap(2); + attributes.put(stringcast(TAG_NAME), stringcast(name is null ? "" : name)); //$NON-NLS-1$ out_.startTag(TAG_SECTION, attributes); attributes.clear(); + Object EMPTY_STR = new ArrayWrapperString(""); foreach( key,value; items ){ - attributes.add(TAG_KEY, key is null ? "" : key); //$NON-NLS-1$ - String string = value;cast(String) items.get(key); - attributes.add(TAG_VALUE, string is null ? "" : string); //$NON-NLS-1$ + attributes.put(stringcast(TAG_KEY), key is null ? EMPTY_STR : key); //$NON-NLS-1$ + String string = stringcast(value);//cast(String) items.get(stringcast(key)); + attributes.put(stringcast(TAG_VALUE), stringcast(string is null ? "" : string)); //$NON-NLS-1$ out_.printTag(TAG_ITEM, attributes, true); } attributes.clear(); foreach( key,value; arrayItems ){ - attributes.add(TAG_KEY, key is null ? "" : key); //$NON-NLS-1$ + attributes.put(stringcast(TAG_KEY), key is null ? EMPTY_STR : key); //$NON-NLS-1$ out_.startTag(TAG_LIST, attributes); attributes.clear(); + String[] strValues = stringArrayFromObject(value); if (value !is null) { - for (int index = 0; index < value.length; index++) { - String string = value[index]; - attributes.add(TAG_VALUE, string is null ? "" : string); //$NON-NLS-1$ + for (int index = 0; index < strValues.length; index++) { + String string = strValues[index]; + attributes.put(stringcast(TAG_VALUE), stringcast(string is null ? "" : string)); //$NON-NLS-1$ out_.printTag(TAG_ITEM, attributes, true); } } out_.endTag(TAG_LIST); attributes.clear(); } - foreach( name, section; sections ){ - section.save(out_); + for (Iterator i = sections.values().iterator(); i.hasNext();) { + (cast(DialogSettings) i.next()).save(out_); } out_.endTag(TAG_SECTION); } @@ -448,20 +449,22 @@ * @param parameters map of parameters * @param close should the tag be ended automatically (=> empty tag) */ - public void printTag(String name, HashMap!(String,String) parameters, bool close) { + public void printTag(String name, HashMap parameters, bool close) { printTag(name, parameters, true, true, close); } - private void printTag(String name, HashMap!(String,String) parameters, bool shouldTab, bool newLine, bool close) { + private void printTag(String name, HashMap parameters, bool shouldTab, bool newLine, bool close) { StringBuffer sb = new StringBuffer(); sb.append('<'); sb.append(name); if (parameters !is null) { - foreach( key, value; parameters ){ + for (Enumeration e = Collections.enumeration(parameters.keySet()); e.hasMoreElements();) { sb.append(" "); //$NON-NLS-1$ + String key = stringcast( e.nextElement()); sb.append(key); sb.append("=\""); //$NON-NLS-1$ - sb.append(xmlEscape(value.dup)); + //sb.append(getEscaped(String.valueOf(parameters.get(key)))); + sb.append(xmlEscape(stringcast(parameters.get(stringcast(key))))); sb.append("\""); //$NON-NLS-1$ } } @@ -485,12 +488,12 @@ * @param name the name of the tag * @param parameters map of parameters */ - public void startTag(String name, HashMap!(String,String) parameters) { + public void startTag(String name, HashMap parameters) { startTag(name, parameters, true); tab++; } - private void startTag(String name, HashMap!(String,String) parameters, bool newLine) { + private void startTag(String name, HashMap parameters, bool newLine) { printTag(name, parameters, true, newLine, false); } }
--- a/dwtx/jface/dialogs/PopupDialog.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/dialogs/PopupDialog.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,9 +17,6 @@ import dwtx.jface.dialogs.IDialogSettings; import dwtx.jface.dialogs.Dialog; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwt.DWT; import dwt.events.DisposeEvent; @@ -55,6 +52,7 @@ import dwtx.jface.window.Window; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -1451,7 +1449,7 @@ * color assigned */ private void applyForegroundColor(Color color, Control control, - SeqView!(Control) exclusions) { + List exclusions) { if (!exclusions.contains(control)) { control.setForeground(color); } @@ -1476,7 +1474,7 @@ * color assigned */ private void applyBackgroundColor(Color color, Control control, - SeqView!(Control) exclusions) { + List exclusions) { if (!exclusions.contains(control)) { control.setBackground(color); } @@ -1530,17 +1528,16 @@ * * @return the List of controls */ - protected SeqView!(Control) getForegroundColorExclusions() { - auto list = new ArraySeq!(Control); - list.capacity(3); + protected List getForegroundColorExclusions() { + List list = new ArrayList(3); if (infoLabel !is null) { - list.append(infoLabel); + list.add(infoLabel); } if (titleSeparator !is null) { - list.append(titleSeparator); + list.add(titleSeparator); } if (infoSeparator !is null) { - list.append(infoSeparator); + list.add(infoSeparator); } return list; } @@ -1552,14 +1549,13 @@ * * @return the List of controls */ - protected SeqView!(Control) getBackgroundColorExclusions() { - auto list = new ArraySeq!(Control); - list.capacity(2); + protected List getBackgroundColorExclusions() { + List list = new ArrayList(2); if (titleSeparator !is null) { - list.append(titleSeparator); + list.add(titleSeparator); } if (infoSeparator !is null) { - list.append(infoSeparator); + list.add(infoSeparator); } return list; }
--- a/dwtx/jface/fieldassist/ContentProposalAdapter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/fieldassist/ContentProposalAdapter.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,7 +19,6 @@ import dwtx.jface.fieldassist.IContentProposalListener; import dwtx.jface.fieldassist.IContentProposalListener2; -import tango.util.collection.ArraySeq; import dwt.DWT; import dwt.events.DisposeEvent; @@ -1048,17 +1047,18 @@ // Check each string for a match. Use the string displayed to the // user, not the proposal content. - auto list = new ArraySeq!(IContentProposal); + scope IContentProposal[] list = new IContentProposal[proposals.length]; + int idx = 0; for (int i = 0; i < proposals.length; i++) { String string = getString(proposals[i]); if (string.length >= filterString.length && string.substring(0, filterString.length) .equalsIgnoreCase(filterString)) { - list.append(proposals[i]); + list[idx++] = proposals[i]; } } - return list.toArray(); + return list[ 0 .. idx ].dup; } Listener getTargetControlListener() {
--- a/dwtx/jface/fieldassist/FieldAssistColors.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/fieldassist/FieldAssistColors.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,10 +12,6 @@ *******************************************************************************/ module dwtx.jface.fieldassist.FieldAssistColors; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; -import tango.util.collection.model.Seq; import dwt.DWT; import dwt.graphics.Color; @@ -25,6 +21,7 @@ import dwtx.jface.resource.JFaceColors; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; import tango.io.Stdout; @@ -53,17 +50,17 @@ * Keys are background colors, values are the color with the alpha value * applied */ - private static Map!(Object,Object) requiredFieldColorMap; + private static Map requiredFieldColorMap; /* * Keys are colors we have created, values are the displays on which they * were created. */ - private static Map!(Object,Object) displays; + private static Map displays; static this(){ - requiredFieldColorMap = new HashMap!(Object,Object); - displays = new HashMap!(Object,Object); + requiredFieldColorMap = new HashMap(); + displays = new HashMap(); } /** @@ -147,10 +144,10 @@ // create the color Color color = new Color(display, destRed, destGreen, destBlue); // record the color in a map using the original color as the key - requiredFieldColorMap.add(dest, color); + requiredFieldColorMap.put(dest, color); // If we have never created a color on this display before, install // a dispose exec on the display. - if (!displays.contains(display)) { + if (!displays.containsKey(display)) { display.disposeExec(new class Runnable { public void run() { disposeColors(display); @@ -158,7 +155,7 @@ }); } // Record the color and its display in a map for later disposal. - displays.add(color, display); + displays.put(color, display); return color; } @@ -166,7 +163,7 @@ * Dispose any colors that were allocated for the given display. */ private static void disposeColors(Display display) { - auto toBeRemoved = new ArraySeq!(Object); + List toBeRemoved = new ArrayList(1); if (DEBUG) { Stdout.formatln("Display map is {}", (cast(Object)displays).toString()); //$NON-NLS-1$ @@ -174,21 +171,22 @@ } // Look for any stored colors that were created on this display - foreach( k, v; displays ){ - Color color = cast(Color) k; + for (Iterator i = displays.keySet().iterator(); i.hasNext();) { + Color color = cast(Color) i.next(); if ((cast(Display) displays.get(color)).opEquals(display)) { // The color is on this display. Mark it for removal. - toBeRemoved.append(color); + toBeRemoved.add(color); // Now look for any references to it in the required field color // map - auto toBeRemovedFromRequiredMap = new ArraySeq!(Object); - foreach( k, v; requiredFieldColorMap ){ - Color bgColor = cast(Color) k; + List toBeRemovedFromRequiredMap = new ArrayList(1); + for (Iterator iter = requiredFieldColorMap.keySet().iterator(); iter + .hasNext();) { + Color bgColor = cast(Color) iter.next(); if ((cast(Color) requiredFieldColorMap.get(bgColor)) .opEquals(color)) { // mark it for removal from the required field color map - toBeRemovedFromRequiredMap.append(bgColor); + toBeRemovedFromRequiredMap.add(bgColor); } } // Remove references in the required field map now that
--- a/dwtx/jface/fieldassist/FieldDecorationRegistry.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/fieldassist/FieldDecorationRegistry.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,7 +14,6 @@ import dwtx.jface.fieldassist.FieldDecoration; -import tango.util.collection.HashMap; import dwt.graphics.Image; import dwtx.jface.resource.ImageDescriptor; @@ -22,6 +21,7 @@ import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * FieldDecorationRegistry is a common registry used to define shared field @@ -222,7 +222,7 @@ private int maxDecorationWidth = 0; private int maxDecorationHeight = 0; - private HashMap!(String,Object) /* <String id, FieldDecoration> */decorations; + private HashMap /* <String id, FieldDecoration> */decorations; /** * Get the default FieldDecorationRegistry. @@ -257,7 +257,7 @@ * Construct a FieldDecorationRegistry. */ public this() { - decorations = new HashMap!(String,Object); + decorations = new HashMap(); maxDecorationWidth = 0; maxDecorationHeight = 0; } @@ -303,7 +303,7 @@ */ public void registerFieldDecoration(String id, String description, Image image) { - decorations.add(id, new Entry(description, image)); + decorations.put(stringcast(id), new Entry(description, image)); // Recompute the maximums since this might be a replacement recomputeMaximums(); } @@ -324,7 +324,7 @@ */ public void registerFieldDecoration(String id, String description, String imageId) { - decorations.add(id, new Entry(description, imageId, JFaceResources + decorations.put(stringcast(id), new Entry(description, imageId, JFaceResources .getImageRegistry())); // Recompute the maximums as this could be a replacement of a previous // image. @@ -349,7 +349,7 @@ */ public void registerFieldDecoration(String id, String description, String imageId, ImageRegistry imageRegistry) { - decorations.add(id, new Entry(description, imageId, imageRegistry)); + decorations.put(stringcast(id), new Entry(description, imageId, imageRegistry)); // Recompute the maximums since this could be a replacement recomputeMaximums(); } @@ -373,7 +373,7 @@ * the String id of the decoration to be unregistered. */ public void unregisterFieldDecoration(String id) { - decorations.removeKey(id); + decorations.remove(stringcast(id)); recomputeMaximums(); } @@ -386,7 +386,7 @@ * if there is no decoration with the specified id. */ public FieldDecoration getFieldDecoration(String id) { - Object entry = decorations.get(id); + Object entry = decorations.get(stringcast(id)); if (entry is null) { return null; } @@ -399,10 +399,12 @@ * called in response to adding, removing, or replacing a decoration. */ private void recomputeMaximums() { + Iterator entries = decorations.values().iterator(); + maxDecorationHeight = 0; maxDecorationWidth = 0; - foreach( k,v; decorations ){ - Image image = (cast(Entry)v).getDecoration().getImage(); + while (entries.hasNext()) { + Image image = (cast(Entry)entries.next()).getDecoration().getImage(); if (image !is null) { maxDecorationHeight = Math.max(maxDecorationHeight, image.getBounds().height); maxDecorationWidth = Math.max(maxDecorationWidth, image.getBounds().width);
--- a/dwtx/jface/fieldassist/SimpleContentProposalProvider.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/fieldassist/SimpleContentProposalProvider.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,9 +16,9 @@ import dwtx.jface.fieldassist.IContentProposalProvider; import dwtx.jface.fieldassist.IContentProposal; -import tango.util.collection.ArraySeq; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * SimpleContentProposalProvider is a class designed to map a static list of @@ -61,7 +61,7 @@ /** * Return an array of Objects representing the valid content proposals for a - * field. + * field. * * @param contents * the current contents of the field (only consulted if filtering @@ -73,15 +73,15 @@ */ public IContentProposal[] getProposals(String contents, int position) { if (filterProposals) { - auto list = new ArraySeq!(IContentProposal); + ArrayList list = new ArrayList(); for (int i = 0; i < proposals.length; i++) { if (proposals[i].length >= contents.length && proposals[i].substring(0, contents.length) .equalsIgnoreCase(contents)) { - list.append(makeContentProposal(proposals[i])); + list.add(cast(Object)makeContentProposal(proposals[i])); } } - return list.toArray(); + return arraycast!(IContentProposal)(list.toArray()); } if (contentProposals is null) { contentProposals = new IContentProposal[proposals.length];
--- a/dwtx/jface/internal/InternalPolicy.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/internal/InternalPolicy.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,7 +12,7 @@ ******************************************************************************/ module dwtx.jface.internal.InternalPolicy; -import tango.util.collection.model.Map; +import dwtx.dwtxhelper.Collection; /** * Internal class used for non-API debug flags. @@ -33,5 +33,5 @@ * (NON-API) Instead of logging current conflicts they can be * held here. If there is a problem, they can be reported then. */ - public static Map!(Object/+???+/,Object/+???+/) currentConflicts = null; + public static Map currentConflicts = null; }
--- a/dwtx/jface/preference/FieldEditorPreferencePage.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/preference/FieldEditorPreferencePage.d Thu Aug 07 15:01:33 2008 +0200 @@ -18,8 +18,6 @@ import dwtx.jface.preference.FieldEditor; import dwtx.jface.preference.FieldEditorPreferencePage; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; // import java.util.Iterator; // import java.util.List; @@ -33,6 +31,7 @@ import dwtx.jface.util.PropertyChangeEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A special abstract preference page to host field editors. @@ -78,7 +77,7 @@ /** * The field editors, or <code>null</code> if not created yet. */ - private Seq!(Object) fields = null; + private List fields = null; /** * The layout style; either <code>FLAT</code> or <code>GRID</code>. @@ -148,9 +147,9 @@ */ protected void addField(FieldEditor editor) { if (fields is null) { - fields = new ArraySeq!(Object); + fields = new ArrayList(); } - fields.append(editor); + fields.add(editor); } /** @@ -173,8 +172,9 @@ */ protected void applyFont() { if (fields !is null) { - foreach( e; fields ){ - FieldEditor pe = cast(FieldEditor) e; + Iterator e = fields.iterator(); + while (e.hasNext()) { + FieldEditor pe = cast(FieldEditor) e.next(); pe.applyFont_package(); } } @@ -188,8 +188,9 @@ private int calcNumberOfColumns() { int result = 0; if (fields !is null) { - foreach( e; fields ){ - FieldEditor pe = cast(FieldEditor) e; + Iterator e = fields.iterator(); + while (e.hasNext()) { + FieldEditor pe = cast(FieldEditor) e.next(); result = Math.max(result, pe.getNumberOfControls()); } } @@ -268,8 +269,9 @@ public override void dispose() { super.dispose(); if (fields !is null) { - foreach( e; fields ){ - FieldEditor pe = cast(FieldEditor) e; + Iterator e = fields.iterator(); + while (e.hasNext()) { + FieldEditor pe = cast(FieldEditor) e.next(); pe.setPage(null); pe.setPropertyChangeListener(null); pe.setPreferenceStore(null); @@ -304,8 +306,9 @@ */ protected void initialize() { if (fields !is null) { - foreach( e; fields ){ - FieldEditor pe = cast(FieldEditor) e; + Iterator e = fields.iterator(); + while (e.hasNext()) { + FieldEditor pe = cast(FieldEditor) e.next(); pe.setPage(this); pe.setPropertyChangeListener(this); pe.setPreferenceStore(getPreferenceStore()); @@ -320,8 +323,9 @@ */ protected override void performDefaults() { if (fields !is null) { - foreach( e; fields ){ - FieldEditor pe = cast(FieldEditor) e; + Iterator e = fields.iterator(); + while (e.hasNext()) { + FieldEditor pe = cast(FieldEditor) e.next(); pe.loadDefault(); } } @@ -341,8 +345,9 @@ */ public override bool performOk() { if (fields !is null) { - foreach( e; fields ){ - FieldEditor pe = cast(FieldEditor) e; + Iterator e = fields.iterator(); + while (e.hasNext()) { + FieldEditor pe = cast(FieldEditor) e.next(); pe.store(); pe.setPresentsDefaultValue_package(false); }
--- a/dwtx/jface/preference/PreferenceConverter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/preference/PreferenceConverter.d Thu Aug 07 15:01:33 2008 +0200 @@ -27,6 +27,7 @@ import dwtx.jface.resource.StringConverter; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A utility class for dealing with preferences whose values are
--- a/dwtx/jface/preference/PreferenceDialog.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/preference/PreferenceDialog.d Thu Aug 07 15:01:33 2008 +0200 @@ -85,6 +85,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; +import dwtx.dwtxhelper.Collection; /** * A preference dialog is a hierarchical presentation of preference pages. Each @@ -264,24 +265,17 @@ */ protected override void cancelPressed() { // Inform all pages that we are cancelling - foreach( e; preferenceManager.getElements(PreferenceManager.PRE_ORDER)){ - IPreferenceNode node = cast(IPreferenceNode) e; + Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); + while (nodes.hasNext()) { + IPreferenceNode node = cast(IPreferenceNode) nodes.next(); if (getPage(node) !is null) { // this_: strange workaround for compiler error with dmd 1.028 in run() - SafeRunnable.run(new class(this,node) SafeRunnable { - IPreferenceNode node_; - PreferenceDialog this_; - this(PreferenceDialog pd, IPreferenceNode b){ - this_=pd; - node_=b; + SafeRunnable.run(dgSafeRunnable((IPreferenceNode node_, PreferenceDialog this_) { + if (!this_.getPage(node_).performCancel()) { + return; } - public void run() { - if (!this_.getPage(node_).performCancel()) { - return; - } - } - }); + }, cast(IPreferenceNode)node, this )); } } setReturnCode(CANCEL); @@ -791,8 +785,9 @@ * found. */ protected IPreferenceNode findNodeMatching(String nodeId) { - foreach( e; preferenceManager.getElements(PreferenceManager.POST_ORDER)){ - IPreferenceNode node = cast(IPreferenceNode) e; + List nodes = preferenceManager.getElements(PreferenceManager.POST_ORDER); + for (Iterator i = nodes.iterator(); i.hasNext();) { + IPreferenceNode node = cast(IPreferenceNode) i.next(); if (node.getId().equals(nodeId)) { return node; } @@ -871,8 +866,9 @@ * </p> */ protected void handleSave() { - foreach( e; preferenceManager.getElements(PreferenceManager.PRE_ORDER)){ - IPreferenceNode node = cast(IPreferenceNode) e; + Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); + while (nodes.hasNext()) { + IPreferenceNode node = cast(IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (cast(PreferencePage)page ) { // Save now in case tbe workbench does not shutdown cleanly @@ -968,8 +964,10 @@ bool hasFailedOK = false; try { // Notify all the pages and give them a chance to abort - foreach( e; preferenceManager.getElements(PreferenceManager.PRE_ORDER)){ - IPreferenceNode node = cast(IPreferenceNode) e; + Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER) + .iterator(); + while (nodes.hasNext()) { + IPreferenceNode node = cast(IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page !is null) { if (!page.performOk()){
--- a/dwtx/jface/preference/PreferenceManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/preference/PreferenceManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,14 +16,13 @@ import dwtx.jface.preference.PreferenceNode; import dwtx.jface.preference.IPreferenceNode; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; // import java.util.List; // import java.util.StringTokenizer; import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.Util; /** @@ -133,16 +132,16 @@ * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> */ - protected void buildSequence(IPreferenceNode node, Seq!(Object) sequence, int order) { + protected void buildSequence(IPreferenceNode node, List sequence, int order) { if (order is PRE_ORDER) { - sequence.append(cast(Object)node); + sequence.add(cast(Object)node); } IPreferenceNode[] subnodes = node.getSubNodes(); for (int i = 0; i < subnodes.length; i++) { buildSequence(subnodes[i], sequence, order); } if (order is POST_ORDER) { - sequence.append(cast(Object)node); + sequence.add(cast(Object)node); } } @@ -192,10 +191,10 @@ * (element type: <code>IPreferenceNode</code>) * in the given order */ - public Seq!(Object) getElements(int order) { + public List getElements(int order) { Assert.isTrue(order is PRE_ORDER || order is POST_ORDER, "invalid traversal order");//$NON-NLS-1$ - auto sequence = new ArraySeq!(Object); + ArrayList sequence = new ArrayList(); IPreferenceNode[] subnodes = getRoot().getSubNodes(); for (int i = 0; i < subnodes.length; i++) { buildSequence(subnodes[i], sequence, order);
--- a/dwtx/jface/preference/PreferenceNode.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/preference/PreferenceNode.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,7 +16,6 @@ import dwtx.jface.preference.IPreferencePage; -import tango.util.collection.ArraySeq; // import java.util.List; import dwt.graphics.Image; @@ -24,6 +23,7 @@ import dwtx.jface.resource.ImageDescriptor; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A concrete implementation of a node in a preference dialog tree. This class @@ -39,7 +39,7 @@ * The list of subnodes (immediate children) of this node (element type: * <code>IPreferenceNode</code>). */ - private ArraySeq!(Object) subNodes; + private List subNodes; /** * Name of a class that implements <code>IPreferencePage</code>, or @@ -128,9 +128,9 @@ */ public void add(IPreferenceNode node) { if (subNodes is null) { - subNodes = new ArraySeq!(Object); + subNodes = new ArrayList(); } - subNodes.append(cast(Object)node); + subNodes.add(cast(Object)node); } /** @@ -274,9 +274,7 @@ if (subNodes is null) { return false; } - bool res = subNodes.contains(cast(Object)node); - subNodes.remove(cast(Object)node); - return res; + return subNodes.remove(cast(Object)node); } /**
--- a/dwtx/jface/preference/PreferenceStore.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/preference/PreferenceStore.d Thu Aug 07 15:01:33 2008 +0200 @@ -25,7 +25,6 @@ // import java.util.ArrayList; // import java.util.Enumeration; // import java.util.Properties; -import tango.util.collection.ArraySeq; import dwtx.core.commands.common.EventManager; import dwtx.core.runtime.Assert; @@ -35,6 +34,7 @@ import dwtx.jface.util.SafeRunnable; import dwt.dwthelper.utils; +// import dwtx.dwtxhelper.Collection; import tango.io.Print; import tango.io.stream.FileStream;
--- a/dwtx/jface/resource/AbstractResourceManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/AbstractResourceManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,10 +15,9 @@ import dwtx.jface.resource.ResourceManager; import dwtx.jface.resource.DeviceResourceDescriptor; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * Abstract implementation of ResourceManager. Maintains reference counts for all previously @@ -33,7 +32,7 @@ /** * Map of ResourceDescriptor onto RefCount. (null when empty) */ - private HashMap!(DeviceResourceDescriptor,RefCount) map = null; + private HashMap map = null; /** * Holds a reference count for a previously-allocated resource @@ -77,11 +76,11 @@ // Lazily allocate the map if (map is null) { - map = new HashMap!(DeviceResourceDescriptor,RefCount); + map = new HashMap(); } // Get the current reference count - RefCount count = map.containsKey(descriptor) ? map.get(descriptor) : null; + RefCount count = cast(RefCount)map.get(descriptor); if (count !is null) { // If this resource already exists, increment the reference count and return // the existing resource. @@ -93,7 +92,7 @@ Object resource = allocate(descriptor); count = new RefCount(resource); - map.add(descriptor, count); + map.put(descriptor, count); return resource; } @@ -108,19 +107,19 @@ } // Find the existing resource - RefCount count = map.get(descriptor); + RefCount count = cast(RefCount)map.get(descriptor); if (count !is null) { // If the resource exists, decrement the reference count. count.count--; if (count.count is 0) { // If this was the last reference, deallocate it. deallocate(count.resource, descriptor); - map.removeKey(descriptor); + map.remove(descriptor); } } // Null out the map when empty to save a small amount of memory - if (map.drained()) { + if (map.isEmpty()) { map = null; } } @@ -138,8 +137,15 @@ return; } - foreach( key, val; map ){ - deallocate(val.resource, key); + Collection entries = map.entrySet(); + + for (Iterator iter = entries.iterator(); iter.hasNext();) { + Map.Entry next = cast(Map.Entry) iter.next(); + + Object key = next.getKey(); + RefCount val = cast(RefCount)next.getValue(); + + deallocate(val.resource, cast(DeviceResourceDescriptor)key); } map = null;
--- a/dwtx/jface/resource/ColorRegistry.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/ColorRegistry.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,13 +16,6 @@ import dwtx.jface.resource.ResourceRegistry; import dwtx.jface.resource.RGBColorDescriptor; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; -import tango.util.collection.HashSet; -import tango.util.collection.model.Map; -import tango.util.collection.model.Set; -import tango.util.collection.model.SetView; -import tango.util.collection.model.Seq; import dwt.graphics.Color; import dwt.graphics.RGB; @@ -30,6 +23,7 @@ import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -80,19 +74,19 @@ * Collection of <code>Color</code> that are now stale to be disposed when * it is safe to do so (i.e. on shutdown). */ - private Seq!(Color) staleColors; + private List staleColors; /** * Table of known colors, keyed by symbolic color name (key type: <code>String</code>, * value type: <code>dwt.graphics.Color</code>. */ - private Map!(String,Color) stringToColor; + private Map stringToColor; /** * Table of known color data, keyed by symbolic color name (key type: * <code>String</code>, value type: <code>dwt.graphics.RGB</code>). */ - private Map!(String,RGB) stringToRGB; + private Map stringToRGB; /** * Runnable that cleans up the manager on disposal of the display. @@ -138,9 +132,9 @@ */ public this(Display display, bool cleanOnDisplayDisposal) { init_DEFAULT_COLOR(); - staleColors = new ArraySeq!(Color); - stringToColor = new HashMap!(String,Color); - stringToRGB = new HashMap!(String,RGB); + staleColors = new ArrayList(); + stringToColor = new HashMap(); + stringToRGB = new HashMap(); init_displayRunnable(); Assert.isNotNull(display); this.display = display; @@ -177,14 +171,12 @@ * * @param iterator over <code>Collection</code> of <code>Color</code> */ - /+ private void disposeColors(Iterator iterator) { while (iterator.hasNext()) { Object next = iterator.next(); - ((Color) next).dispose(); + (cast(Color) next).dispose(); } } - +/ /** * Returns the <code>color</code> associated with the given symbolic color @@ -196,21 +188,21 @@ public Color get(String symbolicName) { Assert.isNotNull(symbolicName); - auto result1 = ( stringToColor.containsKey(symbolicName) ? stringToColor.get(symbolicName) : null ); - if (result1 !is null) { - return result1; + Object result = stringToColor.get(stringcast(symbolicName)); + if (result !is null) { + return cast(Color) result; } Color color = null; - auto result = ( stringToRGB.containsKey(symbolicName) ? stringToRGB.get(symbolicName) : null ); + result = stringToRGB.get(stringcast(symbolicName)); if (result is null) { return null; } - color = createColor(result); + color = createColor( cast(RGB) result); - stringToColor.add(symbolicName, color); + stringToColor.put(stringcast(symbolicName), color); return color; } @@ -218,12 +210,8 @@ /* (non-Javadoc) * @see dwtx.jface.resource.ResourceRegistry#getKeySet() */ - public override SetView!(String) getKeySet() { - auto res = new HashSet!(String); - foreach( k,v; stringToRGB ){ - res.add(k); - } - return res; + public override Set getKeySet() { + return Collections.unmodifiableSet(stringToRGB.keySet()); } /** @@ -235,7 +223,7 @@ */ public RGB getRGB(String symbolicName) { Assert.isNotNull(symbolicName); - return stringToRGB.get(symbolicName); + return cast(RGB) stringToRGB.get(symbolicName); } /** @@ -279,14 +267,8 @@ * @see dwtx.jface.resource.ResourceRegistry#clearCaches() */ protected override void clearCaches() { - foreach( k, v; stringToColor ){ - v.dispose(); - } - foreach( v; staleColors ){ - v.dispose(); - } -// disposeColors(stringToColor.values().iterator()); -// disposeColors(staleColors.iterator()); + disposeColors(stringToColor.values().iterator()); + disposeColors(staleColors.iterator()); stringToColor.clear(); staleColors.clear(); display = null; @@ -342,20 +324,19 @@ Assert.isNotNull(symbolicName); Assert.isNotNull(colorData); - RGB existing = stringToRGB.get(symbolicName); + RGB existing = cast(RGB)stringToRGB.get(symbolicName); if (colorData.opEquals(existing)) { return; } - Color oldColor = stringToColor.get(symbolicName); - stringToColor.removeKey(symbolicName); - stringToRGB.add(symbolicName, colorData); + Color oldColor = cast(Color) stringToColor.remove(symbolicName); + stringToRGB.put(stringcast(symbolicName), colorData); if (update) { fireMappingChanged(symbolicName, existing, colorData); } if (oldColor !is null) { - staleColors.append(oldColor); + staleColors.add(oldColor); } } }
--- a/dwtx/jface/resource/FontRegistry.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/FontRegistry.d Thu Aug 07 15:01:33 2008 +0200 @@ -18,13 +18,7 @@ import dwtx.jface.resource.JFaceResources; import dwtx.jface.resource.DataFormatException; -import tango.util.collection.ArraySeq; import dwtx.dwtxhelper.JHashMap; -import tango.util.collection.model.Map; -import tango.util.collection.model.Seq; -import tango.util.collection.model.Set; -import tango.util.collection.model.SetView; -import tango.util.collection.HashSet; // import java.util.Arrays; // import java.util.Collections; // import java.util.Enumeration; @@ -44,6 +38,7 @@ import dwt.dwthelper.ResourceBundle; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; version(Windows) import dwt.internal.win32.OS; @@ -181,13 +176,13 @@ //Return all of the fonts allocated by the receiver. //if any of them are the defaultFont then don't bother. if (defaultFont !is baseFont && baseFont !is null) { - staleFonts.append(baseFont); + staleFonts.add(baseFont); } if (defaultFont !is boldFont && boldFont !is null) { - staleFonts.append(boldFont); + staleFonts.add(boldFont); } if (defaultFont !is italicFont && italicFont !is null) { - staleFonts.append(italicFont); + staleFonts.add(italicFont); } } } @@ -197,21 +192,21 @@ * (key type: <code>String</code>, * value type: <code>FontRecord</code>. */ - private JHashMapT!(String,FontRecord) stringToFontRecord; + private Map stringToFontRecord; /** * Table of known font data, keyed by symbolic font name * (key type: <code>String</code>, * value type: <code>dwt.graphics.FontData[]</code>). */ - private JHashMapT!(String,FontData[]) stringToFontData; + private Map stringToFontData; /** * Collection of Fonts that are now stale to be disposed * when it is safe to do so (i.e. on shutdown). * @see List */ - private Seq!(Font) staleFonts; + private List staleFonts; /** * Runnable that cleans up the manager on disposal of the display. @@ -307,13 +302,9 @@ clearCaches(); } }; - stringToFontRecord = new JHashMapT!(String,FontRecord); - //stringToFontRecord.capacity(7); - - stringToFontData = new JHashMapT!(String,FontData[]); - //stringToFontData.capacity(7); - - staleFonts = new ArraySeq!(Font); + stringToFontRecord = new HashMap(7); + stringToFontData = new HashMap(7); + staleFonts = new ArrayList(); } /** @@ -497,8 +488,7 @@ * @since 3.1 */ public FontData [] filterData(FontData [] fonts, Display display) { - ArraySeq!(FontData) good = new ArraySeq!(FontData); - good.capacity(fonts.length); + ArrayList good = new ArrayList(fonts.length); for (int i = 0; i < fonts.length; i++) { FontData fd = fonts[i]; @@ -508,26 +498,26 @@ FontData[] fixedFonts = display.getFontList(fd.getName(), false); if (isFixedFont(fixedFonts, fd)) { - good.append(fd); + good.add(fd); } FontData[] scalableFonts = display.getFontList(fd.getName(), true); if (scalableFonts.length > 0) { - good.append(fd); + good.add(fd); } } //None of the provided datas are valid. Return the //first one as it is at least the first choice. - if (good.drained() && fonts.length > 0) { - good.append(fonts[0]); + if (good.isEmpty() && fonts.length > 0) { + good.add(fonts[0]); } else if (fonts.length is 0) { return null; } - return good.toArray(); + return arraycast!(FontData)(good.toArray()); } @@ -602,13 +592,14 @@ */ private FontRecord defaultFontRecord() { - FontRecord record = cast(FontRecord) stringToFontRecord.find(JFaceResources.DEFAULT_FONT); + FontRecord record = cast(FontRecord) stringToFontRecord + .get(JFaceResources.DEFAULT_FONT); if (record is null) { Font defaultFont = calculateDefaultFont(); record = createFont(JFaceResources.DEFAULT_FONT, defaultFont .getFontData()); defaultFont.dispose(); - stringToFontRecord.add(JFaceResources.DEFAULT_FONT, record); + stringToFontRecord.put(stringcast(JFaceResources.DEFAULT_FONT), record); } return record; } @@ -631,12 +622,12 @@ public FontData[] getFontData(String symbolicName) { Assert.isTrue(symbolicName.length > 0); - auto result = stringToFontData.find(symbolicName); - if (result.length is 0) { + Object result = stringToFontData.get(symbolicName); + if (result is null) { return defaultFontData(); } - return result; + return arrayFromObject!(FontData)(result); } /** @@ -687,26 +678,26 @@ */ private FontRecord getFontRecord(String symbolicName) { Assert.isNotNull(symbolicName); - auto result1 = stringToFontRecord.find(symbolicName); - if (result1 !is null) { - return cast(FontRecord) result1; + auto result = stringToFontRecord.get(symbolicName); + if (result !is null) { + return cast(FontRecord) result; } - auto result = stringToFontData.find(symbolicName); + result = stringToFontData.get(symbolicName); FontRecord fontRecord; if (result is null) { fontRecord = defaultFontRecord(); } else { - fontRecord = createFont(symbolicName, result); + fontRecord = createFont(symbolicName, arrayFromObject!(FontData)(result)); } if (fontRecord is null) { fontRecord = defaultFontRecord(); } - stringToFontRecord.add(symbolicName.dup, fontRecord); + stringToFontRecord.put(symbolicName.dup, fontRecord); return fontRecord; } @@ -714,12 +705,8 @@ /* (non-Javadoc) * @see dwtx.jface.resource.ResourceRegistry#getKeySet() */ - public override SetView!(String) getKeySet() { - auto res = new HashSet!(String); - foreach( k, v; stringToFontData ){ - res.add( k ); - } - return res; + public override Set getKeySet() { + return Collections.unmodifiableSet(stringToFontData.keySet()); } /* (non-Javadoc) @@ -733,20 +720,32 @@ * @see dwtx.jface.resource.ResourceRegistry#clearCaches() */ protected override void clearCaches() { - foreach( k,v; stringToFontRecord ){ - v.dispose(); - } - foreach( fnt; staleFonts.toArray ){ - fnt.dispose(); + + Iterator iterator = stringToFontRecord.values().iterator(); + while (iterator.hasNext()) { + Object next = iterator.next(); + (cast(FontRecord) next).dispose(); } + disposeFonts(staleFonts.iterator()); stringToFontRecord.clear(); staleFonts.clear(); - + displayDisposeHooked = false; } /** + * Dispose of all of the fonts in this iterator. + * @param iterator over Collection of Font + */ + private void disposeFonts(Iterator iterator) { + while (iterator.hasNext()) { + Object next = iterator.next(); + (cast(Font) next).dispose(); + } + } + + /** * Hook a dispose listener on the DWT display. */ private void hookDisplayDispose(Display display) { @@ -819,16 +818,15 @@ Assert.isNotNull(symbolicName); Assert.isTrue(fontData.length > 0 ); - FontData[] existing = stringToFontData.find(symbolicName); + FontData[] existing = arrayFromObject!(FontData)( stringToFontData.get(stringcast(symbolicName))); if (ArrayEquals(existing, fontData)) { return; } - FontRecord oldFont = stringToFontRecord.find(symbolicName); - stringToFontRecord.removeKey(symbolicName); - stringToFontData.add(symbolicName.dup, fontData); + FontRecord oldFont = cast(FontRecord) stringToFontRecord.remove(stringcast(symbolicName)); + stringToFontData.put(symbolicName.dup, new ArrayWrapperObject(fontData)); if (update) { - fireMappingChanged(symbolicName, new ArrayWrapperT!(FontData)(existing), new ArrayWrapperT!(FontData)(fontData)); + fireMappingChanged(symbolicName, new ArrayWrapperT!(FontData)(existing), new ArrayWrapperObject(arraycast!(Object)(fontData))); } if (oldFont !is null) { @@ -842,10 +840,12 @@ * real Font objects when requested. */ private void readResourceBundle(ResourceBundle bundle, String bundleName) { - foreach( key; bundle.getKeys() ){ + auto keys = bundle.getKeys(); + foreach ( key; keys ) { int pos = key.lastIndexOf('.'); if (pos is -1) { - stringToFontData.add(key.dup, [ makeFontData(bundle.getString(key)) ]); + stringToFontData.put(stringcast(key.dup), new ArrayWrapperObject(arraycast!(Object)([ makeFontData(bundle + .getString(key)) ]))); } else { String name = key.substring(0, pos); int i = 0; @@ -856,16 +856,16 @@ throw new MissingResourceException( "Wrong key format ", bundleName, key); //$NON-NLS-1$ } - FontData[] elements = stringToFontData.find(name); + FontData[] elements = arrayFromObject!(FontData)( stringToFontData.get(stringcast(name))); if (elements is null) { elements = new FontData[8]; - stringToFontData.add(name.dup, elements); + stringToFontData.put(name.dup, new ArrayWrapperObject(elements)); } if (i > elements.length) { FontData[] na = new FontData[i + 8]; System.arraycopy(elements, 0, na, 0, elements.length); elements = na; - stringToFontData.add(name.dup, elements); + stringToFontData.put(name.dup, new ArrayWrapperObject(elements)); } elements[i] = makeFontData(bundle.getString(key)); }
--- a/dwtx/jface/resource/ImageRegistry.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/ImageRegistry.d Thu Aug 07 15:01:33 2008 +0200 @@ -20,8 +20,6 @@ import dwtx.jface.resource.DeviceResourceException; import dwtx.jface.resource.JFaceResources; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; // import java.util.Iterator; // import java.util.Map; @@ -35,6 +33,7 @@ import dwtx.jface.dialogs.Dialog; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -64,7 +63,7 @@ private ResourceManager manager; - private Map!(String,Entry) table; + private Map table; private Runnable disposeRunnable; private void init_disposeRunnable(){ @@ -263,7 +262,7 @@ Entry entry = getEntry(key); if (entry is null) { entry = new Entry(); - getTable().add(key, entry); + getTable().put(stringcast(key), entry); } if (entry.image !is null) { @@ -324,22 +323,21 @@ ImageDescriptor descriptor = getDescriptor(key); if (descriptor !is null) { manager.destroy(descriptor); - getTable().removeKey(key); + getTable().remove(stringcast(key)); } } private Entry getEntry(String key) { - auto tbl = getTable(); - return cast(Entry) ( tbl.containsKey(key) ? tbl.get(key) : null ); + return cast(Entry) getTable().get(stringcast(key)); } private void putEntry(String key, Entry entry) { - getTable().add(key, entry); + getTable().put(stringcast(key), entry); } - private Map!(String,Entry) getTable() { + private Map getTable() { if (table is null) { - table = new HashMap!(String,Entry)/+(10)+/; + table = new HashMap(10); } return table; } @@ -354,7 +352,8 @@ manager.cancelDisposeExec(disposeRunnable); if (table !is null) { - foreach( key,entry; table ){ + for (Iterator i = table.values().iterator(); i.hasNext();) { + Entry entry = cast(Entry) i.next(); if (entry.image !is null) { manager.destroyImage(entry.descriptor); }
--- a/dwtx/jface/resource/JFaceResources.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/JFaceResources.d Thu Aug 07 15:01:33 2008 +0200 @@ -20,8 +20,6 @@ import dwtx.jface.resource.DeviceResourceManager; import dwtx.jface.resource.ImageDescriptor; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; import dwt.graphics.Font; import dwt.graphics.Image; @@ -34,6 +32,7 @@ import dwtx.jface.wizard.Wizard; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; import dwt.dwthelper.ResourceBundle; import tango.text.convert.Format; @@ -66,11 +65,11 @@ * Map of Display onto DeviceResourceManager. Holds all the resources for * the associated display. */ - private static Map!(Display,ResourceManager) registries; + private static Map registries; private static void init_registries(){ if( registries is null ){ synchronized if( registries is null ){ - registries = new HashMap!(Display,ResourceManager); + registries = new HashMap(); } } } @@ -219,28 +218,21 @@ */ public static ResourceManager getResources(Display toQuery) { init_registries(); - ResourceManager reg = registries.containsKey(toQuery) ? cast(ResourceManager) registries.get(toQuery) : null; + ResourceManager reg = cast(ResourceManager) registries.get(toQuery); if (reg is null) { - toQuery.disposeExec(new class(toQuery) Runnable { - DeviceResourceManager mgr; - Display toQuery_; - this(Display d){ - mgr = new DeviceResourceManager(d); - reg = mgr; - toQuery_ = d; - registries.add(d, reg); - } + DeviceResourceManager mgr = new DeviceResourceManager(toQuery); + reg = mgr; + registries.put(toQuery, reg); + toQuery.disposeExec( dgRunnable( (DeviceResourceManager mgr_, Display toQuery_){ /* * (non-Javadoc) * * @see java.lang.Runnable#run() */ - public void run() { - mgr.dispose(); - registries.removeKey(toQuery_); - } - }); + mgr_.dispose(); + registries.remove(toQuery_); + }, mgr, toQuery )); } return reg;
--- a/dwtx/jface/resource/ResourceManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/ResourceManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -20,8 +20,6 @@ import dwtx.jface.resource.RGBColorDescriptor; // import java.util.ArrayList; -import tango.util.collection.model.Seq; -import tango.util.collection.ArraySeq; import dwt.DWTException; import dwt.graphics.Color; @@ -35,6 +33,7 @@ import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -58,7 +57,7 @@ * List of Runnables scheduled to run when the ResourceManager is disposed. * null if empty. */ - private Seq!(Runnable) disposeExecs = null; + private List disposeExecs = null; /** * Returns the Device for which this ResourceManager will create resources @@ -339,7 +338,7 @@ // here and throw it at the end of the method. RuntimeException foundException = null; - Runnable[] execs = disposeExecs.toArray(); + Runnable[] execs = arraycast!(Runnable)(disposeExecs.toArray()); for (int i = 0; i < execs.length; i++) { Runnable exec = execs[i]; @@ -380,10 +379,10 @@ Assert.isNotNull(cast(Object)r); if (disposeExecs is null) { - disposeExecs = new ArraySeq!(Runnable); + disposeExecs = new ArrayList(); } - disposeExecs.append(r); + disposeExecs.add(cast(Object)r); } /** @@ -400,9 +399,9 @@ return; } - disposeExecs.remove(r); + disposeExecs.remove(cast(Object)r); - if (disposeExecs.drained()) { + if (disposeExecs.isEmpty()) { disposeExecs = null; } }
--- a/dwtx/jface/resource/ResourceRegistry.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/ResourceRegistry.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,13 +12,13 @@ *******************************************************************************/ module dwtx.jface.resource.ResourceRegistry; -import tango.util.collection.model.SetView; import dwtx.core.commands.common.EventManager; import dwtx.jface.util.IPropertyChangeListener; import dwtx.jface.util.PropertyChangeEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * Abstract base class for various JFace registries. @@ -45,7 +45,7 @@ * @return the set of keys this manager knows about. This collection * should be immutable. */ - public abstract SetView!(String) getKeySet(); + public abstract Set getKeySet(); /** * Return whether or not the receiver has a value for the supplied key.
--- a/dwtx/jface/resource/StringConverter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/resource/StringConverter.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,7 +15,6 @@ import dwtx.jface.resource.JFaceResources; import dwtx.jface.resource.DataFormatException; -import tango.util.collection.ArraySeq; import dwt.DWT; import dwt.graphics.FontData; @@ -25,6 +24,7 @@ import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +// import dwtx.dwtxhelper.Collection; static import tango.text.Util; static import tango.text.convert.Float; static import tango.text.convert.Integer; @@ -103,11 +103,7 @@ * @throws DataFormatException thrown if request string could not seperated */ public static String[] asArray(String value) { - ArraySeq!(String) list = new ArraySeq!(String); - foreach ( s; tango.text.Util.delimit( value, " \t\n\r\f" )) { - list.append(s); - } - return list.toArray(); + return tango.text.Util.delimit( value, " \t\n\r\f" ); } /** @@ -313,14 +309,14 @@ if (prop is null || prop.trim().equals("")) { //$NON-NLS-1$ return new String[0]; } - ArraySeq!(String) list = new ArraySeq!(String); + String[] list; foreach ( s; tango.text.Util.delimit( prop, separator )) { String token = s.trim(); if (!token.equals("")) { //$NON-NLS-1$ - list.append(token); + list ~= token; } } - return list.drained() ? null : list.toArray(); + return list; } /** @@ -332,16 +328,15 @@ */ public static FontData[] asFontDataArray(String value) { String[] strings = getArrayFromList(value, FONT_SEPARATOR); - ArraySeq!(FontData) data = new ArraySeq!(FontData); - data.capacity(strings.length); + FontData[] data = new FontData[strings.length]; for (int i = 0; i < strings.length; i++) { try { - data.append(StringConverter.asFontData(strings[i])); + data[i] = StringConverter.asFontData(strings[i]); } catch (DataFormatException e) { //do-nothing } } - return data.toArray(); + return data; } /**
--- a/dwtx/jface/util/DelegatingDragAdapter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/util/DelegatingDragAdapter.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,7 +15,6 @@ import dwtx.jface.util.TransferDragSourceListener; import dwtx.jface.util.SafeRunnable; -import tango.util.collection.ArraySeq; import dwt.dnd.DragSource; import dwt.dnd.DragSourceEvent; @@ -24,6 +23,7 @@ import dwt.dnd.TransferData; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A <code>DelegatingDragAdapter</code> is a <code>DragSourceListener</code> that @@ -93,15 +93,15 @@ * @since 3.0 */ public class DelegatingDragAdapter : DragSourceListener { - private ArraySeq!(Object) listeners; + private List listeners; - private ArraySeq!(Object) activeListeners; + private List activeListeners; private TransferDragSourceListener currentListener; this(){ - listeners = new ArraySeq!(Object); - activeListeners = new ArraySeq!(Object); + listeners = new ArrayList(); + activeListeners = new ArrayList(); } /** @@ -110,7 +110,7 @@ * @param listener the new listener */ public void addDragSourceListener(TransferDragSourceListener listener) { - listeners.append(cast(Object)listener); + listeners.add(cast(Object)listener); } /** @@ -137,8 +137,9 @@ } else { // The drag was canceled and currentListener was never set, so send the // dragFinished event to all the active listeners. - foreach( e; activeListeners ){ - (cast(TransferDragSourceListener) e) + Iterator iterator = activeListeners.iterator(); + while (iterator.hasNext()) { + (cast(TransferDragSourceListener) iterator.next()) .dragFinished(event); } } @@ -187,8 +188,7 @@ // if (Policy.DEBUG_DRAG_DROP) // System.out.println("Drag Start: " + toString()); //$NON-NLS-1$ bool doit = false; // true if any one of the listeners can handle the drag - auto transfers = new ArraySeq!(Object); - transfers.capacity(listeners.size()); + List transfers = new ArrayList(listeners.size()); activeListeners.clear(); for (int i = 0; i < listeners.size(); i++) { @@ -207,8 +207,8 @@ } }); if (event.doit) { // the listener can handle this drag - transfers.append(listener.getTransfer()); - activeListeners.append(cast(Object)listener); + transfers.add(listener.getTransfer()); + activeListeners.add(cast(Object)listener); } doit |= event.doit; } @@ -243,7 +243,7 @@ * <code>false</code> otherwise. */ public bool isEmpty() { - return listeners.drained(); + return listeners.isEmpty(); } /** @@ -275,8 +275,10 @@ if (event.dataType is null) { return; } - foreach( e; activeListeners ){ - TransferDragSourceListener listener = cast(TransferDragSourceListener)e; + Iterator iterator = activeListeners.iterator(); + while (iterator.hasNext()) { + TransferDragSourceListener listener = cast(TransferDragSourceListener) iterator + .next(); if (listener.getTransfer().isSupportedType(event.dataType)) { // if (Policy.DEBUG_DRAG_DROP)
--- a/dwtx/jface/util/DelegatingDropAdapter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/util/DelegatingDropAdapter.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,7 +15,6 @@ import dwtx.jface.util.TransferDropTargetListener; import dwtx.jface.util.SafeRunnable; -import tango.util.collection.ArraySeq; import dwt.dnd.DND; import dwt.dnd.DropTargetEvent; @@ -24,6 +23,7 @@ import dwt.dnd.TransferData; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A <code>DelegatingDropAdapter</code> is a <code>DropTargetListener</code> that @@ -104,14 +104,14 @@ * @since 3.0 */ public class DelegatingDropAdapter : DropTargetListener { - private ArraySeq!(Object) listeners; + private List listeners; private TransferDropTargetListener currentListener; private int originalDropType; this(){ - listeners = new ArraySeq!(Object); + listeners = new ArrayList(); } /** @@ -120,7 +120,7 @@ * @param listener the new listener */ public void addDropTargetListener(TransferDropTargetListener listener) { - listeners.append(cast(Object)listener); + listeners.add(cast(Object)listener); } /** @@ -312,7 +312,7 @@ * <code>false</code> otherwise */ public bool isEmpty() { - return listeners.drained(); + return listeners.isEmpty(); } /** @@ -381,8 +381,10 @@ // to something other than what the user indicated. event.detail = originalDropType; - foreach( e; listeners ){ - TransferDropTargetListener listener = cast(TransferDropTargetListener)e; + Iterator iter = listeners.iterator(); + while (iter.hasNext()) { + TransferDropTargetListener listener = cast(TransferDropTargetListener) iter + .next(); TransferData dataType = getSupportedTransferType(event.dataTypes, listener); if (dataType !is null) {
--- a/dwtx/jface/util/SafeRunnable.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/util/SafeRunnable.d Thu Aug 07 15:01:33 2008 +0200 @@ -60,7 +60,7 @@ /* * (non-Javadoc) - * + * * @see dwtx.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ public void handleException(Exception e) { @@ -184,3 +184,31 @@ } } + +import tango.core.Tuple; +import tango.core.Traits; + +class _DgSafeRunnableT(Dg,T...) : SafeRunnable { + + alias ParameterTupleOf!(Dg) DgArgs; + static assert( is(DgArgs == Tuple!(T)), + "Delegate args not correct" ); + + Dg dg; + T t; + + private this( Dg dg, T t ){ + this.dg = dg; + static if( T.length > 0 ){ + this.t = t; + } + } + + public void run( ){ + dg(t); + } +} + +public _DgSafeRunnableT!(Dg,T) dgSafeRunnable(Dg,T...)( Dg dg, T args ){ + return new _DgSafeRunnableT!(Dg,T)(dg,args); +}
--- a/dwtx/jface/util/SafeRunnableDialog.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/util/SafeRunnableDialog.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,8 +12,6 @@ *******************************************************************************/ module dwtx.jface.util.SafeRunnableDialog; -import tango.util.collection.model.Seq; -import tango.util.collection.ArraySeq; import dwt.DWT; import dwt.graphics.Point; @@ -38,6 +36,7 @@ import dwtx.jface.util.Util; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * SafeRunnableDialog is a dialog that can show the results of multiple safe @@ -48,7 +47,7 @@ private TableViewer statusListViewer; - private Seq!(IStatus) statuses; + private Collection statuses; /** * Create a new instance of the receiver on a status. @@ -60,12 +59,12 @@ super(null, JFaceResources.getString("error"), status.getMessage(), //$NON-NLS-1$ status, IStatus.ERROR); - statuses = new ArraySeq!(IStatus); + statuses = new ArrayList(); setShellStyle(DWT.DIALOG_TRIM | DWT.MODELESS | DWT.RESIZE | DWT.MIN | DWT.MAX | getDefaultOrientation()); setStatus(status); - statuses.append(status); + statuses.add(cast(Object)status); setBlockOnOpen(false); @@ -214,13 +213,7 @@ * @see dwtx.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ public Object[] getElements(Object inputElement) { - Object[] res = new Object[ statuses.size() ]; - int idx; - foreach( st; statuses ){ - res[idx] = cast(Object)st; - idx++; - } - return res; + return statuses.toArray(); } /* @@ -334,7 +327,7 @@ * @param status */ public void addStatus(IStatus status) { - statuses.append(status); + statuses.add(cast(Object)status); refresh(); }
--- a/dwtx/jface/viewers/AbstractListViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/AbstractListViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -22,15 +22,13 @@ import dwtx.jface.viewers.ViewerComparator; import dwtx.jface.viewers.IElementComparer; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwt.widgets.Control; import dwt.widgets.Widget; import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -50,7 +48,7 @@ /** * A list of viewer elements (element type: <code>Object</code>). */ - private Seq!(Object) listMap; + private dwtx.dwtxhelper.Collection.List listMap; /** * Adds the given string to the underlying widget at the given index @@ -132,7 +130,7 @@ protected abstract void listDeselectAll(); public this(){ - listMap = new ArraySeq!(Object); + listMap = new ArrayList(); } /** @@ -160,7 +158,7 @@ private void insertItem(ILabelProvider labelProvider, Object element, int index) { listAdd(getLabelProviderText(labelProvider, element), index); - listMap.addAt(index, element); + listMap.add(index, element); mapElement(element, getControl()); // must map it, since findItem only looks in map, if enabled } @@ -294,14 +292,13 @@ /* (non-Javadoc) * Method declared on StructuredViewer. */ - protected override SeqView!(Object) getSelectionFromWidget() { + protected override List getSelectionFromWidget() { int[] ixs = listGetSelectionIndices(); - ArraySeq!(Object) list = new ArraySeq!(Object); - list.capacity(ixs.length); + ArrayList list = new ArrayList(ixs.length); for (int i = 0; i < ixs.length; i++) { Object e = getElementAt(ixs[i]); if (e !is null) { - list.append(e); + list.add(e); } } return list; @@ -356,7 +353,7 @@ for (int i = 0; i < size; i++) { Object el = children[i]; labels[i] = getLabelProviderText(cast(ILabelProvider) getLabelProvider(),el); - listMap.append(el); + listMap.add(el); mapElement(el, getControl()); // must map it, since findItem only looks in map, if enabled } listSetItems(labels); @@ -373,10 +370,10 @@ listMap.clear(); } unmapAllElements(); - auto selection = getSelectionFromWidget(); + List selection = getSelectionFromWidget(); int topIndex = -1; - if (selection is null || selection.drained()) { + if (selection is null || selection.isEmpty()) { topIndex = listGetTopIndex(); } @@ -384,19 +381,19 @@ list.setRedraw(false); try { listRemoveAll(); - + children = getSortedChildren(getRoot()); String[] items = new String[children.length]; - + ILabelProvider labelProvider = cast(ILabelProvider) getLabelProvider(); - + for (int i = 0; i < items.length; i++) { Object el = children[i]; items[i] = getLabelProviderText(labelProvider, el); - listMap.append(el); + listMap.add(el); mapElement(el, list); // must map it, since findItem only looks in map, if enabled } - + listSetItems(items); } finally { list.setRedraw(true); @@ -450,7 +447,7 @@ int ix = getElementIndex(elements[i]); if (ix >= 0) { listRemove(ix); - listMap.removeAt(ix); + listMap.remove(ix); unmapElement(elements[i], getControl()); } } @@ -472,15 +469,9 @@ if (elements.length is 0) { return; } - preservingSelection(new class(elements) Runnable { - Object[] elements_; - this(Object[] a){ - elements_= a; - } - public void run() { - internalRemove(elements_); - } - }); + preservingSelection( dgRunnable( (Object[] elements_){ + internalRemove(elements_); + }, elements)); } /** @@ -516,7 +507,7 @@ /* (non-Javadoc) * Method declared on StructuredViewer. */ - protected override void setSelectionToWidget(SeqView!(Object) in_, bool reveal) { + protected override void setSelectionToWidget(List in_, bool reveal) { if (in_ is null || in_.size() is 0) { // clear selection listDeselectAll(); } else { @@ -550,14 +541,7 @@ int getElementIndex(Object element) { IElementComparer comparer = getComparer(); if (comparer is null) { - int idx = 0; - foreach( e; listMap ){ - if( e == element ){ - return idx; - } - idx++; - } - return -1; + return listMap.indexOf(element); } int size = listMap.size(); for (int i = 0; i < size; i++) {
--- a/dwtx/jface/viewers/AbstractTableViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/AbstractTableViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -25,9 +25,6 @@ import dwtx.jface.viewers.ViewerComparator; import dwtx.jface.viewers.IStructuredContentProvider; -import tango.util.collection.model.SeqView; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashSet; import dwt.DWT; import dwt.widgets.Control; @@ -38,6 +35,7 @@ import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; import tango.core.Array; @@ -74,32 +72,29 @@ * Add the listener for SetData on the table */ private void addTableListener() { - getControl().addListener(DWT.SetData, new class Listener { + getControl().addListener(DWT.SetData, dgListener( (Event event){ /* * (non-Javadoc) * * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) */ - public void handleEvent(Event event) { - Item item = cast(Item) event.item; - final int index = doIndexOf(item); - Object element = resolveElement(index); - if (element is null) { - // Didn't find it so make a request - // Keep looking if it is not in the cache. - IContentProvider contentProvider = getContentProvider(); - // If we are building lazily then request lookup now - if (auto lcp = cast(ILazyContentProvider)contentProvider ) { - lcp.updateElement(index); - return; - } + Item item = cast(Item) event.item; + final int index = doIndexOf(item); + Object element = resolveElement(index); + if (element is null) { + // Didn't find it so make a request + // Keep looking if it is not in the cache. + IContentProvider contentProvider = getContentProvider(); + // If we are building lazily then request lookup now + if (auto lcp = cast(ILazyContentProvider)contentProvider ) { + lcp.updateElement(index); + return; } - - associate(element, item); - updateItem(item, element); } - }); + associate(element, item); + updateItem(item, element); + })); } /** @@ -479,18 +474,17 @@ * * @see dwtx.jface.viewers.StructuredViewer#getSelectionFromWidget() */ - protected override SeqView!(Object) getSelectionFromWidget() { + protected override List getSelectionFromWidget() { if (virtualManager !is null) { return getVirtualSelection(); } Widget[] items = doGetSelection(); - auto list = new ArraySeq!(Object); - list.capacity(items.length); + ArrayList list = new ArrayList(items.length); for (int i = 0; i < items.length; i++) { Widget item = items[i]; Object e = item.getData(); if (e !is null) { - list.append(e); + list.add(e); } } return list; @@ -503,9 +497,9 @@ * @return List of Object */ - private SeqView!(Object) getVirtualSelection() { + private List getVirtualSelection() { - auto result = new ArraySeq!(Object); + List result = new ArrayList(); int[] selectionIndices = doGetSelectionIndices(); if (auto lazy_ = cast(ILazyContentProvider) getContentProvider() ) { for (int i = 0; i < selectionIndices.length; i++) { @@ -516,7 +510,7 @@ // If this is done deferred the selection will // be incomplete until selection is finished. if (element !is null) { - result.append(element); + result.add(element); } } } else { @@ -533,7 +527,7 @@ element = item.getData(); } if (element !is null) { - result.append(element); + result.add(element); } } @@ -587,11 +581,9 @@ protected override void inputChanged(Object input, Object oldInput) { getControl().setRedraw(false); try { - preservingSelection(new class Runnable { - public void run() { - internalRefresh(getRoot()); - } - }); + preservingSelection(dgRunnable( { + internalRefresh(getRoot()); + })); } finally { getControl().setRedraw(true); } @@ -828,15 +820,9 @@ if (elements.length is 0) { return; } - preservingSelection(new class(elements) Runnable { - Object[] elements_; - this(Object[] a){ - elements_=a; - } - public void run() { - internalRemove(elements_); - } - }); + preservingSelection(dgRunnable( (Object[] elements_){ + internalRemove(elements_); + }, elements)); } /** @@ -878,7 +864,7 @@ * @see dwtx.jface.viewers.StructuredViewer#setSelectionToWidget(java.util.List, * bool) */ - protected override void setSelectionToWidget(SeqView!(Object) list, bool reveal) { + protected override void setSelectionToWidget(List list, bool reveal) { if (list is null) { doDeselectAll(); return; @@ -895,7 +881,8 @@ int size = list.size(); Item[] items = new Item[size]; int count = 0; - foreach( o; list ) { + for (int i = 0; i < size; ++i) { + Object o = list.get(i); Widget w = findItem(o); if (auto item = cast(Item)w ) { items[count++] = item; @@ -907,13 +894,16 @@ doSetSelection(items); } else { doDeselectAll(); // Clear the selection - if( ! list.drained() ) { + if( ! list.isEmpty() ) { int[] indices = new int[list.size()]; + Iterator it = list.iterator(); Item[] items = doGetItems(); + Object modelElement; int count = 0; - foreach( modelElement; list ){ + while( it.hasNext() ) { + modelElement = it.next(); bool found = false; for (int i = 0; i < items.length && !found; i++) { if (opEquals(modelElement, items[i].getData())) { @@ -940,14 +930,15 @@ * @param reveal * Whether or not reveal the first item. */ - private void virtualSetSelectionToWidget(SeqView!(Object) list, bool reveal) { + private void virtualSetSelectionToWidget(List list, bool reveal) { int size = list.size(); int[] indices = new int[list.size()]; Item firstItem = null; int count = 0; - auto virtualElements = new HashSet!(Object); - foreach( o; list ){ + HashSet virtualElements = new HashSet(); + for (int i = 0; i < size; ++i) { + Object o = list.get(i); Widget w = findItem(o); if (auto item = cast(Item)w ) { indices[count++] = doIndexOf(item); @@ -1040,11 +1031,11 @@ * Replace the element at the given index with the given element. This * method will not call the content provider to verify. <strong>Note that * this method will materialize a TableItem the given index.</strong>. - * + * * @param element * @param index * @see ILazyContentProvider - * + * * @since 3.1 */ public void replace(Object element, int index) {
--- a/dwtx/jface/viewers/AbstractTreeViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/AbstractTreeViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -43,10 +43,6 @@ import dwtx.jface.viewers.IBaseLabelProvider; import dwtx.jface.viewers.ITreePathLabelProvider; -import tango.util.collection.LinkSeq; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwt.DWT; @@ -64,6 +60,7 @@ import dwtx.jface.util.SafeRunnable; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -311,8 +308,7 @@ private Object[] filter(Object parentElementOrTreePath, Object[] elements) { ViewerFilter[] filters = getFilters(); if (filters !is null) { - auto filtered = new ArraySeq!(Object); - filtered.capacity(elements.length); + ArrayList filtered = new ArrayList(elements.length); for (int i = 0; i < elements.length; i++) { bool add = true; for (int j = 0; j < filters.length; j++) { @@ -323,7 +319,7 @@ } } if (add) { - filtered.append(elements[i]); + filtered.add(elements[i]); } } return filtered.toArray(); @@ -801,44 +797,35 @@ } } - BusyIndicator.showWhile(widget.getDisplay(), new class(widget,tis) Runnable { - Widget widget_; - Item[] tis_; - this( Widget a, Item[] b){ - widget_ = a; - tis_=b; - } - public void run() { - // fix for PR 1FW89L7: - // don't complain and remove all "dummies" ... - if (tis_ !is null) { - for (int i = 0; i < tis_.length; i++) { - if (tis_[i].getData() !is null) { - disassociate(tis_[i]); - Assert.isTrue(tis_[i].getData() is null, - "Second or later child is non -null");//$NON-NLS-1$ + BusyIndicator.showWhile(widget.getDisplay(), dgRunnable( (Widget widget_, Item[] tis_){ + // fix for PR 1FW89L7: + // don't complain and remove all "dummies" ... + if (tis_ !is null) { + for (int i = 0; i < tis_.length; i++) { + if (tis_[i].getData() !is null) { + disassociate(tis_[i]); + Assert.isTrue(tis_[i].getData() is null, + "Second or later child is non -null");//$NON-NLS-1$ - } - tis_[i].dispose(); } - } - Object d = widget_.getData(); - if (d !is null) { - Object parentElement = d; - Object[] children; - if (isTreePathContentProvider() && (null !is cast(Item)widget_) ) { - TreePath path = getTreePathFromItem(cast(Item) widget_); - children = getSortedChildren(path); - } else { - children = getSortedChildren(parentElement); - } - for (int i = 0; i < children.length; i++) { - createTreeItem(widget_, children[i], -1); - } + tis_[i].dispose(); } } - - }); + Object d = widget_.getData(); + if (d !is null) { + Object parentElement = d; + Object[] children; + if (isTreePathContentProvider() && (null !is cast(Item)widget_) ) { + TreePath path = getTreePathFromItem(cast(Item) widget_); + children = getSortedChildren(path); + } else { + children = getSortedChildren(parentElement); + } + for (int i = 0; i < children.length; i++) { + createTreeItem(widget_, children[i], -1); + } + } + }, widget,tis )); } finally { setBusy(oldBusy); } @@ -994,7 +981,7 @@ * * @since 3.1 in TreeViewer, moved to AbstractTreeViewer in 3.3 */ - protected bool isSameSelection(SeqView!(Item) items, Item[] current) { + protected bool isSameSelection(List items, Item[] current) { // If they are not the same size then they are not equivalent int n = items.size(); if (n !is current.length) { @@ -1002,7 +989,8 @@ } CustomHashtable itemSet = newHashtable(n * 2 + 1); - foreach( item; items ){ + for (Iterator i = items.iterator(); i.hasNext();) { + Item item = cast(Item) i.next(); Object element = item.getData(); itemSet.put(element, element); } @@ -1212,14 +1200,14 @@ * @see #setExpandedElements */ public Object[] getExpandedElements() { - auto items = new ArraySeq!(Item); + ArrayList items = new ArrayList(); internalCollectExpandedItems(items, getControl()); - auto result = new ArraySeq!(Object); - result.capacity(items.size()); - foreach ( item; items ) { + ArrayList result = new ArrayList(items.size()); + for (Iterator it = items.iterator(); it.hasNext();) { + Item item = cast(Item) it.next(); Object data = item.getData(); if (data !is null) { - result.append(data); + result.add(data); } } return result.toArray(); @@ -1414,15 +1402,14 @@ * * @see dwtx.jface.viewers.StructuredViewer#getSelectionFromWidget() */ - protected override SeqView!(Object) getSelectionFromWidget() { + protected override List getSelectionFromWidget() { Widget[] items = getSelection(getControl()); - ArraySeq!(Object) list = new ArraySeq!(Object); - list.capacity(items.length); + ArrayList list = new ArrayList(items.length); for (int i = 0; i < items.length; i++) { Widget item = items[i]; Object e = item.getData(); if (e !is null) { - list.append(e); + list.add(e); } } return list; @@ -1574,12 +1561,12 @@ * @param widget * the widget */ - private void internalCollectExpandedItems(Seq!(Item) result, Widget widget) { + private void internalCollectExpandedItems(List result, Widget widget) { Item[] items = getChildren(widget); for (int i = 0; i < items.length; i++) { Item item = items[i]; if (getExpanded(item)) { - result.append(item); + result.add(item); } internalCollectExpandedItems(result, item); } @@ -1621,12 +1608,14 @@ if (expand && null !is cast(Item)pw ) { // expand parent items top-down Item item = cast(Item) pw; - auto toExpandList = new LinkSeq!(Item); + LinkedList toExpandList = new LinkedList(); while (item !is null && !getExpanded(item)) { - toExpandList.prepend(item); + toExpandList.addFirst(item); item = getParentItem(item); } - foreach( toExpand; toExpandList ){ + for (Iterator it = toExpandList.iterator(); it + .hasNext();) { + Item toExpand = cast(Item) it.next(); setExpanded(toExpand, true); } } @@ -2176,15 +2165,9 @@ } if (checkBusy()) return; - preservingSelection(new class(elementsOrTreePaths) Runnable { - Object[] elementsOrTreePaths_; - this(Object[] a){ - elementsOrTreePaths_=a; - } - public void run() { - internalRemove(elementsOrTreePaths_); - } - }); + preservingSelection( dgRunnable( (Object[] elementsOrTreePaths_){ + internalRemove(elementsOrTreePaths_); + }, elementsOrTreePaths)); } /** @@ -2212,17 +2195,9 @@ } if (checkBusy()) return; - preservingSelection(new class(parent,elements) Runnable { - Object parent_; - Object[] elements_; - this(Object a,Object[] b){ - parent_=a; - elements_=b; - } - public void run() { - internalRemove(parent_, elements_); - } - }); + preservingSelection( dgRunnable( (Object parent_,Object[] elements_){ + internalRemove(parent_, elements_); + }, parent, elements )); } /** @@ -2479,34 +2454,33 @@ * list of items (element type: * <code>dwt.widgets.Item</code>) */ - protected abstract void setSelection(SeqView!(Item) items); + protected abstract void setSelection(List items); /** * This implementation of setSelectionToWidget accepts a list of elements or * a list of tree paths. */ - protected override void setSelectionToWidget(SeqView!(Object) v, bool reveal) { + protected override void setSelectionToWidget(List v, bool reveal) { if (v is null) { - setSelection(new ArraySeq!(Item)); + setSelection(new ArrayList(0)); return; } int size = v.size(); - auto newSelection = new ArraySeq!(Item); - newSelection.capacity(size); + List newSelection = new ArrayList(size); for (int i = 0; i < size; ++i) { Object elementOrTreePath = v.get(i); // Use internalExpand since item may not yet be created. See // 1G6B1AR. Widget w = internalExpand(elementOrTreePath, false); if ( auto it = cast(Item)w ) { - newSelection.append(it); + newSelection.add(it); } else if (w is null && null !is cast(TreePath)elementOrTreePath ) { TreePath treePath = cast(TreePath) elementOrTreePath; Object element = treePath.getLastSegment(); if (element !is null) { w = internalExpand(element, false); if ( auto it = cast(Item)w ) { - newSelection.append(it); + newSelection.add(it); } } } @@ -2836,19 +2810,19 @@ * @since 2.0 */ public Object[] getVisibleExpandedElements() { - auto v = new ArraySeq!(Object); + ArrayList v = new ArrayList(); internalCollectVisibleExpanded(v, getControl()); return v.toArray(); } - private void internalCollectVisibleExpanded(ArraySeq!(Object) result, Widget widget) { + private void internalCollectVisibleExpanded(ArrayList result, Widget widget) { Item[] items = getChildren(widget); for (int i = 0; i < items.length; i++) { Item item = items[i]; if (getExpanded(item)) { Object data = item.getData(); if (data !is null) { - result.append(data); + result.add(data); } // Only recurse if it is expanded - if // not then the children aren't visible @@ -2865,11 +2839,11 @@ * @since 3.2 */ protected TreePath getTreePathFromItem(Item item) { - auto segments = new LinkSeq!(Object); + LinkedList segments = new LinkedList(); while (item !is null) { Object segment = item.getData(); Assert.isNotNull(segment); - segments.prepend(segment); + segments.addFirst(segment); item = getParentItem(item); } return new TreePath(segments.toArray()); @@ -2890,26 +2864,20 @@ return TreeSelection.EMPTY; } Widget[] items = getSelection(getControl()); - auto list = new ArraySeq!(TreePath); - list.capacity(items.length); + ArrayList list = new ArrayList(items.length); for (int i = 0; i < items.length; i++) { Widget item = items[i]; if (item.getData() !is null) { - list.append(getTreePathFromItem(cast(Item) item)); + list.add(getTreePathFromItem(cast(Item) item)); } } - return new TreeSelection( list.toArray(), getComparer()); + return new TreeSelection( arraycast!(TreePath)(list.toArray()), getComparer()); } protected override void setSelectionToWidget(ISelection selection, bool reveal) { if ( auto treeSelection = cast(ITreeSelection)selection ) { - auto list = new ArraySeq!(Object); - auto paths = treeSelection.getPaths(); - list.capacity(paths.length); - foreach( path; paths ){ - list.append(path); - } - setSelectionToWidget(list, reveal); + setSelectionToWidget(Arrays.asList(treeSelection.getPaths()), + reveal); } else { super.setSelectionToWidget(selection, reveal); } @@ -2930,17 +2898,17 @@ * @since 3.2 */ public TreePath[] getExpandedTreePaths() { - auto items = new ArraySeq!(Item); + ArrayList items = new ArrayList(); internalCollectExpandedItems(items, getControl()); - auto result = new ArraySeq!(TreePath); - result.capacity(items.size()); - foreach( item; items ){ + ArrayList result = new ArrayList(items.size()); + for (Iterator it = items.iterator(); it.hasNext();) { + Item item = cast(Item) it.next(); TreePath treePath = getTreePathFromItem(item); if (treePath !is null) { - result.append(treePath); + result.add(treePath); } } - return result.toArray(); + return arraycast!(TreePath)(result.toArray()); } private bool isTreePathContentProvider() {
--- a/dwtx/jface/viewers/ArrayContentProvider.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/ArrayContentProvider.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,9 +16,9 @@ import dwtx.jface.viewers.IStructuredContentProvider; import dwtx.jface.viewers.Viewer; -import tango.util.collection.model.View; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * This implementation of <code>IStructuredContentProvider</code> handles @@ -40,7 +40,7 @@ if ( auto aw = cast(ArrayWrapperT!(T)) inputElement ) { return aw.array; } - if ( auto col = cast(View!(T)) inputElement ) { + if ( auto col = cast(Collection) inputElement ) { return col.toArray(); } return null;
--- a/dwtx/jface/viewers/CheckboxTableViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/CheckboxTableViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -20,8 +20,6 @@ import dwtx.jface.viewers.ColumnWeightData; import dwtx.jface.viewers.CustomHashtable; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwt.DWT; import dwt.events.SelectionEvent; @@ -35,6 +33,7 @@ import dwtx.jface.util.SafeRunnable; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -187,17 +186,9 @@ private void fireCheckStateChanged(CheckStateChangedEvent event) { Object[] array = checkStateListeners.getListeners(); for (int i = 0; i < array.length; i++) { - SafeRunnable.run(new class(cast(ICheckStateListener) array[i], event) SafeRunnable { - ICheckStateListener l; - CheckStateChangedEvent event_; - this(ICheckStateListener a,CheckStateChangedEvent b){ - event_=b; - l = a; - } - public void run() { - l.checkStateChanged(event_); - } - }); + SafeRunnable.run( dgSafeRunnable( (ICheckStateListener l, CheckStateChangedEvent event_) { + l.checkStateChanged(event_); + }, cast(ICheckStateListener) array[i], event )); } } @@ -225,12 +216,11 @@ */ public Object[] getCheckedElements() { TableItem[] children = getTable().getItems(); - auto v = new ArraySeq!(Object); - v.capacity(children.length); + ArrayList v = new ArrayList(children.length); for (int i = 0; i < children.length; i++) { TableItem item = children[i]; if (item.getChecked()) { - v.append(item.getData()); + v.add(item.getData()); } } return v.toArray(); @@ -264,12 +254,11 @@ */ public Object[] getGrayedElements() { TableItem[] children = getTable().getItems(); - auto v = new ArraySeq!(Object); - v.capacity(children.length); + ArrayList v = new ArrayList(children.length); for (int i = 0; i < children.length; i++) { TableItem item = children[i]; if (item.getGrayed()) { - v.append(item.getData()); + v.add(item.getData()); } } return v.toArray();
--- a/dwtx/jface/viewers/CheckboxTreeViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/CheckboxTreeViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -18,8 +18,6 @@ import dwtx.jface.viewers.CustomHashtable; import dwtx.jface.viewers.CheckStateChangedEvent; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwt.DWT; import dwt.events.SelectionEvent; @@ -34,6 +32,7 @@ import dwtx.jface.util.SafeRunnable; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -140,15 +139,9 @@ protected void fireCheckStateChanged(CheckStateChangedEvent event) { Object[] array = checkStateListeners.getListeners(); for (int i = 0; i < array.length; i++) { - SafeRunnable.run(new class(cast(ICheckStateListener) array[i]) SafeRunnable { - ICheckStateListener l; - this(ICheckStateListener a){ - l = a; - } - public void run() { - l.checkStateChanged(event); - } - }); + SafeRunnable.run( dgSafeRunnable( (ICheckStateListener l){ + l.checkStateChanged(event); + }, cast(ICheckStateListener) array[i])); } } @@ -206,7 +199,7 @@ * @see #setCheckedElements */ public Object[] getCheckedElements() { - ArraySeq!(Object) v = new ArraySeq!(Object); + ArrayList v = new ArrayList(); Control tree = getControl(); internalCollectChecked(v, tree); return v.toArray(); @@ -241,7 +234,7 @@ * @see #setGrayedElements */ public Object[] getGrayedElements() { - ArraySeq!(Object) result = new ArraySeq!(Object); + List result = new ArrayList(); internalCollectGrayed(result, getControl()); return result.toArray(); } @@ -294,14 +287,14 @@ * @param result a writable list of elements (element type: <code>Object</code>) * @param widget the widget */ - private void internalCollectChecked(Seq!(Object) result, Widget widget) { + private void internalCollectChecked(List result, Widget widget) { Item[] items = getChildren(widget); for (int i = 0; i < items.length; i++) { Item item = items[i]; if ( null !is cast(TreeItem)item && (cast(TreeItem) item).getChecked()) { Object data = item.getData(); if (data !is null) { - result.append(data); + result.add(data); } } internalCollectChecked(result, item); @@ -315,14 +308,14 @@ * @param result a writable list of elements (element type: <code>Object</code>) * @param widget the widget */ - private void internalCollectGrayed(Seq!(Object) result, Widget widget) { + private void internalCollectGrayed(List result, Widget widget) { Item[] items = getChildren(widget); for (int i = 0; i < items.length; i++) { Item item = items[i]; if (null !is cast(TreeItem)item && (cast(TreeItem) item).getGrayed()) { Object data = item.getData(); if (data !is null) { - result.append(data); + result.add(data); } } internalCollectGrayed(result, item); @@ -586,7 +579,7 @@ * @deprecated as this method only checks or unchecks visible items * is is recommended that {@link #setSubtreeChecked(Object, bool)} * is used instead. - * @see #setSubtreeChecked(Object, bool) + * @see #setSubtreeChecked(Object, bool) * * @since 3.2 */
--- a/dwtx/jface/viewers/CustomHashtable.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/CustomHashtable.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,6 +19,7 @@ // import java.util.NoSuchElementException; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.core.Exception; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer;
--- a/dwtx/jface/viewers/DecorationContext.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/DecorationContext.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,10 +14,9 @@ import dwtx.jface.viewers.IDecorationContext; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A concrete implementation of the {@link IDecorationContext} interface, @@ -38,13 +37,13 @@ DEFAULT_CONTEXT = new DecorationContext(); } - private Map!(String,Object) properties; + private Map properties; /** * Create a decoration context. */ public this() { - properties = new HashMap!(String,Object); + properties = new HashMap(); } @@ -52,18 +51,14 @@ * @see dwtx.jface.viewers.IDecorationContext#getProperty(java.lang.String) */ public Object getProperty(String property) { - return properties.get(property); + return properties.get(stringcast(property)); } /* (non-Javadoc) * @see dwtx.jface.viewers.IDecorationContext#getProperties() */ public String[] getProperties() { - String[] res; - foreach( k,v; properties ){ - res ~= k; - } - return res; + return stringcast( properties.keySet().toArray() ); } /** @@ -76,9 +71,9 @@ */ public void putProperty(String property, Object value) { if (value is null) { - properties.removeKey(property); + properties.remove(stringcast(property)); } else { - properties.add(property, value); + properties.put(stringcast(property), value); } } }
--- a/dwtx/jface/viewers/DelegatingStyledCellLabelProvider.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/DelegatingStyledCellLabelProvider.d Thu Aug 07 15:01:33 2008 +0200 @@ -26,6 +26,7 @@ import dwt.graphics.Image; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A {@link DelegatingStyledCellLabelProvider} is a @@ -112,10 +113,10 @@ StyledString styledString = getStyledText(element); String newText= styledString.toString(); - + StyleRange[] oldStyleRanges= cell.getStyleRanges(); StyleRange[] newStyleRanges= isOwnerDrawEnabled() ? styledString.getStyleRanges() : null; - + if (!Arrays.equals(oldStyleRanges, newStyleRanges)) { cell.setStyleRanges(newStyleRanges); if (cell.getText().equals(newText)) { @@ -123,13 +124,13 @@ cell.setText(""); //$NON-NLS-1$ } } - + cell.setText(newText); cell.setImage(getImage(element)); cell.setFont(getFont(element)); cell.setForeground(getForeground(element)); cell.setBackground(getBackground(element)); - + // no super call required. changes on item will trigger the refresh. }
--- a/dwtx/jface/viewers/IStructuredSelection.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/IStructuredSelection.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,9 +13,7 @@ module dwtx.jface.viewers.IStructuredSelection; import dwtx.jface.viewers.ISelection; - -import tango.util.collection.model.SeqView; -import tango.util.collection.model.Iterator; +import dwtx.dwtxhelper.Collection; /** * A selection containing elements. @@ -34,7 +32,7 @@ * * @return an iterator over the selected elements */ - public Iterator!(Object) iterator(); + public Iterator iterator(); /** * Returns the number of elements selected in this selection. @@ -53,10 +51,10 @@ /** * Returns the elements in this selection as a <code>List</code>. * <strong>Note</strong> In the default implementation of {@link #toList()} in - * {@link StructuredSelection} the returned list is not a copy of the elements of the + * {@link StructuredSelection} the returned list is not a copy of the elements of the * receiver and modifying it will modify the contents of the selection. * * @return the selected elements as a list */ - public SeqView!(Object) toList(); + public List toList(); }
--- a/dwtx/jface/viewers/ListViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/ListViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,7 +17,6 @@ import dwtx.jface.viewers.AbstractListViewer; -import tango.util.collection.model.SeqView; import dwt.DWT; import dwt.graphics.Rectangle; @@ -27,6 +26,7 @@ import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A concrete viewer based on an DWT <code>List</code> control. @@ -220,7 +220,7 @@ /* (non-Javadoc) * @see dwtx.jface.viewers.AbstractListViewer#setSelectionToWidget(java.util.List, bool) */ - protected override void setSelectionToWidget(SeqView!(Object) in_, bool reveal) { + protected override void setSelectionToWidget(List in_, bool reveal) { if( reveal ) { super.setSelectionToWidget(in_, reveal); } else {
--- a/dwtx/jface/viewers/OwnerDrawLabelProvider.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/OwnerDrawLabelProvider.d Thu Aug 07 15:01:33 2008 +0200 @@ -26,7 +26,7 @@ import dwt.widgets.Listener; import dwt.dwthelper.utils; -import tango.util.collection.HashSet; +import dwtx.dwtxhelper.Collection; /** * OwnerDrawLabelProvider is an abstract implementation of a label provider that @@ -44,12 +44,12 @@ alias CellLabelProvider.dispose dispose; static class OwnerDrawListener : Listener { - HashSet!(ViewerColumn) enabledColumns; + Set enabledColumns; int enabledGlobally = 0; private ColumnViewer viewer; this(ColumnViewer viewer) { - enabledColumns = new HashSet!(ViewerColumn); + enabledColumns = new HashSet(); this.viewer = viewer; } @@ -273,7 +273,7 @@ } else { listener.enabledColumns.remove(column); } - if (listener.enabledColumns.drained() + if (listener.enabledColumns.isEmpty() && listener.enabledGlobally <= 0) { viewer.getControl().removeListener(DWT.MeasureItem, listener);
--- a/dwtx/jface/viewers/StructuredSelection.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/StructuredSelection.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,15 +15,12 @@ import dwtx.jface.viewers.IStructuredSelection; import dwtx.jface.viewers.IElementComparer; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; -import tango.util.collection.model.Iterator; import dwtx.core.runtime.Assert; import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A concrete implementation of the <code>IStructuredSelection</code> interface, @@ -87,7 +84,7 @@ * Creates a structured selection from the given <code>List</code>. * @param elements list of selected elements */ - public this(SeqView!(Object) elements) { + public this(List elements) { this(elements, null); } @@ -103,7 +100,8 @@ * the comparer, or null * @since 3.4 */ - public this(SeqView!(Object) elements, IElementComparer comparer) { + public this(List elements, IElementComparer comparer) { + Assert.isNotNull(cast(Object)elements); this.elements = elements.toArray(); this.comparer = comparer; } @@ -173,13 +171,9 @@ /* (non-Javadoc) * Method declared in IStructuredSelection. */ - public Iterator!(Object) iterator() { - auto res = new ArraySeq!(Object); - res.capacity( elements.length ); - foreach( o; elements ){ - res.append( o ); - } - return res.elements; + public Iterator iterator() { + return Arrays.asList(elements is null ? null : elements) + .iterator(); } /* (non-Javadoc) @@ -199,13 +193,8 @@ /* (non-Javadoc) * Method declared in IStructuredSelection. */ - public SeqView!(Object) toList() { - auto res = new ArraySeq!(Object); - res.capacity( elements.length ); - foreach( o; elements ){ - res.append( o ); - } - return res; + public List toList() { + return Arrays.asList(elements is null ? null : elements); } /**
--- a/dwtx/jface/viewers/StructuredViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/StructuredViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -41,9 +41,6 @@ import dwtx.jface.viewers.StructuredSelection; import dwtx.jface.viewers.IStructuredSelection; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwt.custom.TableTreeItem; import dwt.dnd.DragSource; @@ -69,6 +66,7 @@ import dwtx.jface.util.SafeRunnable; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -109,7 +107,7 @@ * This viewer's filters (element type: <code>ViewerFilter</code>). * <code>null</code> means there are no filters. */ - private Seq!(ViewerFilter) filters; + private List filters; /** * Indicates whether a selection change is in progress on this viewer. @@ -597,9 +595,9 @@ */ public void addFilter(ViewerFilter filter) { if (filters is null) { - filters = new ArraySeq!(ViewerFilter); + filters = new ArrayList(); } - filters.append(filter); + filters.add(filter); refresh(); } @@ -732,8 +730,7 @@ */ protected Object[] filter(Object[] elements) { if (filters !is null) { - ArraySeq!(Object) filtered = new ArraySeq!(Object); - filtered.capacity(elements.length); + ArrayList filtered = new ArrayList(elements.length); Object root = getRoot(); for (int i = 0; i < elements.length; i++) { bool add = true; @@ -744,7 +741,7 @@ } } if (add) { - filtered.append(elements[i]); + filtered.add(elements[i]); } } return filtered.toArray(); @@ -830,17 +827,9 @@ protected void fireDoubleClick(DoubleClickEvent event) { Object[] listeners = doubleClickListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { - SafeRunnable.run(new class(cast(IDoubleClickListener) listeners[i], event) SafeRunnable { - IDoubleClickListener l; - DoubleClickEvent event_; - this(IDoubleClickListener a,DoubleClickEvent b){ - l = a; - event_=b; - } - public void run() { - l.doubleClick(event_); - } - }); + SafeRunnable.run( dgSafeRunnable( (IDoubleClickListener l, DoubleClickEvent event_){ + l.doubleClick(event_); + }, cast(IDoubleClickListener) listeners[i], event)); } } package void fireDoubleClick_package(DoubleClickEvent event) { @@ -859,17 +848,9 @@ protected void fireOpen(OpenEvent event) { Object[] listeners = openListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { - SafeRunnable.run(new class(cast(IOpenListener) listeners[i],event) SafeRunnable { - IOpenListener l; - OpenEvent event_; - this(IOpenListener a, OpenEvent b){ - l = a; - event_=b; - } - public void run() { - l.open(event_); - } - }); + SafeRunnable.run( dgSafeRunnable( (IOpenListener l,OpenEvent event_){ + l.open(event_); + }, cast(IOpenListener) listeners[i],event)); } } package void fireOpen_package(OpenEvent event) { @@ -889,17 +870,9 @@ protected void firePostSelectionChanged(SelectionChangedEvent event) { Object[] listeners = postSelectionChangedListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { - SafeRunnable.run(new class(cast(ISelectionChangedListener) listeners[i],event) SafeRunnable { - ISelectionChangedListener l; - SelectionChangedEvent event_; - this(ISelectionChangedListener a,SelectionChangedEvent b){ - l = a; - event_=b; - } - public void run() { - l.selectionChanged(event_); - } - }); + SafeRunnable.run( dgSafeRunnable( (ISelectionChangedListener l, SelectionChangedEvent event_){ + l.selectionChanged(event_); + },cast(ISelectionChangedListener) listeners[i],event)); } } @@ -928,7 +901,8 @@ protected Object[] getFilteredChildren(Object parent) { Object[] result = getRawChildren(parent); if (filters !is null) { - foreach (f;filters) { + for (Iterator iter = filters.iterator(); iter.hasNext();) { + ViewerFilter f = cast(ViewerFilter) iter.next(); result = f.filter(this, parent, result); } } @@ -945,7 +919,7 @@ if (filters is null) { return new ViewerFilter[0]; } - return filters.toArray(); + return arraycast!(ViewerFilter)(filters.toArray()); } /** @@ -1024,7 +998,7 @@ if (control is null || control.isDisposed()) { return StructuredSelection.EMPTY; } - auto list = getSelectionFromWidget(); + List list = getSelectionFromWidget(); return new StructuredSelection(list, comparer); } @@ -1034,8 +1008,8 @@ * * @return the list of selected elements */ - protected abstract SeqView!(Object) getSelectionFromWidget(); - package SeqView!(Object) getSelectionFromWidget_package(){ + protected abstract List getSelectionFromWidget(); + package List getSelectionFromWidget_package(){ return getSelectionFromWidget(); } @@ -1310,19 +1284,13 @@ } } else { Widget[] widgets = (cast(ArrayWrapperT!(Widget)) widgetOrWidgets).array; - int indexOfItem = -1; - foreach( idx, w; widgets ){ - if( w == item ){ - indexOfItem = idx; - break; - } - } + int indexOfItem = Arrays.asList(widgets).indexOf(item); if (indexOfItem is -1) { int length_ = widgets.length; System.arraycopy(widgets, 0, widgets = new Widget[length_ + 1], 0, length_); widgets[length_] = item; - elementMap.put(element, new ArrayWrapperT!(Widget)(widgets)); + elementMap.put(element, new ArrayWrapperObject(widgets)); } } } @@ -1349,7 +1317,8 @@ } if (filters !is null) { - foreach( filter; filters ){ + for (int i = 0, n = filters.size(); i < n; ++i) { + ViewerFilter filter = cast(ViewerFilter) filters.get(i); if (filter.isFilterProperty(element, property)) { return true; } @@ -1490,15 +1459,9 @@ * the element */ public void refresh(Object element) { - preservingSelection(new class(element) Runnable { - Object element_; - this(Object a){ - element_ = a; - } - public void run() { - internalRefresh(element_); - } - }); + preservingSelection( dgRunnable( (Object element_){ + internalRefresh(element_); + }, element )); } /** @@ -1521,17 +1484,9 @@ * @since 2.0 */ public void refresh(Object element, bool updateLabels) { - preservingSelection(new class(element, updateLabels) Runnable { - Object element_; - bool updateLabels_; - this(Object a, bool b){ - element_ = a; - updateLabels_ = b; - } - public void run() { - internalRefresh(element_, updateLabels_); - } - }); + preservingSelection( dgRunnable( (Object element_, bool updateLabels_){ + internalRefresh(element_, updateLabels_); + },element, updateLabels)); } /** @@ -1595,17 +1550,16 @@ if (filters !is null) { // Note: can't use List.remove(Object). Use identity comparison // instead. - int delIdx = 0; - foreach( o; filters ){ + for (Iterator i = filters.iterator(); i.hasNext();) { + Object o = i.next(); if (o is filter) { - filters.removeAt(delIdx); + i.remove(); refresh(); if (filters.size() is 0) { filters = null; } return; } - delIdx++; } } } @@ -1622,11 +1576,7 @@ if (filters.length is 0) { resetFilters(); } else { - auto tmp = new ArraySeq!(ViewerFilter); - foreach( f; filters ){ - tmp.append(f); - } - this.filters = tmp; + this.filters = new ArrayList(Arrays.asList(filters)); refresh(); } } @@ -1738,7 +1688,7 @@ * <code>true</code> if the selection is to be made visible, * and <code>false</code> otherwise */ - protected abstract void setSelectionToWidget(SeqView!(Object) l, bool reveal); + protected abstract void setSelectionToWidget(List l, bool reveal); /** * Converts the selection to a <code>List</code> and calls @@ -1759,7 +1709,7 @@ if ( auto ss = cast(IStructuredSelection) selection ) { setSelectionToWidget(ss.toList(), reveal); } else { - setSelectionToWidget(cast(SeqView!(Object)) null, reveal); + setSelectionToWidget(cast(List) null, reveal); } } @@ -1915,13 +1865,7 @@ } } else { Widget[] widgets = ( cast(ArrayWrapperT!(Widget)) widgetOrWidgets).array; - int indexOfItem = -1; - foreach( idx, w; widgets ){ - if( w == item ){ - indexOfItem = idx; - break; - } - } + int indexOfItem = Arrays.asList(widgets).indexOf(item); if (indexOfItem is -1) { return; } @@ -1932,13 +1876,13 @@ } else { Widget[] updatedWidgets = new Widget[length - 1]; System.arraycopy(widgets, 1, updatedWidgets, 0, length -1 ); - elementMap.put(element, new ArrayWrapperT!(Widget)( updatedWidgets)); + elementMap.put(element, new ArrayWrapperObject( updatedWidgets)); } } else { Widget[] updatedWidgets = new Widget[length - 1]; System.arraycopy(widgets, 0, updatedWidgets, 0, indexOfItem); System.arraycopy(widgets, indexOfItem + 1, updatedWidgets, indexOfItem, length - indexOfItem - 1); - elementMap.put(element, new ArrayWrapperT!(Widget)(updatedWidgets)); + elementMap.put(element, new ArrayWrapperObject(updatedWidgets)); } } } @@ -1946,7 +1890,7 @@ // flag to indicate that a full refresh took place. See bug 102440. private bool refreshOccurred; - + /** * Updates the given elements' presentation when one or more of their * properties change. Only the given elements are updated. @@ -2048,7 +1992,7 @@ for (int i = 0; i < items.length; i++) { internalUpdate(items[i], element, properties); if (mayExitEarly && refreshOccurred) { - // detected a change from refreshOccurred is false to refreshOccurred is true + // detected a change from refreshOccurred is false to refreshOccurred is true return; } } @@ -2084,12 +2028,10 @@ } } if (needsRefilter_) { - preservingSelection(new class Runnable { - public void run() { - internalRefresh(getRoot()); - refreshOccurred = true; - } - }); + preservingSelection(dgRunnable( { + internalRefresh(getRoot()); + refreshOccurred = true; + })); return; }
--- a/dwtx/jface/viewers/StyledString.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/StyledString.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,8 +19,8 @@ import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.convert.Format; -import tango.util.collection.ArraySeq; import tango.core.Exception; @@ -224,8 +224,8 @@ int offset = fBuffer.length(); fBuffer.append(string.toString()); - auto otherRuns = string.fStyleRuns; - if (otherRuns !is null && !otherRuns.drained()) { + List otherRuns = string.fStyleRuns; + if (otherRuns !is null && !otherRuns.isEmpty()) { for (int i = 0; i < otherRuns.size(); i++) { StyleRun curr = cast(StyleRun) otherRuns.get(i); if (i is 0 && curr.offset !is 0) { @@ -345,7 +345,7 @@ Styler prevStyle = endRun > 0 ? fStyleRuns.getRun(endRun - 1).style : null; fStyleRuns - .addAt(endRun, new StyleRun(offset + length, prevStyle)); + .add(endRun, new StyleRun(offset + length, prevStyle)); } } @@ -361,7 +361,7 @@ : null; if (isDifferentStyle(prevStyle, styler) || (startRun is 0 && styler !is null)) { - fStyleRuns.addAt(startRun, new StyleRun(offset, styler)); + fStyleRuns.add(startRun, new StyleRun(offset, styler)); endRun++; // endrun is moved one back } else { startRun--; // we use the previous @@ -381,25 +381,25 @@ */ public StyleRange[] getStyleRanges() { if (hasRuns()) { - StyleRange[] res; + ArrayList res = new ArrayList(); - auto styleRuns = getStyleRuns(); + List styleRuns = getStyleRuns(); int offset = 0; Styler style = null; for (int i = 0; i < styleRuns.size(); i++) { StyleRun curr = cast(StyleRun) styleRuns.get(i); if (isDifferentStyle(curr.style, style)) { if (curr.offset > offset && style !is null) { - res ~= createStyleRange(offset, curr.offset, style); + res.add(createStyleRange(offset, curr.offset, style)); } offset = curr.offset; style = curr.style; } } if (fBuffer.length() > offset && style !is null) { - res ~= createStyleRange(offset, fBuffer.length(), style); + res.add(createStyleRange(offset, fBuffer.length(), style)); } - return res; + return arraycast!(StyleRange)(res.toArray()); } return EMPTY; } @@ -431,7 +431,7 @@ } private bool hasRuns() { - return fStyleRuns !is null && !fStyleRuns.drained(); + return fStyleRuns !is null && !fStyleRuns.isEmpty(); } private void appendStyleRun(Styler style, int offset) { @@ -443,7 +443,7 @@ if (lastRun is null && style !is null || lastRun !is null && isDifferentStyle(style, lastRun.style)) { - getStyleRuns().append(new StyleRun(offset, style)); + getStyleRuns().add(new StyleRun(offset, style)); } } @@ -455,13 +455,13 @@ } private StyleRun getLastRun() { - if (fStyleRuns is null || fStyleRuns.drained()) { + if (fStyleRuns is null || fStyleRuns.isEmpty()) { return null; } return fStyleRuns.getRun(fStyleRuns.size() - 1); } - private StyleRunList getStyleRuns() { + private List getStyleRuns() { if (fStyleRuns is null) fStyleRuns = new StyleRunList(); return fStyleRuns; @@ -481,21 +481,20 @@ } } - private static class StyleRunList : ArraySeq!(Object) { + private static class StyleRunList : ArrayList { private static final long serialVersionUID = 123L; public this() { - super(); - capacity(3); + super(3); } public StyleRun getRun(int index) { return cast(StyleRun) get(index); } - //public void removeRange(int fromIndex, int toIndex) { - // super.removeRange(fromIndex, toIndex); - //} + public void removeRange(int fromIndex, int toIndex) { + super.removeRange(fromIndex, toIndex); + } } private static class DefaultStyler : Styler {
--- a/dwtx/jface/viewers/TableLayout.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TableLayout.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,8 +17,6 @@ import dwtx.jface.viewers.ColumnPixelData; import dwtx.jface.viewers.ColumnWeightData; -import tango.util.collection.model.Seq; -import tango.util.collection.ArraySeq; import dwt.DWT; import dwt.graphics.Point; @@ -33,6 +31,7 @@ import dwtx.jface.layout.TableColumnLayout; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A layout for a table. Call <code>addColumnData</code> to add columns. @@ -71,7 +70,7 @@ * The list of column layout data (element type: * <code>ColumnLayoutData</code>). */ - private Seq!(ColumnLayoutData) columns; + private List columns; /** * Indicates whether <code>layout</code> has yet to be called. @@ -82,7 +81,7 @@ * Creates a new table layout. */ public this() { - columns = new ArraySeq!(ColumnLayoutData); + columns = new ArrayList(); } /** @@ -92,7 +91,7 @@ * the column layout data */ public void addColumnData(ColumnLayoutData data) { - columns.append(data); + columns.add(data); } /* @@ -112,7 +111,8 @@ int width = 0; int size = columns.size(); - foreach( layoutData; columns ){ + for (int i = 0; i < size; ++i) { + ColumnLayoutData layoutData = cast(ColumnLayoutData) columns.get(i); if ( auto col = cast(ColumnPixelData) layoutData ) { width += col.width; if (col.addTrim) { @@ -163,7 +163,7 @@ // First calc space occupied by fixed columns for (int i = 0; i < size; i++) { - ColumnLayoutData col = /+cast(ColumnLayoutData)+/ columns.get(i); + ColumnLayoutData col = cast(ColumnLayoutData) columns.get(i); if ( auto cpd = cast(ColumnPixelData) col ) { int pixels = cpd.width; if (cpd.addTrim) { @@ -190,7 +190,7 @@ int rest = width - fixedWidth; int totalDistributed = 0; for (int i = 0; i < size; ++i) { - ColumnLayoutData col = /+cast(ColumnLayoutData)+/ columns.get(i); + ColumnLayoutData col = cast(ColumnLayoutData) columns.get(i); if (auto cw = cast(ColumnWeightData) col ) { // calculate weight as above // int weight = firstTime ? cw.weight : @@ -212,7 +212,7 @@ if (i is size) { i = 0; } - ColumnLayoutData col = /+cast(ColumnLayoutData)+/ columns.get(i); + ColumnLayoutData col = cast(ColumnLayoutData) columns.get(i); if (cast(ColumnWeightData)col ) { ++widths[i]; --diff;
--- a/dwtx/jface/viewers/TableTreeViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TableTreeViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -27,7 +27,6 @@ import dwtx.jface.viewers.ITableLabelProvider; import dwtx.jface.viewers.ViewerLabel; -import tango.util.collection.model.SeqView; import dwt.DWT; import dwt.custom.TableTree; @@ -50,6 +49,7 @@ import dwt.widgets.Widget; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A concrete viewer based on a DWT <code>TableTree</code> control. @@ -323,11 +323,7 @@ * @return the array of column properties */ public Object[] getColumnProperties() { - Object[] res; - foreach( str; columnProperties ){ - res ~= new ArrayWrapperString( str ); - } - return res; + return stringcast( columnProperties ); } /** @@ -875,8 +871,9 @@ /* * (non-Javadoc) Method declared in AbstractTreeViewer. */ - protected override void setSelection(SeqView!(Item) items) { - getTableTree().setSelection(cast(TableTreeItem[]) items.toArray); + protected override void setSelection(List items) { + TableTreeItem[] newItems = arraycast!(TableTreeItem)(items.toArray()); + getTableTree().setSelection(newItems); } /*
--- a/dwtx/jface/viewers/TableViewerEditor.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TableViewerEditor.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,7 +24,6 @@ import dwtx.jface.viewers.ViewerCell; import dwtx.jface.viewers.StructuredSelection; -// import tango.util.collection.model.Seq; import dwt.DWT; import dwt.custom.TableEditor; @@ -34,6 +33,7 @@ import dwt.widgets.TableItem; import dwt.dwthelper.utils; +// import dwtx.dwtxhelper.Collection; /** * This is an editor-implementation for {@link Table}
--- a/dwtx/jface/viewers/TreeSelection.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TreeSelection.d Thu Aug 07 15:01:33 2008 +0200 @@ -18,12 +18,11 @@ import dwtx.jface.viewers.TreePath; import dwtx.jface.viewers.IElementComparer; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A concrete implementation of the <code>ITreeSelection</code> interface, @@ -58,7 +57,7 @@ } private static class InitializeData { - Seq!(Object) selection; + List selection; TreePath[] paths; CustomHashtable element2TreePaths; @@ -67,21 +66,19 @@ System.arraycopy(paths, 0, this.paths, 0, paths.length); element2TreePaths = new CustomHashtable(comparer); int size = paths.length; - auto s = new ArraySeq!(Object); - s.capacity(size); - selection = s; + selection = new ArrayList(size); for (int i = 0; i < size; i++) { Object lastSegment= paths[i].getLastSegment(); Object mapped= element2TreePaths.get(lastSegment); if (mapped is null) { - selection.append(lastSegment); + selection.add(lastSegment); element2TreePaths.put(lastSegment, paths[i]); - } else if ( cast(Seq!(Object))mapped ) { - (cast(Seq!(Object))mapped).append(paths[i]); + } else if ( cast(List)mapped ) { + (cast(List)mapped).add( cast(Object)paths[i]); } else { - Seq!(Object) newMapped= new ArraySeq!(Object); - newMapped.append(mapped); - newMapped.append(paths[i]); + List newMapped= new ArrayList(); + newMapped.add(mapped); + newMapped.add(paths[i]); element2TreePaths.put(lastSegment, cast(Object) newMapped); } } @@ -217,9 +214,9 @@ return EMPTY_TREE_PATHS; } else if (cast(TreePath)value ) { return [ cast(TreePath)value ]; - } else if (cast(Seq!(Object))value ) { - auto l= cast(Seq!(Object))value; - return cast(TreePath[]) l.toArray(); + } else if (cast(List)value ) { + auto l= cast(List)value; + return arraycast!(TreePath)( l.toArray() ); } else { // should not happen: Assert.isTrue(false, "Unhandled case"); //$NON-NLS-1$
--- a/dwtx/jface/viewers/TreeViewer.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TreeViewer.d Thu Aug 07 15:01:33 2008 +0200 @@ -33,9 +33,6 @@ import dwtx.jface.viewers.TreeExpansionEvent; import dwtx.jface.viewers.ViewerCell; -import tango.util.collection.LinkSeq; -import tango.util.collection.model.Seq; -import tango.util.collection.model.SeqView; import dwt.DWT; import dwt.events.DisposeEvent; @@ -54,6 +51,7 @@ import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -360,7 +358,7 @@ /* * (non-Javadoc) Method declared in AbstractTreeViewer. */ - protected override void setSelection(SeqView!(Item) items) { + protected override void setSelection(List items) { Item[] current = getSelection(getTree()); @@ -369,7 +367,7 @@ return; } - getTree().setSelection( cast(TreeItem[]) items.toArray()); + getTree().setSelection( arraycast!(TreeItem)( items.toArray())); } /* @@ -440,25 +438,17 @@ public void setChildCount(Object elementOrTreePath, int count) { if (checkBusy()) return; - preservingSelection(new class(elementOrTreePath,count) Runnable { - Object elementOrTreePath_; - int count_; - this(Object a,int b){ - elementOrTreePath_=a; - count_=b; + preservingSelection( dgRunnable((Object elementOrTreePath_, int count_) { + if (internalIsInputOrEmptyPath(elementOrTreePath_)) { + getTree().setItemCount(count_); + return; } - public void run() { - if (internalIsInputOrEmptyPath(elementOrTreePath_)) { - getTree().setItemCount(count_); - return; - } - Widget[] items = internalFindItems(elementOrTreePath_); - for (int i = 0; i < items.length; i++) { - TreeItem treeItem = cast(TreeItem) items[i]; - treeItem.setItemCount(count_); - } + Widget[] items = internalFindItems(elementOrTreePath_); + for (int i = 0; i < items.length; i++) { + TreeItem treeItem = cast(TreeItem) items[i]; + treeItem.setItemCount(count_); } - }); + }, elementOrTreePath,count )); } /** @@ -885,16 +875,13 @@ if (checkBusy()) return; preservingSelection(new class((cast(TreeSelection) getSelection()).getPaths(),parentOrTreePath_,index_) Runnable { - Seq!(TreePath) oldSelection; + List oldSelection; Object parentOrTreePath; int index; this(TreePath[] a,Object b,int c){ parentOrTreePath=b; index=c; - oldSelection = new LinkSeq!(TreePath); - foreach( p; a){ - oldSelection.append( p ); - } + oldSelection = new LinkedList(Arrays.asList(a)); } public void run() { TreePath removedPath = null; @@ -926,20 +913,21 @@ } if (removedPath !is null) { bool removed = false; - int delIdx = 0; - foreach ( path; oldSelection.dup ) { + for (Iterator it = oldSelection.iterator(); it + .hasNext();) { + TreePath path = cast(TreePath) it.next(); if (path.startsWith(removedPath, getComparer())) { - oldSelection.removeAt(delIdx); + it.remove(); removed = true; } - delIdx++; } if (removed) { setSelection(new TreeSelection( - oldSelection.toArray(), getComparer()), + arraycast!(TreePath)( oldSelection + .toArray(new TreePath[oldSelection + .size()])), getComparer()), false); } - } } });
--- a/dwtx/jface/viewers/TreeViewerEditor.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TreeViewerEditor.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,7 +24,6 @@ import dwtx.jface.viewers.ViewerCell; import dwtx.jface.viewers.TreeSelection; -import tango.util.collection.model.Seq; import dwt.DWT; import dwt.custom.TreeEditor;
--- a/dwtx/jface/viewers/TreeViewerRow.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/TreeViewerRow.d Thu Aug 07 15:01:33 2008 +0200 @@ -18,7 +18,6 @@ import dwtx.jface.viewers.ViewerRow; import dwtx.jface.viewers.TreePath; -import tango.util.collection.LinkSeq; import dwt.graphics.Color; import dwt.graphics.Font; @@ -31,6 +30,7 @@ import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * TreeViewerRow is the Tree implementation of ViewerRow. @@ -334,11 +334,11 @@ public override TreePath getTreePath() { TreeItem tItem = item; - auto segments = new LinkSeq!(Object); + LinkedList segments = new LinkedList(); while (tItem !is null) { Object segment = tItem.getData(); Assert.isNotNull(segment); - segments.prepend(segment); + segments.addFirst(segment); tItem = tItem.getParentItem(); } @@ -382,14 +382,14 @@ public Rectangle getTextBounds(int index) { return item.getTextBounds(index); } - + /* (non-Javadoc) * @see dwtx.jface.viewers.ViewerRow#getImageBounds(int) */ public Rectangle getImageBounds(int index) { return item.getImageBounds(index); - } - + } + private bool hasColumns() { return this.item.getParent().getColumnCount() !is 0; }
--- a/dwtx/jface/viewers/ViewerFilter.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/ViewerFilter.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,9 +15,9 @@ import dwtx.jface.viewers.Viewer; import dwtx.jface.viewers.TreePath; -import tango.util.collection.ArraySeq; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A viewer filter is used by a structured viewer to @@ -52,12 +52,11 @@ */ public Object[] filter(Viewer viewer, Object parent, Object[] elements) { int size = elements.length; - auto out_ = new ArraySeq!(Object); - out_.capacity(size); + ArrayList out_ = new ArrayList(size); for (int i = 0; i < size; ++i) { Object element = elements[i]; if (select(viewer, parent, element)) { - out_.append(element); + out_.add(element); } } return out_.toArray();
--- a/dwtx/jface/viewers/deferred/ChangeQueue.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/deferred/ChangeQueue.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,9 +12,9 @@ *******************************************************************************/ module dwtx.jface.viewers.deferred.ChangeQueue; -import tango.util.collection.LinkSeq; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * Holds a queue of additions, removals, updates, and SET calls for a @@ -84,11 +84,11 @@ } } - private LinkSeq!(Change) queue; + private LinkedList queue; private int workload = 0; public this(){ - queue = new LinkSeq!(Change); + queue = new LinkedList(); } /** @@ -110,20 +110,21 @@ // them from the queue if (toQueue.type is SET) { workload = 0; - LinkSeq!(Change) newQueue = new LinkSeq!(Change); - foreach( next; queue ){ + LinkedList newQueue = new LinkedList(); + for (Iterator iter = queue.iterator(); iter.hasNext();) { + Change next = cast(Change) iter.next(); if (next.getType() is ADD || next.getType() is REMOVE || next.getType() is SET) { continue; } - newQueue.append(next); + newQueue.add(next); workload += next.elements.length; } queue = newQueue; } - queue.append(toQueue); + queue.add(toQueue); workload += toQueue.elements.length; } @@ -132,8 +133,8 @@ * @return the first change */ public synchronized Change dequeue() { - Change result = queue.head; - queue.removeHead(); + Change result = cast(Change)queue.removeFirst(); + workload -= result.elements.length; return result; @@ -144,6 +145,6 @@ * @return <code>true</code> if empty, <code>false</code> otherwise */ public synchronized bool isEmpty() { - return queue.drained(); + return queue.isEmpty(); } }
--- a/dwtx/jface/viewers/deferred/IntHashMap.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/deferred/IntHashMap.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,7 +12,6 @@ *******************************************************************************/ module dwtx.jface.viewers.deferred.IntHashMap; -import tango.util.collection.HashMap; /** * Represents a map of objects onto ints. This is intended for future optimization: @@ -23,29 +22,28 @@ * @since 3.1 */ /* package */ class IntHashMap { - private HashMap!(Object,int) map; + private int[Object] map; /** * @param size * @param loadFactor */ public this(int size, float loadFactor) { - map = new HashMap!(Object,int); -// (size, loadFactor); +// map = new HashMap(size,loadFactor); } /** * */ public this() { - map = new HashMap!(Object,int); +// map = new HashMap(); } /** * @param key */ public void remove(Object key) { - map.removeKey(key); + map.remove(key); } /** @@ -53,7 +51,7 @@ * @param value */ public void put(Object key, int value) { - map.add(key, value); + map[key] = value; } /** @@ -70,8 +68,8 @@ * @return the int value at the given key, or the default value if this map does not contain the given key */ public int get(Object key, int defaultValue) { - if( map.containsKey( key )){ - return map.get(key); + if( auto res = key in map ){ + return *res; } return defaultValue; } @@ -81,13 +79,16 @@ * @return <code>true</code> if this map contains the given key, <code>false</code> otherwise */ public bool containsKey(Object key) { - return map.containsKey(key); + if( auto res = key in map ){ + return true; + } + return false; } /** * @return the number of key/value pairs */ public int size() { - return map.size(); + return map.length; } }
--- a/dwtx/jface/viewers/deferred/LazySortedCollection.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/deferred/LazySortedCollection.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,11 +17,11 @@ // import java.util.Collection; // import java.util.Comparator; // import java.util.Iterator; -import tango.util.collection.model.View; import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * This object maintains a collection of elements, sorted by a comparator @@ -767,10 +767,11 @@ * * @param toAdd objects to add */ - public final void addAll( View!(Object) toAdd) { + public final void addAll( Collection toAdd) { Assert.isNotNull(cast(Object)toAdd); - foreach( o; toAdd ){ - add( o ); + Iterator iter = toAdd.iterator(); + while (iter.hasNext()) { + add(iter.next()); } testInvariants();
--- a/dwtx/jface/viewers/deferred/SetModel.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/deferred/SetModel.d Thu Aug 07 15:01:33 2008 +0200 @@ -15,12 +15,11 @@ import dwtx.jface.viewers.deferred.AbstractConcurrentModel; import dwtx.jface.viewers.deferred.IConcurrentModelListener; -import tango.util.collection.HashSet; -import tango.util.collection.model.View; import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * Trivial implementation of an <code>IConcurrentModel</code>. Implements @@ -32,10 +31,10 @@ */ public class SetModel : AbstractConcurrentModel { - private HashSet!(Object) data; + private HashSet data; public this(){ - data = new HashSet!(Object); + data = new HashSet(); } /** @@ -62,7 +61,8 @@ } IConcurrentModelListener[] listeners = getListeners(); - foreach( listener; listeners ){ + for (int i = 0; i < listeners.length; i++) { + IConcurrentModelListener listener = listeners[i]; listener.setContents(newContents); } } @@ -97,7 +97,7 @@ * * @param toAdd elements to add */ - public void addAll(View!(Object) toAdd) { + public void addAll(Collection toAdd) { Assert.isNotNull(cast(Object)toAdd); addAll(toAdd.toArray()); }
--- a/dwtx/jface/window/ToolTip.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/window/ToolTip.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,7 +14,6 @@ module dwtx.jface.window.ToolTip; -import tango.util.collection.HashMap; import dwt.DWT; import dwt.events.DisposeEvent; @@ -33,6 +32,7 @@ // import dwtx.jface.viewers.ViewerCell; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; import tango.core.Thread; /** @@ -53,7 +53,7 @@ private ToolTipOwnerControlListener listener; - private HashMap!(String,Object) data; + private HashMap data; // Ensure that only one tooltip is active in time private static Shell CURRENT_TOOLTIP; @@ -152,9 +152,9 @@ */ public void setData(String key, Object value) { if (data is null) { - data = new HashMap!(String,Object); + data = new HashMap(); } - data.add(key, value); + data.put(stringcast(key), value); } /** @@ -166,7 +166,7 @@ */ public Object getData(String key) { if (data !is null) { - return data.get(key); + return data.get(stringcast(key)); } return null; }
--- a/dwtx/jface/window/Window.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/window/Window.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,7 +16,6 @@ import dwtx.jface.window.WindowManager; import dwtx.jface.window.SameShellProvider; -import tango.util.collection.ArraySeq; import dwt.DWT; import dwt.events.ShellAdapter; @@ -41,6 +40,7 @@ import dwtx.jface.util.PropertyChangeEvent; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.io.Stdout; /** @@ -329,8 +329,8 @@ * be called). * </p> * <p> - * Note that in order to prevent recursive calls to this method - * it does not call <code>Shell#close()</code>. As a result <code>ShellListener</code>s + * Note that in order to prevent recursive calls to this method + * it does not call <code>Shell#close()</code>. As a result <code>ShellListener</code>s * will not receive a <code>shellClosed</code> event. * </p> * @@ -384,18 +384,17 @@ // The equivalent in the multi-image version seems to be to remove the // disposed images from the array passed to the shell. if (defaultImages !is null && defaultImages.length > 0) { - auto nonDisposedImages = new ArraySeq!(Image); - nonDisposedImages.capacity(defaultImages.length); + ArrayList nonDisposedImages = new ArrayList(defaultImages.length); for (int i = 0; i < defaultImages.length; ++i) { if (defaultImages[i] !is null && !defaultImages[i].isDisposed()) { - nonDisposedImages.append(defaultImages[i]); + nonDisposedImages.add(defaultImages[i]); } } if (nonDisposedImages.size() <= 0) { Stderr.formatln("Window.configureShell: images disposed"); //$NON-NLS-1$ } else { - newShell.setImages(nonDisposedImages.toArray()); + newShell.setImages(arraycast!(Image)(nonDisposedImages.toArray())); } }
--- a/dwtx/jface/window/WindowManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/window/WindowManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -14,12 +14,11 @@ import dwtx.jface.window.Window; -import tango.util.collection.ArraySeq; -import tango.util.collection.model.Seq; import dwtx.core.runtime.Assert; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * A manager for a group of windows. Window managers are an optional JFace @@ -44,20 +43,20 @@ * List of windows managed by this window manager * (element type: <code>Window</code>). */ - private ArraySeq!(Window) windows; + private ArrayList windows; /** * List of window managers who have this window manager * as their parent (element type: <code>WindowManager</code>). */ - private Seq!(WindowManager) subManagers; + private List subManagers; /** * Creates an empty window manager without a parent window * manager (that is, a root window manager). */ public this() { - windows = new ArraySeq!(Window); + windows = new ArrayList(); } /** @@ -67,7 +66,7 @@ * @param parent the parent window manager */ public this(WindowManager parent) { - windows = new ArraySeq!(Window); + windows = new ArrayList(); Assert.isNotNull(parent); parent.addWindowManager(this); } @@ -81,7 +80,7 @@ */ public void add(Window window) { if (!windows.contains(window)) { - windows.append(window); + windows.add(window); window.setWindowManager(this); } } @@ -94,10 +93,10 @@ */ private void addWindowManager(WindowManager wm) { if (subManagers is null) { - subManagers = new ArraySeq!(WindowManager); + subManagers = new ArrayList(); } if (!subManagers.contains(wm)) { - subManagers.append(wm); + subManagers.add(wm); } } @@ -109,15 +108,19 @@ * and <code>false</code> if any window refused to close */ public bool close() { - auto t = windows.dup(); // make iteration robust - foreach( window; t ){ + List t = cast(List) windows.clone(); // make iteration robust + Iterator e = t.iterator(); + while (e.hasNext()) { + Window window = cast(Window) e.next(); bool closed = window.close(); if (!closed) { return false; } } if (subManagers !is null) { - foreach( wm; subManagers ){ + e = subManagers.iterator(); + while (e.hasNext()) { + WindowManager wm = cast(WindowManager) e.next(); bool closed = wm.close(); if (!closed) { return false; @@ -143,7 +146,7 @@ * @return a possibly empty list of window */ public Window[] getWindows() { - return windows.toArray(); + return arraycast!(Window)(windows.toArray()); } /**
--- a/dwtx/jface/wizard/Wizard.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/wizard/Wizard.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,7 +16,6 @@ import dwtx.jface.wizard.IWizardPage; import dwtx.jface.wizard.IWizardContainer; -import tango.util.collection.ArraySeq; import dwt.graphics.Image; import dwt.graphics.RGB; @@ -28,6 +27,7 @@ import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * An abstract base implementation of a wizard. A typical client subclasses @@ -76,7 +76,7 @@ /** * This wizard's list of pages (element type: <code>IWizardPage</code>). */ - private ArraySeq!(Object) pages; + private List pages; /** * Indicates whether this wizard needs a progress monitor. @@ -126,7 +126,7 @@ */ protected this() { //super(); - pages = new ArraySeq!(Object); + pages = new ArrayList(); defaultImageDescriptor = JFaceResources.getImageRegistry().getDescriptor(DEFAULT_IMAGE); } @@ -138,7 +138,7 @@ * the new page */ public void addPage(IWizardPage page) { - pages.append(cast(Object)page); + pages.add(cast(Object)page); page.setWizard(this); } @@ -232,7 +232,7 @@ * return the page that was added to this wizard after the given page. */ public IWizardPage getNextPage(IWizardPage page) { - int index = seqIndexOf(pages,cast(Object)page ); + int index = pages.indexOf( cast(Object)page ); if (index is pages.size() - 1 || index is -1) { // last page or page not found return null; @@ -273,7 +273,7 @@ * return the page that was added to this wizard before the given page. */ public IWizardPage getPreviousPage(IWizardPage page) { - int index = seqIndexOf(pages,cast(Object)page); + int index = pages.indexOf(cast(Object)page); if (index is 0 || index is -1) { // first page or page not found return null;
--- a/dwtx/jface/wizard/WizardDialog.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/wizard/WizardDialog.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,9 +19,6 @@ import dwtx.jface.wizard.ProgressMonitorPart; // import java.lang.reflect.InvocationTargetException; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; -import tango.util.collection.model.Map; // import java.util.HashMap; // import java.util.Map; @@ -63,6 +60,7 @@ import dwtx.jface.util.SafeRunnable; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; /** @@ -96,10 +94,10 @@ private IWizard wizard; // Wizards to dispose - private ArraySeq!(Object) createdWizards; + private ArrayList createdWizards; // Current nested wizards - private ArraySeq!(Object) nestedWizards; + private ArrayList nestedWizards; // The currently displayed page. private IWizardPage currentPage = null; @@ -294,8 +292,8 @@ * the wizard this dialog is working on */ public this(Shell parentShell, IWizard newWizard) { - createdWizards = new ArraySeq!(Object); - nestedWizards = new ArraySeq!(Object); + createdWizards = new ArrayList(); + nestedWizards = new ArrayList(); pageChangedListeners = new ListenerList(); pageChangingListeners = new ListenerList(); @@ -323,7 +321,7 @@ * @return the saved UI state */ private Object aboutToStart(bool enableCancelButton) { - Map!(Object,Object) savedState = null; + Map savedState = null; if (getShell() !is null) { // Save focus control Control focusControl = getShell().getDisplay().getFocusControl(); @@ -342,7 +340,7 @@ // Deactivate shell savedState = saveUIState(needsProgressMonitor && enableCancelButton); if (focusControl !is null) { - savedState.add(stringcast(FOCUS_CONTROL), focusControl); + savedState.put(stringcast(FOCUS_CONTROL), focusControl); } // Attach the progress monitor part to the cancel button if (needsProgressMonitor) { @@ -893,7 +891,7 @@ * the key * @see #saveEnableStateAndSet */ - private void restoreEnableState(Control w, Map!(Object,Object) h, String key) { + private void restoreEnableState(Control w, Map h, String key) { if (w !is null) { Boolean b = cast(Boolean) h.get(stringcast(key)); if (b !is null) { @@ -911,7 +909,7 @@ * <code>saveUIState</code> * @see #saveUIState */ - private void restoreUIState(Map!(Object,Object) state) { + private void restoreUIState(Map state) { restoreEnableState(backButton, state, "back"); //$NON-NLS-1$ restoreEnableState(nextButton, state, "next"); //$NON-NLS-1$ restoreEnableState(finishButton, state, "finish"); //$NON-NLS-1$ @@ -980,10 +978,10 @@ * <code>false</code> to disable it * @see #restoreEnableState(Control, Map, String) */ - private void saveEnableStateAndSet(Control w, Map!(Object,Object) h, String key, + private void saveEnableStateAndSet(Control w, Map h, String key, bool enabled) { if (w !is null) { - h.add(stringcast(key), w.getEnabled() ? Boolean.TRUE : Boolean.FALSE); + h.put(stringcast(key), w.getEnabled() ? Boolean.TRUE : Boolean.FALSE); w.setEnabled(enabled); } } @@ -1001,8 +999,8 @@ * with <code>restoreUIState</code> * @see #restoreUIState */ - private Map!(Object,Object) saveUIState(bool keepCancelEnabled) { - Map!(Object,Object) savedState = new HashMap!(Object,Object); + private Map saveUIState(bool keepCancelEnabled) { + Map savedState = new HashMap(10); saveEnableStateAndSet(backButton, savedState, "back", false); //$NON-NLS-1$ saveEnableStateAndSet(nextButton, savedState, "next", false); //$NON-NLS-1$ saveEnableStateAndSet(finishButton, savedState, "finish", false); //$NON-NLS-1$ @@ -1010,7 +1008,7 @@ "cancel", keepCancelEnabled); //$NON-NLS-1$ saveEnableStateAndSet(helpButton, savedState, "help", false); //$NON-NLS-1$ if (currentPage !is null) { - savedState.add(stringcast("page"), ControlEnableState.disable(currentPage.getControl())); //$NON-NLS-1$ + savedState.put(stringcast("page"), ControlEnableState.disable(currentPage.getControl())); //$NON-NLS-1$ } return savedState; } @@ -1092,9 +1090,9 @@ wizard = newWizard; wizard.setContainer(this); if (!createdWizards.contains(cast(Object)wizard)) { - createdWizards.append(cast(Object)wizard); + createdWizards.add(cast(Object)wizard); // New wizard so just add it to the end of our nested list - nestedWizards.append(cast(Object)wizard); + nestedWizards.add(cast(Object)wizard); if (pageContainer !is null) { // Dialog is already open // Allow the wizard pages to precreate their page controls @@ -1110,10 +1108,10 @@ // the last wizard from the list int size = nestedWizards.size(); if (size >= 2 && nestedWizards.get(size - 2) is cast(Object)wizard) { - nestedWizards.removeAt(size - 1); + nestedWizards.remove(size - 1); } else { // Assume we are going forward to revisit a wizard - nestedWizards.append(cast(Object)wizard); + nestedWizards.add(cast(Object)wizard); } } } @@ -1225,7 +1223,7 @@ progressMonitorPart.setVisible(false); progressMonitorPart.removeFromCancelComponent(cancelButton); } - Map!(Object,Object) state = cast(Map!(Object,Object)) savedState; + Map state = cast(Map) savedState; restoreUIState(state); cancelButton.addSelectionListener(cancelListener); setDisplayCursor(null);
--- a/dwtx/jface/wizard/WizardSelectionPage.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/wizard/WizardSelectionPage.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,9 +17,9 @@ import dwtx.jface.wizard.WizardPage; import dwtx.jface.wizard.IWizardNode; -import tango.util.collection.ArraySeq; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * An abstract implementation of a wizard page that manages a @@ -44,7 +44,7 @@ * List of wizard nodes that have cropped up in the past * (element type: <code>IWizardNode</code>). */ - private ArraySeq!(Object) selectedWizardNodes; + private List selectedWizardNodes; /** * Creates a new wizard selection page with the given name, and @@ -54,7 +54,7 @@ */ protected this(String pageName) { super(pageName); - selectedWizardNodes = new ArraySeq!(Object); + selectedWizardNodes = new ArrayList(); // Cannot finish from this page setPageComplete(false); } @@ -74,7 +74,7 @@ return; } - selectedWizardNodes.append(cast(Object)node); + selectedWizardNodes.add(cast(Object)node); } /**
--- a/dwtx/ui/forms/DetailsPart.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/DetailsPart.d Thu Aug 07 15:01:33 2008 +0200 @@ -28,7 +28,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * This managed form part handles the 'details' portion of the @@ -51,7 +51,7 @@ private ScrolledPageBook pageBook; private IFormPart masterPart; private IStructuredSelection currentSelection; - private HashMap!(Object,Object) pages; + private Hashtable pages; private IDetailsPageProvider pageProvider; private int pageLimit=Integer.MAX_VALUE; @@ -93,7 +93,7 @@ */ public this(IManagedForm mform, ScrolledPageBook pageBook) { this.pageBook = pageBook; - pages = new HashMap!(Object,Object); + pages = new Hashtable(); initialize(mform); } /** @@ -118,7 +118,7 @@ } private void registerPage(Object objectClass, IDetailsPage page, bool fixed) { - pages.add(objectClass, new PageBag(page, fixed)); + pages.put(objectClass, new PageBag(page, fixed)); page.initialize(managedForm); } /** @@ -158,8 +158,8 @@ * @see dwtx.ui.forms.IFormPart#dispose() */ public void dispose() { - foreach( k, v; pages ){ - PageBag pageBag = cast(PageBag) v; + for (Enumeration enm = pages.elements(); enm.hasMoreElements();) { + PageBag pageBag = cast(PageBag) enm.nextElement(); pageBag.dispose(); } } @@ -235,7 +235,8 @@ private void update() { Object key = null; if (currentSelection !is null) { - foreach ( obj; currentSelection.iterator() ) { + for (Iterator iter = currentSelection.iterator(); iter.hasNext();) { + Object obj = iter.next(); if (key is null) key = getKey(obj); else if (getKey(obj).opEquals(key) is false) { @@ -299,8 +300,9 @@ // overflow int currentTicket = PageBag.getCurrentTicket(); int cutoffTicket = currentTicket - getPageLimit(); - foreach( key, v; cast(HashMap!(Object,Object))pages.dup ){ - PageBag pageBag = cast(PageBag)v; + for (Enumeration enm=pages.keys(); enm.hasMoreElements();) { + Object key = enm.nextElement(); + PageBag pageBag = cast(PageBag)pages.get(key); if (pageBag.getTicket()<=cutoffTicket) { // candidate - see if it is active and not fixed if (!pageBag.isFixed() && !(cast(Object)pageBag.getPage()).opEquals(cast(Object)getCurrentPage())) {
--- a/dwtx/ui/forms/FormColors.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/FormColors.d Thu Aug 07 15:01:33 2008 +0200 @@ -20,7 +20,7 @@ import dwt.widgets.Display; import dwt.dwthelper.utils; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * Manages colors that will be applied to forms and form widgets. The colors are @@ -96,7 +96,7 @@ */ public static const String TB_TOGGLE_HOVER = IFormColors.TB_TOGGLE_HOVER; - protected HashMap!(String,Object) colorRegistry; + protected Map colorRegistry; protected Color background; @@ -115,7 +115,7 @@ * the display to use */ public this(Display display) { - colorRegistry = new HashMap!(String,Object); + colorRegistry = new HashMap(10); this.display = display; initialize(); } @@ -258,10 +258,10 @@ */ public Color createColor(String key, int r, int g, int b) { Color c = new Color(display, r, g, b); - Color prevC = cast(Color) (colorRegistry.containsKey(key) ? colorRegistry.get(key) : null ); + Color prevC = cast(Color) colorRegistry.get(key); if (prevC !is null) prevC.dispose(); - colorRegistry.add(key, c); + colorRegistry.put(key, c); return c; } @@ -368,9 +368,9 @@ * Disposes all the colors in the registry. */ public void dispose() { - foreach( k, v; colorRegistry ) - (cast(Color) v).dispose(); - + Iterator e = colorRegistry.values().iterator(); + while (e.hasNext()) + (cast(Color) e.next()).dispose(); colorRegistry = null; } @@ -621,7 +621,7 @@ private void disposeIfFound(String key) { Color color = getColor(key); if (color !is null) { - colorRegistry.removeKey(key); + colorRegistry.remove(key); color.dispose(); } }
--- a/dwtx/ui/forms/HyperlinkGroup.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/HyperlinkGroup.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,7 +24,7 @@ import dwtx.ui.forms.widgets.Hyperlink; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; /** * Manages a group of hyperlinks. It tracks activation, updates normal and @@ -36,7 +36,7 @@ */ public final class HyperlinkGroup : HyperlinkSettings { - private ArraySeq!(Object) links; + private ArrayList links; private Hyperlink lastActivated; private Hyperlink lastEntered; private GroupListener listener; @@ -113,7 +113,7 @@ */ public this(Display display) { - links = new ArraySeq!(Object); + links = new ArrayList(); super(display); listener = new GroupListener(); } @@ -225,7 +225,7 @@ link.addListener(DWT.Dispose, listener); link.addListener(DWT.MouseEnter, listener); link.addListener(DWT.MouseExit, listener); - links.append(link); + links.add(link); } private void unhook(Hyperlink link) {
--- a/dwtx/ui/forms/ManagedForm.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/ManagedForm.d Thu Aug 07 15:01:33 2008 +0200 @@ -25,7 +25,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; import tango.core.Thread; /** @@ -61,7 +61,7 @@ private MessageManager messageManager; - private ArraySeq!(Object) parts; + private Vector parts; /** * Creates a managed form in the provided parent. Form toolkit and widget @@ -71,7 +71,7 @@ * the parent widget */ public this(Composite parent) { - parts = new ArraySeq!(Object); + parts = new Vector(); toolkit = new FormToolkit(parent.getDisplay()); ownsToolkit = true; form = toolkit.createScrolledForm(parent); @@ -84,7 +84,7 @@ * @param form */ public this(FormToolkit toolkit, ScrolledForm form) { - parts = new ArraySeq!(Object); + parts = new Vector(); this.form = form; this.toolkit = toolkit; } @@ -95,7 +95,7 @@ * @see dwtx.ui.forms.IManagedForm#addPart(dwtx.ui.forms.IFormPart) */ public void addPart(IFormPart part) { - parts.append(cast(Object)part); + parts.add(cast(Object)part); part.initialize(this); }
--- a/dwtx/ui/forms/MasterDetailsBlock.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/MasterDetailsBlock.d Thu Aug 07 15:01:33 2008 +0200 @@ -32,7 +32,7 @@ import dwtx.ui.forms.widgets.ScrolledForm; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; /** * This class implements the 'master/details' UI pattern suitable for inclusion @@ -77,10 +77,10 @@ static const int DRAGGER_SIZE = 40; class MDSashForm : SashForm { - ArraySeq!(Sash) sashes; + ArrayList sashes; Listener listener; public this(Composite parent, int style) { - sashes = new ArraySeq!(Sash); + sashes = new ArrayList(); listener = dgListener ( (Event e){ switch (e.type) { case DWT.MouseEnter: @@ -122,14 +122,15 @@ sash.addListener(DWT.Paint, listener); sash.addListener(DWT.MouseEnter, listener); sash.addListener(DWT.MouseExit, listener); - sashes.append(sash); + sashes.add(sash); } } } private void purgeSashes() { - foreach ( sash; sashes.dup ) { + for (Iterator iter=sashes.iterator(); iter.hasNext();) { + Sash sash = cast(Sash)iter.next(); if (sash.isDisposed()) - sashes.remove(sash); + iter.remove(); } } }
--- a/dwtx/ui/forms/widgets/FormText.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/widgets/FormText.d Thu Aug 07 15:01:33 2008 +0200 @@ -79,8 +79,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.InputStream; import tango.io.Stdout; -import tango.util.collection.HashMap; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; /** * This class is a read-only text control that is capable of rendering wrapped @@ -206,7 +205,7 @@ private ListenerList listeners; - private HashMap!(String,Object) resourceTable; + private Hashtable resourceTable; private IHyperlinkSegment entered; @@ -364,7 +363,7 @@ * the widget style */ public this(Composite parent, int style) { - resourceTable = new HashMap!(String,Object); + resourceTable = new Hashtable(); super(parent, DWT.NO_BACKGROUND | DWT.WRAP | style); setLayout(new FormTextLayout()); model = new FormTextModel(); @@ -562,7 +561,7 @@ * an object of a type <samp>Image </samp>. */ public void setImage(String key, Image image) { - resourceTable.add("i." ~ key, image); //$NON-NLS-1$ + resourceTable.put("i." ~ key, image); //$NON-NLS-1$ } /** @@ -582,9 +581,9 @@ public void setColor(String key, Color color) { String fullKey = "c." ~ key; //$NON-NLS-1$ if (color is null) - resourceTable.removeKey(fullKey); + resourceTable.remove(fullKey); else - resourceTable.add(fullKey, color); + resourceTable.put(fullKey, color); } /** @@ -604,9 +603,9 @@ public void setFont(String key, Font font) { String fullKey = "f." ~ key; //$NON-NLS-1$ if (font is null) - resourceTable.removeKey(fullKey); + resourceTable.remove(fullKey); else - resourceTable.add(fullKey, font); + resourceTable.put(fullKey, font); model.clearCache(fullKey); } @@ -629,9 +628,9 @@ public void setControl(String key, Control control) { String fullKey = "o." ~ key; //$NON-NLS-1$ if (control is null) - resourceTable.removeKey(fullKey); + resourceTable.remove(fullKey); else - resourceTable.add(fullKey, control); + resourceTable.put(fullKey, control); } /** @@ -648,7 +647,7 @@ Font boldFont = cast(Font) resourceTable.get(FormTextModel.BOLD_FONT_ID); if (boldFont !is null) { FormFonts.getInstance().markFinished(boldFont); - resourceTable.removeKey(FormTextModel.BOLD_FONT_ID); + resourceTable.remove(FormTextModel.BOLD_FONT_ID); } ensureBoldFontPresent(getFont()); } @@ -1552,11 +1551,11 @@ } private void ensureBoldFontPresent(Font regularFont) { - Font boldFont = resourceTable.containsKey(FormTextModel.BOLD_FONT_ID) ? cast(Font) resourceTable.get(FormTextModel.BOLD_FONT_ID) : null; + Font boldFont = cast(Font) resourceTable.get(FormTextModel.BOLD_FONT_ID); if (boldFont !is null) return; boldFont = FormFonts.getInstance().getBoldFont(getDisplay(), regularFont); - resourceTable.add(FormTextModel.BOLD_FONT_ID, boldFont); + resourceTable.put(FormTextModel.BOLD_FONT_ID, boldFont); } private void paint(PaintEvent e) { @@ -1669,22 +1668,24 @@ .get(FormTextModel.BOLD_FONT_ID); if (boldFont !is null) { FormFonts.getInstance().markFinished(boldFont); - resourceTable.removeKey(FormTextModel.BOLD_FONT_ID); + resourceTable.remove(FormTextModel.BOLD_FONT_ID); } } - ArraySeq!(String) imagesToRemove = new ArraySeq!(String); - foreach( key, obj; resourceTable ){ + ArrayList imagesToRemove = new ArrayList(); + for (Enumeration enm = resourceTable.keys(); enm.hasMoreElements();) { + String key = stringcast( enm.nextElement()); if (key.startsWith(ImageSegment.SEL_IMAGE_PREFIX)) { + Object obj = resourceTable.get(key); if (auto image = cast(Image)obj ) { if (!image.isDisposed()) { image.dispose(); - imagesToRemove.append(key); + imagesToRemove.add(key); } } } } for (int i = 0; i < imagesToRemove.size(); i++) { - resourceTable.removeKey(imagesToRemove.get(i)); + resourceTable.remove(imagesToRemove.get(i)); } }
--- a/dwtx/ui/forms/widgets/ScrolledPageBook.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/widgets/ScrolledPageBook.d Thu Aug 07 15:01:33 2008 +0200 @@ -26,7 +26,8 @@ import dwtx.ui.internal.forms.widgets.WrappedPageBook; import dwt.dwthelper.utils; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; + /** * ScrolledPageBook is a class that is capable of stacking several composites * (pages), while showing one at a time. The content is scrolled if there is @@ -36,7 +37,7 @@ */ public class ScrolledPageBook : SharedScrolledComposite { private WrappedPageBook pageBook; - private HashMap!(Object,Object) pages; + private Hashtable pages; private Composite emptyPage; private Control currentPage; /** @@ -60,7 +61,7 @@ super(parent, style); pageBook = new WrappedPageBook(this, DWT.NULL); setContent(pageBook); - pages = new HashMap!(Object,Object); + pages = new Hashtable(); setExpandHorizontal(true); setExpandVertical(true); this.addListener(DWT.Traverse, dgListener( (Event e) { @@ -110,7 +111,7 @@ */ public Composite createPage(Object key) { Composite page = createPage(); - pages.add(key, page); + pages.put(key, page); return page; } /** @@ -133,7 +134,7 @@ * @see #getContainer */ public void registerPage(Object key, Control page) { - pages.add(key, page); + pages.put(key, page); } /** * Removes the page under the provided key from the page book. Does nothing
--- a/dwtx/ui/forms/widgets/Section.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/widgets/Section.d Thu Aug 07 15:01:33 2008 +0200 @@ -34,8 +34,7 @@ import dwtx.ui.internal.forms.widgets.FormUtil; import dwt.dwthelper.utils; - -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * A variation of the expandable composite that adds optional description below @@ -67,7 +66,7 @@ private Control separator; - private HashMap!(String,Object) titleColors; + private Hashtable titleColors; private static const String COLOR_BG = "bg"; //$NON-NLS-1$ @@ -339,8 +338,8 @@ if (color is null) return; if (titleColors is null) - titleColors = new HashMap!(String,Object); - titleColors.add(key, color); + titleColors = new Hashtable(); + titleColors.put(key, color); } protected void onPaint(PaintEvent e) {
--- a/dwtx/ui/forms/widgets/SizeCache.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/widgets/SizeCache.d Thu Aug 07 15:01:33 2008 +0200 @@ -36,7 +36,7 @@ import dwtx.ui.internal.forms.widgets.FormUtil; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; + /** * Caches the preferred size of an DWT control *
--- a/dwtx/ui/forms/widgets/TableWrapLayout.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/forms/widgets/TableWrapLayout.d Thu Aug 07 15:01:33 2008 +0200 @@ -25,8 +25,7 @@ import dwt.widgets.Layout; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * This implementation of the layout algorithm attempts to position controls in @@ -101,9 +100,9 @@ private bool initialLayout = true; - private ArraySeq!(Object) grid = null; + private Vector grid = null; - private HashMap!(Object,Object) rowspans; + private Hashtable rowspans; private int[] minColumnWidths, maxColumnWidths; @@ -179,7 +178,7 @@ } if (grid is null || changed) { changed = true; - grid = new ArraySeq!(Object); + grid = new Vector(); createGrid(parent); } if (minColumnWidths is null) @@ -211,7 +210,7 @@ } if (grid is null || changed) { changed = true; - grid = new ArraySeq!(Object); + grid = new Vector(); createGrid(parent); } if (maxColumnWidths is null) @@ -247,7 +246,7 @@ } if (grid is null || changed) { changed = true; - grid = new ArraySeq!(Object); + grid = new Vector(); createGrid(parent); } resetColumnWidths(); @@ -299,7 +298,7 @@ for (int i = 0; i < grid.size(); i++) { int rowHeight = rowHeights[i]; int x = leftMargin+clientArea.x; - TableWrapData[] row = (cast(ArrayWrapperT!(TableWrapData)) grid.get(i)).array; + TableWrapData[] row = arrayFromObject!(TableWrapData)( grid.elementAt(i)); for (int j = 0; j < numColumns; j++) { TableWrapData td = row[j]; if (td.isItemData) { @@ -318,7 +317,7 @@ bool changed) { int[] rowHeights = new int[grid.size()]; for (int i = 0; i < grid.size(); i++) { - TableWrapData[] row = (cast(ArrayWrapperT!(TableWrapData)) grid.get(i)).array; + TableWrapData[] row = arrayFromObject!(TableWrapData)( grid.elementAt(i)); rowHeights[i] = 0; for (int j = 0; j < numColumns; j++) { TableWrapData td = row[j]; @@ -339,7 +338,7 @@ size = new Point(size.x, td.heightHint); } td.compSize = size; - RowSpan rowspan = rowspans.containsKey(child) ? cast(RowSpan) rowspans.get(child) : null; + RowSpan rowspan = cast(RowSpan) rowspans.get(child); if (rowspan is null) { rowHeights[i] = Math.max(rowHeights[i], size.y); } else @@ -347,8 +346,8 @@ } updateRowSpans(i, rowHeights[i]); } - foreach( k, v; rowspans ){ - RowSpan rowspan = cast(RowSpan) v; + for (Enumeration enm = rowspans.elements(); enm.hasMoreElements();) { + RowSpan rowspan = cast(RowSpan) enm.nextElement(); int increase = rowspan.getRequiredHeightIncrease(); if (increase is 0) continue; @@ -431,7 +430,7 @@ int width = td.compSize.x-td.indent; width = Math.min(width, colWidth); int slotHeight = rowHeights[row]; - RowSpan rowspan = rowspans.containsKey(control) ? cast(RowSpan) rowspans.get(control) : null; + RowSpan rowspan = cast(RowSpan) rowspans.get(control); if (rowspan !is null) { slotHeight = 0; for (int i = row; i < row + td.rowspan; i++) { @@ -463,15 +462,15 @@ int row, column, rowFill, columnFill; Control[] children; TableWrapData spacerSpec; - ArraySeq!(Object) growingCols = new ArraySeq!(Object); - ArraySeq!(Object) growingRows = new ArraySeq!(Object); - rowspans = new HashMap!(Object,Object); + Vector growingCols = new Vector(); + Vector growingRows = new Vector(); + rowspans = new Hashtable(); // children = composite.getChildren(); if (children.length is 0) return; // - grid.append( new ArrayWrapperT!(TableWrapData)(createEmptyRow())); + grid.addElement( new ArrayWrapperObject(createEmptyRow())); row = 0; column = 0; // Loop through the children and place their associated layout specs in @@ -481,13 +480,13 @@ // Find the first available spot in the grid. Control child = children[i]; TableWrapData spec = cast(TableWrapData) child.getLayoutData(); - while ((cast(ArrayWrapperT!(TableWrapData)) grid.get(row)).array[column] !is null) { + while (arrayFromObject!(TableWrapData)( grid.elementAt(row))[column] !is null) { column = column + 1; if (column >= numColumns) { row = row + 1; column = 0; if (row >= grid.size()) { - grid.append(new ArrayWrapperT!(TableWrapData)(createEmptyRow())); + grid.addElement(new ArrayWrapperObject(createEmptyRow())); } } } @@ -495,25 +494,25 @@ // not, go to the // next row. if (column + spec.colspan - 1 >= numColumns) { - grid.append(new ArrayWrapperT!(TableWrapData)(createEmptyRow())); + grid.addElement(new ArrayWrapperObject(createEmptyRow())); row = row + 1; column = 0; } // The vertical span for the item will be at least 1. If it is > 1, // add other rows to the grid. if (spec.rowspan > 1) { - rowspans.add(child, new RowSpan(child, column, row)); + rowspans.put(child, new RowSpan(child, column, row)); } for (int j = 2; j <= spec.rowspan; j++) { if (row + j > grid.size()) { - grid.append(new ArrayWrapperT!(TableWrapData)(createEmptyRow())); + grid.addElement(new ArrayWrapperObject(createEmptyRow())); } } // Store the layout spec. Also cache the childIndex. NOTE: That we // assume the children of a // composite are maintained in the order in which they are created // and added to the composite. - (cast(ArrayWrapperT!(TableWrapData)) grid.get(row)).array[column] = spec; + arrayFromObject!(TableWrapData)( grid.elementAt(row))[column] = spec; spec.childIndex = i; if (spec.grabHorizontal) { updateGrowingColumns(growingCols, spec, column); @@ -530,14 +529,14 @@ for (int c = 0; c < spec.colspan; c++) { spacerSpec = new TableWrapData(); spacerSpec.isItemData = false; - (cast(ArrayWrapperT!(TableWrapData)) grid.get(row + r)).array[column + c] = spacerSpec; + arrayFromObject!(TableWrapData)( grid.elementAt(row + r))[column + c] = spacerSpec; } } for (int c = 1; c <= columnFill; c++) { for (int r = 0; r < spec.rowspan; r++) { spacerSpec = new TableWrapData(); spacerSpec.isItemData = false; - (cast(ArrayWrapperT!(TableWrapData)) grid.get(row + r)).array[column + c] = spacerSpec; + arrayFromObject!(TableWrapData)( grid.elementAt(row + r))[column + c] = spacerSpec; } } column = column + spec.colspan - 1; @@ -546,12 +545,12 @@ for (int k = column + 1; k < numColumns; k++) { spacerSpec = new TableWrapData(); spacerSpec.isItemData = false; - (cast(ArrayWrapperT!(TableWrapData)) grid.get(row)).array[k] = spacerSpec; + arrayFromObject!(TableWrapData)( grid.elementAt(row))[k] = spacerSpec; } for (int k = row + 1; k < grid.size(); k++) { spacerSpec = new TableWrapData(); spacerSpec.isItemData = false; - (cast(ArrayWrapperT!(TableWrapData)) grid.get(k)).array[column] = spacerSpec; + arrayFromObject!(TableWrapData)( grid.elementAt(k))[column] = spacerSpec; } growingColumns = new int[growingCols.size()]; for (int i = 0; i < growingCols.size(); i++) { @@ -563,7 +562,7 @@ } } - private void updateGrowingColumns(ArraySeq!(Object) growingColumns, + private void updateGrowingColumns(Vector growingColumns, TableWrapData spec, int column) { int affectedColumn = column + spec.colspan - 1; for (int i = 0; i < growingColumns.size(); i++) { @@ -571,10 +570,10 @@ if (col.intValue() is affectedColumn) return; } - growingColumns.append(new Integer(affectedColumn)); + growingColumns.add(new Integer(affectedColumn)); } - private void updateGrowingRows(ArraySeq!(Object) growingRows, TableWrapData spec, + private void updateGrowingRows(Vector growingRows, TableWrapData spec, int row) { int affectedRow = row + spec.rowspan - 1; for (int i = 0; i < growingRows.size(); i++) { @@ -582,7 +581,7 @@ if (irow.intValue() is affectedRow) return; } - growingRows.append(new Integer(affectedRow)); + growingRows.add(new Integer(affectedRow)); } private TableWrapData[] createEmptyRow() { @@ -615,7 +614,7 @@ } if (grid is null || changed) { changed = true; - grid = new ArraySeq!(Object); + grid = new Vector(); createGrid(parent); } resetColumnWidths(); @@ -666,7 +665,7 @@ int innerHeight = 0; // compute widths for (int i = 0; i < grid.size(); i++) { - TableWrapData[] row = (cast(ArrayWrapperT!(TableWrapData)) grid.get(i)).array; + TableWrapData[] row = arrayFromObject!(TableWrapData)( grid.elementAt(i)); // assign widths, calculate heights int rowHeight = 0; for (int j = 0; j < numColumns; j++) { @@ -687,7 +686,7 @@ Point size = computeSize(td.childIndex, cwidth, td.indent, td.maxWidth, td.maxHeight); cy = size.y; } - RowSpan rowspan = rowspans.containsKey(child) ? cast(RowSpan) rowspans.get(child) : null; + RowSpan rowspan = cast(RowSpan) rowspans.get(child); if (rowspan !is null) { // don't take the height of this child into acount // because it spans multiple rows @@ -701,7 +700,7 @@ innerHeight += verticalSpacing; innerHeight += rowHeight; } - if (!rowspans.drained()) + if (!rowspans.isEmpty()) innerHeight = compensateForRowSpans(innerHeight); totalHeight = topMargin + innerHeight + bottomMargin; return new Point(tableWidth, totalHeight); @@ -710,15 +709,15 @@ private void updateRowSpans(int row, int rowHeight) { if (rowspans is null || rowspans.size() is 0) return; - foreach( k, v; rowspans ){ - RowSpan rowspan = cast(RowSpan) v; + for (Enumeration enm = rowspans.elements(); enm.hasMoreElements();) { + RowSpan rowspan = cast(RowSpan) enm.nextElement(); rowspan.update(row, rowHeight); } } private int compensateForRowSpans(int totalHeight) { - foreach( k, v; rowspans ){ - RowSpan rowspan = cast(RowSpan) v; + for (Enumeration enm = rowspans.elements(); enm.hasMoreElements();) { + RowSpan rowspan = cast(RowSpan) enm.nextElement(); totalHeight += rowspan.getRequiredHeightIncrease(); } return totalHeight; @@ -780,7 +779,7 @@ void calculateColumnWidths(Composite parent, int [] columnWidths, bool max, bool changed) { bool secondPassNeeded=false; for (int i = 0; i < grid.size(); i++) { - TableWrapData[] row = (cast(ArrayWrapperT!(TableWrapData)) grid.get(i)).array; + TableWrapData[] row = arrayFromObject!(TableWrapData)( grid.elementAt(i)); for (int j = 0; j < numColumns; j++) { TableWrapData td = row[j]; if (td.isItemData is false) @@ -808,7 +807,7 @@ // Second pass for controls with multi-column horizontal span for (int i = 0; i < grid.size(); i++) { - TableWrapData[] row = (cast(ArrayWrapperT!(TableWrapData)) grid.get(i)).array; + TableWrapData[] row = arrayFromObject!(TableWrapData)( grid.elementAt(i)); for (int j = 0; j < numColumns; j++) { TableWrapData td = row[j]; if (td.isItemData is false || td.colspan is 1)
--- a/dwtx/ui/internal/forms/MessageManager.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/MessageManager.d Thu Aug 07 15:01:33 2008 +0200 @@ -31,9 +31,8 @@ import dwtx.ui.forms.widgets.ScrolledForm; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; import tango.util.Convert; import tango.text.Text; import tango.io.model.IFile; @@ -55,8 +54,8 @@ } return DEFAULT_PREFIX_PROVIDER_; } - private ArraySeq!(Object) messages; - private HashMap!(Object,Object) decorators; + private ArrayList messages; + private Hashtable decorators; private bool autoUpdate = true; private ScrolledForm scrolledForm; private IMessagePrefixProvider prefixProvider; @@ -237,11 +236,11 @@ class ControlDecorator { private ControlDecoration decoration; - private ArraySeq!(Object) controlMessages; + private ArrayList controlMessages; private String prefix; this(Control control) { - controlMessages = new ArraySeq!(Object); + controlMessages = new ArrayList(); this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody()); } @@ -277,10 +276,8 @@ prefix = ""; //$NON-NLS-1$ } - void addAll(ArraySeq!(Object) target) { - foreach( o; controlMessages ){ - target.append(o); - } + void addAll(ArrayList target) { + target.addAll(controlMessages); } void addMessage(Object key, String text, Object data, int type) { @@ -302,7 +299,7 @@ } bool removeMessages() { - if (controlMessages.drained()) + if (controlMessages.isEmpty()) return false; controlMessages.clear(); if (isAutoUpdate()) @@ -311,11 +308,11 @@ } public void update() { - if (controlMessages.drained()) { + if (controlMessages.isEmpty()) { decoration.setDescriptionText(null); decoration.hide(); } else { - auto peers = createPeers(controlMessages); + ArrayList peers = createPeers(controlMessages); int type = (cast(IMessage) peers.get(0)).getMessageType(); String description = createDetails(createPeers(peers), true); if (type is IMessageProvider.ERROR) @@ -339,8 +336,8 @@ */ public this(ScrolledForm scrolledForm) { prefixProvider = DEFAULT_PREFIX_PROVIDER; - messages = new ArraySeq!(Object); - decorators = new HashMap!(Object,Object); + messages = new ArrayList(); + decorators = new Hashtable(); this.scrolledForm = scrolledForm; } @@ -368,7 +365,7 @@ if (dec is null) { dec = new ControlDecorator(control); - decorators.add(control, dec); + decorators.put(control, dec); } dec.addMessage(key, messageText, data, type); if (isAutoUpdate()) @@ -395,7 +392,7 @@ * @see dwtx.ui.forms.IMessageManager#removeMessages() */ public void removeMessages() { - if (!messages.drained()) { + if (!messages.isEmpty()) { messages.clear(); if (isAutoUpdate()) updateForm(); @@ -439,12 +436,12 @@ */ public void removeAllMessages() { bool needsUpdate = false; - foreach( v; decorators ){ - ControlDecorator control = cast(ControlDecorator) v; + for (Enumeration enm = decorators.elements(); enm.hasMoreElements();) { + ControlDecorator control = cast(ControlDecorator) enm.nextElement(); if (control.removeMessages()) needsUpdate = true; } - if (!messages.drained()) { + if (!messages.isEmpty()) { messages.clear(); needsUpdate = true; } @@ -457,12 +454,12 @@ */ private Message addMessage(String prefix, Object key, String messageText, - Object data, int type, ArraySeq!(Object) list) { + Object data, int type, ArrayList list) { Message message = findMessage(key, list); if (message is null) { message = new Message(key, messageText, type, data); message.prefix = prefix; - list.append(message); + list.add(message); } else { message.message = messageText; message.type = type; @@ -475,7 +472,7 @@ * Finds the message with the provided key in the provided list. */ - private Message findMessage(Object key, ArraySeq!(Object) list) { + private Message findMessage(Object key, ArrayList list) { for (int i = 0; i < list.size(); i++) { Message message = cast(Message) list.get(i); if (message.getKey().opEquals(key)) @@ -491,8 +488,8 @@ */ public void update() { // Update decorations - foreach( v; decorators ){ - ControlDecorator dec = cast(ControlDecorator) v; + for (Iterator iter = decorators.values().iterator(); iter.hasNext();) { + ControlDecorator dec = cast(ControlDecorator) iter.next(); dec.update(); } // Update the form @@ -504,24 +501,22 @@ */ private void updateForm() { - ArraySeq!(Object) mergedList = new ArraySeq!(Object); - foreach( o; messages ){ - mergedList.append(o); - } - foreach( v; decorators ){ - ControlDecorator dec = cast(ControlDecorator) v; + ArrayList mergedList = new ArrayList(); + mergedList.addAll(messages); + for (Enumeration enm = decorators.elements(); enm.hasMoreElements();) { + ControlDecorator dec = cast(ControlDecorator) enm.nextElement(); dec.addAll(mergedList); } update(mergedList); } - private void update(ArraySeq!(Object) mergedList) { + private void update(ArrayList mergedList) { pruneControlDecorators(); - if (scrolledForm.getForm().getHead().getBounds().height is 0 || mergedList.drained() || mergedList is null) { + if (scrolledForm.getForm().getHead().getBounds().height is 0 || mergedList.isEmpty() || mergedList is null) { scrolledForm.setMessage(null, IMessageProvider.NONE); return; } - auto peers = createPeers(mergedList); + ArrayList peers = createPeers(mergedList); int maxType = (cast(IMessage) peers.get(0)).getMessageType(); String messageText; IMessage[] array = arraycast!(IMessage)( peers @@ -550,22 +545,22 @@ return message.getPrefix() ~ message.getMessage(); } - private ArraySeq!(Object) createPeers(ArraySeq!(Object) messages) { - auto peers = new ArraySeq!(Object); + private ArrayList createPeers(ArrayList messages) { + ArrayList peers = new ArrayList(); int maxType = 0; - foreach( o; messages ){ - auto message = cast(Message)o; + for (int i = 0; i < messages.size(); i++) { + Message message = cast(Message) messages.get(i); if (message.type > maxType) { peers.clear(); maxType = message.type; } if (message.type is maxType) - peers.append(message); + peers.add(message); } return peers; } - private String createDetails(ArraySeq!(Object) messages, bool excludePrefix) { + private String createDetails(ArrayList messages, bool excludePrefix) { auto txt = new tango.text.Text.Text!(char); for (int i = 0; i < messages.size(); i++) { @@ -600,10 +595,10 @@ } private void pruneControlDecorators() { - foreach( o; decorators.dup ){ - ControlDecorator dec = cast(ControlDecorator) o; + for (Iterator iter = decorators.values().iterator(); iter.hasNext();) { + ControlDecorator dec = cast(ControlDecorator) iter.next(); if (dec.isDisposed()) - decorators.remove(o); + iter.remove(); } } @@ -623,8 +618,8 @@ */ public void setMessagePrefixProvider(IMessagePrefixProvider provider) { this.prefixProvider = provider; - foreach( o; decorators ){ - ControlDecorator dec = cast(ControlDecorator) o; + for (Iterator iter = decorators.values().iterator(); iter.hasNext();) { + ControlDecorator dec = cast(ControlDecorator) iter.next(); dec.updatePrefix(); } } @@ -645,8 +640,8 @@ */ public void setDecorationPosition(int position) { this.decorationPosition = position; - foreach( o; decorators ){ - ControlDecorator dec = cast(ControlDecorator) o; + for (Iterator iter = decorators.values().iterator(); iter.hasNext();) { + ControlDecorator dec = cast(ControlDecorator) iter.next(); dec.updatePosition(); } }
--- a/dwtx/ui/internal/forms/widgets/AggregateHyperlinkSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/AggregateHyperlinkSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,7 +24,7 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; /** * This segment contains a collection of images and links that all belong to one @@ -34,18 +34,18 @@ IHyperlinkSegment { private String href; - private ArraySeq!(Object) segments; + private Vector segments; public this() { - segments = new ArraySeq!(Object); + segments = new Vector(); } public void add(TextHyperlinkSegment segment) { - segments.append(segment); + segments.add(segment); } public void add(ImageHyperlinkSegment segment) { - segments.append(segment); + segments.add(segment); } /*
--- a/dwtx/ui/internal/forms/widgets/BreakSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/BreakSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -16,13 +16,12 @@ import dwtx.ui.internal.forms.widgets.Locator; import dwtx.ui.internal.forms.widgets.SelectionData; -//import java.util.Hashtable; - import dwt.graphics.FontMetrics; import dwt.graphics.GC; import dwt.graphics.Rectangle; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; /** * This segment serves as break within a paragraph. It has no data -
--- a/dwtx/ui/internal/forms/widgets/BulletParagraph.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/BulletParagraph.d Thu Aug 07 15:01:33 2008 +0200 @@ -17,8 +17,6 @@ import dwtx.ui.internal.forms.widgets.SelectionData; import dwtx.ui.internal.forms.widgets.IHyperlinkSegment; -//import java.util.Hashtable; - import dwt.graphics.Color; import dwt.graphics.GC; import dwt.graphics.Image; @@ -26,6 +24,7 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; public class BulletParagraph : Paragraph { public static const int CIRCLE = 1;
--- a/dwtx/ui/internal/forms/widgets/ControlSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/ControlSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -26,6 +26,7 @@ import dwt.widgets.Control; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; public class ControlSegment : ObjectSegment, IFocusSelectable {
--- a/dwtx/ui/internal/forms/widgets/FormFonts.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormFonts.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.ui.internal.forms.widgets.FormFonts; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; import dwt.DWT; import dwt.graphics.Font; @@ -23,8 +23,6 @@ public class FormFonts { - alias HashMap!(Object,Object) HashMapStrToObj; - private static FormFonts instance; public static FormFonts getInstance() { @@ -33,8 +31,8 @@ return instance; } - private HashMapStrToObj fonts; - private HashMapStrToObj ids; + private HashMap fonts; + private HashMap ids; private this() { } @@ -85,14 +83,14 @@ public Font getBoldFont(Display display, Font font) { checkHashMaps(); FontIdentifier fid = new FontIdentifier(display, font); - FontReference result = fonts.containsKey(fid) ? cast(FontReference) fonts.get(fid) : null; + FontReference result = cast(FontReference) fonts.get(fid); if (result !is null && !result.getFont().isDisposed()) { result.incCount(); return result.getFont(); } Font boldFont = createBoldFont(display, font); - fonts.add(fid, new FontReference(boldFont)); - ids.add(boldFont, fid); + fonts.put(fid, new FontReference(boldFont)); + ids.put(boldFont, fid); return boldFont; } @@ -126,9 +124,9 @@ private void checkHashMaps() { if (fonts is null) - fonts = new HashMapStrToObj(); + fonts = new HashMap(); if (ids is null) - ids = new HashMapStrToObj(); + ids = new HashMap(); } private void validateHashMaps() {
--- a/dwtx/ui/internal/forms/widgets/FormHeading.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormHeading.d Thu Aug 07 15:01:33 2008 +0200 @@ -58,7 +58,7 @@ import dwtx.ui.internal.forms.MessageManager; import dwt.dwthelper.utils; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * Form header moved out of the form class. @@ -84,7 +84,7 @@ private Image gradientImage; - HashMap!(String,Object) colors; + Hashtable colors; private int flags; @@ -432,7 +432,7 @@ ensureControlExists(); if (needHyperlink()) { messageHyperlink.setText(newMessage); - messageHyperlink.setHref(new ArrayWrapperT!(IMessage)(messages)); + messageHyperlink.setHref(new ArrayWrapperObject(arraycast!(Object)(messages))); } else { messageLabel.setText(newMessage); } @@ -516,7 +516,7 @@ messageHyperlink = new Hyperlink(this.outer, DWT.NULL); messageHyperlink.setUnderlined(true); messageHyperlink.setText(message); - messageHyperlink.setHref(new ArrayWrapperT!(IMessage)(messages)); + messageHyperlink.setHref(new ArrayWrapperObject(arraycast!(Object)(messages))); Object[] llist = listeners.getListeners(); for (int i = 0; i < llist.length; i++) messageHyperlink @@ -525,7 +525,7 @@ messageToolTipManager.createToolTip(messageHyperlink, false); } else if (!messageHyperlink.getVisible()) { messageHyperlink.setText(message); - messageHyperlink.setHref(new ArrayWrapperT!(IMessage)(messages)); + messageHyperlink.setHref(new ArrayWrapperObject(arraycast!(Object)(messages))); messageHyperlink.setVisible(true); } } else { @@ -584,7 +584,7 @@ * the parent widget */ public this(Composite parent, int style) { - colors = new HashMap!(String,Object); + colors = new Hashtable(); toolbarCache = new SizeCache(); clientCache = new SizeCache(); messageCache = new SizeCache(); @@ -997,9 +997,9 @@ public void putColor(String key, Color color) { if (color is null) - colors.removeKey(key); + colors.remove(key); else - colors.add(key, color); + colors.put(key, color); } public Color getColor(String key) {
--- a/dwtx/ui/internal/forms/widgets/FormImages.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormImages.d Thu Aug 07 15:01:33 2008 +0200 @@ -21,7 +21,7 @@ import dwt.widgets.Display; import dwt.dwthelper.utils; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; public class FormImages { private static FormImages instance; @@ -32,8 +32,8 @@ return instance; } - private HashMap!(Object,Object) images; - private HashMap!(Object,Object) ids; + private HashMap images; + private HashMap ids; private this() { } @@ -179,8 +179,8 @@ return result.getImage(); } Image image = createGradient(display, color1, color2, realtheight, theight, marginHeight); - images.add(id, new ImageReference(image)); - ids.add(image, id); + images.put(id, new ImageReference(image)); + ids.put(image, id); return image; } @@ -194,8 +194,8 @@ return result.getImage(); } Image image = createGradient(display, colors, percents, length, vertical, bg); - images.add(id, new ImageReference(image)); - ids.add(image, id); + images.put(id, new ImageReference(image)); + ids.put(image, id); return image; } @@ -221,9 +221,9 @@ private void checkHashMaps() { if (images is null) - images = new HashMap!(Object,Object); + images = new HashMap(); if (ids is null) - ids = new HashMap!(Object,Object); + ids = new HashMap(); } private void validateHashMaps() {
--- a/dwtx/ui/internal/forms/widgets/FormTextModel.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormTextModel.d Thu Aug 07 15:01:33 2008 +0200 @@ -26,11 +26,11 @@ import dwt.dwthelper.utils; import dwt.dwthelper.InputStream; +import dwtx.dwtxhelper.Collection; static import tango.text.xml.Document; static import tango.io.Buffer; -import tango.util.collection.ArraySeq; public class FormTextModel { // private static const DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory // .newInstance(); @@ -40,8 +40,7 @@ private bool whitespaceNormalized = true; - private alias ArraySeq!(Paragraph) TArraySeqParagraph; - private TArraySeqParagraph paragraphs; + private Vector paragraphs; private IFocusSelectable[] selectableSegments; @@ -69,8 +68,8 @@ public Paragraph[] getParagraphs() { if (paragraphs is null) return new Paragraph[0]; - return paragraphs - .toArray(); + return arraycast!(Paragraph)(paragraphs + .toArray()); } public String getAccessibleText() { @@ -143,7 +142,7 @@ // processSubnodes(paragraphs, children, expandURLs); // } -/+ private void processSubnodes(TArraySeqParagraph plist, NodeList children, bool expandURLs) { +/+ private void processSubnodes(Vector plist, NodeList children, bool expandURLs) { //o for (int i = 0; i < children.getLength(); i++) { //o Node child = children.item(i); foreach( child; children ){ @@ -544,14 +543,14 @@ regularText = getNormalizedText(regularText); Paragraph p = new Paragraph(true); - paragraphs.append(p); + paragraphs.add(p); int pstart = 0; for (int i = 0; i < regularText.length; i++) { char c = regularText.charAt(i); if (p is null) { p = new Paragraph(true); - paragraphs.append(p); + paragraphs.add(p); } if (c is '\n') { String text = regularText.substring(pstart, i); @@ -581,7 +580,7 @@ private void reset() { if (paragraphs is null) - paragraphs = new TArraySeqParagraph; + paragraphs = new Vector; paragraphs.clear(); selectedSegmentIndex = -1; savedSelectedLinkIndex = -1; @@ -591,16 +590,16 @@ IFocusSelectable[] getFocusSelectableSegments() { if (selectableSegments !is null || paragraphs is null) return selectableSegments; - IFocusSelectable[] result; + Vector result = new Vector(); for (int i = 0; i < paragraphs.size(); i++) { Paragraph p = cast(Paragraph) paragraphs.get(i); ParagraphSegment[] segments = p.getSegments(); for (int j = 0; j < segments.length; j++) { if (null !is cast(IFocusSelectable)segments[j] ) - result ~= cast(IFocusSelectable)segments[j]; + result.add(segments[j]); } } - selectableSegments = result; + selectableSegments = arraycast!(IFocusSelectable)(result.toArray()); return selectableSegments; }
--- a/dwtx/ui/internal/forms/widgets/IFocusSelectable.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/IFocusSelectable.d Thu Aug 07 15:01:33 2008 +0200 @@ -12,13 +12,12 @@ *******************************************************************************/ module dwtx.ui.internal.forms.widgets.IFocusSelectable; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; import dwt.graphics.Rectangle; import dwt.dwthelper.utils; public interface IFocusSelectable { - alias HashMap!(String,Object) Hashtable; bool isFocusSelectable(Hashtable resourceTable); bool setFocus(Hashtable resourceTable, bool direction); Rectangle getBounds();
--- a/dwtx/ui/internal/forms/widgets/ImageHyperlinkSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/ImageHyperlinkSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -22,6 +22,7 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; public class ImageHyperlinkSegment : ImageSegment, IHyperlinkSegment {
--- a/dwtx/ui/internal/forms/widgets/ImageSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/ImageSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -23,14 +23,13 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * @version 1.0 * @author */ public class ImageSegment : ObjectSegment { - alias HashMap!(String,Object) Hashtable; public static const String SEL_IMAGE_PREFIX = "isel."; //$NON-NLS-1$ public Image getImage(Hashtable objectTable) { @@ -54,7 +53,7 @@ if (image is null) { image = FormUtil.createAlphaMashImage(selData.display, getImage(objectTable)); if (image !is null) - objectTable.add(key, image); + objectTable.put(key, image); } return image; }
--- a/dwtx/ui/internal/forms/widgets/Locator.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/Locator.d Thu Aug 07 15:01:33 2008 +0200 @@ -13,7 +13,7 @@ module dwtx.ui.internal.forms.widgets.Locator; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; public class Locator : Cloneable { public int indent; @@ -24,7 +24,7 @@ public int marginWidth; public int marginHeight; public int rowCounter; - public ArraySeq!( ArrayWrapperInt ) heights; + public ArrayList heights; public Locator clone(){ auto res = new Locator(); @@ -56,7 +56,7 @@ // } } public void collectHeights() { - heights.append(new ArrayWrapperInt( [ rowHeight, leading ] ) ); + heights.add(new ArrayWrapperObject( [ new Integer(rowHeight), new Integer(leading) ] ) ); rowCounter++; } public int getBaseline(int segmentHeight) { @@ -65,9 +65,9 @@ } public int getMiddle(int segmentHeight, bool text) { if (heights !is null && heights.size() > rowCounter) { - int [] rdata = heights.get(rowCounter).array; - int rheight = rdata[0]; - int rleading = rdata[1]; + Integer [] rdata = arrayFromObject!(Integer)(heights.get(rowCounter)); + int rheight = rdata[0].value; + int rleading = rdata[1].value; if (text) return y + rheight/2 - segmentHeight/2 - rleading; return y + rheight/2 - segmentHeight/2; @@ -76,9 +76,9 @@ } public int getBaseline(int segmentHeight, bool text) { if (heights !is null && heights.size()>rowCounter) { - int [] rdata = heights.get(rowCounter).array; - int rheight = rdata[0]; - int rleading = rdata[1]; + Integer [] rdata = arrayFromObject!(Integer)(heights.get(rowCounter)); + int rheight = rdata[0].value; + int rleading = rdata[1].value; if (text) return y + rheight - segmentHeight - rleading; return y + rheight - segmentHeight;
--- a/dwtx/ui/internal/forms/widgets/ObjectSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/ObjectSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -22,6 +22,7 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; public abstract class ObjectSegment : ParagraphSegment { public static const int TOP = 1;
--- a/dwtx/ui/internal/forms/widgets/Paragraph.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/Paragraph.d Thu Aug 07 15:01:33 2008 +0200 @@ -24,8 +24,7 @@ import dwtx.ui.forms.HyperlinkSettings; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; import tango.io.model.IFile; import tango.text.Text; @@ -37,10 +36,7 @@ public class Paragraph { public static const String HTTP = "http://"; //$NON-NLS-1$ - alias ArraySeq!(ParagraphSegment) TArraySeqParagraphSegment; - alias HashMap!(String,Object) Hashtable; - - private TArraySeqParagraphSegment segments; + private Vector segments; private bool addVerticalSpace = true; @@ -62,14 +58,14 @@ public ParagraphSegment[] getSegments() { if (segments is null) return null; - return segments - .toArray(); + return arraycast!(ParagraphSegment)(segments + .toArray()); } public void addSegment(ParagraphSegment segment) { if (segments is null) - segments = new TArraySeqParagraphSegment; - segments.append(segment); + segments = new Vector; + segments.add(segment); } public void parseRegularText(String text, bool expandURLs, bool wrapAllowed, @@ -133,7 +129,7 @@ ParagraphSegment[] segments = getSegments(); // compute heights Locator hloc = loc.create(); - ArraySeq!(ArrayWrapperInt) heights = new ArraySeq!(ArrayWrapperInt); + ArrayList heights = new ArrayList(); hloc.heights = heights; hloc.rowCounter = 0; int innerWidth = width - loc.marginWidth*2;
--- a/dwtx/ui/internal/forms/widgets/ParagraphSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/ParagraphSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,16 +19,13 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; - -import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * @version 1.0 * @author */ public abstract class ParagraphSegment { - - alias HashMap!(String,Object) Hashtable; /** * Moves the locator according to the content of this segment. * @param gc
--- a/dwtx/ui/internal/forms/widgets/SelectionData.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/SelectionData.d Thu Aug 07 15:01:33 2008 +0200 @@ -21,7 +21,8 @@ import dwt.widgets.Display; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; + static import tango.text.Text; public class SelectionData { @@ -30,12 +31,12 @@ public Color fg; private Point start; private Point stop; - private ArraySeq!(String) segments; + private ArrayList segments; private bool newLineNeeded; public this(MouseEvent e) { display = e.display; - segments = new ArraySeq!(String); + segments = new ArrayList(); start = new Point(e.x, e.y); stop = new Point(e.x, e.y); bg = e.display.getSystemColor(DWT.COLOR_LIST_SELECTION); @@ -47,10 +48,10 @@ } public void addSegment(String text) { if (newLineNeeded) { - segments.append(System.getProperty("line.separator")); //$NON-NLS-1$ + segments.add(System.getProperty("line.separator")); //$NON-NLS-1$ newLineNeeded=false; } - segments.append(text); + segments.add(text); } public void update(MouseEvent e) { @@ -64,7 +65,7 @@ public String getSelectionText() { auto buf = new tango.text.Text.Text!(char); for (int i=0; i<segments.size(); i++) { - buf.append(segments.get(i)); + buf.append(stringcast(segments.get(i))); } return buf.toString(); } @@ -91,7 +92,7 @@ return isInverted(rowHeight) ? start.x:stop.x; } private bool isInverted(Locator locator) { - int rowHeight = locator.heights.get(locator.rowCounter).array[0]; + int rowHeight = arrayFromObject!(Integer)(locator.heights.get(locator.rowCounter))[0].value; return isInverted(rowHeight); } private bool isInverted(int rowHeight) { @@ -110,7 +111,7 @@ public bool isSelectedRow(Locator locator) { if (!isEnclosed()) return false; - int rowHeight = locator.heights.get(locator.rowCounter).array[0]; + int rowHeight = arrayFromObject!(Integer)(locator.heights.get(locator.rowCounter))[0].value; return isSelectedRow(locator.y, rowHeight); } public bool isSelectedRow(int y, int rowHeight) { @@ -122,7 +123,7 @@ public bool isFirstSelectionRow(Locator locator) { if (!isEnclosed()) return false; - int rowHeight = locator.heights.get(locator.rowCounter).array[0]; + int rowHeight = arrayFromObject!(Integer)(locator.heights.get(locator.rowCounter))[0].value; return (locator.y + rowHeight >= getTopOffset() && locator.y <= getTopOffset()); } @@ -135,7 +136,7 @@ public bool isLastSelectionRow(Locator locator) { if (!isEnclosed()) return false; - int rowHeight = locator.heights.get(locator.rowCounter).array[0]; + int rowHeight = arrayFromObject!(Integer)(locator.heights.get(locator.rowCounter))[0].value; return (locator.y + rowHeight >=getBottomOffset() && locator.y <= getBottomOffset()); }
--- a/dwtx/ui/internal/forms/widgets/TextHyperlinkSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/TextHyperlinkSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -22,7 +22,7 @@ import dwtx.ui.forms.HyperlinkSettings; import dwt.dwthelper.utils; -//import tango.util.collection.HashMap; +import dwtx.dwtxhelper.Collection; /** * @version 1.0 @@ -90,7 +90,7 @@ repaintRegion); gc.setForeground(savedFg); } - + protected void drawString(GC gc, String s, int clipX, int clipY) { gc.drawString(s, clipX, clipY, false); }
--- a/dwtx/ui/internal/forms/widgets/TextSegment.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/TextSegment.d Thu Aug 07 15:01:33 2008 +0200 @@ -29,7 +29,7 @@ import dwt.dwthelper.utils; import dwtx.dwtxhelper.mangoicu.UBreakIterator; -import tango.util.collection.ArraySeq; +import dwtx.dwtxhelper.Collection; /** * @version 1.0 @@ -47,7 +47,7 @@ private bool wrapAllowed = true; - protected ArraySeq!(Object) areaRectangles; + protected Vector areaRectangles; private TextFragment[] textFragments; @@ -114,7 +114,7 @@ } public this(String text, String fontId, String colorId, bool wrapAllowed) { - areaRectangles = new ArraySeq!(Object); + areaRectangles = new Vector(); this.text = cleanup(text); this.fontId = fontId; this.colorId = colorId; @@ -343,7 +343,7 @@ //int lineY = ly + lineHeight - descent + 1; Rectangle br = new Rectangle(locator.x, ly, ewidth, lineHeight - descent + 3); - areaRectangles.append(new AreaRectangle(br, 0, -1)); + areaRectangles.add(new AreaRectangle(br, 0, -1)); locator.x += ewidth; locator.width = ewidth; locator.rowHeight = Math.max(locator.rowHeight, extent.y); @@ -677,7 +677,7 @@ locator.x - 1:locator.x, ly, isSelectable()?lineExtent.x + 1:lineExtent.x, lineHeight - descent + 3); areaRectangles - .append(new AreaRectangle(br, lineStart, lastLoc)); + .add(new AreaRectangle(br, lineStart, lastLoc)); locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); @@ -704,7 +704,7 @@ isSelectable()?lineExtent.x + 1:lineExtent.x, lineHeight - descent + 3); //int lineY = ly + lineHeight - descent + 1; - areaRectangles.append(new AreaRectangle(br, lineStart, lastLoc)); + areaRectangles.add(new AreaRectangle(br, lineStart, lastLoc)); locator.x += lastWidth; locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); } @@ -716,7 +716,7 @@ private void computeTextFragments(GC gc) { if (textFragments !is null) return; - ArraySeq!(Object) list = new ArraySeq!(Object); + ArrayList list = new ArrayList(); auto wb = UBreakIterator.openLineIterator( ULocale.Default, getText() ); scope(exit) wb.close(); int cursor = 0; @@ -725,7 +725,7 @@ continue; String word = text.substring(cursor, loc); Point extent = gc.textExtent(word); - list.append(new TextFragment(cast(short) loc, cast(short) extent.x)); + list.add(new TextFragment(cast(short) loc, cast(short) extent.x)); cursor = loc; } textFragments = arraycast!(TextFragment)(list.toArray());