comparison dwtx/core/commands/ExecutionEvent.d @ 104:04b47443bb01

Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections. These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 15:01:33 +0200
parents ea8ff534f622
children
comparison
equal deleted inserted replaced
103:2d6540440fe6 104:04b47443bb01
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwtx.core.commands.ExecutionEvent; 13 module dwtx.core.commands.ExecutionEvent;
14 14
15 // import java.util.Collections; 15 // import java.util.Collections;
16 import tango.util.collection.model.Map;
17 import tango.util.collection.HashMap;
18 16
19 import dwtx.core.commands.common.NotDefinedException; 17 import dwtx.core.commands.common.NotDefinedException;
20 import dwtx.core.commands.ExecutionException; 18 import dwtx.core.commands.ExecutionException;
21 import dwtx.core.commands.Command; 19 import dwtx.core.commands.Command;
22 import dwtx.core.commands.ParameterType; 20 import dwtx.core.commands.ParameterType;
23 import dwtx.core.commands.AbstractParameterValueConverter; 21 import dwtx.core.commands.AbstractParameterValueConverter;
24 import dwtx.core.commands.ParameterValueConversionException; 22 import dwtx.core.commands.ParameterValueConversionException;
25 23
26 import dwt.dwthelper.utils; 24 import dwt.dwthelper.utils;
25 import dwtx.dwtxhelper.Collection;
27 26
28 import tango.text.convert.Format; 27 import tango.text.convert.Format;
29 28
30 /** 29 /**
31 * <p> 30 * <p>
41 * </p> 40 * </p>
42 * 41 *
43 * @since 3.1 42 * @since 3.1
44 */ 43 */
45 public final class ExecutionEvent { 44 public final class ExecutionEvent {
46 private static const Map!(String,String) EMPTY_MAP;
47 static this(){
48 EMPTY_MAP = new HashMap!(String,String);
49 }
50 /** 45 /**
51 * The state of the application at the time the execution was triggered. In 46 * The state of the application at the time the execution was triggered. In
52 * the Eclipse workbench, this might contain information about the active 47 * the Eclipse workbench, this might contain information about the active
53 * part of the active selection (for example). This value may be 48 * part of the active selection (for example). This value may be
54 * <code>null</code>. 49 * <code>null</code>.
63 /** 58 /**
64 * The parameters to qualify the execution. For handlers that normally 59 * The parameters to qualify the execution. For handlers that normally
65 * prompt for additional information, these can be used to avoid prompting. 60 * prompt for additional information, these can be used to avoid prompting.
66 * This value may be empty, but it is never <code>null</code>. 61 * This value may be empty, but it is never <code>null</code>.
67 */ 62 */
68 private const Map!(String,String) parameters; 63 private const Map parameters;
69 64
70 /** 65 /**
71 * The object that triggered the execution. In an event-driven architecture, 66 * The object that triggered the execution. In an event-driven architecture,
72 * this is typically just another event. In the Eclipse workbench, this is 67 * this is typically just another event. In the Eclipse workbench, this is
73 * typically an DWT event. This value may be <code>null</code>. 68 * typically an DWT event. This value may be <code>null</code>.
80 * convenience method. 75 * convenience method.
81 * 76 *
82 * @since 3.2 77 * @since 3.2
83 */ 78 */
84 public this() { 79 public this() {
85 this(null, EMPTY_MAP, null, null); 80 this(null, Collections.EMPTY_MAP, null, null);
86 } 81 }
87 82
88 /** 83 /**
89 * Constructs a new instance of <code>ExecutionEvent</code>. 84 * Constructs a new instance of <code>ExecutionEvent</code>.
90 * 85 *
99 * The state of the application at the time the execution was 94 * The state of the application at the time the execution was
100 * triggered; may be <code>null</code>. 95 * triggered; may be <code>null</code>.
101 * @deprecated use 96 * @deprecated use
102 * {@link ExecutionEvent#ExecutionEvent(Command, Map, Object, Object)} 97 * {@link ExecutionEvent#ExecutionEvent(Command, Map, Object, Object)}
103 */ 98 */
104 public this(Map!(String,String) parameters, Object trigger, 99 public this(Map parameters, Object trigger,
105 Object applicationContext) { 100 Object applicationContext) {
106 this(null, parameters, trigger, applicationContext); 101 this(null, parameters, trigger, applicationContext);
107 } 102 }
108 103
109 /** 104 /**
121 * @param applicationContext 116 * @param applicationContext
122 * The state of the application at the time the execution was 117 * The state of the application at the time the execution was
123 * triggered; may be <code>null</code>. 118 * triggered; may be <code>null</code>.
124 * @since 3.2 119 * @since 3.2
125 */ 120 */
126 public this(Command command, Map!(String,String) parameters, 121 public this(Command command, Map parameters,
127 Object trigger, Object applicationContext) { 122 Object trigger, Object applicationContext) {
128 if (parameters is null) { 123 if (parameters is null) {
129 throw new NullPointerException( 124 throw new NullPointerException(
130 "An execution event must have a non-null map of parameters"); //$NON-NLS-1$ 125 "An execution event must have a non-null map of parameters"); //$NON-NLS-1$
131 } 126 }
211 * The id of the parameter to retrieve; may be <code>null</code>. 206 * The id of the parameter to retrieve; may be <code>null</code>.
212 * @return The parameter value; <code>null</code> if the parameter cannot 207 * @return The parameter value; <code>null</code> if the parameter cannot
213 * be found. 208 * be found.
214 */ 209 */
215 public final String getParameter(String parameterId) { 210 public final String getParameter(String parameterId) {
216 return parameters.get(parameterId); 211 return stringcast(parameters.get(parameterId));
217 } 212 }
218 213
219 /** 214 /**
220 * Returns all of the parameters. 215 * Returns all of the parameters.
221 * 216 *
222 * @return The parameters; never <code>null</code>, but may be empty. 217 * @return The parameters; never <code>null</code>, but may be empty.
223 */ 218 */
224 public final Map!(String,String) getParameters() { 219 public final Map getParameters() {
225 return parameters; 220 return parameters;
226 } 221 }
227 222
228 /** 223 /**
229 * Returns the object that triggered the execution 224 * Returns the object that triggered the execution
241 * @return The string representation; never <code>null</code>. 236 * @return The string representation; never <code>null</code>.
242 */ 237 */
243 public override final String toString() { 238 public override final String toString() {
244 String parm; 239 String parm;
245 foreach( k, v; parameters ){ 240 foreach( k, v; parameters ){
246 parm ~= "{"~k~","~v~"}"; 241 parm ~= "{"~stringcast(k)~","~stringcast(v)~"}";
247 } 242 }
248 return Format( "ExecutionEvent({},{},{})", command, parm, trigger, applicationContext ); 243 return Format( "ExecutionEvent({},{},{})", command, parm, trigger, applicationContext );
249 } 244 }
250 } 245 }