Mercurial > projects > dwt-addons
comparison dwtx/jface/viewers/DecorationContext.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 46a6e0e6ccd4 |
children |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module dwtx.jface.viewers.DecorationContext; | 13 module dwtx.jface.viewers.DecorationContext; |
14 | 14 |
15 import dwtx.jface.viewers.IDecorationContext; | 15 import dwtx.jface.viewers.IDecorationContext; |
16 | 16 |
17 import tango.util.collection.HashMap; | |
18 import tango.util.collection.model.Map; | |
19 | 17 |
20 import dwt.dwthelper.utils; | 18 import dwt.dwthelper.utils; |
19 import dwtx.dwtxhelper.Collection; | |
21 | 20 |
22 /** | 21 /** |
23 * A concrete implementation of the {@link IDecorationContext} interface, | 22 * A concrete implementation of the {@link IDecorationContext} interface, |
24 * suitable for instantiating. | 23 * suitable for instantiating. |
25 * <p> | 24 * <p> |
36 public static const IDecorationContext DEFAULT_CONTEXT; | 35 public static const IDecorationContext DEFAULT_CONTEXT; |
37 static this(){ | 36 static this(){ |
38 DEFAULT_CONTEXT = new DecorationContext(); | 37 DEFAULT_CONTEXT = new DecorationContext(); |
39 } | 38 } |
40 | 39 |
41 private Map!(String,Object) properties; | 40 private Map properties; |
42 | 41 |
43 /** | 42 /** |
44 * Create a decoration context. | 43 * Create a decoration context. |
45 */ | 44 */ |
46 public this() { | 45 public this() { |
47 properties = new HashMap!(String,Object); | 46 properties = new HashMap(); |
48 } | 47 } |
49 | 48 |
50 | 49 |
51 /* (non-Javadoc) | 50 /* (non-Javadoc) |
52 * @see dwtx.jface.viewers.IDecorationContext#getProperty(java.lang.String) | 51 * @see dwtx.jface.viewers.IDecorationContext#getProperty(java.lang.String) |
53 */ | 52 */ |
54 public Object getProperty(String property) { | 53 public Object getProperty(String property) { |
55 return properties.get(property); | 54 return properties.get(stringcast(property)); |
56 } | 55 } |
57 | 56 |
58 /* (non-Javadoc) | 57 /* (non-Javadoc) |
59 * @see dwtx.jface.viewers.IDecorationContext#getProperties() | 58 * @see dwtx.jface.viewers.IDecorationContext#getProperties() |
60 */ | 59 */ |
61 public String[] getProperties() { | 60 public String[] getProperties() { |
62 String[] res; | 61 return stringcast( properties.keySet().toArray() ); |
63 foreach( k,v; properties ){ | |
64 res ~= k; | |
65 } | |
66 return res; | |
67 } | 62 } |
68 | 63 |
69 /** | 64 /** |
70 * Set the given property to the given value. Setting the value of | 65 * Set the given property to the given value. Setting the value of |
71 * a property to <code>null</code> removes the property from | 66 * a property to <code>null</code> removes the property from |
74 * @param value the value of the property or <code>null</code> | 69 * @param value the value of the property or <code>null</code> |
75 * if the property is to be removed. | 70 * if the property is to be removed. |
76 */ | 71 */ |
77 public void putProperty(String property, Object value) { | 72 public void putProperty(String property, Object value) { |
78 if (value is null) { | 73 if (value is null) { |
79 properties.removeKey(property); | 74 properties.remove(stringcast(property)); |
80 } else { | 75 } else { |
81 properties.add(property, value); | 76 properties.put(stringcast(property), value); |
82 } | 77 } |
83 } | 78 } |
84 } | 79 } |