aboutsummaryrefslogtreecommitdiffstats
blob: 21a8f34acef14b8581984b3f54f6cfbfcf207a36 (plain)
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
52
53
/*******************************************************************************
 * Copyright (c) 2000, 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.jface.tests.viewers;

import java.util.Vector;

public class TestModel {
    Vector fListeners = new Vector();

    int fNumLevels;

    int fNumChildren;

    public TestModel(int numLevels, int numChildren) {
        fNumLevels = numLevels;
        fNumChildren = numChildren;
    }

    public void addListener(ITestModelListener listener) {
        fListeners.addElement(listener);
    }

    /**
     * Fires a model changed event to all listeners.
     */
    public void fireModelChanged(TestModelChange change) {
        for (int i = 0; i < fListeners.size(); ++i) {
            ITestModelListener listener = (ITestModelListener) fListeners
                    .get(i);
            listener.testModelChanged(change);
        }
    }

    public int getNumChildren() {
        return fNumChildren;
    }

    public int getNumLevels() {
        return fNumLevels;
    }

    public void removeListener(ITestModelListener listener) {
        fListeners.removeElement(listener);
    }
}