Author: dazarov
Date: 2010-02-05 10:19:30 -0500 (Fri, 05 Feb 2010)
New Revision: 20145
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointListHyperlink.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/messages.properties
Log:
https://jira.jboss.org/jira/browse/JBIDE-3125
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsMessages.java 2010-02-05
15:11:07 UTC (rev 20144)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsMessages.java 2010-02-05
15:19:30 UTC (rev 20145)
@@ -21,4 +21,5 @@
public static String CDI_EXT_PLUGIN_NO_MESSAGE;
public static String CDI_INJECTED_POINT_HYPERLINK_OPEN_BEAN;
+ public static String CDI_INJECTED_POINT_HYPERLINK_OPEN_INJECTED_CLASS;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2010-02-05
15:11:07 UTC (rev 20144)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2010-02-05
15:19:30 UTC (rev 20145)
@@ -11,8 +11,6 @@
package org.jboss.tools.cdi.text.ext.hyperlink;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -33,12 +31,6 @@
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.cdi.core.CDIConstants;
-import org.jboss.tools.cdi.core.CDICoreNature;
-import org.jboss.tools.cdi.core.CDICorePlugin;
-import org.jboss.tools.cdi.core.CDIUtil;
-import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.core.ICDIProject;
-import org.jboss.tools.cdi.core.IInjectionPoint;
public class InjectedPointHyperlinkDetector extends AbstractHyperlinkDetector{
@@ -76,18 +68,8 @@
if(file == null)
return null;
- CDICoreNature cdiNature = CDICorePlugin.getCDI(file.getProject(), true);
- if(cdiNature == null)
- return null;
- ICDIProject cdiProject = cdiNature.getDelegate();
-
- if(cdiProject == null)
- return null;
-
- Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
-
IJavaElement[] elements = null;
try {
@@ -113,17 +95,11 @@
IAnnotation annotation =
annotatable.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
if (annotation == null)
continue;
- IInjectionPoint injectionPoint = CDIUtil.findInjectionPoint(beans, element);
- if(injectionPoint != null){
- Set<IBean> resultBeanSet = cdiProject.getBeans(injectionPoint);
- List<IBean> resultBeanList = CDIUtil.sortBeans(resultBeanSet);
- for(IBean bean : resultBeanList){
- if(bean != null)
- hyperlinks.add(new InjectedPointHyperlink(wordRegion, bean, document));
- }
- }
+
+ hyperlinks.add(new InjectedPointListHyperlink(file, textViewer, wordRegion, element,
document));
}
}
+
if (hyperlinks != null && !hyperlinks.isEmpty()) {
return (IHyperlink[])hyperlinks.toArray(new IHyperlink[hyperlinks.size()]);
}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointListHyperlink.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointListHyperlink.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointListHyperlink.java 2010-02-05
15:19:30 UTC (rev 20145)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.text.ext.hyperlink;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.MultipleHyperlinkPresenter;
+import org.eclipse.swt.graphics.RGB;
+import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.text.ext.CDIExtensionsMessages;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+
+public class InjectedPointListHyperlink extends AbstractHyperlink{
+ private IFile file;
+ private IJavaElement element;
+ private IRegion region;
+ private ITextViewer viewer;
+
+ private static MultipleHyperlinkPresenter mhp = new MultipleHyperlinkPresenter(new
RGB(0, 0, 255));
+ private static boolean installed = false;
+
+ public InjectedPointListHyperlink(IFile file, ITextViewer viewer, IRegion region,
IJavaElement element, IDocument document){
+ this.file = file;
+ this.element = element;
+ this.region = region;
+ this.viewer = viewer;
+ setDocument(document);
+
+ }
+
+
+ @Override
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ return region;
+ }
+
+ protected void doHyperlink(IRegion region) {
+ CDICoreNature cdiNature = CDICorePlugin.getCDI(file.getProject(), true);
+
+ if(cdiNature == null){
+ openFileFailed();
+ return;
+ }
+
+ ICDIProject cdiProject = cdiNature.getDelegate();
+
+ if(cdiProject == null){
+ openFileFailed();
+ return;
+ }
+
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+
+
+ IInjectionPoint injectionPoint = CDIUtil.findInjectionPoint(beans, element);
+ if(injectionPoint == null){
+ openFileFailed();
+ return;
+ }
+
+ Set<IBean> resultBeanSet = cdiProject.getBeans(injectionPoint);
+ List<IBean> resultBeanList = CDIUtil.sortBeans(resultBeanSet);
+
+ IHyperlink[] hyperlinks = new IHyperlink[resultBeanList.size()];
+
+ int index=0;
+ for(IBean bean : resultBeanList){
+ if(bean != null)
+ hyperlinks[index++] = new InjectedPointHyperlink(region, bean, getDocument());
+ }
+ if(hyperlinks.length == 1){
+ ((InjectedPointHyperlink)hyperlinks[0]).doHyperlink(region);
+ }else{
+ if(installed)
+ mhp.uninstall();
+
+ installed = true;
+
+ mhp.install(viewer);
+// if(mhp.canHideHyperlinks())
+// mhp.hideHyperlinks();
+// else
+ mhp.showHyperlinks(hyperlinks);
+ }
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ return CDIExtensionsMessages.CDI_INJECTED_POINT_HYPERLINK_OPEN_INJECTED_CLASS;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointListHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/messages.properties 2010-02-05
15:11:07 UTC (rev 20144)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/messages.properties 2010-02-05
15:19:30 UTC (rev 20145)
@@ -1,2 +1,3 @@
CDI_EXT_PLUGIN_NO_MESSAGE=No message
CDI_INJECTED_POINT_HYPERLINK_OPEN_BEAN=Open CDI Bean
+CDI_INJECTED_POINT_HYPERLINK_OPEN_INJECTED_CLASS=Open Injected Class