Author: dazarov
Date: 2011-10-11 11:49:35 -0400 (Tue, 11 Oct 2011)
New Revision: 35542
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventHyperlink.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/IInformationItem.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlink.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodHyperlink.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java
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/InjectionPointLabelProvider.java
Log:
Updated Label Providers in order to look similar
https://issues.jboss.org/browse/JBIDE-9801
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -13,6 +13,13 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IBeanField;
+import org.jboss.tools.cdi.core.IBeanMember;
+import org.jboss.tools.cdi.core.IBeanMethod;
+import org.jboss.tools.cdi.core.ICDIElement;
+import org.jboss.tools.cdi.core.IInitializerMethod;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IParameter;
import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.internal.core.impl.AbstractBeanElement;
import org.jboss.tools.common.text.ITextSourceReference;
@@ -75,5 +82,34 @@
return sb.toString();
}
+
+ public static String getCDIElementKind(ICDIElement element){
+ if(element instanceof IBean){
+ return getBeanKind((IBean)element);
+ }else if(element instanceof IInjectionPoint){
+ return "Injection Point";
+ }else if(element instanceof IInitializerMethod){
+ return "Injection Point";
+ }else if(element instanceof IBeanMethod){
+ return "Bean Method";
+ }else if(element instanceof IBeanField){
+ return "Bean Field";
+ }else if(element instanceof IParameter){
+ return "Parameter";
+
+ }
+ return null;
+ }
+
+ public static String getCDIElementLocation(ICDIElement element, boolean
includeElementName){
+ if(element instanceof IBean){
+ return getBeanLocation((IBean)element, includeElementName);
+ }else if(element instanceof IInjectionPoint){
+ return getBeanLocation(((IInjectionPoint) element).getBean(), includeElementName);
+ }else if(element instanceof IBeanMember){
+ return getBeanLocation(((IBeanMember) element).getClassBean(), includeElementName);
+ }
+ return null;
+ }
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventHyperlink.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventHyperlink.java 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventHyperlink.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -17,10 +17,8 @@
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
-import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.ICDIElement;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IInjectionPointField;
@@ -84,17 +82,4 @@
public Set<? extends ICDIElement> getCDIElements() {
return null;
}
-
- public String getFullyQualifiedName() {
- return event.getClassBean().getBeanClass().getFullyQualifiedName();
- }
-
- public String getInformation() {
- return event.getElementName();
- }
-
- public Image getImage() {
- return CDIImages.getImageByElement(event);
- }
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/IInformationItem.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/IInformationItem.java 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/IInformationItem.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -10,28 +10,15 @@
******************************************************************************/
package org.jboss.tools.cdi.text.ext.hyperlink;
-import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.cdi.core.ICDIElement;
public interface IInformationItem {
/**
- * Returns the simple name of item
+ * Returns CDI element
*
* @return
*/
- public String getInformation();
+ public ICDIElement getCDIElement();
- /**
- * Returns the java element fully qualified name
- *
- * @return
- */
- public String getFullyQualifiedName();
-
- /**
- * Returns the icon image
- *
- * @return
- */
- public Image getImage();
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlink.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlink.java 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlink.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -17,14 +17,10 @@
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
-import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIElement;
-import org.jboss.tools.cdi.core.IDecorator;
-import org.jboss.tools.cdi.core.IInterceptor;
import org.jboss.tools.cdi.core.IProducerField;
import org.jboss.tools.cdi.core.IProducerMethod;
import org.jboss.tools.cdi.core.util.BeanPresentationUtil;
@@ -114,17 +110,4 @@
public Set<? extends ICDIElement> getCDIElements() {
return null;
}
-
- public String getFullyQualifiedName() {
- return bean.getBeanClass().getFullyQualifiedName();
- }
-
- public String getInformation() {
- return bean.getElementName();
- }
-
- public Image getImage() {
- return CDIImages.getImageByElement(bean);
- }
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodHyperlink.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodHyperlink.java 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ObserverMethodHyperlink.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -17,10 +17,8 @@
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
-import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.ICDIElement;
import org.jboss.tools.cdi.core.IObserverMethod;
import org.jboss.tools.cdi.text.ext.CDIExtensionsMessages;
@@ -75,17 +73,4 @@
public Set<? extends ICDIElement> getCDIElements() {
return null;
}
-
- public String getFullyQualifiedName() {
- return observerMethod.getClassBean().getBeanClass().getFullyQualifiedName();
- }
-
- public String getInformation() {
- return observerMethod.getElementName();
- }
-
- public Image getImage() {
- return CDIImages.getImageByElement(observerMethod);
- }
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/HierarchyInformationControl.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -32,6 +32,9 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.dialogs.SearchPattern;
+import org.jboss.tools.cdi.core.CDIImages;
+import org.jboss.tools.cdi.core.ICDIElement;
+import org.jboss.tools.cdi.core.util.BeanPresentationUtil;
import org.jboss.tools.cdi.text.ext.hyperlink.IInformationItem;
/**
@@ -144,13 +147,13 @@
Object element) {
if (element instanceof IInformationItem) {
- String information = ((IInformationItem)element).getInformation();
+ String name = ((IInformationItem)element).getCDIElement().getElementName();
if(getFilterText().getText().isEmpty()){
patternMatcher.setPattern("*");
}else{
patternMatcher.setPattern(getFilterText().getText());
}
- return patternMatcher.matches(information);
+ return patternMatcher.matches(name);
}else
return true;
}
@@ -199,11 +202,11 @@
StyledString sb = new StyledString();
if(element instanceof IHyperlink){
if(element instanceof IInformationItem){
- String info = ((IInformationItem)element).getInformation();
- String qualifiedName = ((IInformationItem)element).getFullyQualifiedName();
- String packageName = qualifiedName.substring(0,
qualifiedName.lastIndexOf("."));
- sb.append(info, NAME_STYLE);
- sb.append(" - ", PACKAGE_STYLE).append(packageName, PACKAGE_STYLE);
+ ICDIElement cdiElement = ((IInformationItem)element).getCDIElement();
+ String name = cdiElement.getElementName();
+ String location = BeanPresentationUtil.getCDIElementLocation(cdiElement, false);
+ sb.append(name, NAME_STYLE);
+ sb.append(location, PACKAGE_STYLE);
}else{
sb.append(((IHyperlink)element).getHyperlinkText(), NAME_STYLE);
}
@@ -213,7 +216,8 @@
public Image getImage(Object element) {
if(element instanceof IInformationItem){
- return ((IInformationItem)element).getImage();
+ ICDIElement cdiElement = ((IInformationItem)element).getCDIElement();
+ return CDIImages.getImageByElement(cdiElement);
}
return null;
}
Modified:
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 2011-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/CDIBeanQueryParticipant.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -40,6 +40,7 @@
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IInjectionPointField;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
+import org.jboss.tools.cdi.core.util.BeanPresentationUtil;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.java.IParametedType;
@@ -170,16 +171,12 @@
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 IInitializerMethod){
- //It is not an injection point, but it has annotation @Inject and contains injection
point parameters
- 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);
+ String kind = BeanPresentationUtil.getCDIElementKind(cdiElement);
+ String text = "";
+ if(kind != null){
+ text = kind+" ";
}
+ return
text+cdiElement.getElementName()+BeanPresentationUtil.getCDIElementLocation(cdiElement,
false);
}
return ""; //$NON-NLS-1$
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-10-11
15:35:17 UTC (rev 35541)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointLabelProvider.java 2011-10-11
15:49:35 UTC (rev 35542)
@@ -12,16 +12,10 @@
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIElement;
-import org.jboss.tools.cdi.core.IInitializerMethod;
-import org.jboss.tools.cdi.core.IInjectionPointField;
-import org.jboss.tools.cdi.core.IInjectionPointParameter;
-import org.jboss.tools.cdi.core.IObserverMethod;
-import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.core.util.BeanPresentationUtil;
public class InjectionPointLabelProvider implements ILabelProvider {
@@ -35,20 +29,14 @@
public String getText(Object element) {
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 IInitializerMethod){
- 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);
+ String kind = BeanPresentationUtil.getCDIElementKind(cdiElement);
+ String text = "";
+ if(kind != null){
+ text = kind+" ";
}
+ return
text+cdiElement.getElementName()+BeanPresentationUtil.getCDIElementLocation(cdiElement,
false);
}
- return ""; //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
}
public void addListener(ILabelProviderListener listener) {