1 11 12 package org.eclipse.debug.internal.ui.views.breakpoints; 13 14 import java.util.HashMap ; 15 import java.util.Vector ; 16 17 import org.eclipse.core.resources.IMarker; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.debug.core.DebugPlugin; 20 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 21 import org.eclipse.debug.internal.ui.importexport.breakpoints.IImportExportConstants; 22 import org.eclipse.ui.IWorkingSet; 23 import org.eclipse.ui.IWorkingSetManager; 24 import org.eclipse.ui.PlatformUI; 25 26 34 public class BreakpointWorkingSetCache { 35 36 41 HashMap fCache = null; 42 43 47 public BreakpointWorkingSetCache() { 48 fCache = new HashMap (15); 49 } 50 51 56 public void addEntry(IMarker marker, Object entry) { 57 Vector list = (Vector )fCache.get(marker); 58 if (list == null) { 59 list = new Vector (); 60 list.addElement(entry); 61 fCache.put(marker, list); 62 } 63 else { 64 if(!list.contains(entry)) { 65 list.addElement(entry); 66 } 67 } 68 } 69 70 75 public void removeMappedEntry(IMarker marker, Object entry) { 76 Vector list = (Vector )fCache.get(marker); 77 if(list != null) { 78 list.remove(entry); 79 } 80 } 81 82 86 public void flushMarkerCache(IMarker marker) { 87 IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); 88 Vector list = (Vector )fCache.get(marker); 89 if(list != null) { 90 String names = IImportExportConstants.DELIMITER; 91 String ids = IImportExportConstants.DELIMITER; 92 for(int i = 0; i < list.size(); i++) { 93 String name = (String )list.elementAt(i); 94 IWorkingSet ws = manager.getWorkingSet(name); 95 if(ws != null) { 96 names += name+IImportExportConstants.DELIMITER; 97 ids += ws.getId()+IImportExportConstants.DELIMITER; 98 } 99 } 100 try { 101 marker.setAttribute(IInternalDebugUIConstants.WORKING_SET_NAME, names); 102 marker.setAttribute(IInternalDebugUIConstants.WORKING_SET_ID, ids); 103 } 104 catch(CoreException e) {DebugPlugin.log(e);} 105 } 106 } 107 108 } 109 | Popular Tags |