[jbosstools-commits] JBoss Tools SVN: r30795 - in cdi/plugins/org.jboss.tools.cdi.seam.text.ext: .settings and 10 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Apr 22 20:44:16 EDT 2011
Author: dazarov
Date: 2011-04-22 20:44:15 -0400 (Fri, 22 Apr 2011)
New Revision: 30795
Added:
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.classpath
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.project
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.settings/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.settings/org.eclipse.jdt.core.prefs
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/about.html
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/build.properties
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/pom.xml
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtPlugin.java
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlink.java
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties
Log:
https://issues.jboss.org/browse/JBIDE-8202
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.classpath
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.classpath (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.classpath 2011-04-23 00:44:15 UTC (rev 30795)
@@ -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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.project
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.project (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.project 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.cdi.seam.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: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.settings/org.eclipse.jdt.core.prefs 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,12 @@
+#Tue Apr 19 15:15:09 PDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ActivationPolicy: lazy
+Bundle-Name: %Bundle-Name.0
+Bundle-Activator: org.jboss.tools.cdi.seam.text.ext.CDISeamExtPlugin
+Bundle-ManifestVersion: 2
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.jboss.tools.cdi.seam.text.ext;singleton:=true
+Bundle-Localization: plugin
+Export-Package: org.jboss.tools.cdi.seam.text.ext,
+ org.jboss.tools.cdi.seam.text.ext.hyperlink
+Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
+ org.jboss.tools.common.text.ext;bundle-version="2.0.0",
+ org.eclipse.jface.text;bundle-version="3.5.0",
+ org.eclipse.jdt.ui;bundle-version="3.5.0",
+ org.jboss.tools.cdi.ui;bundle-version="1.2.0",
+ org.jboss.tools.jst.web;bundle-version="3.2.0"
+Bundle-Version: 1.2.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/about.html
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/about.html (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/about.html 2011-04-23 00:44:15 UTC (rev 30795)
@@ -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://www.eclipse.org/org/documents/epl-v10.php</A>.
+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</A>.</P>
+
+</BODY>
+</HTML>
\ No newline at end of file
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/about.html
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/build.properties
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/build.properties (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/build.properties 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,11 @@
+source.. = src/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html
+src.includes = plugin.xml,\
+ plugin.properties,\
+ about.html,\
+ META-INF/,\
+ src/
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/build.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,2 @@
+providerName=JBoss by Red Hat
+Bundle-Name.0 = CDI Seam Text Editors Extensions
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml 2011-04-23 00:44:15 UTC (rev 30795)
@@ -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.seam.text.ext.hyperlink.CDISeamResourceLoadingHyperlinkDetector"
+ id="org.jboss.tools.cdi.seam.text.ext.hyperlink.CDISeamResourceLoadingHyperlinkDetector"
+ name="%CDISeamResourceLoadingHyperlinkDetector"
+ targetId="org.eclipse.jdt.ui.javaCode">
+ </hyperlinkDetector>
+ </extension>
+
+</plugin>
\ No newline at end of file
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/pom.xml
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/pom.xml (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/pom.xml 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.2-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.cdi.plugins</groupId>
+ <artifactId>org.jboss.tools.cdi.seam.text.ext</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CDISeamExtMessages extends NLS{
+ private static final String BUNDLE_NAME = "org.jboss.tools.cdi.seam.text.ext.messages"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, CDISeamExtMessages.class);
+ }
+ public static String CDI_SEAM_EXT_PLUGIN_NO_MESSAGE;
+ public static String CDI_SEAM_RESOURCE_LOADING_HYPERLINK;
+}
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtMessages.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtPlugin.java
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtPlugin.java (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtPlugin.java 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class CDISeamExtPlugin extends AbstractUIPlugin{
+ //The shared instance.
+ private static CDISeamExtPlugin plugin;
+ //Resource bundle.
+ private ResourceBundle resourceBundle;
+
+ public static final String PLUGIN_ID = "org.jboss.tools.cdi.seam.text.ext"; //$NON-NLS-1$
+
+
+ /**
+ * The constructor.
+ */
+ public CDISeamExtPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static CDISeamExtPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ /**
+ * Returns the string from the plugin's resource bundle,
+ * or 'key' if not found.
+ */
+ public static String getResourceString(String key) {
+ ResourceBundle bundle= CDISeamExtPlugin.getDefault().getResourceBundle();
+ try {
+ return bundle.getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the plugin's resource bundle,
+ */
+ public ResourceBundle getResourceBundle() {
+ return resourceBundle;
+ }
+
+ static public void log(String msg) {
+ CDISeamExtPlugin.getDefault().getLog().log(new Status(Status.INFO, PLUGIN_ID, Status.OK, msg, null));
+ }
+
+ public static void log(IStatus status) {
+ CDISeamExtPlugin.getDefault().getLog().log(status);
+ }
+ public static void log(String message, Exception exception) {
+ CDISeamExtPlugin.getDefault().getLog().log(new Status(Status.ERROR, CDISeamExtPlugin.PLUGIN_ID, Status.OK, message, exception));
+ }
+ static public void log(Exception ex) {
+ CDISeamExtPlugin.getDefault().getLog().log(new Status(Status.ERROR, CDISeamExtPlugin.PLUGIN_ID, Status.OK, CDISeamExtMessages.CDI_SEAM_EXT_PLUGIN_NO_MESSAGE, ex));
+ }
+
+
+
+}
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/CDISeamExtPlugin.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlink.java
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlink.java (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlink.java 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.cdi.seam.text.ext.CDISeamExtMessages;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+
+public class CDISeamResourceLoadingHyperlink extends AbstractHyperlink{
+ private IRegion region;
+ private String path;
+ private IFile file;
+
+ public CDISeamResourceLoadingHyperlink(IFile file, IDocument document, IRegion region, String path){
+ super();
+ this.file = file;
+ this.region = region;
+ this.path = path;
+ setDocument(document);
+ }
+
+ protected IFile getFile(){
+ return file;
+ }
+
+ @Override
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ return region;
+ }
+
+ @Override
+ protected void doHyperlink(IRegion region) {
+ IFile file = getFile().getProject().getFile(path);
+ IEditorPart part = openFileInEditor(file);
+ if(part == null)
+ openFileFailed();
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ return NLS.bind(CDISeamExtMessages.CDI_SEAM_RESOURCE_LOADING_HYPERLINK, path);
+ }
+
+}
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlink.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.ISourceRange;
+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.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+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.seam.text.ext.CDISeamExtPlugin;
+import org.jboss.tools.cdi.ui.marker.MarkerResolutionUtils;
+import org.jboss.tools.common.EclipseUtil;
+
+public class CDISeamResourceLoadingHyperlinkDetector extends AbstractHyperlinkDetector{
+ public static final String RESOURCE_ANNOTATION = "org.jboss.seam.solder.resourceLoader.Resource";
+ public static final String VALUE = "value";
+
+ @Override
+ 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)
+ return null;
+
+ IDocument document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+
+ IFile file = null;
+
+ try {
+ IResource resource = input.getCorrespondingResource();
+ if (resource instanceof IFile)
+ file = (IFile) resource;
+ } catch (JavaModelException e) {
+ CDISeamExtPlugin.log(e);
+ }
+
+ if(file == null)
+ return null;
+
+ try {
+
+ ICompilationUnit cu = EclipseUtil.getCompilationUnit(file);
+
+ IJavaElement element = cu.getElementAt(offset);
+ if(element != null){
+ if(element instanceof IField){
+ IAnnotation annotation = MarkerResolutionUtils.getAnnotation(element, RESOURCE_ANNOTATION);
+ if(annotation != null && annotation.exists()){
+ IRegion annotationRegion = getAnnotationRegion(document, annotation);
+ String text = getValue(annotation);
+ if(text != null){
+ return new IHyperlink[]{new CDISeamResourceLoadingHyperlink(file, document, annotationRegion, text)};
+ }
+ }
+ }
+ }
+ }catch(CoreException ex){
+ CDISeamExtPlugin.log(ex);
+ }catch(BadLocationException ex){
+ CDISeamExtPlugin.log(ex);
+ }
+
+ return null;
+ }
+
+ private IRegion getAnnotationRegion(IDocument document, IAnnotation annotation) throws BadLocationException, JavaModelException{
+ ISourceRange sourceRange = annotation.getSourceRange();
+ String annotationText = document.get(sourceRange.getOffset(), sourceRange.getLength());
+ int offset = sourceRange.getOffset();
+ int length = sourceRange.getLength();
+ int first = annotationText.indexOf("\"");
+ if(first >= 0){
+ int last = annotationText.lastIndexOf("\"");
+ if(last > 0 && last != first){
+ offset += first + 1;
+ length = last - first - 1;
+ }
+ }
+
+ IRegion region = new Region(offset, length);
+ return region;
+ }
+
+ private String getValue(IAnnotation annotation) throws JavaModelException{
+ IMemberValuePair[] pairs = annotation.getMemberValuePairs();
+ for(IMemberValuePair pair : pairs){
+ if(pair.getMemberName().equals(VALUE) && pair.getValueKind() == IMemberValuePair.K_STRING){
+ return (String)pair.getValue();
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties
===================================================================
--- cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties (rev 0)
+++ cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties 2011-04-23 00:44:15 UTC (rev 30795)
@@ -0,0 +1,2 @@
+CDI_SEAM_EXT_PLUGIN_NO_MESSAGE=No message
+CDI_SEAM_RESOURCE_LOADING_HYPERLINK=Open Resource ''{0}''
\ No newline at end of file
Property changes on: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/messages.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
More information about the jbosstools-commits
mailing list