Author: dazarov
Date: 2010-09-20 08:42:28 -0400 (Mon, 20 Sep 2010)
New Revision: 25022
Removed:
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/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/browse/JBIDE-6640
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-09-20
12:18:12 UTC (rev 25021)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2010-09-20
12:42:28 UTC (rev 25022)
@@ -11,6 +11,7 @@
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;
@@ -32,7 +33,6 @@
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.ui.texteditor.ITextEditor;
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;
@@ -40,10 +40,15 @@
import org.jboss.tools.cdi.text.ext.CDIExtensionsPlugin;
public class InjectedPointHyperlinkDetector extends AbstractHyperlinkDetector{
-
+ private IRegion region;
+ private IDocument document;
+ private ITextViewer viewer;
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
+ this.region = region;
+ this.viewer = textViewer;
+
ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
if (region == null || !canShowMultipleHyperlinks || !(textEditor instanceof
JavaEditor))
return null;
@@ -57,7 +62,7 @@
if (input.getResource() == null || input.getResource().getProject() == null)
return null;
- IDocument document=
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+ document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
IRegion wordRegion= JavaWordFinder.findWord(document, offset);
if (wordRegion == null)
return null;
@@ -99,9 +104,7 @@
}
}
- if(findInjectedBeans(cdiNature, element, position, file)){
- hyperlinks.add(new InjectedPointListHyperlink(file, textViewer, wordRegion, element,
position, document));
- }
+ findInjectedBeans(cdiNature, element, position, file, hyperlinks);
}
if (hyperlinks != null && !hyperlinks.isEmpty()) {
@@ -113,24 +116,30 @@
return null;
}
- private boolean findInjectedBeans(CDICoreNature nature, IJavaElement element, int
offset, IFile file){
+ private void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset,
IFile file, ArrayList<IHyperlink> hyperlinks){
ICDIProject cdiProject = nature.getDelegate();
if(cdiProject == null){
- return false;
+ return;
}
Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
IInjectionPoint injectionPoint = CDIUtil.findInjectionPoint(beans, element, offset);
if(injectionPoint == null){
- return false;
+ return;
}
- Set<IBean> resultBeanSet = cdiProject.getBeans(false, injectionPoint);
- if(resultBeanSet.size() > 0)
- return true;
+ Set<IBean> resultBeanSet = cdiProject.getBeans(true, injectionPoint);
+ List<IBean> resultBeanList = CDIUtil.sortBeans(resultBeanSet);
- return false;
+ Set<IBean> alternativeBeanSet = cdiProject.getBeans(false, injectionPoint);
+ List<IBean> alternativeBeanList = CDIUtil.sortBeans(alternativeBeanSet);
+
+ if(resultBeanList.size() > 0){
+ hyperlinks.add(new InjectedPointHyperlink(region, resultBeanList.get(0), document,
true));
+ if(alternativeBeanList.size() > 1)
+ hyperlinks.add(new AlternativeInjectedPointListHyperlink(region, alternativeBeanList,
viewer, document));
+ }
}
}
Deleted:
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 2010-09-20
12:18:12 UTC (rev 25021)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointListHyperlink.java 2010-09-20
12:42:28 UTC (rev 25022)
@@ -1,116 +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.text.ext.hyperlink;
-
-import java.util.ArrayList;
-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.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 int position;
- private IRegion region;
- private ITextViewer viewer;
-
- public InjectedPointListHyperlink(IFile file, ITextViewer viewer, IRegion region,
IJavaElement element, int position, IDocument document){
- this.file = file;
- this.element = element;
- this.position = position;
- 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, position);
- if(injectionPoint == null){
- openFileFailed();
- return;
- }
-
- Set<IBean> resultBeanSet = cdiProject.getBeans(true, injectionPoint);
- List<IBean> resultBeanList = CDIUtil.sortBeans(resultBeanSet);
-
- Set<IBean> alternativeBeanSet = cdiProject.getBeans(false, injectionPoint);
- List<IBean> alternativeBeanList = CDIUtil.sortBeans(alternativeBeanSet);
-
- ArrayList<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
-
- if(resultBeanList.size() > 0){
- hyperlinks.add(new InjectedPointHyperlink(region, resultBeanList.get(0),
getDocument(), true));
- //alternativeBeanList.remove(resultBeanList.get(0));
- if(alternativeBeanList.size() > 0)
- hyperlinks.add(new AlternativeInjectedPointListHyperlink(region, alternativeBeanList,
viewer, getDocument()));
- }else if(alternativeBeanList.size() > 0){
- hyperlinks.add(new InjectedPointHyperlink(region, alternativeBeanList.get(0),
getDocument(), true));
- //alternativeBeanList.remove(0);
- if(alternativeBeanList.size() > 0)
- hyperlinks.add(new AlternativeInjectedPointListHyperlink(region, alternativeBeanList,
viewer, getDocument()));
- }
-
- IHyperlink[] result = hyperlinks.toArray(new IHyperlink[hyperlinks.size()]);
-
- if(result.length == 0){
- openFileFailed();
- return;
- }
-
- if(result.length == 1){
- ((InjectedPointHyperlink)result[0]).doHyperlink(region);
- }else{
- MultipleHyperlinkPresenterManager.installAndShow(viewer, result);
- }
- }
-
- @Override
- public String getHyperlinkText() {
- return CDIExtensionsMessages.CDI_INJECTED_POINT_HYPERLINK_OPEN_INJECTED_BEAN;
- }
-
-}
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-09-20
12:18:12 UTC (rev 25021)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/messages.properties 2010-09-20
12:42:28 UTC (rev 25022)
@@ -7,7 +7,7 @@
CDI_INJECTED_POINT_HYPERLINK_OPEN_SELECTED_ALTERNATIVE=Open *@Alternative
CDI_INJECTED_POINT_HYPERLINK_OPEN_ALTERNATIVE=Open @Alternative
CDI_INJECTED_POINT_HYPERLINK_OPEN_PRODUCER=Open @Produces
-CDI_INJECTED_POINT_HYPERLINK_SHOW_ALTERNATIVES=Show All...
+CDI_INJECTED_POINT_HYPERLINK_SHOW_ALTERNATIVES=Show All Eligible Beans...
CDI_PRODUCER_DISPOSER_HYPERLINK_OPEN_BOUND_DISPOSER=Open Bound Disposer Method
CDI_PRODUCER_DISPOSER_HYPERLINK_OPEN_BOUND_PRODUCER=Open Bound Producer Method
CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS=Open CDI Observer Methods