1 7 package java.awt.dnd; 8 9 import java.awt.AWTEventMulticaster ; 10 import java.lang.reflect.Array ; 11 import java.util.EventListener ; 12 import java.io.Serializable ; 13 import java.io.ObjectOutputStream ; 14 import java.io.IOException ; 15 import java.util.EventListener ; 16 17 18 27 28 class DnDEventMulticaster extends AWTEventMulticaster 29 implements DragSourceListener , DragSourceMotionListener { 30 31 41 protected DnDEventMulticaster(EventListener a, EventListener b) { 42 super(a,b); 43 } 44 45 51 public void dragEnter(DragSourceDragEvent dsde) { 52 ((DragSourceListener )a).dragEnter(dsde); 53 ((DragSourceListener )b).dragEnter(dsde); 54 } 55 56 62 public void dragOver(DragSourceDragEvent dsde) { 63 ((DragSourceListener )a).dragOver(dsde); 64 ((DragSourceListener )b).dragOver(dsde); 65 } 66 67 73 public void dropActionChanged(DragSourceDragEvent dsde) { 74 ((DragSourceListener )a).dropActionChanged(dsde); 75 ((DragSourceListener )b).dropActionChanged(dsde); 76 } 77 78 84 public void dragExit(DragSourceEvent dse) { 85 ((DragSourceListener )a).dragExit(dse); 86 ((DragSourceListener )b).dragExit(dse); 87 } 88 89 95 public void dragDropEnd(DragSourceDropEvent dsde) { 96 ((DragSourceListener )a).dragDropEnd(dsde); 97 ((DragSourceListener )b).dragDropEnd(dsde); 98 } 99 100 106 public void dragMouseMoved(DragSourceDragEvent dsde) { 107 ((DragSourceMotionListener )a).dragMouseMoved(dsde); 108 ((DragSourceMotionListener )b).dragMouseMoved(dsde); 109 } 110 111 118 public static DragSourceListener add(DragSourceListener a, 119 DragSourceListener b) { 120 return (DragSourceListener )addInternal(a, b); 121 } 122 123 130 public static DragSourceMotionListener add(DragSourceMotionListener a, 131 DragSourceMotionListener b) { 132 return (DragSourceMotionListener )addInternal(a, b); 133 } 134 135 142 public static DragSourceListener remove(DragSourceListener l, 143 DragSourceListener oldl) { 144 return (DragSourceListener )removeInternal(l, oldl); 145 } 146 147 155 public static DragSourceMotionListener remove(DragSourceMotionListener l, 156 DragSourceMotionListener ol) { 157 return (DragSourceMotionListener )removeInternal(l, ol); 158 } 159 160 170 protected static EventListener addInternal(EventListener a, EventListener b) { 171 if (a == null) return b; 172 if (b == null) return a; 173 return new DnDEventMulticaster (a, b); 174 } 175 176 181 protected EventListener remove(EventListener oldl) { 182 if (oldl == a) return b; 183 if (oldl == b) return a; 184 EventListener a2 = removeInternal(a, oldl); 185 EventListener b2 = removeInternal(b, oldl); 186 if (a2 == a && b2 == b) { 187 return this; } 189 return addInternal(a2, b2); 190 } 191 192 203 protected static EventListener removeInternal(EventListener l, EventListener oldl) { 204 if (l == oldl || l == null) { 205 return null; 206 } else if (l instanceof DnDEventMulticaster ) { 207 return ((DnDEventMulticaster )l).remove(oldl); 208 } else { 209 return l; } 211 } 212 213 protected static void save(ObjectOutputStream s, String k, EventListener l) 214 throws IOException { 215 AWTEventMulticaster.save(s, k, l); 216 } 217 } 218 | Popular Tags |