01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 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.ui.internal.preferences;
11:
12: import java.util.Set;
13:
14: import org.eclipse.jface.util.IPropertyChangeListener;
15: import org.eclipse.jface.util.PropertyChangeEvent;
16: import org.eclipse.ui.themes.IThemeManager;
17:
18: /**
19: * @since 3.1
20: */
21: public class ThemeManagerAdapter extends PropertyMapAdapter {
22:
23: private IThemeManager manager;
24:
25: private IPropertyChangeListener listener = new IPropertyChangeListener() {
26: public void propertyChange(PropertyChangeEvent event) {
27: firePropertyChange(event.getProperty());
28: }
29: };
30:
31: public ThemeManagerAdapter(IThemeManager manager) {
32: this .manager = manager;
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.ui.internal.preferences.PropertyMapAdapter#attachListener()
37: */
38: protected void attachListener() {
39: manager.addPropertyChangeListener(listener);
40: }
41:
42: /* (non-Javadoc)
43: * @see org.eclipse.ui.internal.preferences.PropertyMapAdapter#detachListener()
44: */
45: protected void detachListener() {
46: manager.removePropertyChangeListener(listener);
47: }
48:
49: /* (non-Javadoc)
50: * @see org.eclipse.ui.internal.preferences.IPropertyMap#keySet()
51: */
52: public Set keySet() {
53: Set result = ThemeAdapter.getKeySet(manager.getCurrentTheme());
54:
55: return result;
56: }
57:
58: /* (non-Javadoc)
59: * @see org.eclipse.ui.internal.preferences.IPropertyMap#getValue(java.lang.String, java.lang.Class)
60: */
61: public Object getValue(String propertyId, Class propertyType) {
62: return ThemeAdapter.getValue(manager.getCurrentTheme(),
63: 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 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 propertyId, Object newValue) {
77: throw new UnsupportedOperationException();
78: }
79:
80: }
|