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
|
@ -6,13 +6,17 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
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.IAdaptable;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.IndexTypeInfo;
|
||||
|
@ -26,7 +30,7 @@ import org.eclipse.cdt.core.index.IIndexName;
|
|||
*
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMSearchElement {
|
||||
public class PDOMSearchElement implements IAdaptable {
|
||||
|
||||
private final ITypeInfo typeInfo;
|
||||
private final IIndexFileLocation location;
|
||||
|
@ -58,4 +62,15 @@ public class PDOMSearchElement {
|
|||
IIndexFileLocation getLocation() {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
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.TreeViewer;
|
||||
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.IndexLocationFactory;
|
||||
|
@ -145,24 +143,14 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
remove(element);
|
||||
}
|
||||
}
|
||||
|
||||
Display d= PlatformUI.getWorkbench().getDisplay();
|
||||
d.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (!viewer.getTree().isDisposed()) {
|
||||
viewer.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!viewer.getTree().isDisposed()) {
|
||||
viewer.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
tree.clear();
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
viewer.refresh();
|
||||
}
|
||||
});
|
||||
viewer.refresh();
|
||||
}
|
||||
|
||||
protected void remove(Object element) {
|
||||
|
|
Loading…
Add table
Reference in a new issue