KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > variables > JavaExpressionContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2007 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.jdt.internal.debug.ui.variables;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.model.IExpression;
15 import org.eclipse.debug.core.model.IValue;
16 import org.eclipse.debug.internal.ui.model.elements.ExpressionContentProvider;
17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
19 import org.eclipse.jdt.debug.core.IJavaObject;
20 import org.eclipse.jdt.internal.debug.core.logicalstructures.JDIAllInstancesValue;
21 import org.eclipse.jdt.internal.debug.core.model.JDIDebugModelMessages;
22 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListValue;
23 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListVariable;
24
25 import com.ibm.icu.text.MessageFormat;
26
27 /**
28  * Provides content for the result of an inspect operation that is displayed in the expressions view.
29  *
30  * @since 3.3
31  * @see JavaVariableContentProvider
32  * @see JavaInspectExpression
33  */

34 public class JavaExpressionContentProvider extends ExpressionContentProvider{
35
36     /* (non-Javadoc)
37      * @see org.eclipse.debug.internal.ui.model.elements.VariableContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
38      */

39     protected Object JavaDoc[] getChildren(Object JavaDoc parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
40         Object JavaDoc[] variables = getAllChildren(parent, context);
41         if (JavaVariableContentProvider.displayReferencesAsChild(parent)){
42             IValue value = ((IExpression)parent).getValue();
43             if (!(value instanceof JDIAllInstancesValue) && !(value instanceof JDIReferenceListValue)) {
44                 Object JavaDoc[] moreVariables = new Object JavaDoc[variables.length+1];
45                 System.arraycopy(variables, 0, moreVariables, 1, variables.length);
46                 moreVariables[0] = new JDIReferenceListVariable(MessageFormat.format(JDIDebugModelMessages.JDIReferenceListValue_6, new String JavaDoc[]{value.getReferenceTypeName() + " " + value.getValueString()}),(IJavaObject)value); //$NON-NLS-1$
47
return getElements(moreVariables, index, length);
48             }
49         }
50         return getElements(variables, index, length);
51     }
52     
53     /* (non-Javadoc)
54      * @see org.eclipse.debug.internal.ui.model.elements.VariableContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
55      */

56     protected int getChildCount(Object JavaDoc element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
57         int count = super.getChildCount(element, context, monitor);
58         if (JavaVariableContentProvider.displayReferencesAsChild(element)){
59             IValue value = ((IExpression)element).getValue();
60             if (!(value instanceof JDIAllInstancesValue) && !(value instanceof JDIReferenceListValue)) {
61                 count++;
62             }
63         }
64         return count;
65     }
66     
67     /* (non-Javadoc)
68      * @see org.eclipse.debug.internal.ui.model.elements.ExpressionContentProvider#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
69      */

70     protected boolean hasChildren(Object JavaDoc element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
71         if (JavaVariableContentProvider.displayReferencesAsChild(element)){
72             return true;
73         }
74         return super.hasChildren(element, context, monitor);
75     }
76     
77 }
78
Popular Tags