1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Select first match in search results, bug 210446.

This commit is contained in:
Markus Schorn 2007-12-10 13:32:42 +00:00
parent 45b020487a
commit 39358ec2b9
2 changed files with 24 additions and 21 deletions

View file

@ -6,13 +6,17 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Path;
import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.browser.IndexTypeInfo; import org.eclipse.cdt.core.browser.IndexTypeInfo;
@ -26,7 +30,7 @@ import org.eclipse.cdt.core.index.IIndexName;
* *
* @author Doug Schaefer * @author Doug Schaefer
*/ */
public class PDOMSearchElement { public class PDOMSearchElement implements IAdaptable {
private final ITypeInfo typeInfo; private final ITypeInfo typeInfo;
private final IIndexFileLocation location; private final IIndexFileLocation location;
@ -58,4 +62,15 @@ public class PDOMSearchElement {
IIndexFileLocation getLocation() { IIndexFileLocation getLocation() {
return location; return location;
} }
public Object getAdapter(Class adapterType) {
if (adapterType.isAssignableFrom(IFile.class)) {
String fullPath= location.getFullPath();
if (fullPath != null) {
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fullPath));
}
}
return null;
}
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
@ -26,8 +26,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.index.IndexLocationFactory;
@ -145,24 +143,14 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
remove(element); remove(element);
} }
} }
if (!viewer.getTree().isDisposed()) {
Display d= PlatformUI.getWorkbench().getDisplay(); viewer.refresh();
d.asyncExec(new Runnable() { }
public void run() {
if (!viewer.getTree().isDisposed()) {
viewer.refresh();
}
}
});
} }
public void clear() { public void clear() {
tree.clear(); tree.clear();
Display.getDefault().asyncExec(new Runnable() { viewer.refresh();
public void run() {
viewer.refresh();
}
});
} }
protected void remove(Object element) { protected void remove(Object element) {