Author: dazarov
Date: 2011-04-15 19:55:47 -0400 (Fri, 15 Apr 2011)
New Revision: 30619
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIBeanQueryParticipant.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIElementWrapper.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIMatch.java
Removed:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/BeanMatch.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/EventMatch.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatch.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/ObserverMethodMatch.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointLabelProvider.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatchPresentation.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java
Log:
https://issues.jboss.org/browse/JBIDE-8705
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -17,7 +17,7 @@
*
* @author Alexey Kazakov
*/
-public interface IBeanMember extends IJavaSourceReference, IAnnotated {
+public interface IBeanMember extends IJavaSourceReference, IAnnotated, ICDIElement {
/**
* Returns the class bean that declares this method.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2011-04-15 23:49:05 UTC (rev
30618)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/plugin.xml 2011-04-15 23:55:47 UTC (rev
30619)
@@ -117,6 +117,15 @@
nature="org.jboss.tools.cdi.core.cdinature">
</queryParticipant>
</extension>
+ <extension
+ point="org.eclipse.jdt.ui.queryParticipants">
+ <queryParticipant
+ class="org.jboss.tools.cdi.ui.search.CDIBeanQueryParticipant"
+ id="org.jboss.tools.cdi.ui.search.CDIBeanQueryParticipant"
+ name="cdi-BeanReferencesParticipant"
+ nature="org.jboss.tools.cdi.core.cdinature">
+ </queryParticipant>
+ </extension>
<!-- Refactorng -->
<extension
point="org.eclipse.ui.menus">
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -24,6 +24,11 @@
public static String INJECTION_POINT_LABEL_PROVIDER_OBSERVER_METHOD;
public static String INJECTION_POINT_LABEL_PROVIDER_EVENT;
+ public static String CDI_BEAN_QUERY_PARTICIPANT_TASK;
+ public static String CDI_BEAN_QUERY_PARTICIPANT_INJECT_FIELD;
+ public static String CDI_BEAN_QUERY_PARTICIPANT_INJECT_METHOD;
+ public static String CDI_BEAN_QUERY_PARTICIPANT_INJECT_PARAMETER;
+
public static String CDI_UI_IMAGESBASE_URL_FOR_IMAGE_REGISTRY_CANNOT_BE_NULL;
public static String CDI_UI_IMAGESIMAGE_NAME_CANNOT_BE_NULL;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-04-15
23:55:47 UTC (rev 30619)
@@ -10,8 +10,14 @@
##################################################################################
INJECTION_POINT_LABEL_PROVIDER_INJECT_BEAN=@Inject Bean ''{0}''
-INJECTION_POINT_LABEL_PROVIDER_OBSERVER_METHOD=CDI Observer Method
''{0}.{1}()''
-INJECTION_POINT_LABEL_PROVIDER_EVENT=CDI Event ''{0}.{1}''
+INJECTION_POINT_LABEL_PROVIDER_OBSERVER_METHOD=CDI Observer Method
''{0}''
+INJECTION_POINT_LABEL_PROVIDER_EVENT=CDI Event ''{0}''
+
+CDI_BEAN_QUERY_PARTICIPANT_TASK=Searching CDI Injection Points...
+CDI_BEAN_QUERY_PARTICIPANT_INJECT_FIELD=@Inject Filed ''{0}''
+CDI_BEAN_QUERY_PARTICIPANT_INJECT_METHOD=@Inject Method ''{0}''
+CDI_BEAN_QUERY_PARTICIPANT_INJECT_PARAMETER=@Inject Parameter ''{0}''
+
CDI_UI_IMAGESBASE_URL_FOR_IMAGE_REGISTRY_CANNOT_BE_NULL=Base url for image registry
cannot be null.
CDI_UI_IMAGESIMAGE_NAME_CANNOT_BE_NULL=Image name cannot be null.
CDI_REFACTOR_CONTRIBUTOR_MENU_NAME=CDI Refactor
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -26,6 +26,7 @@
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageDeclaration;
@@ -35,6 +36,7 @@
import org.eclipse.jdt.core.ITypeParameter;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.SourceRange;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
@@ -311,6 +313,41 @@
}
}
+ public static ISourceRange getParameterRegion(IInjectionPointParameter
injectionParameter){
+ try{
+ String paramName = injectionParameter.getName();
+ IMethod method = injectionParameter.getBeanMethod().getMethod();
+
+ ICompilationUnit compilationUnit = method.getCompilationUnit();
+
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ MethodStructure ms = parseMethod(method, buffer.getContents());
+ if(ms == null)
+ return null;
+ for(Parameter parameter : ms.getParameters()){
+ if(parameter.getName().equals(paramName)){
+ return new SourceRange(parameter.getOffset(), parameter.getLength());
+ }
+ }
+ }catch(JavaModelException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ return null;
+ }
+
+ public static ILocalVariable getParameter(IMethod method, String name){
+ try{
+ for(ILocalVariable param : method.getParameters()){
+ if(param.getElementName().equals(name))
+ return param;
+ }
+ }catch(JavaModelException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ return null;
+ }
+
static void getParams(IMethod method, MethodStructure ms, String paramsString, int
offset) throws JavaModelException{
String[] types = method.getParameterTypes();
String[] names = method.getParameterNames();
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/BeanMatch.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/BeanMatch.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/BeanMatch.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.ui.search;
-
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.search.ui.text.Match;
-import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.ui.CDIUIPlugin;
-
-public class BeanMatch extends Match {
- private IBean bean;
- public BeanMatch(IBean bean){
- super(bean, 0, 0);
- try{
- ISourceRange range = bean.getBeanClass().getNameRange();
- setOffset(range.getOffset());
- setLength(range.getLength());
- }catch(JavaModelException ex){
- CDIUIPlugin.getDefault().logError(ex);
- }
- this.bean = bean;
- }
-
- public IBean getBean(){
- return bean;
- }
-}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIBeanQueryParticipant.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIBeanQueryParticipant.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIBeanQueryParticipant.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.search;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+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.jface.viewers.ILabelProviderListener;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.ICDIElement;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointMethod;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.cdi.ui.CDIUiImages;
+
+public class CDIBeanQueryParticipant implements IQueryParticipant{
+ static CDIBeanLabelProvider labelProvider = new CDIBeanLabelProvider();
+
+ @Override
+ public void search(ISearchRequestor requestor,
+ QuerySpecification querySpecification, IProgressMonitor monitor)
+ throws CoreException {
+ if(querySpecification instanceof ElementQuerySpecification){
+ if (!isSearchForReferences(querySpecification.getLimitTo()))
+ return;
+
+ ElementQuerySpecification qs = (ElementQuerySpecification)querySpecification;
+ IJavaElement element = qs.getElement();
+ if(element instanceof IType){
+ IFile file = (IFile)element.getResource();
+ if(file == null)
+ return;
+
+ CDICoreNature cdiNature = CDICorePlugin.getCDI(file.getProject(), true);
+
+ if(cdiNature == null)
+ return;
+
+ ICDIProject cdiProject = cdiNature.getDelegate();
+
+ if(cdiProject == null)
+ return;
+
+ IClassBean sourceBean = cdiProject.getBeanClass((IType)element);
+
+ IBean[] beans = cdiProject.getBeans();
+
+ monitor.beginTask(CDIUIMessages.CDI_BEAN_QUERY_PARTICIPANT_TASK, beans.length);
+
+ for(IBean bean : beans){
+ monitor.worked(1);
+ Set<IInjectionPoint> injectionPoints = bean.getInjectionPoints();
+
+ for(IInjectionPoint injectionPoint : injectionPoints){
+ Set<IBean> resultBeans = cdiProject.getBeans(false, injectionPoint);
+
+ for(IBean cBean : resultBeans){
+ if(cBean == sourceBean){
+ Match match = new CDIMatch(injectionPoint);
+ requestor.reportMatch(match);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public boolean isSearchForReferences(int limitTo) {
+ int maskedLimitTo = limitTo &
~(IJavaSearchConstants.IGNORE_DECLARING_TYPE+IJavaSearchConstants.IGNORE_RETURN_TYPE);
+ if (maskedLimitTo == IJavaSearchConstants.REFERENCES || maskedLimitTo ==
IJavaSearchConstants.ALL_OCCURRENCES) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int estimateTicks(QuerySpecification specification) {
+ return 10;
+ }
+
+ @Override
+ public IMatchPresentation getUIParticipant() {
+ //return null;
+ return new CDIBeanMatchPresentation();
+ }
+
+ TextFileDocumentProvider provider=null;
+
+ private TextFileDocumentProvider getDocumentProvider(){
+ if(provider == null){
+ provider = new TextFileDocumentProvider();
+ }
+ return provider;
+ }
+
+ class CDIBeanMatchPresentation implements IMatchPresentation{
+
+ @Override
+ public ILabelProvider createLabelProvider() {
+ return labelProvider;
+ }
+
+ @Override
+ public void showMatch(Match match, int currentOffset,
+ int currentLength, boolean activate) throws PartInitException {
+ if(match instanceof CDIMatch){
+ IJavaElement element = ((CDIMatch)match).getJavaElement();
+ if(element != null){
+ try{
+ JavaUI.openInEditor(element);
+ }catch(JavaModelException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }catch(PartInitException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+ }
+
+ }
+
+ }
+
+ static class CDIBeanLabelProvider implements ILabelProvider{
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return CDIUiImages.WELD_IMAGE;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if(element instanceof CDIElementWrapper){
+ ICDIElement cdiElement = ((CDIElementWrapper)element).getCDIElement();
+ String label = ((CDIElementWrapper)element).getLabel();
+
+ if(cdiElement instanceof IInjectionPointField){
+ return NLS.bind(CDIUIMessages.CDI_BEAN_QUERY_PARTICIPANT_INJECT_FIELD, label);
+ }else if(cdiElement instanceof IInjectionPointMethod){
+ return NLS.bind(CDIUIMessages.CDI_BEAN_QUERY_PARTICIPANT_INJECT_METHOD, label);
+ }else if(cdiElement instanceof IInjectionPointParameter){
+ return NLS.bind(CDIUIMessages.CDI_BEAN_QUERY_PARTICIPANT_INJECT_PARAMETER, label);
+ }
+ }
+ return ""; //$NON-NLS-1$
+
+ }
+
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIBeanQueryParticipant.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIElementWrapper.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIElementWrapper.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIElementWrapper.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.search;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.Signature;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.ICDIElement;
+import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointMethod;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
+import org.jboss.tools.cdi.core.IObserverMethod;
+import org.jboss.tools.cdi.ui.marker.MarkerResolutionUtils;
+
+public class CDIElementWrapper {
+ private static String SPACE = " ";
+ private static String DOT = ".";
+ private static String OPEN = "(";
+ private static String CLOSE = ")";
+ private static String BRACKETS = OPEN+CLOSE;
+ private ICDIElement element;
+ private String label;
+ private IJavaElement javaElement;
+
+ public CDIElementWrapper(ICDIElement element){
+ this.element = element;
+ if(element instanceof IBean){
+ javaElement = ((IBean)element).getBeanClass();
+ label = javaElement.getElementName();
+ }else if(element instanceof IObserverMethod){
+ javaElement = ((IObserverMethod)element).getMethod();
+ label =
((IObserverMethod)element).getMethod().getDeclaringType().getElementName()+DOT+((IObserverMethod)element).getMethod().getElementName()+BRACKETS;
+ }else if(element instanceof IInjectionPointField){
+ javaElement = ((IInjectionPointField)element).getField();
+ label =
((IInjectionPointField)element).getField().getDeclaringType().getElementName()+DOT+((IInjectionPointField)element).getField().getElementName();
+ }else if(element instanceof IInjectionPointMethod){
+ javaElement = ((IInjectionPointMethod)element).getMethod();
+ label =
((IInjectionPointMethod)element).getMethod().getDeclaringType().getElementName()+DOT+((IInjectionPointMethod)element).getMethod().getElementName()+BRACKETS;
+ }else if(element instanceof IInjectionPointParameter){
+ IMethod method = ((IInjectionPointParameter)element).getBeanMethod().getMethod();
+ javaElement = MarkerResolutionUtils.getParameter(method,
((IInjectionPointParameter)element).getName());
+ String type =
Signature.getSignatureSimpleName(((ILocalVariable)javaElement).getTypeSignature());
+ label =
method.getDeclaringType().getElementName()+DOT+method.getElementName()+OPEN+type+SPACE+javaElement.getElementName()+CLOSE;
+ }
+
+ }
+
+ public ICDIElement getCDIElement(){
+ return element;
+ }
+
+ public IJavaElement getJavaElement(){
+ return javaElement;
+ }
+
+ public String getLabel(){
+ return label;
+ }
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIElementWrapper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIMatch.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIMatch.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIMatch.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.search;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.search.ui.text.Match;
+import org.jboss.tools.cdi.core.ICDIElement;
+
+public class CDIMatch extends Match {
+ public CDIMatch(ICDIElement element) {
+ super(new CDIElementWrapper(element), 0, 0);
+ }
+
+ public String getLabel(){
+ return ((CDIElementWrapper)getElement()).getLabel();
+ }
+
+ public IJavaElement getJavaElement(){
+ return ((CDIElementWrapper)getElement()).getJavaElement();
+ }
+
+ public ICDIElement getCDIElement(){
+ return ((CDIElementWrapper)getElement()).getCDIElement();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIMatch.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/EventMatch.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/EventMatch.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/EventMatch.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.ui.search;
-
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.search.ui.text.Match;
-import org.jboss.tools.cdi.core.IInjectionPoint;
-import org.jboss.tools.cdi.core.IInjectionPointField;
-import org.jboss.tools.cdi.core.IInjectionPointMethod;
-import org.jboss.tools.cdi.core.IInjectionPointParameter;
-import org.jboss.tools.cdi.ui.CDIUIPlugin;
-
-public class EventMatch extends Match {
- private IInjectionPoint event;
-
- public EventMatch(IInjectionPoint event) {
- super(event, 0, 0);
- try{
- ISourceRange range = null;
- if(event instanceof IInjectionPointField){
- range = ((IInjectionPointField)event).getField().getNameRange();
- }else if(event instanceof IInjectionPointMethod){
- range = ((IInjectionPointMethod)event).getMethod().getNameRange();
- }else if(event instanceof IInjectionPointParameter){
- range =
((IInjectionPointParameter)event).getBeanMethod().getMethod().getNameRange();
- }
-
- if(range != null){
- setOffset(range.getOffset());
- setLength(range.getLength());
- }
- }catch(JavaModelException ex){
- CDIUIPlugin.getDefault().logError(ex);
- }
- this.event = event;
- }
-
- public IInjectionPoint getEvent(){
- return event;
- }
-}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointLabelProvider.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointLabelProvider.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointLabelProvider.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -15,6 +15,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.ICDIElement;
import org.jboss.tools.cdi.core.IInjectionPointField;
import org.jboss.tools.cdi.core.IInjectionPointMethod;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
@@ -25,22 +26,25 @@
public class InjectionPointLabelProvider implements ILabelProvider {
public Image getImage(Object element) {
- //return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CLASS);
return CDIUiImages.WELD_IMAGE;
}
public String getText(Object element) {
- if(element instanceof IBean){
- return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_INJECT_BEAN,
((IBean)element).getBeanClass().getElementName());
- }else if(element instanceof IObserverMethod){
- return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_OBSERVER_METHOD,
((IObserverMethod)element).getMethod().getDeclaringType().getElementName(),
((IObserverMethod)element).getMethod().getElementName());
- }else if(element instanceof IInjectionPointField){
- return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_EVENT,
((IInjectionPointField)element).getField().getDeclaringType().getElementName(),
((IInjectionPointField)element).getField().getElementName());
- }else if(element instanceof IInjectionPointMethod){
- return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_EVENT,
((IInjectionPointMethod)element).getMethod().getDeclaringType().getElementName(),
((IInjectionPointMethod)element).getMethod().getElementName());
- }else if(element instanceof IInjectionPointParameter){
- return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_EVENT,
((IInjectionPointParameter)element).getBeanMethod().getMethod().getDeclaringType().getElementName(),
((IInjectionPointParameter)element).getBeanMethod().getMethod().getElementName());
- }else
+ if(element instanceof CDIElementWrapper){
+ ICDIElement cdiElement = ((CDIElementWrapper)element).getCDIElement();
+ String label = ((CDIElementWrapper)element).getLabel();
+ if(cdiElement instanceof IBean){
+ return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_INJECT_BEAN, label);
+ }else if(cdiElement instanceof IObserverMethod){
+ return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_OBSERVER_METHOD,
label);
+ }else if(cdiElement instanceof IInjectionPointField){
+ return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_EVENT, label);
+ }else if(cdiElement instanceof IInjectionPointMethod){
+ return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_EVENT, label);
+ }else if(cdiElement instanceof IInjectionPointParameter){
+ return NLS.bind(CDIUIMessages.INJECTION_POINT_LABEL_PROVIDER_EVENT, label);
+ }
+ }
return ""; //$NON-NLS-1$
}
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatch.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatch.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatch.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.ui.search;
-
-import org.eclipse.search.ui.text.Match;
-import org.jboss.tools.cdi.core.IBean;
-
-public class InjectionPointMatch extends Match {
- private IBean bean;
- public InjectionPointMatch(IBean bean, int offset, int length){
- super(bean, offset, length);
- this.bean = bean;
- }
-
- public IBean getBean(){
- return bean;
- }
-}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatchPresentation.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatchPresentation.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointMatchPresentation.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -10,16 +10,13 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.search;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.search.IMatchPresentation;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.search.ui.text.Match;
import org.eclipse.ui.PartInitException;
-import org.jboss.tools.cdi.core.IInjectionPoint;
-import org.jboss.tools.cdi.core.IInjectionPointField;
-import org.jboss.tools.cdi.core.IInjectionPointMethod;
-import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
public class InjectionPointMatchPresentation implements IMatchPresentation {
@@ -33,20 +30,8 @@
boolean activate) throws PartInitException {
try{
- if(match instanceof BeanMatch){
- JavaUI.openInEditor(((BeanMatch)match).getBean().getBeanClass());
- }else if(match instanceof ObserverMethodMatch){
- JavaUI.openInEditor(((ObserverMethodMatch)match).getObserverMethod().getMethod());
- }else if(match instanceof EventMatch){
- IInjectionPoint iPoint = ((EventMatch)match).getEvent();
- if(iPoint instanceof IInjectionPointField){
- JavaUI.openInEditor(((IInjectionPointField)iPoint).getField());
- }else if(iPoint instanceof IInjectionPointMethod){
- JavaUI.openInEditor(((IInjectionPointMethod)iPoint).getMethod());
- }else if(iPoint instanceof IInjectionPointParameter){
- JavaUI.openInEditor(((IInjectionPointParameter)iPoint).getBeanMethod().getMethod());
- }
- }
+ IJavaElement element = ((CDIMatch)match).getJavaElement();
+ JavaUI.openInEditor(element);
}catch(JavaModelException ex){
CDIUIPlugin.getDefault().logError(ex);
}catch(PartInitException ex){
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -86,7 +86,7 @@
for(IBean bean : resultBeanList){
if(bean != null){
if(!objects.contains(bean)){
- Match match = new BeanMatch(bean);
+ Match match = new CDIMatch(bean);
requestor.reportMatch(match);
objects.add(bean);
}
@@ -96,7 +96,7 @@
for(IObserverMethod observerMethod : observerMethods){
// match observer method
if(!objects.contains(observerMethod)){
- Match match = new ObserverMethodMatch(observerMethod);
+ Match match = new CDIMatch(observerMethod);
requestor.reportMatch(match);
objects.add(observerMethod);
}
@@ -109,7 +109,7 @@
for(IInjectionPoint event : events){
// match event
if(!objects.contains(event)){
- Match match = new EventMatch(event);
+ Match match = new CDIMatch(event);
requestor.reportMatch(match);
objects.add(event);
}
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/ObserverMethodMatch.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/ObserverMethodMatch.java 2011-04-15
23:49:05 UTC (rev 30618)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/ObserverMethodMatch.java 2011-04-15
23:55:47 UTC (rev 30619)
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.ui.search;
-
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.search.ui.text.Match;
-import org.jboss.tools.cdi.core.IObserverMethod;
-import org.jboss.tools.cdi.ui.CDIUIPlugin;
-
-public class ObserverMethodMatch extends Match {
- private IObserverMethod observerMethod;
-
- public ObserverMethodMatch(IObserverMethod observerMethod) {
- super(observerMethod, 0, 0);
- try{
- ISourceRange range = observerMethod.getMethod().getNameRange();
- setOffset(range.getOffset());
- setLength(range.getLength());
- }catch(JavaModelException ex){
- CDIUIPlugin.getDefault().logError(ex);
- }
-
- this.observerMethod = observerMethod;
- }
-
- public IObserverMethod getObserverMethod(){
- return observerMethod;
- }
-}