1 11 12 package org.eclipse.search2.internal.ui.text; 13 14 import java.util.HashMap ; 15 16 import org.eclipse.search.ui.text.AbstractTextSearchResult; 17 import org.eclipse.ui.IWindowListener; 18 import org.eclipse.ui.IWorkbenchWindow; 19 import org.eclipse.ui.PlatformUI; 20 21 public class AnnotationManagers { 22 static { 23 fgManagerMap = new HashMap (); 24 IWindowListener listener = new IWindowListener() { 25 public void windowActivated(IWorkbenchWindow window) { 26 } 28 29 public void windowDeactivated(IWorkbenchWindow window) { 30 } 32 33 public void windowClosed(IWorkbenchWindow window) { 34 disposeAnnotationManager(window); 35 } 36 37 public void windowOpened(IWorkbenchWindow window) { 38 } 40 }; 41 PlatformUI.getWorkbench().addWindowListener(listener); 42 } 43 44 private static HashMap fgManagerMap; 45 46 47 private static void disposeAnnotationManager(IWorkbenchWindow window) { 48 WindowAnnotationManager mgr = (WindowAnnotationManager) fgManagerMap.remove(window); 49 if (mgr != null) 50 mgr.dispose(); 51 } 52 53 public static void addSearchResult(IWorkbenchWindow window, AbstractTextSearchResult newResult) { 54 getWindowAnnotationManager(window).addSearchResult(newResult); 55 } 56 57 public static void removeSearchResult(IWorkbenchWindow window, AbstractTextSearchResult result) { 58 getWindowAnnotationManager(window).removeSearchResult(result); 59 } 60 61 private static WindowAnnotationManager getWindowAnnotationManager(IWorkbenchWindow window) { 62 WindowAnnotationManager mgr= (WindowAnnotationManager) fgManagerMap.get(window); 63 if (mgr == null) { 64 mgr= new WindowAnnotationManager(window); 65 fgManagerMap.put(window, mgr); 66 } 67 return mgr; 68 } 69 70 71 } 72 | Popular Tags |