KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > expression > RemoteExpressionContentManager


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.views.expression;
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 import org.eclipse.debug.core.model.IVariable;
18 import org.eclipse.debug.internal.ui.elements.adapters.DeferredExpressionLogicalStructure;
19 import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
20 import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
21 import org.eclipse.debug.internal.ui.views.variables.VariablesView;
22 import org.eclipse.jface.viewers.ITreeContentProvider;
23 import org.eclipse.ui.IWorkbenchPartSite;
24 import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
25
26 /**
27  * Remote content manager for variables. Creates an appropriate adapter for
28  * logical structures.
29  */

30 public class RemoteExpressionContentManager extends RemoteVariableContentManager {
31
32     private IDeferredWorkbenchAdapter fExpressionLogicalStructureAdapter = new DeferredExpressionLogicalStructure();
33     
34     /**
35      * Constructs a remote content manager for a variables view.
36      */

37     public RemoteExpressionContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
38         super(provider, viewer, site, view);
39     }
40
41     /* (non-Javadoc)
42      * @see org.eclipse.ui.progress.DeferredTreeContentManager#getAdapter(java.lang.Object)
43      */

44     protected IDeferredWorkbenchAdapter getAdapter(Object JavaDoc element) {
45         if (element instanceof IExpression && fView !=null && fView.isShowLogicalStructure()) {
46             return fExpressionLogicalStructureAdapter;
47         }
48         return super.getAdapter(element);
49     }
50
51     public boolean mayHaveChildren(Object JavaDoc element) {
52         if (element instanceof IErrorReportingExpression) {
53             IErrorReportingExpression iere = (IErrorReportingExpression) element;
54             if (iere.hasErrors()) {
55                 //errors are displayed as children of the expression
56
return true;
57             }
58         }
59         
60         if (element instanceof IExpression) {
61             IExpression expression = (IExpression) element;
62             IValue value = expression.getValue();
63             if (value != null) {
64                 try {
65                     IVariable[] variables = value.getVariables();
66                     if (variables.length > 0) {
67                         //definitely children...
68
return true;
69                     }
70                     
71                     //returning false because value!=null && variables.length=0 means no children
72
return false;
73                 } catch (DebugException e) {
74                 }
75             }
76         }
77         
78         //expression has not been evaluated
79
return super.mayHaveChildren(element);
80     }
81     
82     
83     
84 }
85
Popular Tags