Author: dazarov
Date: 2010-01-21 12:06:44 -0500 (Thu, 21 Jan 2010)
New Revision: 19855
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.classpath
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.project
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/META-INF/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/META-INF/MANIFEST.MF
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/about.html
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/build.properties
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.properties
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsPlugin.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/
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/InjectedPointHyperlinkDetector.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3125
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.classpath
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.classpath (rev
0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.classpath 2010-01-21 17:06:44 UTC (rev
19855)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.project
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.project (rev
0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.project 2010-01-21 17:06:44 UTC (rev
19855)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.cdi.text.ext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/META-INF/MANIFEST.MF 2010-01-21
17:06:44 UTC (rev 19855)
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ActivationPolicy: lazy
+Bundle-Name: %Bundle-Name.0
+Bundle-Activator: org.jboss.tools.cdi.text.ext.CDIExtensionsPlugin
+Bundle-ManifestVersion: 2
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.jboss.tools.cdi.text.ext; singleton:=true
+Bundle-Localization: plugin
+Export-Package: org.jboss.tools.cdi.text.ext,
+ org.jboss.tools.cdi.text.ext.hyperlink
+Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0",
+ org.jboss.tools.common.text.ext;bundle-version="2.0.0",
+ org.eclipse.core.resources;bundle-version="3.5.0",
+ org.eclipse.jface.text;bundle-version="3.5.0",
+ org.eclipse.jdt.ui;bundle-version="3.5.0",
+ org.eclipse.jdt.core;bundle-version="3.5.0",
+ org.eclipse.ui.ide;bundle-version="3.5.0",
+ org.jboss.tools.cdi.core;bundle-version="1.0.0",
+ org.jboss.tools.common;bundle-version="2.0.0"
+Bundle-Version: 2.0.0
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/about.html
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/about.html (rev
0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/about.html 2010-01-21 17:06:44 UTC (rev
19855)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+
+<BODY lang="EN-US">
+
+<H3>About This Content</H3>
+
+<P>©2007 Red Hat, Inc. All rights reserved</P>
+
+<H3>License</H3>
+
+<P>Red Hat Inc., through its JBoss division, makes available all content in this
plug-in
+("Content"). Unless otherwise indicated below, the Content is provided to you
+under the terms and conditions of the Eclipse Public License Version 1.0
+("EPL"). A copy of the EPL is available at
+<A
href="http://www.eclipse.org/org/documents/epl-v10.php">http...;.
+For purposes of the EPL, "Program" will mean the Content.</P>
+
+<P>If you did not receive this Content directly from Red Hat Inc., the
+Content is being redistributed by another party ("Redistributor") and different
+terms and conditions may apply to your use of any object code in the Content.
+Check the Redistributor's license that was provided with the Content. If no such
+license exists, contact the Redistributor. Unless otherwise indicated below, the
+terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at
+ <A
href="http://www.jboss.org/tools">http://www.jboss.org/tools...
+
+</BODY>
+</HTML>
\ No newline at end of file
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/about.html
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/build.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/build.properties
(rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/build.properties 2010-01-21 17:06:44
UTC (rev 19855)
@@ -0,0 +1,3 @@
+source.. = src/
+bin.includes = META-INF/,\
+ .
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.properties
(rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.properties 2010-01-21 17:06:44
UTC (rev 19855)
@@ -0,0 +1,3 @@
+providerName=JBoss by Red Hat
+InjectedPointHyperlinkDetector=CDI Injected Point
+Bundle-Name.0 = CDI Text Editors Extensions
\ No newline at end of file
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml (rev
0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml 2010-01-21 17:06:44 UTC (rev
19855)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+ <hyperlinkDetector
+
class="org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlinkDetector"
+
id="org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlinkDetector"
+ name="%InjectedPointHyperlinkDetector"
+ targetId="org.eclipse.jdt.ui.javaCode">
+ </hyperlinkDetector>
+ </extension>
+
+</plugin>
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsPlugin.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsPlugin.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsPlugin.java 2010-01-21
17:06:44 UTC (rev 19855)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class CDIExtensionsPlugin extends AbstractUIPlugin{
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/CDIExtensionsPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlink.java 2010-01-21
17:06:44 UTC (rev 19855)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.text.IRegion;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+
+public class InjectedPointHyperlink extends AbstractHyperlink{
+
+ @Override
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void doHyperlink(IRegion region) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2010-01-21
17:06:44 UTC (rev 19855)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IAnnotatable;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.ICodeAssist;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jdt.internal.ui.text.JavaWordFinder;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
+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.IBean;
+
+public class InjectedPointHyperlinkDetector extends AbstractHyperlinkDetector{
+
+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
+ IRegion region, boolean canShowMultipleHyperlinks) {
+ ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
+ if (region == null || !canShowMultipleHyperlinks || !(textEditor instanceof
JavaEditor))
+ return null;
+
+ int offset= region.getOffset();
+
+ IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, false);
+ if (input == null)
+ return null;
+
+ if (input.getResource() == null || input.getResource().getProject() == null)
+ return null;
+
+ IDocument document=
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+ IRegion wordRegion= JavaWordFinder.findWord(document, offset);
+ if (wordRegion == null)
+ return null;
+
+ IFile file = null;
+
+ try {
+ IResource resource = input.getCorrespondingResource();
+ if (resource instanceof IFile)
+ file = (IFile) resource;
+ } catch (JavaModelException e) {
+ // Ignore. It is probably because of Java element's resource is not found
+ }
+
+ if(file == null)
+ return null;
+
+ CDICoreNature cdiProject = CDICorePlugin.getCDI(file.getProject(), false);
+ Set<IBean> beans = cdiProject.getDelegate().getBeans(file.getFullPath());
+
+ int[] range = new int[]{wordRegion.getOffset(), wordRegion.getOffset() +
wordRegion.getLength()};
+
+ IJavaElement[] elements = null;
+
+ try {
+ elements = ((ICodeAssist)input).codeSelect(wordRegion.getOffset(),
wordRegion.getLength());
+ if (elements == null)
+ return null;
+
+ ArrayList<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
+ for (IJavaElement element : elements) {
+ if (element instanceof IAnnotatable) {
+ IAnnotatable annotatable = (IAnnotatable)element;
+
+ IAnnotation annotation = annotatable.getAnnotation("Injected");
+ if (annotation == null)
+ continue;
+
+ String nameToSearch = element.getElementName();
+
+ IMemberValuePair[] mvPairs = annotation.getMemberValuePairs();
+ if (mvPairs != null) {
+ for (IMemberValuePair mvPair : mvPairs) {
+ if ("value".equals(mvPair.getMemberName()) && mvPair.getValue()
!= null) {
+ String name = mvPair.getValue().toString();
+ if (name != null && name.trim().length() != 0) {
+ nameToSearch = name;
+ break;
+ }
+ }
+ }
+ }
+
+
+ if (nameToSearch == null && nameToSearch.trim().length() == 0)
+ continue;
+
+ }
+ }
+ if (hyperlinks != null && !hyperlinks.isEmpty()) {
+ return (IHyperlink[])hyperlinks.toArray(new IHyperlink[hyperlinks.size()]);
+ }
+ } catch (JavaModelException jme) {
+ // ignore
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain