Mercurial > projects > dwt-addons
annotate 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 |
rev | line source |
---|---|
10 | 1 /******************************************************************************* |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
2 * Copyright (c) 2006, 2008 IBM Corporation and others. |
10 | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.viewers.DecorationContext; | |
14 | |
15 import dwtx.jface.viewers.IDecorationContext; | |
16 | |
17 | |
18 import dwt.dwthelper.utils; | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
19 import dwtx.dwtxhelper.Collection; |
10 | 20 |
21 /** | |
22 * A concrete implementation of the {@link IDecorationContext} interface, | |
23 * suitable for instantiating. | |
24 * <p> | |
25 * This class is not intended to be subclassed. | |
26 * </p> | |
27 * @since 3.2 | |
28 */ | |
29 public class DecorationContext : IDecorationContext { | |
30 | |
31 /** | |
32 * Constant that defines a default decoration context that has | |
33 * no context ids associated with it. | |
34 */ | |
35 public static const IDecorationContext DEFAULT_CONTEXT; | |
36 static this(){ | |
37 DEFAULT_CONTEXT = new DecorationContext(); | |
38 } | |
39 | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
40 private Map properties; |
10 | 41 |
42 /** | |
43 * Create a decoration context. | |
44 */ | |
45 public this() { | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
46 properties = new HashMap(); |
10 | 47 } |
48 | |
49 | |
50 /* (non-Javadoc) | |
51 * @see dwtx.jface.viewers.IDecorationContext#getProperty(java.lang.String) | |
52 */ | |
53 public Object getProperty(String property) { | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
54 return properties.get(stringcast(property)); |
10 | 55 } |
56 | |
57 /* (non-Javadoc) | |
58 * @see dwtx.jface.viewers.IDecorationContext#getProperties() | |
59 */ | |
60 public String[] getProperties() { | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
61 return stringcast( properties.keySet().toArray() ); |
10 | 62 } |
63 | |
64 /** | |
65 * Set the given property to the given value. Setting the value of | |
66 * a property to <code>null</code> removes the property from | |
67 * the context. | |
68 * @param property the property | |
69 * @param value the value of the property or <code>null</code> | |
70 * if the property is to be removed. | |
71 */ | |
72 public void putProperty(String property, Object value) { | |
73 if (value is null) { | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
74 properties.remove(stringcast(property)); |
10 | 75 } else { |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
70
diff
changeset
|
76 properties.put(stringcast(property), value); |
10 | 77 } |
78 } | |
79 } |