Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Rennie2007-05-07 15:31:06 +0000
committerMichael Rennie2007-05-07 15:31:06 +0000
commit48090b1ab4475ad860a4c61ea2ad620136e6e865 (patch)
tree57086cf8d614c6baa8df1caf461735e080e17f82 /org.eclipse.debug.ui
parentbeff888fc4385573a69ba2594aefaf5b22612e8d (diff)
downloadeclipse.platform.debug-48090b1ab4475ad860a4c61ea2ad620136e6e865.tar.gz
eclipse.platform.debug-48090b1ab4475ad860a4c61ea2ad620136e6e865.tar.xz
eclipse.platform.debug-48090b1ab4475ad860a4c61ea2ad620136e6e865.zip
Bug 169438
[Debug Framework] DefaultVariableCellModifier doesn't call verifyValue
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java63
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java22
2 files changed, 45 insertions, 40 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java
index 8cab47360..db82aec58 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java
@@ -47,7 +47,44 @@ public class DetailPaneAssignValueAction extends Action{
private IViewSite fViewSite;
private ITextViewer fTextViewer;
private IStructuredSelection fCurrentSelection;
-
+
+ /**
+ * Attempts to evaluate the given string expression and assign the resulting value to the
+ * specified variable. Displays error dialogs to the user if a problem is encountered.
+ *
+ * @see DetailPaneAssignValueAction
+ * @see org.eclipse.debug.internal.ui.elements.adapters.DefaultVariableCellModifier
+ *
+ * @param shell the shell to use to open dialogs
+ * @param variable the variable that is getting a new value
+ * @param newValueExpression the expression to evaluate and set as the new value
+ * @since 3.3.0
+ */
+ public static void assignValue(Shell shell, IVariable variable, String newValueExpression){
+ String modelIdentifier = variable.getModelIdentifier();
+ IVariableValueEditor editor = VariableValueEditorManager.getDefault().getVariableValueEditor(modelIdentifier);
+ if (editor != null) {
+ if (editor.saveVariable(variable, newValueExpression, shell)) {
+ // If we successfully delegate to an editor which performs the save,
+ // don't do any more work.
+ return;
+ }
+ }
+
+ try {
+ // If we failed to delegate to anyone, perform the default assignment.
+ if (variable.verifyValue(newValueExpression)) {
+ variable.setValue(newValueExpression);
+ } else {
+ if (shell != null) {
+ DebugUIPlugin.errorDialog(shell, ActionMessages.DetailPaneAssignValueAction_2, MessageFormat.format(ActionMessages.DetailPaneAssignValueAction_3, new String[] {newValueExpression, variable.getName()}), new StatusInfo(IStatus.ERROR, ActionMessages.DetailPaneAssignValueAction_4)); //
+ }
+ }
+ } catch (DebugException e) {
+ MessageDialog.openError(shell, ActionMessages.DetailPaneAssignValueAction_0, e.getStatus().getMessage());
+ }
+ }
+
public DetailPaneAssignValueAction(ITextViewer textViewer, IViewSite viewSite) {
super(ActionMessages.DetailPaneAssignValueAction_1);
@@ -101,29 +138,7 @@ public class DetailPaneAssignValueAction extends Action{
activeShell= window.getShell();
}
- String modelIdentifier = variable.getModelIdentifier();
- IVariableValueEditor editor = VariableValueEditorManager.getDefault().getVariableValueEditor(modelIdentifier);
- if (editor != null) {
- if (editor.saveVariable(variable, value, activeShell)) {
- // If we successfully delegate to an editor which performs the save,
- // don't do any more work.
- return;
- }
- }
-
- try {
- // If we failed to delegate to anyone, perform the default assignment.
- if (variable.verifyValue(value)) {
- variable.setValue(value);
- } else {
- if (activeShell != null) {
- DebugUIPlugin.errorDialog(activeShell, ActionMessages.DetailPaneAssignValueAction_2, MessageFormat.format(ActionMessages.DetailPaneAssignValueAction_3, new String[] {value, variable.getName()}), new StatusInfo(IStatus.ERROR, ActionMessages.DetailPaneAssignValueAction_4)); //
- }
- }
- } catch (DebugException e) {
- MessageDialog.openError(activeShell, ActionMessages.DetailPaneAssignValueAction_0, e.getStatus().getMessage());
- }
-
+ assignValue(activeShell, variable, value);
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java
index ff566ca5c..346efdc21 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2007 IBM Corporation 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
@@ -14,8 +14,7 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
-import org.eclipse.debug.internal.ui.VariableValueEditorManager;
-import org.eclipse.debug.ui.actions.IVariableValueEditor;
+import org.eclipse.debug.internal.ui.actions.variables.details.DetailPaneAssignValueAction;
import org.eclipse.jface.viewers.ICellModifier;
/**
@@ -61,20 +60,11 @@ public class DefaultVariableCellModifier implements ICellModifier {
if (!value.equals(oldValue)) {
if (VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals(property)) {
if (element instanceof IVariable) {
- IVariable variable = (IVariable) element;
- IVariableValueEditor editor = VariableValueEditorManager.getDefault().getVariableValueEditor(variable.getModelIdentifier());
if (value instanceof String) {
- value = DefaultLabelProvider.encodeEsacpedChars((String)value);
- }
- if (editor != null) {
- if (editor.saveVariable(variable, (String) value, DebugUIPlugin.getShell())) {
- return;
- }
- }
- try {
- variable.setValue((String) value);
- } catch (DebugException e) {
- DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), Messages.VariableColumnPresentation_4, Messages.VariableColumnPresentation_5, e.getStatus());
+ // The value column displays special characters escaped, so encode the string with any special characters escaped properly
+ String valueExpression = DefaultLabelProvider.encodeEsacpedChars((String)value);
+ IVariable variable = (IVariable) element;
+ DetailPaneAssignValueAction.assignValue(DebugUIPlugin.getShell(), variable, valueExpression);
}
}
}

Back to the top