1 11 package org.eclipse.debug.internal.ui.views.expression; 12 13 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.DebugPlugin; 16 import org.eclipse.debug.core.IExpressionManager; 17 import org.eclipse.debug.core.model.IErrorReportingExpression; 18 import org.eclipse.debug.core.model.IExpression; 19 import org.eclipse.debug.core.model.IValue; 20 import org.eclipse.debug.core.model.IVariable; 21 import org.eclipse.debug.internal.ui.DebugUIPlugin; 22 import org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider; 23 import org.eclipse.debug.ui.IDebugView; 24 25 28 public class ExpressionViewContentProvider extends VariablesViewContentProvider { 29 30 public ExpressionViewContentProvider(IDebugView view) { 31 super(view); 32 } 33 34 37 public Object [] getChildren(Object parent) { 38 Object [] children= null; 39 try { 40 if (parent instanceof IExpressionManager) { 41 return ((IExpressionManager)parent).getExpressions(); 43 } else if (parent instanceof IExpression) { 44 if (parent instanceof IErrorReportingExpression) { 45 IErrorReportingExpression expression= (IErrorReportingExpression) parent; 46 if (expression.hasErrors()) { 47 children= expression.getErrorMessages(); 48 } 49 } 50 if (children == null) { 51 IExpression expression = (IExpression)parent; 52 IValue value = expression.getValue(); 53 children = getModelSpecificChildren(expression, value); 54 } 55 } else if (parent instanceof IVariable) { 56 IVariable variable = (IVariable)parent; 57 IValue value = variable.getValue(); 58 children = getModelSpecificChildren(variable, value); 59 } 60 if (children != null) { 61 cache(parent, children); 62 return children; 63 } 64 } catch (DebugException de) { 65 DebugUIPlugin.log(de); 66 } 67 return new Object [0]; 68 } 69 70 73 public Object getParent(Object item) { 74 if (item instanceof IExpression) { 75 return DebugPlugin.getDefault().getExpressionManager(); 76 } 77 return super.getParent(item); 78 } 79 80 83 public boolean hasChildren(Object element) { 84 if (element instanceof IExpressionManager) { 85 return ((IExpressionManager)element).hasExpressions(); 86 } else if (element instanceof IExpression) { 87 if (element instanceof IErrorReportingExpression && ((IErrorReportingExpression) element).hasErrors()) { 88 return true; 89 } 90 IValue v = ((IExpression)element).getValue(); 91 if (v == null) { 92 return false; 93 } 94 try { 95 return v.hasVariables(); 96 } catch (DebugException e) { 97 DebugUIPlugin.log(e); 98 return false; 99 } 100 } 101 return super.hasChildren(element); 102 } 103 } 104 | Popular Tags |