KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > preferences > ThemeManagerAdapter


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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.ui.internal.preferences;
12
13 import java.util.Set JavaDoc;
14
15 import org.eclipse.jface.util.IPropertyChangeListener;
16 import org.eclipse.jface.util.PropertyChangeEvent;
17 import org.eclipse.ui.themes.IThemeManager;
18
19 /**
20  * @since 3.1
21  */

22 public class ThemeManagerAdapter extends PropertyMapAdapter {
23
24     private IThemeManager manager;
25     
26     private IPropertyChangeListener listener = new IPropertyChangeListener() {
27         public void propertyChange(PropertyChangeEvent event) {
28             firePropertyChange(event.getProperty());
29         }
30     };
31     
32     public ThemeManagerAdapter(IThemeManager manager) {
33         this.manager = manager;
34     }
35     
36     /* (non-Javadoc)
37      * @see org.eclipse.ui.internal.preferences.PropertyMapAdapter#attachListener()
38      */

39     protected void attachListener() {
40         manager.addPropertyChangeListener(listener);
41     }
42
43     /* (non-Javadoc)
44      * @see org.eclipse.ui.internal.preferences.PropertyMapAdapter#detachListener()
45      */

46     protected void detachListener() {
47         manager.removePropertyChangeListener(listener);
48     }
49
50     /* (non-Javadoc)
51      * @see org.eclipse.ui.internal.preferences.IPropertyMap#keySet()
52      */

53     public Set JavaDoc keySet() {
54         Set JavaDoc result = ThemeAdapter.getKeySet(manager.getCurrentTheme());
55         
56         return result;
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.ui.internal.preferences.IPropertyMap#getValue(java.lang.String, java.lang.Class)
61      */

62     public Object JavaDoc getValue(String JavaDoc propertyId, Class JavaDoc propertyType) {
63         return ThemeAdapter.getValue(manager.getCurrentTheme(), propertyId, propertyType);
64     }
65
66     /* (non-Javadoc)
67      * @see org.eclipse.ui.internal.preferences.IPropertyMap#propertyExists(java.lang.String)
68      */

69     public boolean propertyExists(String JavaDoc propertyId) {
70         return keySet().contains(propertyId);
71     }
72
73     /* (non-Javadoc)
74      * @see org.eclipse.ui.internal.preferences.IPropertyMap#setValue(java.lang.String, java.lang.Object)
75      */

76     public void setValue(String JavaDoc propertyId, Object JavaDoc newValue) {
77         throw new UnsupportedOperationException JavaDoc();
78     }
79
80 }
81
Popular Tags