Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/dsf
diff options
context:
space:
mode:
authorPawel Piech2010-04-08 18:44:08 +0000
committerPawel Piech2010-04-08 18:44:08 +0000
commit2db4f5c708b159d096cd69afb302b4f4dff67ac2 (patch)
treee504ee65b68bd326937e21289bf5d04ab698c093 /dsf
parentcbf285ec26bece5e5433e16bd1764862ea9ca8d8 (diff)
downloadorg.eclipse.cdt-2db4f5c708b159d096cd69afb302b4f4dff67ac2.tar.gz
org.eclipse.cdt-2db4f5c708b159d096cd69afb302b4f4dff67ac2.tar.xz
org.eclipse.cdt-2db4f5c708b159d096cd69afb302b4f4dff67ac2.zip
[308540] - [expressions][update policy][cdi] Disabled expressions are still evaluated
Diffstat (limited to 'dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/DisabledExpressionVMNode.java163
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java6
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/MessagesForExpressionVM.java3
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/messages.properties3
4 files changed, 174 insertions, 1 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/DisabledExpressionVMNode.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/DisabledExpressionVMNode.java
new file mode 100644
index 00000000000..f1ab7a4b4b9
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/DisabledExpressionVMNode.java
@@ -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;
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java
index cebf3137d1c..edc462ff673 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java
@@ -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.
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/MessagesForExpressionVM.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/MessagesForExpressionVM.java
index b04d8ad18be..5579a1162a3 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/MessagesForExpressionVM.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/MessagesForExpressionVM.java
@@ -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);
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/messages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/messages.properties
index 9102d757a58..a2038e7a4af 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/messages.properties
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/messages.properties
@@ -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) \ No newline at end of file

Back to the top