KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > elements > adapters > ExpressionContentAdapter


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.elements.adapters;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.model.IErrorReportingExpression;
15 import org.eclipse.debug.core.model.IExpression;
16 import org.eclipse.debug.core.model.IValue;
17 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
18
19 /**
20  *
21  */

22 public class ExpressionContentAdapter extends VariableContentAdapter {
23
24     protected Object JavaDoc[] getChildren(Object JavaDoc parent, IPresentationContext context) throws CoreException {
25         if (parent instanceof IErrorReportingExpression) {
26             IErrorReportingExpression expression = (IErrorReportingExpression) parent;
27             if (expression.hasErrors()) {
28                 return expression.getErrorMessages();
29             }
30         }
31
32         if (parent instanceof IExpression) {
33             IExpression expression = (IExpression) parent;
34             IValue value = expression.getValue();
35             if (value != null) {
36                 return getValueChildren(expression, value, context);
37             }
38         }
39         
40         return EMPTY;
41     }
42     
43     protected boolean hasChildren(Object JavaDoc element, IPresentationContext context) throws CoreException {
44         if (element instanceof IErrorReportingExpression) {
45             IErrorReportingExpression expression = (IErrorReportingExpression) element;
46             if (expression.hasErrors()) {
47                 return true;
48             }
49         }
50         
51         if (element instanceof IExpression) {
52             IValue value = ((IExpression) element).getValue();
53             if (value != null) {
54                 return value.hasVariables();
55             }
56         }
57         
58         return false;
59     }
60     
61 }
62
Popular Tags