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;
11:
12: /**
13: * Represents a single integer that can send notifications when it changes.
14: * IChangeListeners can be attached which will receive notifications whenever
15: * the integer changes.
16: */
17: public class IntModel extends Model {
18: public IntModel(int initialValue) {
19: super (new Integer(initialValue));
20: }
21:
22: /**
23: * Sets the value of the integer and notifies all
24: * change listeners except for the one that caused the change.
25: *
26: * @param newValue the new value of the integer
27: */
28: public void set(int newValue, IChangeListener source) {
29: setState(new Integer(newValue), source);
30: }
31:
32: /**
33: * Sets the value of the integer and notifies all change listeners
34: * of the change.
35: *
36: * @param newValue the new value of the integer
37: */
38: public void set(int newValue) {
39: setState(new Integer(newValue), null);
40: }
41:
42: /**
43: * Returns the value of the integer.
44: *
45: * @return the value of the integer
46: */
47: public int get() {
48: return ((Integer) getState()).intValue();
49: }
50: }
|