mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
[308540] - [expressions][update policy][cdi] Disabled expressions are still evaluated
This commit is contained in:
parent
cbf285ec26
commit
2db4f5c708
5 changed files with 180 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.DisabledExpressionVMNode;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionManagerVMNode;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.IExpressionVMNode;
|
||||
|
@ -72,6 +73,10 @@ public class GdbExpressionVMProvider extends ExpressionVMProvider {
|
|||
addChildNodes(rootNode, new IVMNode[] {expressionManagerNode});
|
||||
}
|
||||
|
||||
// Disabled expression node intercepts disabled expressions and prevents them from being
|
||||
// evaluated by other nodes.
|
||||
IExpressionVMNode disabledExpressionNode = new DisabledExpressionVMNode(this);
|
||||
|
||||
/*
|
||||
* The expression view wants to support fully all of the components of the register view.
|
||||
*/
|
||||
|
@ -105,7 +110,7 @@ public class GdbExpressionVMProvider extends ExpressionVMProvider {
|
|||
* assume what it was passed was for it and the real node which wants to handle it would be
|
||||
* left out in the cold.
|
||||
*/
|
||||
setExpressionNodes(new IExpressionVMNode[] {registerGroupNode, variableNode});
|
||||
setExpressionNodes(new IExpressionVMNode[] {disabledExpressionNode, registerGroupNode, variableNode});
|
||||
|
||||
/*
|
||||
* Let the work know which is the top level node.
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.ui.viewmodel.expression;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.model.IExpression;
|
||||
import org.eclipse.debug.core.model.IWatchExpression;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.ICellModifier;
|
||||
import org.eclipse.jface.viewers.TextCellEditor;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
* Expression VM Node which handles displaying disabled expressions.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DisabledExpressionVMNode extends AbstractVMNode
|
||||
implements IExpressionVMNode, IElementEditor
|
||||
{
|
||||
|
||||
/** Cached reference to a cell modifier for editing expression strings of disabled expressions */
|
||||
private WatchExpressionCellModifier fWatchExpressionCellModifier = new WatchExpressionCellModifier();
|
||||
|
||||
|
||||
private static class DisabledExpressionVMContext extends InvalidExpressionVMContext {
|
||||
|
||||
private static final MessageFormat NO_COLUMN_FORMAT = new MessageFormat(MessagesForExpressionVM.DisabledExpressionVMNode_disabled_no_columns);
|
||||
|
||||
DisabledExpressionVMContext(IVMNode node, IExpression expression) {
|
||||
super(node, expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the label for the DisabledExpressionVMNode.
|
||||
*/
|
||||
@Override
|
||||
public void update(ILabelUpdate[] updates) {
|
||||
for (ILabelUpdate update : updates) {
|
||||
if (update.getColumnIds() == null) {
|
||||
update.setLabel(NO_COLUMN_FORMAT.format( new Object[] { getExpression().getExpressionText() }), 0);
|
||||
update.setImageDescriptor(DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), 0);
|
||||
} else {
|
||||
String[] columnIds = update.getColumnIds();
|
||||
|
||||
for (int i = 0; i < update.getColumnIds().length; i++) {
|
||||
if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnIds[i]) ||
|
||||
IDebugVMConstants.COLUMN_ID__NAME.equals(columnIds[i]))
|
||||
{
|
||||
update.setLabel(getExpression().getExpressionText(), i);
|
||||
update.setImageDescriptor(DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), i);
|
||||
} else {
|
||||
update.setLabel(MessagesForExpressionVM.DisabledExpressionVMNode_disabled_value, i);
|
||||
}
|
||||
update.setFontData(JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0], i);
|
||||
}
|
||||
}
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DisabledExpressionVMNode(IVMProvider provider) {
|
||||
super(provider);
|
||||
}
|
||||
|
||||
public boolean canParseExpression(IExpression expression) {
|
||||
return expression instanceof IWatchExpression && !((IWatchExpression)expression).isEnabled();
|
||||
}
|
||||
|
||||
public int getDeltaFlagsForExpression(IExpression expression, Object event) {
|
||||
return IModelDelta.NO_CHANGE;
|
||||
}
|
||||
|
||||
public int getDeltaFlags(Object event) {
|
||||
return IModelDelta.NO_CHANGE;
|
||||
}
|
||||
|
||||
public void buildDelta(Object event, VMDelta parent, int nodeOffset, RequestMonitor requestMonitor) {
|
||||
requestMonitor.done();
|
||||
}
|
||||
|
||||
public void update(IChildrenCountUpdate[] updates) {
|
||||
for (IViewerUpdate update : updates) {
|
||||
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(IChildrenUpdate[] updates) {
|
||||
for (IViewerUpdate update : updates) {
|
||||
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(IHasChildrenUpdate[] updates) {
|
||||
for (IViewerUpdate update : updates) {
|
||||
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(IExpressionUpdate update) {
|
||||
update.setExpressionElement(new DisabledExpressionVMContext(this, update.getExpression()));
|
||||
update.done();
|
||||
}
|
||||
|
||||
public void buildDeltaForExpression(IExpression expression, int elementIdx, Object event, VMDelta parentDelta,
|
||||
TreePath path, RequestMonitor rm)
|
||||
{
|
||||
rm.done();
|
||||
}
|
||||
|
||||
public void buildDeltaForExpressionElement(Object element, int elementIdx, Object event, VMDelta parentDelta,
|
||||
RequestMonitor rm) {
|
||||
rm.done();
|
||||
}
|
||||
|
||||
public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) {
|
||||
if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnId)) {
|
||||
return new TextCellEditor(parent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ICellModifier getCellModifier(IPresentationContext context, Object element) {
|
||||
return fWatchExpressionCellModifier;
|
||||
}
|
||||
|
||||
}
|
|
@ -226,6 +226,10 @@ public class ExpressionVMProvider extends AbstractDMVMProvider
|
|||
addChildNodes(rootNode, new IVMNode[] {expressionManagerNode});
|
||||
}
|
||||
|
||||
// Disabled expression node intercepts disabled expressions and prevents them from being
|
||||
// evaluated by other nodes.
|
||||
IExpressionVMNode disabledExpressionNode = new DisabledExpressionVMNode(this);
|
||||
|
||||
/*
|
||||
* The expression view wants to support fully all of the components of the register view.
|
||||
*/
|
||||
|
@ -264,7 +268,7 @@ public class ExpressionVMProvider extends AbstractDMVMProvider
|
|||
* assume what it was passed was for it and the real node which wants to handle it would be
|
||||
* left out in the cold.
|
||||
*/
|
||||
setExpressionNodes(new IExpressionVMNode[] {registerGroupNode, variableNode});
|
||||
setExpressionNodes(new IExpressionVMNode[] {disabledExpressionNode, registerGroupNode, variableNode});
|
||||
|
||||
/*
|
||||
* Let the work know which is the top level node.
|
||||
|
|
|
@ -30,6 +30,9 @@ public class MessagesForExpressionVM extends NLS {
|
|||
|
||||
public static String ExpressionManagerLayoutNode__newExpression_label;
|
||||
|
||||
public static String DisabledExpressionVMNode_disabled_value;
|
||||
public static String DisabledExpressionVMNode_disabled_no_columns;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, MessagesForExpressionVM.class);
|
||||
|
|
|
@ -19,3 +19,6 @@ ExpressionColumnPresentation_description=Description
|
|||
ExpressionManagerLayoutNode__invalidExpression_nameColumn_label=Invalid expression
|
||||
ExpressionManagerLayoutNode__invalidExpression_valueColumn_label=Invalid expression
|
||||
ExpressionManagerLayoutNode__newExpression_label=Add new expression
|
||||
|
||||
DisabledExpressionVMNode_disabled_value=(disabled)
|
||||
DisabledExpressionVMNode_disabled_no_columns={0} (disabled)
|
Loading…
Add table
Reference in a new issue