diff options
author | Michael Rennie | 2006-02-22 19:32:08 +0000 |
---|---|---|
committer | Michael Rennie | 2006-02-22 19:32:08 +0000 |
commit | cd1d720036d6151915d70399fd512fc9ac84516b (patch) | |
tree | 5ed1ab9361f4f64b73e0e34aba3fb49f44650288 /org.eclipse.debug.ui/ui/org/eclipse | |
parent | bfc840dea75541effc64c61f11c12579e72c7071 (diff) | |
download | eclipse.platform.debug-cd1d720036d6151915d70399fd512fc9ac84516b.tar.gz eclipse.platform.debug-cd1d720036d6151915d70399fd512fc9ac84516b.tar.xz eclipse.platform.debug-cd1d720036d6151915d70399fd512fc9ac84516b.zip |
bug fix for 128534
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse')
3 files changed, 131 insertions, 15 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java new file mode 100644 index 000000000..faebed41a --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.launchConfigurations; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; +import org.eclipse.ui.progress.WorkbenchJob; + +/** + * extension of <code>FilteredTree</code> to allow us to update the filtering label and maintain selection + * @since 3.2 + */ +public class LaunchConfigurationFilteredTree extends FilteredTree { + + private final ILaunchConfigurationDialog fDialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog(); + private Job fRefreshJob; + + /** + * Constructor + * @param parent the parent for this control + * @param treeStyle the style fo the tree + * @param filter the initial pattern filter + */ + public LaunchConfigurationFilteredTree(Composite parent, int treeStyle, PatternFilter filter) { + super(parent, treeStyle, filter); + createRefreshJob(); + } + + /** + * Create the refresh job for the receiver. + */ + private void createRefreshJob() { + fRefreshJob = new WorkbenchJob("Refresh Filter"){//$NON-NLS-1$ + public IStatus runInUIThread(IProgressMonitor monitor) { + if(!treeViewer.getControl().isDisposed()) { + String text = getFilterString(); + if (text == null) { + return Status.OK_STATUS; + } + boolean initial = initialText != null && initialText.equals(text); + if (initial) { + getPatternFilter().setPattern(null); + } + else { + getPatternFilter().setPattern(text); + } + boolean update = text.length() > 0 && !initial; + updateToolbar(update); + treeViewer.refresh(true); + if(fDialog != null && fDialog instanceof LaunchConfigurationsDialog) { + treeViewer.expandAll(); + ((LaunchConfigurationsDialog)fDialog).refreshFilteringLabel(); + } + return Status.OK_STATUS; + } + return Status.CANCEL_STATUS; + } + }; + fRefreshJob.setSystem(true); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.FilteredTree#textChanged() + */ + protected void textChanged() { + if(fRefreshJob != null) { + fRefreshJob.schedule(); + } + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java index 7c53886bd..82e013b63 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2006 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 @@ -44,9 +44,9 @@ import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.model.WorkbenchViewerSorter; @@ -55,9 +55,26 @@ import org.eclipse.ui.model.WorkbenchViewerSorter; */ public class LaunchConfigurationView extends AbstractDebugView implements ILaunchConfigurationListener { + /** + * the viewer from the view + */ private Viewer fViewer; /** + * the filtering tree viewer + * + * @since 3.2 + */ + private LaunchConfigurationFilteredTree fTree; + + /** + * a handle to the launch manager + * + * @since 3.2 + */ + private ILaunchManager fLaunchManager = DebugPlugin.getDefault().getLaunchManager(); + + /** * The launch group to display */ private LaunchGroupExtension fLaunchGroup; @@ -68,6 +85,7 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc private CreateLaunchConfigurationAction fCreateAction; private DeleteLaunchConfigurationAction fDeleteAction; private DuplicateLaunchConfigurationAction fDuplicateAction; + /** * Action for providing filtering to the Launch Configuraiton Dialog * @since 3.2 @@ -100,9 +118,9 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc * @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite) */ protected Viewer createViewer(Composite parent) { - FilteredTree tree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter()); - tree.setBackground(new Color(parent.getDisplay(), 255, 255, 255)); - TreeViewer treeViewer = tree.getViewer(); + fTree = new LaunchConfigurationFilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter()); + fTree.setBackground(new Color(parent.getDisplay(), 255, 255, 255)); + TreeViewer treeViewer = fTree.getViewer(); treeViewer.setLabelProvider(DebugUITools.newDebugModelPresentation()); treeViewer.setSorter(new WorkbenchViewerSorter()); treeViewer.setContentProvider(new LaunchConfigurationTreeContentProvider(fLaunchGroup.getMode(), parent.getShell())); @@ -159,6 +177,20 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc return super.getAdapter(key); } + /** + * gets the filtering text control from the viewer + * @return the filtering text control + * + * @since 3.2 + */ + public Text getFilteringTextControl() { + return fTree.getFilterControl(); + } + + /** + * Computes the context id for this viewer + * @return the context id + */ private String computeContextId() { try { ISelection selection = getViewer().getSelection(); @@ -168,7 +200,8 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc ILaunchConfigurationType configType = null; if (firstSelected instanceof ILaunchConfigurationType) { configType = (ILaunchConfigurationType) firstSelected; - } else if (firstSelected instanceof ILaunchConfiguration) { + } + else if (firstSelected instanceof ILaunchConfiguration) { configType = ((ILaunchConfiguration) firstSelected).getType(); } if (configType != null) { @@ -178,9 +211,8 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc } } } - } catch (CoreException ce) { - DebugUIPlugin.log(ce); - } + } + catch (CoreException ce) {DebugUIPlugin.log(ce);} return null; } @@ -394,8 +426,6 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc } } - - /** * @see org.eclipse.debug.ui.IDebugView#getViewer() */ @@ -403,8 +433,12 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc return fViewer; } + /** + * returns the launch manager + * @return + */ protected ILaunchManager getLaunchManager() { - return DebugPlugin.getDefault().getLaunchManager(); + return fLaunchManager; } /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java index 23f3d19ed..274ba1492 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java @@ -692,9 +692,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun viewForm.setContent(viewFormContents); fFilteringLabel = new Label(viewFormContents, SWT.NONE); - gd = new GridData(GridData.FILL_HORIZONTAL | SWT.BEGINNING); - gd.horizontalIndent = 5; - fFilteringLabel.setLayoutData(gd); + fFilteringLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | SWT.BEGINNING)); fFilteringLabel.setBackground(new Color(parent.getDisplay(), 255, 255, 255)); refreshFilteringLabel(); |