01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.viewers;
11:
12: import java.util.HashMap;
13: import java.util.Map;
14:
15: /**
16: * A concrete implementation of the {@link IDecorationContext} interface,
17: * suitable for instantiating.
18: * <p>
19: * This class is not intended to be subclassed.
20: * </p>
21: * @since 3.2
22: */
23: public class DecorationContext implements IDecorationContext {
24:
25: /**
26: * Constant that defines a default decoration context that has
27: * no context ids associated with it.
28: */
29: public static final IDecorationContext DEFAULT_CONTEXT = new DecorationContext();
30:
31: private Map properties = new HashMap();
32:
33: /**
34: * Create a decoration context.
35: */
36: public DecorationContext() {
37: }
38:
39: /* (non-Javadoc)
40: * @see org.eclipse.jface.viewers.IDecorationContext#getProperty(java.lang.String)
41: */
42: public Object getProperty(String property) {
43: return properties.get(property);
44: }
45:
46: /* (non-Javadoc)
47: * @see org.eclipse.jface.viewers.IDecorationContext#getProperties()
48: */
49: public String[] getProperties() {
50: return (String[]) properties.keySet().toArray(
51: new String[properties.size()]);
52: }
53:
54: /**
55: * Set the given property to the given value. Setting the value of
56: * a property to <code>null</code> removes the property from
57: * the context.
58: * @param property the property
59: * @param value the value of the property or <code>null</code>
60: * if the property is to be removed.
61: */
62: public void putProperty(String property, Object value) {
63: if (value == null) {
64: properties.remove(property);
65: } else {
66: properties.put(property, value);
67: }
68: }
69: }
|