Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2005-01-27 00:48:49 +0000
committerJared Burns2005-01-27 00:48:49 +0000
commit4231b6ff78ff74521329751ac5ac1b82ad0dd47c (patch)
tree41f0e2c0df6603df6056e8cb81d1ff9738dd7e53
parentafd5d41ef31757a7d56c4075e2fa528b1d11d467 (diff)
downloadeclipse.platform.debug-4231b6ff78ff74521329751ac5ac1b82ad0dd47c.tar.gz
eclipse.platform.debug-4231b6ff78ff74521329751ac5ac1b82ad0dd47c.tar.xz
eclipse.platform.debug-4231b6ff78ff74521329751ac5ac1b82ad0dd47c.zip
Bug 75849 - Support for search in variables view.
-rw-r--r--org.eclipse.debug.ui/plugin.properties1
-rw-r--r--org.eclipse.debug.ui/plugin.xml6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java45
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java210
5 files changed, 266 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index 03cd7feaf..0c25afb89 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -107,6 +107,7 @@ RunHistoryMenuAction.label=Run His&tory
RunWithConfigurationAction.label=R&un As
RunToLine.label=Run to &Line
SelectAll.label=Select &All
+FindVariable.label=&Find Variable...
StepWithFiltersAction.label=Use Step &Filters
StepWithFiltersAction.tooltip=Use Step Filters/Step Debug
StepIntoAction.label=Step &Into
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index c12c749ad..7c47f098b 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -1229,6 +1229,12 @@
menubarPath="variableGroup"
id="org.eclipse.debug.ui.actions.SelectAllVariablesAction">
</action>
+ <action
+ helpContextId="find_variable_action_context"
+ label="%FindVariable.label"
+ class="org.eclipse.debug.internal.ui.actions.FindVariableAction"
+ menubarPath="variableGroup"
+ id="org.eclipse.debug.ui.actions.FindVariableAction"/>
</viewerContribution>
<!-- Contributions to Expression View Popup Menu -->
<viewerContribution
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties
index 1cba04436..8d3b6860f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties
@@ -139,3 +139,7 @@ ModifyWatchpointAction.0=Error
ModifyWatchpointAction.1=Failed to modify watchpoint
LaunchShortcutsAction.0={0} As
LaunchShortcutsAction.1=(none applicable)
+FindVariableDialog.0=An exception occurred computing variable name. See log for details.
+FindVariableDialog.1=&Select a variable to display (? = any character, * = any String):
+FindVariableDialog.2=&Matching variables:
+FindVariableDialog.3=Find Variable
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java
new file mode 100644
index 000000000..d84fd9cc7
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.internal.ui.actions;
+
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * Action which prompts the user to help them find a variable in
+ * the variables view.
+ */
+public class FindVariableAction implements IViewActionDelegate {
+
+ private VariablesView fView;
+
+ public FindVariableAction() {
+ super();
+ }
+
+ public void init(IViewPart view) {
+ fView= (VariablesView) view;
+ }
+
+ public void run(IAction action) {
+ Shell shell = fView.getSite().getShell();
+ FindVariableDialog dialog= new FindVariableDialog(shell, fView);
+ dialog.open();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java
new file mode 100644
index 000000000..3fcd3a153
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * 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.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.views.DebugViewDecoratingLabelProvider;
+import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider;
+import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator;
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
+import org.eclipse.debug.internal.ui.views.variables.VariablesViewer;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.internal.ide.StringMatcher;
+
+public class FindVariableDialog extends Dialog {
+
+ private TableViewer fViewer;
+ private VariablesView fView;
+ private Text fText;
+ private StringMatcher fMatcher;
+ private int fTextLength;
+
+ private class FindVariableContentProvider implements IStructuredContentProvider {
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public Object[] getElements(Object inputElement) {
+ return getVariables(((VariablesViewer) fView.getViewer()).getTree().getItems());
+ }
+ private IVariable[] getVariables(TreeItem[] items) {
+ List variables= new ArrayList();
+ getVariables(items, variables);
+ return (IVariable[]) variables.toArray(new IVariable[variables.size()]);
+ }
+ private void getVariables(TreeItem[] items, List variables) {
+ for (int i = 0; i < items.length; i++) {
+ Object data = items[i].getData();
+ if (data instanceof IVariable) {
+ variables.add(data);
+ }
+ getVariables(items[i].getItems(), variables);
+ }
+ }
+ }
+
+ private class FindVariableFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (fMatcher == null) {
+ return true;
+ }
+ try {
+ String name= ((IVariable) element).getName();
+ fMatcher.match(name, 0, fTextLength - 1);
+ return fMatcher.match(name);
+ } catch (DebugException e) {
+ }
+ return false;
+ }
+ }
+
+ private class FindVariableModelPresentation implements IDebugModelPresentation {
+ public Image getImage(Object element) {
+ IVariable variable= (IVariable) element;
+ IDebugModelPresentation presentation= fView.getPresentation(variable.getModelIdentifier());
+ return presentation.getImage(element);
+ }
+ public String getText(Object element) {
+ try {
+ return ((IVariable) element).getName();
+ } catch (DebugException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ return ActionMessages.getString("FindVariableDialog.0"); //$NON-NLS-1$
+ }
+ public void setAttribute(String attribute, Object value) {}
+ public void computeDetail(IValue value, IValueDetailListener listener) {}
+ public void addListener(ILabelProviderListener listener) {}
+ public void dispose() {}
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {}
+ public IEditorInput getEditorInput(Object element) {
+ return null;
+ }
+ public String getEditorId(IEditorInput input, Object element) {
+ return null;
+ }
+ }
+
+ protected FindVariableDialog(Shell parentShell, VariablesView view) {
+ super(parentShell);
+ fView= view;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite= (Composite) super.createDialogArea(parent);
+
+ Label label= new Label(composite, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ label.setFont(parent.getFont());
+ label.setText(ActionMessages.getString("FindVariableDialog.1")); //$NON-NLS-1$
+
+ fText= new Text(composite, SWT.SINGLE);
+ fText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fText.setFont(parent.getFont());
+ fText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ textModified();
+ }
+ });
+
+ label= new Label(composite, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ label.setFont(parent.getFont());
+ label.setText(ActionMessages.getString("FindVariableDialog.2")); //$NON-NLS-1$
+
+ fViewer= new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ Table table = fViewer.getTable();
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint= 200;
+ table.setLayoutData(gridData);
+ table.setFont(parent.getFont());
+ fViewer.setContentProvider(new FindVariableContentProvider());
+ fViewer.addFilter(new FindVariableFilter());
+ fViewer.setInput(new Object());
+ FindVariableModelPresentation presentation = new FindVariableModelPresentation();
+ ILabelProvider provider= new DebugViewDecoratingLabelProvider(fViewer, new DebugViewInterimLabelProvider(presentation), new DebugViewLabelDecorator(presentation));
+ fViewer.setLabelProvider(provider);
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ selectionChanged();
+ }
+ });
+
+ return composite;
+ }
+
+ private void textModified() {
+ StringBuffer text = new StringBuffer(fText.getText());
+ if (text.length() == 0 || text.charAt(text.length() - 1) != '*') {
+ text.append("*"); //$NON-NLS-1$
+ }
+ fMatcher= new StringMatcher(text.toString(), true, false);
+ fTextLength= text.length();
+ fViewer.refresh(false);
+ if (((IStructuredSelection) fViewer.getSelection()).isEmpty()) {
+ Table table= fViewer.getTable();
+ if (table.getItemCount() > 0) {
+ fViewer.setSelection(new StructuredSelection(table.getItem(0).getData()));
+ selectionChanged();
+ }
+ }
+ }
+
+ private void selectionChanged() {
+ fView.getViewer().setSelection(fViewer.getSelection(), true);
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+ true);
+ }
+
+ protected void configureShell(Shell newShell) {
+ newShell.setText(ActionMessages.getString("FindVariableDialog.3")); //$NON-NLS-1$
+ super.configureShell(newShell);
+ }
+
+}

Back to the top