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.IRegisterGroup; 15 import org.eclipse.debug.core.model.IStackFrame; 16 import org.eclipse.debug.core.model.IVariable; 17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 18 import org.eclipse.debug.ui.IDebugUIConstants; 19 import org.eclipse.ui.IMemento; 20 21 24 public class VariablesViewElementMementoProvider extends ElementMementoProvider { 25 26 29 private static final String ELEMENT_NAME = "ELEMENT_NAME"; 31 protected boolean encodeElement(Object element, IMemento memento, IPresentationContext context) throws CoreException { 32 if (element instanceof IStackFrame) { 33 IStackFrame frame = (IStackFrame) element; 34 if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId())) { 35 memento.putString(ELEMENT_NAME, frame.getModelIdentifier()); 37 } else { 38 memento.putString(ELEMENT_NAME, frame.getName()); 39 } 40 } else if (element instanceof IVariable) { 41 memento.putString(ELEMENT_NAME, ((IVariable) element).getName()); 42 } else if (element instanceof IRegisterGroup) { 43 memento.putString(ELEMENT_NAME, ((IRegisterGroup) element).getName()); 44 } else { 45 return false; 46 } 47 return true; 48 } 49 50 protected boolean isEqual(Object element, IMemento memento, IPresentationContext context) throws CoreException { 51 String mementoName = memento.getString(ELEMENT_NAME); 52 if (mementoName != null) { 53 String elementName = null; 54 if (element instanceof IStackFrame) { 55 IStackFrame frame = (IStackFrame) element; 56 if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId())) { 57 elementName = frame.getModelIdentifier(); 59 } else { 60 elementName = frame.getName(); 61 } 62 } else if (element instanceof IVariable) { 63 elementName = ((IVariable)element).getName(); 64 } else if (element instanceof IRegisterGroup) { 65 elementName = ((IRegisterGroup)element).getName(); 66 } 67 if (elementName != null) { 68 return elementName.equals(mementoName); 69 } 70 } 71 return false; 72 } 73 74 } 75 | Popular Tags |