KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.debug.core.DebugException;
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
18 public class DeferredExpression extends DeferredVariable {
19
20     /* (non-Javadoc)
21      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
22      */

23     public Object JavaDoc[] getChildren(Object JavaDoc parent) {
24         if (parent instanceof IErrorReportingExpression) {
25             IErrorReportingExpression expression= (IErrorReportingExpression) parent;
26             if (expression.hasErrors()) {
27                 return expression.getErrorMessages();
28             }
29         }
30         if (parent instanceof IExpression) {
31             IExpression expression = (IExpression)parent;
32             IValue value = expression.getValue();
33             try {
34                 return getValueChildren(expression, value);
35             } catch (DebugException e) {
36             }
37         }
38         return super.getChildren(parent);
39     }
40
41     protected boolean hasChildren(Object JavaDoc child) {
42         if (child instanceof IErrorReportingExpression) {
43             IErrorReportingExpression expression = (IErrorReportingExpression) child;
44             if (expression.hasErrors()) {
45                 return true;
46             }
47         }
48         
49         if (child instanceof IExpression) {
50             IExpression expression = (IExpression) child;
51             IValue value = expression.getValue();
52             if (value != null) {
53                 try {
54                     return value.hasVariables();
55                 } catch (DebugException e) {
56                 }
57             }
58         }
59         
60         return super.hasChildren(child);
61     }
62
63     
64
65 }
66
Popular Tags