Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 255026 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbViewModelAdapter.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 Wind River Systems and others.
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
11
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
12
12
13
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
13
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
14
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
14
import org.eclipse.cdt.dsf.debug.ui.viewmodel.AbstractDebugVMAdapter;
15
import org.eclipse.cdt.dsf.debug.ui.viewmodel.AbstractDebugVMAdapter;
15
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
16
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
16
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
17
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
Lines 28-34 Link Here
28
 * 
29
 * 
29
 */
30
 */
30
@ThreadSafe
31
@ThreadSafe
31
@SuppressWarnings("restriction")
32
public class GdbViewModelAdapter extends AbstractDebugVMAdapter
32
public class GdbViewModelAdapter extends AbstractDebugVMAdapter
33
{
33
{
34
    public GdbViewModelAdapter(DsfSession session, SteppingController controller) {
34
    public GdbViewModelAdapter(DsfSession session, SteppingController controller) {
Lines 52-57 Link Here
52
            return new RegisterVMProvider(this, context, getSession());
52
            return new RegisterVMProvider(this, context, getSession());
53
        } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
53
        } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
54
            return new ExpressionVMProvider(this, context, getSession());
54
            return new ExpressionVMProvider(this, context, getSession());
55
        } else if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(context.getId()) ) {
56
            return new ExpressionVMProvider(this, context, getSession());
55
        } else if (IDebugUIConstants.ID_MODULE_VIEW.equals(context.getId()) ) {
57
        } else if (IDebugUIConstants.ID_MODULE_VIEW.equals(context.getId()) ) {
56
            return new ModulesVMProvider(this, context, getSession());
58
            return new ModulesVMProvider(this, context, getSession());
57
        }
59
        }
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 Wind River Systems and others.
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 67-72 Link Here
67
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
67
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
68
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
68
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
69
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
69
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
70
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider;
70
import org.eclipse.debug.ui.contexts.ISuspendTrigger;
71
import org.eclipse.debug.ui.contexts.ISuspendTrigger;
71
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
72
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
72
73
Lines 115-121 Link Here
115
            session.registerModelAdapter(SteppingController.class, fSteppingController);
116
            session.registerModelAdapter(SteppingController.class, fSteppingController);
116
117
117
            fViewModelAdapter = new GdbViewModelAdapter(session, fSteppingController);
118
            fViewModelAdapter = new GdbViewModelAdapter(session, fSteppingController);
118
119
			session.registerModelAdapter(IViewerInputProvider.class, fViewModelAdapter);
120
			
119
            if (launch.getSourceLocator() instanceof ISourceLookupDirector) {
121
            if (launch.getSourceLocator() instanceof ISourceLookupDirector) {
120
                fSourceDisplayAdapter = new DsfSourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator(), fSteppingController);
122
                fSourceDisplayAdapter = new DsfSourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator(), fSteppingController);
121
            } else {
123
            } else {
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java (+4 lines)
Lines 25-28 Link Here
25
        return GdbLaunchDelegate.GDB_DEBUG_MODEL_ID;
25
        return GdbLaunchDelegate.GDB_DEBUG_MODEL_ID;
26
    }
26
    }
27
27
28
    @Override
29
    protected boolean useExpressionExplorer() {
30
    	return true;
31
    }
28
}
32
}
(-)src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java (-2 / +92 lines)
Lines 17-22 Link Here
17
17
18
package org.eclipse.cdt.dsf.debug.ui;
18
package org.eclipse.cdt.dsf.debug.ui;
19
19
20
import java.util.concurrent.Callable;
21
import java.util.concurrent.ExecutionException;
22
20
import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
23
import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
21
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
24
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
22
import org.eclipse.cdt.dsf.concurrent.Query;
25
import org.eclipse.cdt.dsf.concurrent.Query;
Lines 31-49 Link Here
31
import org.eclipse.cdt.dsf.service.DsfSession;
34
import org.eclipse.cdt.dsf.service.DsfSession;
32
import org.eclipse.core.runtime.IAdaptable;
35
import org.eclipse.core.runtime.IAdaptable;
33
import org.eclipse.debug.core.model.IDebugModelProvider;
36
import org.eclipse.debug.core.model.IDebugModelProvider;
37
import org.eclipse.jface.text.BadLocationException;
38
import org.eclipse.jface.text.DefaultInformationControl;
39
import org.eclipse.jface.text.IDocument;
40
import org.eclipse.jface.text.IInformationControl;
41
import org.eclipse.jface.text.IInformationControlCreator;
42
import org.eclipse.jface.text.IRegion;
43
import org.eclipse.jface.text.ITextHoverExtension2;
44
import org.eclipse.jface.text.ITextViewer;
45
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.ui.editors.text.EditorsUI;
34
47
35
/**
48
/**
36
 * An implementation of AbstractDebugTextHover using DSF services.
49
 * An implementation of AbstractDebugTextHover using DSF services
37
 * 
50
 * 
38
 * @since 2.1
51
 * @since 2.1
39
 */
52
 */
40
abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover {
53
abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover implements ITextHoverExtension2 {
41
54
42
    /**
55
    /**
43
     * Returns the debug model ID of that this debug text hover is to be used for.
56
     * Returns the debug model ID of that this debug text hover is to be used for.
44
     */
57
     */
45
    abstract protected String getModelId();
58
    abstract protected String getModelId();
46
    
59
    
60
    /**
61
     * Returns whether the expression explorer information control should be used.
62
     * The default implementation returns <code>false</code>.
63
     */
64
    protected boolean useExpressionExplorer() {
65
    	return false;
66
    }
67
    
47
	private static class GetExpressionValueQuery extends Query<FormattedValueDMData> {
68
	private static class GetExpressionValueQuery extends Query<FormattedValueDMData> {
48
    	private final IFrameDMContext frame;
69
    	private final IFrameDMContext frame;
49
    	private final String expression;
70
    	private final String expression;
Lines 128-131 Link Here
128
        return null;
149
        return null;
129
	}
150
	}
130
151
152
	@Override
153
	public IInformationControlCreator getHoverControlCreator() {
154
		if (useExpressionExplorer()) {
155
			return new ExpressionInformationControlCreator();
156
		} else {
157
			return new IInformationControlCreator() {
158
				public IInformationControl createInformationControl(Shell parent) {
159
					return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
160
				}
161
			};
162
		}
163
	}
164
165
	/*
166
	 * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
167
	 */
168
	public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
169
    	final String simpleInfo = getHoverInfo(textViewer, hoverRegion);
170
		if (!useExpressionExplorer() || simpleInfo == null) {
171
    		return simpleInfo;
172
    	}
173
		// improved version using ExpressionInformationControlCreator
174
    	// see also getHoverControlCreator()
175
    	final String text = getExpressionText(textViewer, hoverRegion);
176
    	if (text != null && text.length() > 0) {
177
			final IFrameDMContext frameDmc = getFrame();
178
			final DsfSession dsfSession = DsfSession.getSession(frameDmc.getSessionId());
179
			Callable<IExpressionDMContext> callable = new Callable<IExpressionDMContext>() {
180
				public IExpressionDMContext call() throws Exception {
181
					DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), frameDmc.getSessionId());
182
					try {
183
						IExpressions expressions = tracker.getService(IExpressions.class);
184
						if (expressions != null) {
185
							return expressions.createExpression(frameDmc, text);
186
						}
187
						return null;
188
					} finally {
189
						tracker.dispose();
190
					}
191
				}
192
			};
193
			try {
194
				return dsfSession.getExecutor().submit(callable).get();
195
			} catch (InterruptedException e) {
196
			} catch (ExecutionException e) {
197
			}
198
    	}
199
    	return null;
200
	}
201
202
	private String getExpressionText(ITextViewer textViewer, IRegion hoverRegion) {
203
		IDocument document = textViewer.getDocument();
204
		if (document == null)
205
			return null;
206
		String expression;
207
		try {
208
			expression= document.get(hoverRegion.getOffset(),
209
					hoverRegion.getLength());
210
		} catch (BadLocationException exc) {
211
			return null;
212
		}
213
		if (expression == null)
214
			return null;
215
		expression = expression.trim();
216
		if (expression.length() == 0)
217
			return null;
218
		return expression;
219
	}
220
131
}
221
}
(-)src/org/eclipse/cdt/dsf/debug/ui/IDsfDebugUIConstants.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 Wind River Systems and others.
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 79-82 Link Here
79
     * @since 2.0 
79
     * @since 2.0 
80
     */
80
     */
81
    public static final String PREF_COLOR_STALE_DATA_BACKGROUND= PLUGIN_ID + ".staledata.background"; //$NON-NLS-1$
81
    public static final String PREF_COLOR_STALE_DATA_BACKGROUND= PLUGIN_ID + ".staledata.background"; //$NON-NLS-1$
82
83
    /**
84
     * Presentation context id for the expression hover.
85
     * 
86
     * @since 2.1
87
     */
88
	public static final String ID_EXPRESSION_HOVER= PLUGIN_ID + ".expression_hover"; //$NON-NLS-1$
82
}
89
}
(-)src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java (-3 / +26 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 Wind River Systems and others.
2
 * Copyright (c) 2006, 2009 Wind River Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-24 Link Here
19
import org.eclipse.cdt.dsf.debug.service.ICachingService;
19
import org.eclipse.cdt.dsf.debug.service.ICachingService;
20
import org.eclipse.cdt.dsf.debug.service.IExpressions;
20
import org.eclipse.cdt.dsf.debug.service.IExpressions;
21
import org.eclipse.cdt.dsf.debug.service.IRegisters;
21
import org.eclipse.cdt.dsf.debug.service.IRegisters;
22
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
22
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
23
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
23
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
24
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
24
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
25
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
Lines 46-51 Link Here
46
import org.eclipse.debug.internal.core.IExpressionsListener2;
47
import org.eclipse.debug.internal.core.IExpressionsListener2;
47
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
48
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
48
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
49
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
50
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
49
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
51
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
50
import org.eclipse.jface.preference.IPreferenceStore;
52
import org.eclipse.jface.preference.IPreferenceStore;
51
import org.eclipse.jface.util.IPropertyChangeListener;
53
import org.eclipse.jface.util.IPropertyChangeListener;
Lines 210-217 Link Here
210
        /*
212
        /*
211
         * Now the Over-arching management node.
213
         * Now the Over-arching management node.
212
         */
214
         */
213
        ExpressionManagerVMNode expressionManagerNode = new ExpressionManagerVMNode(this);
215
        if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(getPresentationContext().getId())) {
214
        addChildNodes(rootNode, new IVMNode[] {expressionManagerNode});
216
        	SingleExpressionVMNode expressionManagerNode = new SingleExpressionVMNode(this);
217
        	addChildNodes(rootNode, new IVMNode[] { expressionManagerNode });
218
        } else {
219
            ExpressionManagerVMNode expressionManagerNode = new ExpressionManagerVMNode(this);
220
            addChildNodes(rootNode, new IVMNode[] {expressionManagerNode});
221
        }
215
        
222
        
216
        /*
223
        /*
217
         *  The expression view wants to support fully all of the components of the register view.
224
         *  The expression view wants to support fully all of the components of the register view.
Lines 372-375 Link Here
372
            // Session disposed, ignore.
379
            // Session disposed, ignore.
373
        }
380
        }
374
    }
381
    }
382
383
    @Override
384
    public void update(IViewerInputUpdate update) {
385
        if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(getPresentationContext().getId())) {
386
        	Object input = update.getElement();
387
        	if (input instanceof IExpressionDMContext) {
388
        		IExpressionDMContext dmc= (IExpressionDMContext) input;
389
        		SingleExpressionVMNode vmNode = (SingleExpressionVMNode) getChildVMNodes(getRootVMNode())[0];
390
        		vmNode.setExpression(dmc);
391
				update.setInputElement(vmNode.createVMContext(dmc));
392
        		update.done();
393
        		return;
394
        	}
395
        }
396
        super.update(update);
397
    }
375
}
398
}
(-)src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/SingleExpressionVMNode.java (+327 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Wind River Systems, Inc. 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
 *     Wind River Systems - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.debug.ui.viewmodel.expression;
13
14
import java.util.LinkedList;
15
import java.util.List;
16
17
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
18
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
19
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
20
import org.eclipse.cdt.dsf.datamodel.IDMContext;
21
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
22
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
23
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionsChangedEvent;
24
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.InvalidExpressionVMContext;
25
import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor;
26
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMContext;
27
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
28
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
29
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMNode;
30
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
31
import org.eclipse.debug.core.ILaunch;
32
import org.eclipse.debug.core.model.IDebugTarget;
33
import org.eclipse.debug.core.model.IExpression;
34
import org.eclipse.debug.core.model.IValue;
35
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
36
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
37
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
38
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
39
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
40
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
41
import org.eclipse.jface.viewers.TreePath;
42
43
/**
44
 * A VM node for displaying a single expression in the expression hover.
45
 */
46
public class SingleExpressionVMNode extends AbstractDMVMNode implements IElementLabelProvider {
47
48
	private static class RootDMVMContext extends AbstractVMContext implements IDMVMContext {
49
		private final IDMContext fDmc;
50
		public RootDMVMContext(IVMNode node, IDMContext dmc) {
51
			super(node);
52
			fDmc = dmc;
53
		}
54
		public IDMContext getDMContext() {
55
			return fDmc;
56
		}
57
		@SuppressWarnings("unchecked")
58
		@Override
59
		public Object getAdapter(Class adapter) {
60
            Object superAdapter = super.getAdapter(adapter);
61
            if (superAdapter != null) {
62
                return superAdapter;
63
            } else {
64
                // Delegate to the Data Model to find the context.
65
                if (adapter.isInstance(fDmc)) {
66
                    return fDmc;
67
                } else {
68
                    return fDmc.getAdapter(adapter);
69
                }
70
            }
71
		}
72
73
		@Override
74
		public boolean equals(Object other) {
75
            if (!(other instanceof RootDMVMContext)) return false;
76
            RootDMVMContext otherVmc = (RootDMVMContext)other;
77
            return getVMNode().equals(otherVmc.getVMNode()) &&
78
                   fDmc.equals(otherVmc.fDmc);
79
		}
80
81
		@Override
82
		public int hashCode() {
83
            return getVMNode().hashCode() + fDmc.hashCode(); 
84
		}
85
86
	}
87
88
	private static class SimpleExpression implements IExpression {
89
		private String fExpressionText;
90
		SimpleExpression(String text) {
91
			fExpressionText = text;
92
		}
93
		public void dispose() {
94
		}
95
		public IDebugTarget getDebugTarget() {
96
			return null;
97
		}
98
		public String getExpressionText() {
99
			return fExpressionText;
100
		}
101
		public IValue getValue() {
102
			return null;
103
		}
104
		public ILaunch getLaunch() {
105
			return null;
106
		}
107
		public String getModelIdentifier() {
108
			return null;
109
		}
110
		@SuppressWarnings("unchecked")
111
		public Object getAdapter(Class adapter) {
112
			return null;
113
		}
114
115
	}
116
117
	private static class SingleExpressionManager {
118
		private static final IExpression[] NO_EXPRESSIONS = {};
119
		IExpression fExpression;
120
		public IExpression[] getExpressions() {
121
			if (fExpression != null) {
122
				return new IExpression[] { fExpression };
123
			}
124
			return NO_EXPRESSIONS;
125
		}
126
		public void setExpression(IExpression expression) {
127
			fExpression = expression;
128
		}
129
130
	}
131
132
	/** Local reference to the expression manager */ 
133
    private final SingleExpressionManager fManager;
134
    
135
    public SingleExpressionVMNode(ExpressionVMProvider provider) {
136
        super(provider, provider.getSession(), IExpressionDMContext.class);
137
        fManager = new SingleExpressionManager();
138
    }
139
140
	@Override
141
    public String toString() {
142
        return "SingleExpressionVMNode";  //$NON-NLS-1$ 
143
    }
144
    
145
    private ExpressionVMProvider getExpressionVMProvider() {
146
        return (ExpressionVMProvider)getVMProvider();
147
    }
148
149
    @Override
150
	public void update(IHasChildrenUpdate[] updates) {
151
        // Test availability of children based on whether there are any expressions 
152
        // in the manager.  We assume that the getExpressions() will just read 
153
        // local state data, so we don't bother using a job to perform this 
154
        // operation.
155
        for (int i = 0; i < updates.length; i++) {
156
            updates[i].setHasChilren(fManager.getExpressions().length != 0);
157
            updates[i].done();
158
        }
159
    }
160
    
161
    @Override
162
	public void update(IChildrenCountUpdate[] updates) {
163
        for (IChildrenCountUpdate update : updates) {
164
            if (!checkUpdate(update)) continue;
165
166
            // We assume that the getExpressions() will just read local state data,
167
            // so we don't bother using a job to perform this operation.
168
            update.setChildCount(fManager.getExpressions().length);
169
            update.done();
170
        }
171
    }
172
    
173
    @Override
174
	public void update(final IChildrenUpdate[] updates) {
175
        for (IChildrenUpdate update : updates) {
176
            doUpdateChildren(update);
177
        }        
178
    }
179
    
180
    public void doUpdateChildren(final IChildrenUpdate update) {
181
        final IExpression[] expressions = fManager.getExpressions();
182
        
183
        // For each (expression) element in update, find the layout node that can 
184
        // parse it.  And for each expression that has a corresponding layout node, 
185
        // call IExpressionLayoutNode#getElementForExpression to generate a VMC.
186
        // Since the last is an async call, we need to create a multi-RM to wait
187
        // for all the calls to complete.
188
        final CountingRequestMonitor multiRm = new ViewerCountingRequestMonitor(getVMProvider().getExecutor(), update);
189
        int multiRmCount = 0;
190
        
191
        int lowOffset= update.getOffset();
192
        if (lowOffset < 0) {
193
        	lowOffset = 0;
194
        }
195
		int length= update.getLength();
196
		if (length <= 0) {
197
			length = expressions.length;
198
		}
199
		final int highOffset= lowOffset + length;
200
		for (int i = lowOffset; i < highOffset && i < expressions.length + 1; i++) {
201
            if (i < expressions.length) {
202
                multiRmCount++;
203
                final int childIndex = i;
204
                final IExpression expression = expressions[i];
205
                // getElementForExpression() accepts a IElementsUpdate as an argument.
206
                // Construct an instance of VMElementsUpdate which will call a 
207
                // the request monitor when it is finished.  The request monitor
208
                // will in turn set the element in the update argument in this method. 
209
                ((ExpressionVMProvider)getVMProvider()).update(
210
                    new VMExpressionUpdate(
211
                        update, expression,
212
                        new DataRequestMonitor<Object>(getVMProvider().getExecutor(), multiRm) {
213
                            @Override
214
                            protected void handleSuccess() {
215
                                update.setChild(getData(), childIndex);
216
                                multiRm.done();
217
                            } 
218
                            
219
                            @Override
220
                            protected void handleError() {
221
                                update.setChild(new InvalidExpressionVMContext(SingleExpressionVMNode.this, expression), childIndex);                                
222
                                multiRm.done();
223
                            }
224
                        })
225
                    );
226
            }
227
        }
228
229
        // If no expressions were parsed, we're finished.
230
        // Set the count to the counting RM.
231
        multiRm.setDoneCount(multiRmCount);
232
    }
233
234
    public void update(ILabelUpdate[] updates) {
235
        // The label update handler only handles labels for the invalid expression VMCs.
236
        // The expression layout nodes are responsible for supplying label providers 
237
        // for their VMCs.
238
        for (ILabelUpdate update : updates) {
239
        	update.done();
240
        }
241
    }
242
243
    public int getDeltaFlags(Object event) {
244
        int retVal = 0;
245
246
        // Add a flag if the list of expressions in the global expression manager has changed.
247
        if (event instanceof ExpressionsChangedEvent) {
248
            retVal |= IModelDelta.ADDED | IModelDelta.REMOVED | IModelDelta.INSERTED | IModelDelta.CONTENT ;
249
        }
250
251
        for (IExpression expression : fManager.getExpressions()) {
252
            retVal |= getExpressionVMProvider().getDeltaFlagsForExpression(expression, event);
253
        }
254
        
255
        return retVal;
256
    }
257
258
    public void buildDelta(final Object event, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor requestMonitor) {
259
        if (event instanceof ExpressionsChangedEvent) {
260
            buildDeltaForExpressionsChangedEvent((ExpressionsChangedEvent)event, parentDelta, nodeOffset, requestMonitor);
261
        } else {
262
        
263
            // For each expression, find its corresponding node and ask that
264
            // layout node for its delta flags for given event.  If there are delta flags to be 
265
            // generated, call the asynchronous method to do so.
266
            CountingRequestMonitor multiRm = new CountingRequestMonitor(getExecutor(), requestMonitor);
267
            
268
            int buildDeltaForExpressionCallCount = 0;
269
            
270
            IExpression[] expressions = fManager.getExpressions();
271
            for (int i = 0; i < expressions.length; i++ ) {
272
                int flags = getExpressionVMProvider().getDeltaFlagsForExpression(expressions[i], event);
273
                // If the given expression has no delta flags, skip it.
274
                if (flags == IModelDelta.NO_CHANGE) continue;
275
    
276
                int elementOffset = nodeOffset >= 0 ? nodeOffset + i : -1;
277
                getExpressionVMProvider().buildDeltaForExpression(
278
                    expressions[i], elementOffset, event, parentDelta, getTreePathFromDelta(parentDelta), 
279
                    new RequestMonitor(getExecutor(), multiRm));
280
                buildDeltaForExpressionCallCount++;
281
            }
282
            
283
            multiRm.setDoneCount(buildDeltaForExpressionCallCount);
284
        }
285
    }
286
    
287
    private void buildDeltaForExpressionsChangedEvent(ExpressionsChangedEvent event, VMDelta parentDelta, 
288
        int nodeOffset, RequestMonitor requestMonitor) 
289
    {
290
        CountingRequestMonitor multiRm = new CountingRequestMonitor(getExecutor(), requestMonitor);
291
        for (int i = 0; i < event.getExpressions().length; i++) {
292
            int expIndex = event.getIndex() != -1 
293
                ? nodeOffset + event.getIndex() + i 
294
                : -1; 
295
            getExpressionVMProvider().buildDeltaForExpression(
296
                event.getExpressions()[i], expIndex, event, parentDelta, getTreePathFromDelta(parentDelta), 
297
                new RequestMonitor(getExecutor(), multiRm));                
298
        }
299
        multiRm.setDoneCount(event.getExpressions().length);
300
    }
301
        
302
    private TreePath getTreePathFromDelta(IModelDelta delta) {
303
        List<Object> elementList = new LinkedList<Object>();
304
        IModelDelta listDelta = delta;
305
        elementList.add(0, listDelta.getElement());
306
        while (listDelta.getParentDelta() != null) {
307
            elementList.add(0, listDelta.getElement());
308
            listDelta = listDelta.getParentDelta();
309
        }
310
        return new TreePath(elementList.toArray());
311
    }
312
313
	@Override
314
	protected void updateElementsInSessionThread(IChildrenUpdate update) {
315
        doUpdateChildren(update);
316
	}
317
318
    @Override
319
	public IDMVMContext createVMContext(IDMContext dmc) {
320
        return new RootDMVMContext(getVMProvider().getRootVMNode(), dmc);
321
    }
322
323
    void setExpression(IExpressionDMContext dmc) {
324
		String text = dmc.getExpression();
325
		fManager.setExpression(new SimpleExpression(text));
326
    }
327
}
(-)src/org/eclipse/cdt/dsf/debug/ui/ExpressionInformationControlCreator.java (+447 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 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
 *     Wind River Systems - adapted for DSF
11
 *******************************************************************************/
12
package org.eclipse.cdt.dsf.debug.ui;
13
14
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
15
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.model.IVariable;
18
import org.eclipse.debug.internal.ui.SWTFactory;
19
import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
20
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
21
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
22
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor;
23
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
24
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
25
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
26
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
27
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
28
import org.eclipse.debug.internal.ui.viewers.model.provisional.ViewerInputService;
29
import org.eclipse.debug.internal.ui.views.variables.details.DefaultDetailPane;
30
import org.eclipse.debug.internal.ui.views.variables.details.DetailPaneProxy;
31
import org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer;
32
import org.eclipse.debug.ui.AbstractDebugView;
33
import org.eclipse.debug.ui.IDebugUIConstants;
34
import org.eclipse.jface.dialogs.IDialogSettings;
35
import org.eclipse.jface.text.AbstractInformationControl;
36
import org.eclipse.jface.text.IInformationControl;
37
import org.eclipse.jface.text.IInformationControlCreator;
38
import org.eclipse.jface.text.IInformationControlExtension2;
39
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.viewers.StructuredViewer;
41
import org.eclipse.jface.viewers.TreeSelection;
42
import org.eclipse.jface.viewers.ViewerFilter;
43
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.custom.SashForm;
45
import org.eclipse.swt.events.SelectionEvent;
46
import org.eclipse.swt.events.SelectionListener;
47
import org.eclipse.swt.graphics.Color;
48
import org.eclipse.swt.graphics.Point;
49
import org.eclipse.swt.layout.GridData;
50
import org.eclipse.swt.layout.GridLayout;
51
import org.eclipse.swt.widgets.Composite;
52
import org.eclipse.swt.widgets.Layout;
53
import org.eclipse.swt.widgets.Shell;
54
import org.eclipse.swt.widgets.Tree;
55
import org.eclipse.ui.IWorkbenchPage;
56
import org.eclipse.ui.IWorkbenchPartSite;
57
58
/**
59
 * Creates an information control to display an expression in a hover control.
60
 * 
61
 * @noextend This class is not intended to be subclassed by clients.
62
 * 
63
 * @since 2.1
64
 */
65
public class ExpressionInformationControlCreator implements IInformationControlCreator {
66
67
	class ExpressionInformationControl extends AbstractInformationControl implements IInformationControlExtension2, IViewerInputRequestor {
68
69
		/**
70
		 * Dialog setting key for height
71
		 */
72
		private static final String HEIGHT = "HEIGHT"; //$NON-NLS-1$
73
74
		/**
75
		 * Dialog setting key for width. 
76
		 */
77
		private static final String WIDTH = "WIDTH"; //$NON-NLS-1$
78
79
		/**
80
		 * Dialog setting key for tree sash weight
81
		 */
82
		private static final String SASH_WEIGHT_TREE = "SashWeightTree"; //$NON-NLS-1$
83
		
84
		/**
85
		 * Dialog setting key for details sash weight
86
		 */
87
		private static final String SASH_WEIGHT_DETAILS = "SashWeightDetails"; //$NON-NLS-1$		
88
		
89
		/**
90
		 * Variable to display.
91
		 */
92
		private Object fVariable;
93
		
94
	    private TreeModelViewer fViewer;
95
	    private SashForm fSashForm;
96
	    private Composite fDetailPaneComposite;
97
	    private DetailPaneProxy fDetailPane;
98
	    private Tree fTree;
99
100
		private ViewerInputService fInputService;
101
		    
102
		/**
103
	     * Creates the content for the root element of the tree viewer in the hover
104
	     */
105
	    private class TreeRoot extends ElementContentProvider {
106
			@Override
107
			protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
108
				return 1;
109
			}
110
			@Override
111
			protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
112
				return new Object[] { fVariable };
113
			}
114
			@Override
115
			protected boolean supportsContextId(String id) {
116
				return true;
117
			}
118
	    }
119
	    
120
		/**
121
		 * Inner class implementing IDetailPaneContainer methods.  Handles changes to detail
122
		 * pane and provides limited access to the detail pane proxy.
123
		 */
124
		private class DetailPaneContainer implements IDetailPaneContainer {
125
		
126
			/*
127
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getCurrentPaneID()
128
			 */
129
			public String getCurrentPaneID() {
130
				return fDetailPane.getCurrentPaneID();
131
			}
132
		
133
			/*
134
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getCurrentSelection()
135
			 */
136
			public IStructuredSelection getCurrentSelection() {
137
				return (IStructuredSelection)fViewer.getSelection();
138
			}
139
		
140
			/*
141
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#refreshDetailPaneContents()
142
			 */
143
			public void refreshDetailPaneContents() {		
144
				fDetailPane.display(getCurrentSelection());
145
			}
146
		
147
			/*
148
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getParentComposite()
149
			 */
150
			public Composite getParentComposite() {
151
				return fDetailPaneComposite;
152
			}
153
		
154
			/*
155
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getWorkbenchPartSite()
156
			 */
157
			public IWorkbenchPartSite getWorkbenchPartSite() {
158
				return null;
159
			}
160
		
161
			/*
162
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#paneChanged(java.lang.String)
163
			 */
164
			public void paneChanged(String newPaneID) {
165
				if (DefaultDetailPane.ID.equals(newPaneID)){
166
					fDetailPane.getCurrentControl().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
167
				}
168
			}
169
		
170
		}	    
171
172
		/**
173
		 * Constructs a new control in the given shell.
174
		 * 
175
		 * @param parentShell shell
176
		 * @param resize whether resize is supported
177
		 */
178
		ExpressionInformationControl(Shell parentShell, boolean resize) {
179
			super(parentShell, resize);
180
			create();
181
		}
182
		
183
		@Override
184
		public Point computeSizeHint() {
185
			IDialogSettings settings = getDialogSettings(false);
186
			if (settings != null) {
187
				int x = getIntSetting(settings, WIDTH);
188
				if (x > 0) {
189
					int y = getIntSetting(settings, HEIGHT);
190
					if (y > 0) {
191
						final Point size= new Point(x,y);
192
						return size;
193
					}
194
				}
195
			}
196
			return super.computeSizeHint();
197
		}
198
199
		/**
200
		 * Returns the dialog settings for this hover or <code>null</code> if none
201
		 * 
202
		 * @param create whether to create the settings
203
		 */
204
		private IDialogSettings getDialogSettings(boolean create) {
205
			IDialogSettings settings = DsfUIPlugin.getDefault().getDialogSettings();
206
			IDialogSettings section = settings.getSection(this.getClass().getName());
207
			if (section == null & create) {
208
				section = settings.addNewSection(this.getClass().getName());
209
			}
210
			return section;
211
		}
212
		
213
		/**
214
		 * Returns an integer value in the given dialog settings or -1 if none.
215
		 * 
216
		 * @param settings dialog settings
217
		 * @param key key
218
		 * @return value or -1 if not present
219
		 */
220
		private int getIntSetting(IDialogSettings settings, String key) {
221
			try {
222
				return settings.getInt(key);
223
			} catch (NumberFormatException e) {
224
				return -1;
225
			}
226
		}
227
		
228
		@Override
229
		public void dispose() {
230
			persistSettings(getShell());
231
			super.dispose();
232
		}
233
234
		/**
235
		 * Persists dialog settings.
236
		 * 
237
		 * @param shell
238
		 */
239
		private void persistSettings(Shell shell) {
240
			if (shell != null && !shell.isDisposed()) {
241
				if (isResizable()) {
242
					IDialogSettings settings = getDialogSettings(true);
243
					Point size = shell.getSize();
244
					System.out.println("ExpressionInformationControlCreator.ExpressionInformationControl.persistSettings() " + size);
245
					settings.put(WIDTH, size.x);
246
					settings.put(HEIGHT, size.y);
247
					int[] weights = fSashForm.getWeights();
248
					settings.put(SASH_WEIGHT_TREE, weights[0]);
249
					settings.put(SASH_WEIGHT_DETAILS, weights[1]);
250
				}
251
			}
252
		}
253
		
254
		@Override
255
		public void setVisible(boolean visible) {
256
			if (!visible) {		
257
				persistSettings(getShell());
258
			}
259
			super.setVisible(visible);
260
		}
261
262
		@Override
263
		protected void createContent(Composite parent) {
264
265
	        fSashForm = new SashForm(parent, parent.getStyle());
266
	        fSashForm.setOrientation(SWT.VERTICAL);
267
268
		    // update presentation context
269
	        AbstractDebugView view = getViewToEmulate();
270
	        IPresentationContext context = new PresentationContext(IDsfDebugUIConstants.ID_EXPRESSION_HOVER);
271
	        if (view != null) {
272
	        	// copy over properties
273
	        	IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext();
274
	        	try {
275
		        	String[] properties = copy.getProperties();
276
		        	for (int i = 0; i < properties.length; i++) {
277
						String key = properties[i];
278
						context.setProperty(key, copy.getProperty(key));
279
					}
280
	        	} catch (NoSuchMethodError e) {
281
	        		// ignore
282
	        	}
283
	        }
284
	       
285
	        fViewer = new TreeModelViewer(fSashForm, SWT.NO_TRIM | SWT.MULTI | SWT.VIRTUAL, context);
286
	        fViewer.setAutoExpandLevel(1);
287
	        
288
	        if (view != null) {
289
	        	// copy over filters
290
	        	StructuredViewer structuredViewer = (StructuredViewer) view.getViewer();
291
	            if (structuredViewer != null) {
292
	                ViewerFilter[] filters = structuredViewer.getFilters();
293
	                for (int i = 0; i < filters.length; i++) {
294
	                    fViewer.addFilter(filters[i]);
295
	                }
296
	            }
297
	        }
298
	        fInputService = new ViewerInputService(fViewer, this);
299
	        
300
	        fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
301
	        Layout layout = fDetailPaneComposite.getLayout();
302
	        if (layout instanceof GridLayout) {
303
				GridLayout gl = (GridLayout) layout;
304
				gl.marginHeight = 0;
305
				gl.marginWidth = 0;
306
			}
307
	        
308
	        fDetailPane = new DetailPaneProxy(new DetailPaneContainer());
309
	        fDetailPane.display(null); // Bring up the default pane so the user doesn't see an empty composite
310
	      
311
	        fTree = fViewer.getTree();
312
	        fTree.addSelectionListener(new SelectionListener() {
313
	            public void widgetSelected(SelectionEvent e) {
314
	            	fDetailPane.display((IStructuredSelection)fViewer.getSelection());
315
	            }
316
	            public void widgetDefaultSelected(SelectionEvent e) {}
317
	        });
318
319
	        initSashWeights();
320
	        
321
	        // add update listener to auto-select and display details of root expression
322
	        fViewer.addViewerUpdateListener(new IViewerUpdateListener() {
323
				public void viewerUpdatesComplete() {
324
				}
325
				public void viewerUpdatesBegin() {
326
				}
327
				public void updateStarted(IViewerUpdate update) {
328
				}
329
				public void updateComplete(IViewerUpdate update) {
330
					if (update instanceof IChildrenUpdate) {
331
						fViewer.removeViewerUpdateListener(this);
332
						fViewer.getDisplay().timerExec(100, new Runnable() {
333
							public void run() {
334
								TreeSelection selection = new TreeSelection(fViewer.getTopElementPath());
335
								fViewer.setSelection(selection);
336
								fDetailPane.display(selection);
337
							}});
338
					}
339
				}
340
			});        
341
	        
342
	        setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
343
		}
344
		
345
346
		/**
347
	     * Attempts to find an appropriate view to emulate, this will either be the
348
	     * variables view or the expressions view.
349
	     * @return a view to emulate or <code>null</code>
350
	     */
351
	    private AbstractDebugView getViewToEmulate() {
352
	        IWorkbenchPage page = DsfUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
353
	        AbstractDebugView expressionsView = (AbstractDebugView) page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW);
354
	        if (expressionsView != null && expressionsView.isVisible()) {
355
	            return expressionsView;
356
	        }
357
	        AbstractDebugView variablesView = (AbstractDebugView) page.findView(IDebugUIConstants.ID_VARIABLE_VIEW);
358
	        if (variablesView != null && variablesView.isVisible()) {
359
	            return variablesView;
360
	        }
361
	        if (expressionsView != null) {
362
	            return expressionsView;
363
	        }
364
	        return variablesView;
365
	    }	
366
367
		/**
368
	     * Initializes the sash form weights from the preference store (using default values if 
369
	     * no sash weights were stored previously).
370
	     */
371
	    protected void initSashWeights(){
372
	    	IDialogSettings settings = getDialogSettings(false);
373
	    	if (settings != null) {
374
		    	int tree = getIntSetting(settings, SASH_WEIGHT_TREE);
375
		    	if (tree > 0) {
376
		    		int details = getIntSetting(settings, SASH_WEIGHT_DETAILS);
377
		    		if (details > 0) {
378
		    			fSashForm.setWeights(new int[]{tree, details});
379
		    		}
380
		    	}
381
	    	}
382
	    }
383
	    		
384
		/* (non-Javadoc)
385
		 * @see org.eclipse.jface.text.AbstractInformationControl#setBackgroundColor(org.eclipse.swt.graphics.Color)
386
		 */
387
		@Override
388
		public void setBackgroundColor(Color background) {
389
			super.setBackgroundColor(background);
390
			fDetailPaneComposite.setBackground(background);
391
			fTree.setBackground(background);
392
		}
393
	
394
		/* (non-Javadoc)
395
		 * @see org.eclipse.jface.text.AbstractInformationControl#setFocus()
396
		 */
397
		@Override
398
		public void setFocus() {
399
			super.setFocus();
400
			fTree.setFocus();
401
		}
402
		
403
		/* (non-Javadoc)
404
		 * @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
405
		 */
406
		public boolean hasContents() {
407
			return fVariable != null;
408
		}
409
410
		/* (non-Javadoc)
411
		 * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
412
		 */
413
		public void setInput(Object input) {
414
			if (input instanceof IExpressionDMContext) {
415
				fVariable = input;
416
				fInputService.resolveViewerInput(input);
417
			} else if (input instanceof IVariable) {
418
				fVariable = input;
419
		        fViewer.setInput(new TreeRoot());
420
			}
421
		}
422
423
		@Override
424
		public IInformationControlCreator getInformationPresenterControlCreator() {
425
			return new ExpressionInformationControlCreator() {
426
				@Override
427
				public IInformationControl createInformationControl(Shell shell) {
428
					return new ExpressionInformationControl(shell, true);
429
				}
430
			};
431
		}
432
433
		public void viewerInputComplete(IViewerInputUpdate update) {
434
			fViewer.setInput(fVariable = update.getInputElement());
435
		}
436
437
	}
438
439
	/*
440
	 * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
441
	 */
442
	public IInformationControl createInformationControl(Shell parent) {
443
		return new ExpressionInformationControl(parent, false);
444
	}
445
446
447
}

Return to bug 255026