Mercurial > projects > dwt-addons
annotate dwtx/jface/viewers/DecorationContext.d @ 70:46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 01:36:46 +0200 |
parents | b6c35faf97c8 |
children | 04b47443bb01 |
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 import tango.util.collection.HashMap; | |
18 import tango.util.collection.model.Map; | |
19 | |
20 import dwt.dwthelper.utils; | |
21 | |
22 /** | |
23 * A concrete implementation of the {@link IDecorationContext} interface, | |
24 * suitable for instantiating. | |
25 * <p> | |
26 * This class is not intended to be subclassed. | |
27 * </p> | |
28 * @since 3.2 | |
29 */ | |
30 public class DecorationContext : IDecorationContext { | |
31 | |
32 /** | |
33 * Constant that defines a default decoration context that has | |
34 * no context ids associated with it. | |
35 */ | |
36 public static const IDecorationContext DEFAULT_CONTEXT; | |
37 static this(){ | |
38 DEFAULT_CONTEXT = new DecorationContext(); | |
39 } | |
40 | |
41 private Map!(String,Object) properties; | |
42 | |
43 /** | |
44 * Create a decoration context. | |
45 */ | |
46 public this() { | |
47 properties = new HashMap!(String,Object); | |
48 } | |
49 | |
50 | |
51 /* (non-Javadoc) | |
52 * @see dwtx.jface.viewers.IDecorationContext#getProperty(java.lang.String) | |
53 */ | |
54 public Object getProperty(String property) { | |
55 return properties.get(property); | |
56 } | |
57 | |
58 /* (non-Javadoc) | |
59 * @see dwtx.jface.viewers.IDecorationContext#getProperties() | |
60 */ | |
61 public String[] getProperties() { | |
62 String[] res; | |
63 foreach( k,v; properties ){ | |
64 res ~= k; | |
65 } | |
66 return res; | |
67 } | |
68 | |
69 /** | |
70 * Set the given property to the given value. Setting the value of | |
71 * a property to <code>null</code> removes the property from | |
72 * the context. | |
73 * @param property the property | |
74 * @param value the value of the property or <code>null</code> | |
75 * if the property is to be removed. | |
76 */ | |
77 public void putProperty(String property, Object value) { | |
78 if (value is null) { | |
79 properties.removeKey(property); | |
80 } else { | |
81 properties.add(property, value); | |
82 } | |
83 } | |
84 } |