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:
parent
45b020487a
commit
39358ec2b9
2 changed files with 24 additions and 21 deletions
|
@ -12,7 +12,11 @@
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,25 +143,15 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
remove(element);
|
remove(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Display d= PlatformUI.getWorkbench().getDisplay();
|
|
||||||
d.asyncExec(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!viewer.getTree().isDisposed()) {
|
if (!viewer.getTree().isDisposed()) {
|
||||||
viewer.refresh();
|
viewer.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
tree.clear();
|
tree.clear();
|
||||||
Display.getDefault().asyncExec(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
viewer.refresh();
|
viewer.refresh();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void remove(Object element) {
|
protected void remove(Object element) {
|
||||||
Object parent = getParent(element);
|
Object parent = getParent(element);
|
||||||
|
|
Loading…
Add table
Reference in a new issue