KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > DecorationContext


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
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  *******************************************************************************/

11 package org.eclipse.jface.viewers;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 /**
17  * A concrete implementation of the {@link IDecorationContext} interface,
18  * suitable for instantiating.
19  * <p>
20  * This class is not intended to be subclassed.
21  * </p>
22  * @since 3.2
23  */

24 public class DecorationContext implements IDecorationContext {
25     
26     /**
27      * Constant that defines a default decoration context that has
28      * no context ids associated with it.
29      */

30     public static final IDecorationContext DEFAULT_CONTEXT = new DecorationContext();
31     
32     private Map JavaDoc properties = new HashMap JavaDoc();
33
34     /**
35      * Create a decoration context.
36      */

37     public DecorationContext() {
38     }
39     
40
41     /* (non-Javadoc)
42      * @see org.eclipse.jface.viewers.IDecorationContext#getProperty(java.lang.String)
43      */

44     public Object JavaDoc getProperty(String JavaDoc property) {
45         return properties.get(property);
46     }
47
48     /* (non-Javadoc)
49      * @see org.eclipse.jface.viewers.IDecorationContext#getProperties()
50      */

51     public String JavaDoc[] getProperties() {
52         return (String JavaDoc[]) properties.keySet().toArray(new String JavaDoc[properties.size()]);
53     }
54
55     /**
56      * Set the given property to the given value. Setting the value of
57      * a property to <code>null</code> removes the property from
58      * the context.
59      * @param property the property
60      * @param value the value of the property or <code>null</code>
61      * if the property is to be removed.
62      */

63     public void putProperty(String JavaDoc property, Object JavaDoc value) {
64         if (value == null) {
65             properties.remove(property);
66         } else {
67             properties.put(property, value);
68         }
69     }
70 }
71
Popular Tags