1 11 package org.eclipse.debug.internal.ui.views.launch; 12 13 import java.util.ArrayList ; 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 import java.util.ListIterator ; 18 import java.util.Map ; 19 20 import org.eclipse.debug.core.model.IDebugTarget; 21 import org.eclipse.debug.core.model.IThread; 22 23 26 public class DecorationManager { 27 28 private static Map fDecorations = new HashMap (10); 30 31 37 public static void addDecoration(Decoration decoration) { 38 synchronized (fDecorations) { 39 IDebugTarget target = decoration.getThread().getDebugTarget(); 40 List list = (List ) fDecorations.get(target); 41 if (list == null) { 42 list = new ArrayList (); 43 fDecorations.put(target, list); 44 } 45 list.add(decoration); 46 } 47 } 48 49 55 public static void removeDecorations(IDebugTarget target) { 56 doRemoveDecorations(target, null); 57 } 58 59 65 public static void removeDecorations(IThread thread) { 66 doRemoveDecorations(thread.getDebugTarget(), thread); 67 } 68 69 private static void doRemoveDecorations(IDebugTarget target, IThread thread) { 70 ArrayList decorationsToRemove = new ArrayList (); 71 synchronized (fDecorations) { 72 List list = (List ) fDecorations.get(target); 73 if (list != null) { 74 ListIterator iterator = list.listIterator(); 75 while (iterator.hasNext()) { 76 Decoration decoration = (Decoration) iterator.next(); 77 if (thread == null || thread.equals(decoration.getThread())) { 78 decorationsToRemove.add(decoration); 79 iterator.remove(); 80 } 81 } 82 if (list.isEmpty()) { 83 fDecorations.remove(target); 84 } 85 } 86 } 87 Iterator iter = decorationsToRemove.iterator(); 88 while (iter.hasNext()) 89 { 90 Decoration decoration = (Decoration)iter.next(); 91 decoration.remove(); 92 } 93 } 94 95 } 96 | Popular Tags |