1
/*******************************************************************************
2
* Copyright (c) 2006 IBM Corporation.
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
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
*******************************************************************************/
12
package org.eclipse.linuxtools.systemtap.ui.structures;
14
import java.util.ArrayList;
15
import java.util.Timer;
16
import java.util.TimerTask;
18
import org.eclipse.linuxtools.systemtap.ui.structures.listeners.IUpdateListener;
22
public class UpdateManager {
23
public UpdateManager(int delay) {
24
updateListeners = new ArrayList<IUpdateListener>();
27
timer = new Timer("Update Manager", true);
28
timer.scheduleAtFixedRate(new Notify(), delay, delay);
32
* Terminates the timer and removes all update listeners.
38
for(int i=0; i<updateListeners.size(); i++)
39
removeUpdateListener(updateListeners.get(i));
43
public void addUpdateListener(IUpdateListener l) {
44
if(!updateListeners.contains(l))
45
updateListeners.add(l);
47
public void removeUpdateListener(IUpdateListener l) {
48
if(updateListeners.contains(l))
49
updateListeners.remove(l);
52
public boolean isRunning() {
56
public void dispose() {
61
updateListeners = null;
66
* Handle any events that are timed to occur.
68
private class Notify extends TimerTask {
73
for(int i = 0; i < updateListeners.size(); i++)
74
(updateListeners.get(i)).handleUpdateEvent();
76
}catch(Exception e) {}
82
private ArrayList<IUpdateListener> updateListeners;
83
private boolean stopped;
84
private boolean disposed;