1 11 package org.eclipse.debug.internal.ui.model.elements; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.IExpressionManager; 15 import org.eclipse.debug.core.model.IExpression; 16 import org.eclipse.debug.core.model.IVariable; 17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 18 import org.eclipse.ui.IMemento; 19 20 25 public class ExpressionsViewMementoProvider extends ElementMementoProvider { 26 27 30 private static final String ELEMENT_NAME = "ELEMENT_NAME"; 32 private static final String EXP_MGR = "EXP_MGR"; 34 protected boolean encodeElement(Object element, IMemento memento, IPresentationContext context) throws CoreException { 35 if (element instanceof IExpressionManager) { 36 memento.putString(ELEMENT_NAME, EXP_MGR); 37 } else if (element instanceof IExpression) { 38 memento.putString(ELEMENT_NAME, ((IExpression) element).getExpressionText()); 39 } else if (element instanceof IVariable) { 40 memento.putString(ELEMENT_NAME, ((IVariable) element).getName()); 41 } else { 42 return false; 43 } 44 return true; 45 } 46 47 protected boolean isEqual(Object element, IMemento memento, IPresentationContext context) throws CoreException { 48 String mementoName = memento.getString(ELEMENT_NAME); 49 if (mementoName != null) { 50 String elementName = null; 51 if (element instanceof IExpressionManager) { 52 elementName = EXP_MGR; 53 } else if (element instanceof IVariable) { 54 elementName = ((IVariable)element).getName(); 55 } else if (element instanceof IExpression) { 56 elementName = ((IExpression)element).getExpressionText(); 57 } 58 if (elementName != null) { 59 return elementName.equals(mementoName); 60 } 61 } 62 return false; 63 } 64 65 } 66 | Popular Tags |