| 1 package org.oddjob.jmx.client; 2 3 import java.rmi.RemoteException ; 4 import java.util.ArrayList ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 8 import org.oddjob.images.IconEvent; 9 import org.oddjob.images.IconHelper; 10 import org.oddjob.images.IconListener; 11 12 18 19 class ClientIconHelper { 20 21 22 private IconEvent lastEvent = new IconEvent(this, IconHelper.NULL); 23 24 25 private final List listeners = new ArrayList (); 26 27 28 private final Object owner; 29 30 37 public ClientIconHelper(Object owner) { 38 super(); 39 this.owner = owner; 40 } 41 42 public void iconEvent(IconEvent event) { 43 IconEvent iconEvent = new IconEvent(owner, event.getIconId()); 46 47 lastEvent = event; 48 49 synchronized (listeners) { 50 for (Iterator it = listeners.iterator(); it.hasNext();) { 51 ((IconListener)it.next()).iconEvent(iconEvent); 52 } 53 } 54 } 55 56 public void addIconListener(IconListener listener) { 57 IconEvent nowEvent = null; 58 nowEvent = lastEvent; 59 synchronized (listeners) { 60 listener.iconEvent(nowEvent); 61 listeners.add(listener); 62 } 63 } 64 65 70 public void removeIconListener(IconListener listener) { 71 synchronized (listeners) { 72 listeners.remove(listener); 73 } 74 } 75 76 } 77 | Popular Tags |