Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2004-11-15 19:52:23 +0000
committerJared Burns2004-11-15 19:52:23 +0000
commit03f923aea2f81ae135343ce72d86085bcc8253f2 (patch)
tree989628f02890251604c38fba54739e8d7c83ca30 /org.eclipse.debug.ui
parentc1098be33d4e1b5e350b22d8f4c3ad5e3abcc392 (diff)
downloadeclipse.platform.debug-03f923aea2f81ae135343ce72d86085bcc8253f2.tar.gz
eclipse.platform.debug-03f923aea2f81ae135343ce72d86085bcc8253f2.tar.xz
eclipse.platform.debug-03f923aea2f81ae135343ce72d86085bcc8253f2.zip
Bug 75851 - Custom variable edit widget
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/plugin.properties2
-rw-r--r--org.eclipse.debug.ui/plugin.xml3
-rw-r--r--org.eclipse.debug.ui/schema/variableValueEditors.exsd117
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ChangeVariableValueAction.java126
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java14
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java39
7 files changed, 273 insertions, 30 deletions
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index c73135b17..b0bf4de64 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -26,6 +26,8 @@ ConsolePreferencePage.name=Console
DebugModelContextBindingsName=Debug Model Context Bindings
DebugModelActivityBindingsName=Debug Model Activity Bindings
ContextViewBindingsName=Context View Bindings
+BreakpointContainerFactoriesName=Breakpoint Container Factories
+VariableValueEditorsName=Variable Value Editors
BreakpointActionSet.label=Breakpoints
CollapseAll.label=Collapse All
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 6acf64b6c..c04c07bb9 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -40,7 +40,8 @@
<extension-point id="sourceContainerPresentations" name="%SourceContainerPresentationsName" schema="schema/sourceContainerPresentations.exsd"/>
<extension-point id="debugModelContextBindings" name="%DebugModelContextBindingsName" schema="schema/debugModelContextBindings.exsd"/>
<extension-point id="contextViewBindings" name="%ContextViewBindingsName" schema="schema/contextViewBindings.exsd"/>
- <extension-point id="breakpointContainerFactories" name="Breakpoint Container Factories" schema="schema/breakpointContainerFactories.exsd"/>
+ <extension-point id="breakpointContainerFactories" name="%BreakpointContainerFactoriesName" schema="schema/breakpointContainerFactories.exsd"/>
+ <extension-point id="variableValueEditors" name="%VariableValueEditorsName" schema="schema/variableValueEditors.exsd"/>
<!-- Extensions -->
<extension
diff --git a/org.eclipse.debug.ui/schema/variableValueEditors.exsd b/org.eclipse.debug.ui/schema/variableValueEditors.exsd
new file mode 100644
index 000000000..69acd5733
--- /dev/null
+++ b/org.eclipse.debug.ui/schema/variableValueEditors.exsd
@@ -0,0 +1,117 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.debug.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.debug.ui" id="variableValueEditors" name="Variable Value Editors"/>
+ </appInfo>
+ <documentation>
+ This extension point provides a mechanism for contributing variable value editors for a particular debug model. When the user invokes the &quot;Change Value...&quot; action on a variable in the Variables view, the contributed &lt;code&gt;org.eclipse.debug.ui.actions.IVariableValueEditor&lt;/code&gt; will be invoked to change the value.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="variableValueEditor"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="variableValueEditor">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Implementation of org.eclipse.debug.ui.actions.IVariableValueEditor
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="modelId" type="string" use="required">
+ <annotation>
+ <documentation>
+ The debug model identifier for which the given variable value editor is applicable.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;pre&gt;
+ &lt;extension
+ point=&quot;org.eclipse.debug.ui.variableValueEditors&quot;&gt;
+ &lt;variableEditor
+ modelId=&quot;com.examples.myDebugModel&quot;
+ class=&quot;com.examples.variables.MyVariableValueEditor&quot;/&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Value of the attribute &lt;b&gt;class&lt;/b&gt; must be a fully qualified name of a Java class that implements the interface &lt;b&gt;org.eclipse.debug.ui.actions.IVariableValueEditor&lt;/b&gt;.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2004 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Common Public License v1.0 which
+accompanies this distribution, and is available at
+&lt;a href=&quot;http://www.eclipse.org/legal/cpl-v10.html&quot;&gt;http://www.eclipse.org/legal/cpl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ChangeVariableValueAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ChangeVariableValueAction.java
index 5268092c1..c01acb403 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ChangeVariableValueAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ChangeVariableValueAction.java
@@ -12,8 +12,14 @@ package org.eclipse.debug.internal.ui.actions;
import java.text.MessageFormat;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValueModification;
import org.eclipse.debug.core.model.IVariable;
@@ -21,26 +27,38 @@ import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.actions.IVariableValueEditor;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.help.WorkbenchHelp;
/**
* Action for changing the value of primitives and <code>String</code> variables.
+ * This action will attempt to delegate the editing operation to a registered
+ * variable value editor, if any is provided for the variable's debug model.
+ * @see org.eclipse.debug.ui.actions.IVariableValueEditor
*/
public class ChangeVariableValueAction extends SelectionProviderAction {
-
- private ChangeVariableValueInputDialog fInputDialog;
+
protected IVariable fVariable;
+ private VariablesView fView;
+ private boolean fEditing= false;
+ /**
+ * Mapping of debug model identifiers to variable value editors.
+ * The keys in this map are always Strings (model ids).
+ * The values in the map are IConfigurationElements at startup,
+ * which are replaced by IVariableValueEditors as the editors
+ * are instantiated (editors are loaded lazily, then cached).
+ */
+ private Map fEditorMap= new HashMap();
- public ChangeVariableValueAction(Viewer viewer) {
- super(viewer, ActionMessages.getString("ChangeVariableValue.title")); //$NON-NLS-1$
+ public ChangeVariableValueAction(VariablesView view) {
+ super(view.getViewer(), ActionMessages.getString("ChangeVariableValue.title")); //$NON-NLS-1$
setDescription(ActionMessages.getString("ChangeVariableValue.toolTipText")); //$NON-NLS-1$
setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_CHANGE_VARIABLE_VALUE));
setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_CHANGE_VARIABLE_VALUE));
@@ -48,35 +66,90 @@ public class ChangeVariableValueAction extends SelectionProviderAction {
WorkbenchHelp.setHelp(
this,
IDebugHelpContextIds.CHANGE_VALUE_ACTION);
+ fView= view;
+ loadVariableEditors();
+ }
+
+ /**
+ * Loads contributors to the org.eclipse.debug.ui.variableValueEditors extension point,
+ * for use when the user runs this action.
+ */
+ private void loadVariableEditors() {
+ IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.EXTENSION_POINT_VARIABLE_VALUE_EDITORS);
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ String modelId = element.getAttribute("modelId"); //$NON-NLS-1$
+ if (modelId != null) {
+ fEditorMap.put(modelId, element);
+ }
+ }
}
/**
* Edit the variable value with an inline text editor.
*/
protected void doActionPerformed(final IVariable variable) {
- IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow();
- if (window == null) {
- return;
- }
- Shell activeShell= window.getShell();
-
- // If a previous edit is still in progress, don't start another
- if (fInputDialog != null) {
- return;
- }
-
+ Shell shell = fView.getViewSite().getShell();
+
+ // If a previous edit is still in progress, don't start another
+ if (fEditing) {
+ return;
+ }
+ fEditing= true;
fVariable = variable;
- String name= ""; //$NON-NLS-1$
+ if (!delegateEdit(shell)) {
+ doDefaultEdit(shell);
+ }
+ fEditing= false;
+ }
+
+ /**
+ * Attempts to edit the variable by delegating to anyone who's
+ * contributed a variable value editor via extension. Returns
+ * <code>true</code> if a delegate handled the edit, <code>false</code>
+ * if the variable still needs to be edited.
+ *
+ * @param shell a shell for prompting the user
+ * @return whether or not a delegate attempted to edit the variable
+ */
+ private boolean delegateEdit(Shell shell) {
+ String modelIdentifier = fVariable.getModelIdentifier();
+ Object object = fEditorMap.get(modelIdentifier);
+ IVariableValueEditor editor= null;
+ if (object instanceof IVariableValueEditor) {
+ editor= (IVariableValueEditor) object;
+ } else if (object instanceof IConfigurationElement) {
+ try {
+ editor = (IVariableValueEditor) ((IConfigurationElement) object).createExecutableExtension("class"); //$NON-NLS-1$
+ fEditorMap.put(modelIdentifier, editor);
+ } catch (CoreException e) {
+ // If an exception occurs, loading the extension, just log it and
+ // return false to use the default editor.
+ DebugUIPlugin.log(e);
+ }
+ }
+ if (editor != null) {
+ return editor.editVariable(fVariable, shell);
+ }
+ return false;
+ }
+
+ /**
+ * Edits the variable using the default variable editor
+ * @param shell a shell for prompting the user
+ */
+ protected void doDefaultEdit(Shell shell) {
+ String name= ""; //$NON-NLS-1$
String value= ""; //$NON-NLS-1$
try {
name= fVariable.getName();
value= fVariable.getValue().getValueString();
} catch (DebugException exception) {
- DebugUIPlugin.errorDialog(activeShell, ActionMessages.getString("ChangeVariableValue.errorDialogTitle"),ActionMessages.getString("ChangeVariableValue.errorDialogMessage"), exception); //$NON-NLS-2$ //$NON-NLS-1$
- fInputDialog= null;
+ DebugUIPlugin.errorDialog(shell, ActionMessages.getString("ChangeVariableValue.errorDialogTitle"),ActionMessages.getString("ChangeVariableValue.errorDialogMessage"), exception); //$NON-NLS-2$ //$NON-NLS-1$
return;
}
- fInputDialog= new ChangeVariableValueInputDialog(activeShell, ActionMessages.getString("ChangeVariableValue.1"), MessageFormat.format(ActionMessages.getString("ChangeVariableValue.2"), new String[] {name}), value, new IInputValidator() { //$NON-NLS-1$ //$NON-NLS-2$
+ ChangeVariableValueInputDialog inputDialog= new ChangeVariableValueInputDialog(shell, ActionMessages.getString("ChangeVariableValue.1"), MessageFormat.format(ActionMessages.getString("ChangeVariableValue.2"), new String[] {name}), value, new IInputValidator() { //$NON-NLS-1$ //$NON-NLS-2$
/**
* Returns an error string if the input is invalid
*/
@@ -92,20 +165,17 @@ public class ChangeVariableValueAction extends SelectionProviderAction {
}
});
- fInputDialog.open();
- String newValue= fInputDialog.getValue();
+ inputDialog.open();
+ String newValue= inputDialog.getValue();
if (newValue != null) {
// null value means cancel was pressed
try {
fVariable.setValue(newValue);
- getSelectionProvider().setSelection(new StructuredSelection(variable));
+ getSelectionProvider().setSelection(new StructuredSelection(fVariable));
} catch (DebugException de) {
- DebugUIPlugin.errorDialog(activeShell, ActionMessages.getString("ChangeVariableValue.errorDialogTitle"),ActionMessages.getString("ChangeVariableValue.errorDialogMessage"), de); //$NON-NLS-2$ //$NON-NLS-1$
- fInputDialog= null;
- return;
+ DebugUIPlugin.errorDialog(shell, ActionMessages.getString("ChangeVariableValue.errorDialogTitle"),ActionMessages.getString("ChangeVariableValue.errorDialogMessage"), de); //$NON-NLS-2$ //$NON-NLS-1$
}
}
- fInputDialog= null;
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
index 084ef8db2..7bb2bf896 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
@@ -797,7 +797,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
action = new CollapseAllAction(getVariablesViewer());
setAction("CollapseAll", action); //$NON-NLS-1$
- action = new ChangeVariableValueAction(getViewer());
+ action = new ChangeVariableValueAction(this);
action.setEnabled(false);
setAction("ChangeVariableValue", action); //$NON-NLS-1$
setAction(DOUBLE_CLICK_ACTION, action);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
index 6861a068e..17504d508 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
@@ -937,6 +937,20 @@ public interface IDebugUIConstants {
*/
public static final String EXTENSION_POINT_LAUNCH_VARIABLE_COMPONENTS = "launchVariableComponents"; //$NON-NLS-1$
+ /**
+ * Breakpoint container factories extension point identifier (value
+ * <code>"breakpointContainerFactories"</code>
+ *
+ * @since 3.1
+ */
public static final String EXTENSION_POINT_BREAKPOINT_CONTAINER_FACTORIES = "breakpointContainerFactories"; //$NON-NLS-1$
+
+ /**
+ * Variable value editors extension point identifier (value
+ * <code>"variableValueEditors"</code>
+ *
+ * @since 3.1
+ */
+ public static final String EXTENSION_POINT_VARIABLE_VALUE_EDITORS = "variableValueEditors"; //$NON-NLS-1$
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java
new file mode 100644
index 000000000..f4db8ecc1
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IVariableValueEditor.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.actions;
+
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A variable value editor allows the user to edit a variable's value.
+ * Variable value editors are contributed for a debug model via the
+ * org.eclipse.debug.ui.variableValueEditors extension point.
+ *
+ * @since 3.1
+ */
+public interface IVariableValueEditor {
+
+ /**
+ * Edits the given variable, if appropriate. If this editor does not apply to
+ * the given variable this method returns false, which indicates that the
+ * Debug Platform's default variable edit dialog should be used.
+ *
+ * @param variable the variable to edit
+ * @param shell the currently active shell, which can be used to open a dialog
+ * for the user
+ * @return whether this editor has completed the edit operation for the given variable.
+ * <code>true</code> if no more work should be done, <code>false</code> if the debug
+ * platform should prompt the user to edit the given variable using the default
+ * variable editor.
+ */
+ public boolean editVariable(IVariable variable, Shell shell);
+}

Back to the top