Author: dazarov
Date: 2009-10-04 12:32:44 -0400 (Sun, 04 Oct 2009)
New Revision: 17883
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4771
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-10-02
23:47:05 UTC (rev 17882)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-10-04
16:32:44 UTC (rev 17883)
@@ -16,22 +16,31 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.internal.ui.search.JavaSearchResultPage;
import org.eclipse.jdt.ui.search.ElementQuerySpecification;
import org.eclipse.jdt.ui.search.IMatchPresentation;
import org.eclipse.jdt.ui.search.IQueryParticipant;
import org.eclipse.jdt.ui.search.ISearchRequestor;
import org.eclipse.jdt.ui.search.QuerySpecification;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.search.internal.ui.util.FileLabelProvider;
+import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match;
+import org.eclipse.search2.internal.ui.SearchView;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.internal.Workbench;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELMethodInvocation;
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
import org.jboss.tools.seam.internal.core.refactoring.SeamRefactorSearcher;
public class SeamELReferencesQueryParticipant implements IQueryParticipant,
IMatchPresentation{
- SeamSearchViewLabelProvider labelProvider = new SeamSearchViewLabelProvider(null, 0);
private ELSearcher searcher;
+ private ELLabelProvider labelProvider;
+ JavaSearchResultPage searchPage = null;
public int estimateTicks(QuerySpecification specification) {
return 10;
@@ -44,6 +53,7 @@
public void search(ISearchRequestor requestor,
QuerySpecification querySpecification, IProgressMonitor monitor)
throws CoreException {
+
if(querySpecification instanceof ElementQuerySpecification){
ElementQuerySpecification qs = (ElementQuerySpecification)querySpecification;
if(qs.getElement() instanceof IMethod){
@@ -59,17 +69,88 @@
}
public ILabelProvider createLabelProvider() {
+ if(labelProvider == null){
+ if(searchPage == null){
+ IWorkbenchWindow[] windows = Workbench.getInstance().getWorkbenchWindows();
+ for(IWorkbenchWindow window : windows){
+ IWorkbenchPage[] pages = window.getPages();
+ for(IWorkbenchPage page : pages){
+ SearchView view =
(SearchView)page.findView("org.eclipse.search.ui.views.SearchView");
+ if(view.getActivePage() instanceof JavaSearchResultPage){
+ searchPage = (JavaSearchResultPage)view.getActivePage();
+ }
+ }
+ }
+ }
+ labelProvider = new ELLabelProvider(searchPage);
+ }
+
return labelProvider;
}
public void showMatch(Match match, int currentOffset,
int currentLength, boolean activate) throws PartInitException {
+ if(searchPage != null && match.getElement() instanceof FileWrapper){
+ FileWrapper wrapper = (FileWrapper)match.getElement();
+ Match nMatch = new Match(wrapper.getFile(), match.getOffset(), match.getLength());
+ searchPage.showMatch(nMatch, match.getOffset(), match.getLength(), activate);
+ }
}
+ class FileWrapper{
+ IFile file;
+ boolean resolved;
+ public FileWrapper(IFile file, boolean resolved) {
+ this.file = file;
+ this.resolved = resolved;
+ }
+
+ public IFile getFile(){
+ return file;
+ }
+
+ public boolean isResolved(){
+ return resolved;
+ }
+
+ }
+
+ class ELLabelProvider extends SeamSearchViewLabelProvider{
+
+
+ public ELLabelProvider(AbstractTextSearchViewPage page) {
+ super(page, FileLabelProvider.SHOW_PATH_LABEL);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if(element instanceof FileWrapper){
+ FileWrapper wrapper = (FileWrapper)element;
+ IFile file = wrapper.getFile();
+ String text = super.getText(file);
+ if(!wrapper.isResolved())
+ // TODO: find good phrase and externalize it
+ text += " (not resolved)";
+ return text;
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof FileWrapper){
+ FileWrapper wrapper = (FileWrapper)element;
+ IFile file = wrapper.getFile();
+ return super.getImage(file);
+ }
+ return super.getImage(element);
+ }
+ }
+
class ELSearcher extends SeamRefactorSearcher{
ISearchRequestor requestor;
public ELSearcher(ISearchRequestor requestor, IJavaElement element, IFile file, String
name){
- super(file, name/*, element*/);
+ super(file, name, element);
this.requestor = requestor;
}
@@ -87,7 +168,7 @@
@Override
protected void match(IFile file, int offset, int length, boolean resolved) {
- Match match = new Match(file, offset, length);
+ Match match = new Match(new FileWrapper(file, resolved), offset, length);
requestor.reportMatch(match);
}
@@ -106,5 +187,4 @@
return null;
}
}
-
}