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: /**
13: * @since 3.1
14: */
15: public abstract class AbstractBooleanListener extends
16: AbstractPropertyListener {
17:
18: private IDynamicPropertyMap map;
19: private boolean defaultValue;
20: private String propertyId;
21:
22: public AbstractBooleanListener() {
23: }
24:
25: public void attach(IDynamicPropertyMap map, String propertyId,
26: boolean defaultValue) {
27: this .defaultValue = defaultValue;
28: this .propertyId = propertyId;
29: if (this .map != null) {
30: this .map.removeListener(this );
31: }
32:
33: this .map = map;
34:
35: if (this .map != null) {
36: this .map.addListener(new String[] { propertyId }, this );
37: }
38: }
39:
40: /* (non-Javadoc)
41: * @see org.eclipse.ui.internal.preferences.AbstractPropertyListener#update()
42: */
43: protected void update() {
44: handleValue(PropertyUtil.get(map, propertyId, defaultValue));
45: }
46:
47: /**
48: * @param b
49: * @since 3.1
50: */
51: protected abstract void handleValue(boolean b);
52:
53: }
|