KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.runtime.IProgressMonitor;
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.IExpression;
18 import org.eclipse.debug.core.model.IValue;
19 import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
20 import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
21 import org.eclipse.ui.progress.IElementCollector;
22
23 public class DeferredExpressionManager extends DeferredDebugElementWorkbenchAdapter {
24
25     /* (non-Javadoc)
26      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
27      */

28     public Object JavaDoc[] getChildren(Object JavaDoc parent) {
29         return ((IExpressionManager)parent).getExpressions();
30     }
31
32     /* (non-Javadoc)
33      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
34      */

35     public Object JavaDoc getParent(Object JavaDoc element) {
36         return null;
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor)
41      */

42     public void fetchDeferredChildren(Object JavaDoc object, IElementCollector collector, IProgressMonitor monitor) {
43         if (monitor.isCanceled()) {
44             return;
45         }
46         Object JavaDoc[] children = getChildren(object);
47         if (monitor.isCanceled()) {
48             return;
49         }
50         if (children.length > 0) {
51             if (collector instanceof RemoteVariableContentManager.VariableCollector) {
52                 RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector;
53                 for (int i = 0; i < children.length; i++) {
54                     if (monitor.isCanceled()) {
55                         return;
56                     }
57                     IExpression child = (IExpression) children[i];
58                     try {
59                         IValue value = child.getValue();
60                         if (value == null) {
61                             remoteCollector.setHasChildren(child, false);
62                         } else {
63                             remoteCollector.setHasChildren(child, value.hasVariables());
64                         }
65                     } catch (DebugException e) {
66                     }
67                 }
68             }
69             collector.add(children, monitor);
70         }
71         collector.done();
72     }
73
74     /* (non-Javadoc)
75      * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer()
76      */

77     public boolean isContainer() {
78         return DebugPlugin.getDefault().getExpressionManager().hasExpressions();
79     }
80     
81     
82 }
83
Popular Tags