Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 168c7d4dc79df8605ca53c65d7610c1caf51b0a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2004, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.internal.preferences;

/**
 * @since 3.1
 */
public abstract class AbstractIntegerListener extends AbstractPropertyListener {

    private IDynamicPropertyMap map;
    private int defaultValue;
    private String propertyId;

    public AbstractIntegerListener() {
    }

    public void attach(IDynamicPropertyMap map, String propertyId, int defaultValue) {
        this.defaultValue = defaultValue;
        this.propertyId = propertyId;
        if (this.map != null) {
            this.map.removeListener(this);
        }

        this.map = map;

        if (this.map != null) {
            this.map.addListener(new String[]{propertyId}, this);
        }
    }

    @Override
	protected void update() {
        handleValue(PropertyUtil.get(map, propertyId, defaultValue));
    }

    /**
     * @param b
     * @since 3.1
     */
    protected abstract void handleValue(int b);


}

Back to the top