Author: scabanovich
Date: 2011-06-09 18:41:08 -0400 (Thu, 09 Jun 2011)
New Revision: 31993
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlink.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointListHyperlink.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties
Log:
JBIDE-9110
https://issues.jboss.org/browse/JBIDE-9110
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF 2011-06-09
22:36:21 UTC (rev 31992)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF 2011-06-09
22:41:08 UTC (rev 31993)
@@ -13,6 +13,8 @@
org.jboss.tools.common.text.ext;bundle-version="2.0.0",
org.eclipse.jface.text;bundle-version="3.7.0",
org.eclipse.jdt.ui;bundle-version="3.7.0",
+ org.eclipse.ui.ide,
+ org.jboss.tools.common.model.ui,
org.jboss.tools.cdi.ui;bundle-version="1.2.0",
org.jboss.tools.cdi.core,
org.jboss.tools.cdi.text.ext,
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties 2011-06-09
22:36:21 UTC (rev 31992)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties 2011-06-09
22:41:08 UTC (rev 31993)
@@ -1,3 +1,4 @@
providerName=JBoss by Red Hat
Bundle-Name.0 = CDI Seam Text Editors Extensions
GenericInjectedPointHyperlinkDetector = CDI Seam Generic Injected Point
+SeamConfigInjectedPointHyperlinkDetector = CDI Seam Config Injected Beans
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml 2011-06-09 22:36:21 UTC
(rev 31992)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml 2011-06-09 22:41:08 UTC
(rev 31993)
@@ -23,6 +23,16 @@
</hyperlinkDetector>
</extension>
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+ <hyperlinkDetector
+
class="org.jboss.tools.cdi.seam.text.ext.hyperlink.SeamConfigInjectedPointHyperlinkDetector"
+
id="org.jboss.tools.cdi.seam.text.ext.hyperlink.SeamConfigInjectedPointHyperlinkDetector"
+ name="%SeamConfigInjectedPointHyperlinkDetector"
+ targetId="org.eclipse.jdt.ui.javaCode">
+ </hyperlinkDetector>
+ </extension>
+
<extension
point="org.jboss.tools.common.text.ext.hyperlinkPartitioner"
id="org.jboss.tools.cdi.text.ext.hyperlinkPartitioner"
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java 2011-06-09
22:36:21 UTC (rev 31992)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java 2011-06-09
22:41:08 UTC (rev 31993)
@@ -23,6 +23,7 @@
public static String CDI_SEAM_CONFIG_OPEN_TAG;
public static String CDI_INJECTED_POINT_HYPERLINK_SHOW_GENERIC_BEANS;
+ public static String CDI_INJECTED_POINT_HYPERLINK_SHOW_SEAM_CONFIG_BEANS;
public static String OPEN_GENERIC_BEAN;
public static String OPEN_GENERIC_PRODUCER_BEAN;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointHyperlinkDetector.java 2011-06-09
22:36:21 UTC (rev 31992)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/GenericInjectedPointHyperlinkDetector.java 2011-06-09
22:41:08 UTC (rev 31993)
@@ -48,13 +48,11 @@
import org.jboss.tools.cdi.seam.solder.core.CDISeamSolderConstants;
import org.jboss.tools.cdi.seam.solder.core.generic.GenericClassBean;
import org.jboss.tools.cdi.text.ext.CDIExtensionsPlugin;
-import org.jboss.tools.cdi.text.ext.hyperlink.AlternativeInjectedPointListHyperlink;
-import org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlink;
public class GenericInjectedPointHyperlinkDetector extends AbstractHyperlinkDetector{
- private IRegion region;
- private IDocument document;
- private ITextViewer viewer;
+ protected IRegion region;
+ protected IDocument document;
+ protected ITextViewer viewer;
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
@@ -128,7 +126,7 @@
return null;
}
- private void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset,
IFile file, ArrayList<IHyperlink> hyperlinks){
+ protected void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset,
IFile file, ArrayList<IHyperlink> hyperlinks){
ICDIProject cdiProject = nature.getDelegate();
if(cdiProject == null) {
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlink.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlink.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlink.java 2011-06-09
22:41:08 UTC (rev 31993)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.seam.text.ext.hyperlink;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IProducerField;
+import org.jboss.tools.cdi.core.IProducerMethod;
+import org.jboss.tools.cdi.internal.core.impl.AbstractBeanElement;
+import org.jboss.tools.cdi.seam.config.core.definition.IConfigDefinition;
+import org.jboss.tools.cdi.seam.text.ext.CDISeamExtMessages;
+import org.jboss.tools.cdi.seam.text.ext.CDISeamExtPlugin;
+import org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlink;
+import org.jboss.tools.common.editor.ObjectMultiPageEditor;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.jboss.tools.common.text.ITextSourceReference;
+
+public class SeamConfigInjectedPointHyperlink extends InjectedPointHyperlink {
+
+ public SeamConfigInjectedPointHyperlink(IRegion region, IBean bean, IDocument document,
boolean b) {
+ super(region, bean, document, b);
+ }
+
+ protected void doHyperlink(IRegion region) {
+ IEditorPart part = null;
+ ITextSourceReference source =
((AbstractBeanElement)bean).getDefinition().getOriginalDefinition();
+ IFile resource = (IFile)source.getResource();
+ IWorkbenchWindow window =
CDISeamExtPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) return;
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ part = IDE.openEditor(page, resource);
+ } catch (PartInitException e) {
+ CDISeamExtPlugin.log(e);
+ }
+ if(part instanceof EditorPartWrapper) {
+ part = ((EditorPartWrapper)part).getEditor();
+ }
+ if(part instanceof ObjectMultiPageEditor) {
+ ObjectMultiPageEditor mpe = (ObjectMultiPageEditor)part;
+ ITextEditor textEditor = (ITextEditor)mpe.getAdapter(ITextEditor.class);
+ if(textEditor != null) {
+ mpe.setActiveEditor(textEditor);
+ part = textEditor;
+ }
+ }
+ if(part != null) {
+ part.getEditorSite().getSelectionProvider().setSelection(new
TextSelection(source.getStartPosition(), source.getLength()));
+ }
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ String text = super.getHyperlinkText();
+ IConfigDefinition configDef =
(IConfigDefinition)((AbstractBeanElement)bean).getDefinition();
+ int line = configDef.getConfig().getNode().getLocation().getLine();
+ ITextSourceReference source =
((AbstractBeanElement)bean).getDefinition().getOriginalDefinition();
+ text += " in " + source.getResource().getName() + " at line " +
line;
+ return text;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlink.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlinkDetector.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlinkDetector.java 2011-06-09
22:41:08 UTC (rev 31993)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.seam.text.ext.hyperlink;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+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.hyperlink.IHyperlink;
+import org.jboss.tools.cdi.core.CDICoreNature;
+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.internal.core.impl.AbstractBeanElement;
+import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
+import org.jboss.tools.cdi.seam.config.core.definition.IConfigDefinition;
+import org.jboss.tools.common.text.ITextSourceReference;
+
+public class SeamConfigInjectedPointHyperlinkDetector extends
GenericInjectedPointHyperlinkDetector {
+
+ protected void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset,
IFile file, ArrayList<IHyperlink> hyperlinks){
+ ICDIProject cdiProject = nature.getDelegate();
+
+ if(cdiProject == null) {
+ return;
+ }
+
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+
+ Set<IInjectionPoint> injectionPoints =
GenericInjectedPointHyperlinkDetector.findInjectionPoints(beans, element, offset);
+ if(injectionPoints.isEmpty()) {
+ return;
+ }
+
+ Set<IBean> resultBeanSet2 = new HashSet<IBean>();
+
+ for (IInjectionPoint injectionPoint: injectionPoints) {
+ Set<IBean> resultBeanSet = cdiProject.getBeans(true, injectionPoint);
+ for (IBean b: resultBeanSet) {
+ if(b instanceof AbstractBeanElement) {
+ AbstractMemberDefinition def = ((AbstractBeanElement)b).getDefinition();
+ if(def instanceof IConfigDefinition) {
+ ITextSourceReference ref = def.getOriginalDefinition();
+ if(ref != null) {
+ resultBeanSet2.add(b);
+ }
+ }
+ }
+ }
+ }
+
+ List<IBean> resultBeanList = CDIUtil.sortBeans(resultBeanSet2);
+ if(resultBeanList.size() == 1) {
+ hyperlinks.add(new SeamConfigInjectedPointHyperlink(region, resultBeanList.get(0),
document, true));
+ } else if(resultBeanList.size() > 0) {
+ hyperlinks.add(new SeamConfigInjectedPointListHyperlink(region, resultBeanList,
viewer, document));
+ }
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointHyperlinkDetector.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointListHyperlink.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointListHyperlink.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointListHyperlink.java 2011-06-09
22:41:08 UTC (rev 31993)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.seam.text.ext.hyperlink;
+
+import java.util.List;
+
+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.IBean;
+import org.jboss.tools.cdi.seam.text.ext.CDISeamExtMessages;
+import org.jboss.tools.cdi.text.ext.hyperlink.AlternativeInjectedPointListHyperlink;
+
+public class SeamConfigInjectedPointListHyperlink extends
+ AlternativeInjectedPointListHyperlink {
+
+ public SeamConfigInjectedPointListHyperlink(IRegion region, List<IBean> beans,
+ ITextViewer viewer, IDocument document) {
+ super(region, beans, viewer, document);
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ return CDISeamExtMessages.CDI_INJECTED_POINT_HYPERLINK_SHOW_SEAM_CONFIG_BEANS;
+ }
+
+ @Override
+ protected IHyperlink createHyperlink(IRegion region, IBean bean) {
+ return new SeamConfigInjectedPointHyperlink(region, bean, getDocument(), false);
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/SeamConfigInjectedPointListHyperlink.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties 2011-06-09
22:36:21 UTC (rev 31992)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties 2011-06-09
22:41:08 UTC (rev 31993)
@@ -2,5 +2,6 @@
CDI_SEAM_RESOURCE_LOADING_HYPERLINK=Open Resource ''{0}''
CDI_SEAM_CONFIG_OPEN_TAG=Open Seam Config tag {0}
CDI_INJECTED_POINT_HYPERLINK_SHOW_GENERIC_BEANS=Show All Generic Beans...
+CDI_INJECTED_POINT_HYPERLINK_SHOW_SEAM_CONFIG_BEANS=Show All Seam Config Bean
Definitions...
OPEN_GENERIC_BEAN=Open Generic Bean {0}
OPEN_GENERIC_PRODUCER_BEAN=Open Generic Producer Bean {0}