KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
14  * @since 3.1
15  */

16 public abstract class AbstractIntegerListener extends AbstractPropertyListener {
17
18     private IDynamicPropertyMap map;
19     private int defaultValue;
20     private String JavaDoc propertyId;
21     
22     public AbstractIntegerListener() {
23     }
24     
25     public void attach(IDynamicPropertyMap map, String JavaDoc propertyId, int defaultValue) {
26         this.defaultValue = defaultValue;
27         this.propertyId = propertyId;
28         if (this.map != null) {
29             this.map.removeListener(this);
30         }
31         
32         this.map = map;
33         
34         if (this.map != null) {
35             this.map.addListener(new String JavaDoc[]{propertyId}, this);
36         }
37     }
38
39     /* (non-Javadoc)
40      * @see org.eclipse.ui.internal.preferences.AbstractPropertyListener#update()
41      */

42     protected void update() {
43         handleValue(PropertyUtil.get(map, propertyId, defaultValue));
44     }
45
46     /**
47      * @param b
48      * @since 3.1
49      */

50     protected abstract void handleValue(int b);
51    
52     
53 }
54
Popular Tags