1 11 package org.eclipse.debug.internal.ui.model.elements; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.model.IMemoryBlock; 15 import org.eclipse.debug.core.model.IMemoryBlockRetrieval; 16 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 17 import org.eclipse.debug.ui.IDebugUIConstants; 18 import org.eclipse.ui.IMemento; 19 20 public class MemoryViewElementMementoProvider extends ElementMementoProvider { 21 22 private static final String OBJECT_ID = "OBJECT_ID"; 24 protected boolean encodeElement(Object element, IMemento memento, 25 IPresentationContext context) throws CoreException { 26 String id = context.getId(); 27 if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 28 { 29 if (element instanceof IMemoryBlock || element instanceof IMemoryBlockRetrieval) 30 { 31 memento.putInteger(OBJECT_ID, element.hashCode()); 32 return true; 33 } 34 } 35 return false; 36 } 37 38 protected boolean isEqual(Object element, IMemento memento, 39 IPresentationContext context) throws CoreException { 40 String id = context.getId(); 41 if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 42 { 43 if (element instanceof IMemoryBlock || element instanceof IMemoryBlockRetrieval) 44 { 45 Integer objectId = memento.getInteger(OBJECT_ID); 46 if (objectId != null && objectId.intValue() == element.hashCode()) 47 return true; 48 } 49 } 50 return false; 51 } 52 53 } 54 | Popular Tags |