[jbosstools-commits] JBoss Tools SVN: r31117 - in trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui: META-INF and 10 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu May 5 21:22:22 EDT 2011


Author: scabanovich
Date: 2011-05-05 21:22:22 -0400 (Thu, 05 May 2011)
New Revision: 31117

Added:
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.project
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/META-INF/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/META-INF/MANIFEST.MF
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/about.html
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/build.properties
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/icons/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/icons/cdi16.png
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.properties
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.xml
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/pom.xml
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIMessages.java
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIPlugin.java
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/TagData.java
   trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/messages.properties
Log:
JBIDE-8842
https://issues.jboss.org/browse/JBIDE-8842

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath	2011-05-06 01:22:22 UTC (rev 31117)
@@ -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: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.project
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.project	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.project	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.jboss.tools.cdi.seam.config.ui</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.seam.config.ui/.project
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/META-INF/MANIFEST.MF	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ActivationPolicy: lazy
+Bundle-Name: %Bundle-Name.0
+Bundle-Activator: org.jboss.tools.cdi.seam.config.ui.CDISeamConfigUIPlugin
+Bundle-ManifestVersion: 2
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.jboss.tools.cdi.seam.config.ui;singleton:=true
+Bundle-Localization: plugin
+Export-Package: org.jboss.tools.cdi.seam.config.ui,
+ org.jboss.tools.cdi.seam.config.ui.contentassist
+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.eclipse.wst.xml.ui,
+ org.jboss.tools.cdi.ui;bundle-version="1.2.0",
+ org.jboss.tools.cdi.core,
+ org.jboss.tools.cdi.seam.config.core,
+ org.jboss.tools.jst.web.kb,
+ org.jboss.tools.jst.web;bundle-version="3.2.0"
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/about.html
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/about.html	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/about.html	2011-05-06 01:22:22 UTC (rev 31117)
@@ -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>&copy;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: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/about.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/build.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/build.properties	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/build.properties	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,12 @@
+source.. = src/
+bin.includes = META-INF/,\
+               icons/,\
+               .,\
+               plugin.xml,\
+               plugin.properties,\
+               about.html
+src.includes = plugin.xml,\
+               plugin.properties,\
+               about.html,\
+               META-INF/,\
+               src/


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/build.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/icons/cdi16.png
===================================================================
(Binary files differ)


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/icons/cdi16.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.properties	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.properties	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,4 @@
+providerName=JBoss by Red Hat
+Bundle-Name.0 = CDI Seam Config UI
+
+proposalCategory.seamConfigTag=Seam Config Tag


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.xml	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.xml	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+   <extension
+       point="org.eclipse.wst.sse.ui.completionProposal">
+	<proposalCategory
+          icon="icons/cdi16.png"
+          id="org.jboss.tools.cdi.ui.proposalCategory.seamConfigTag"
+          name="%proposalCategory.seamConfigTag">
+    </proposalCategory>
+    <proposalComputer
+          activate="true"
+          categoryId="org.jboss.tools.cdi.ui.proposalCategory.cdiClass"
+          class="org.jboss.tools.cdi.seam.config.ui.contentassist.SeamConfigXmlCompletionProposalComputer"
+          id="org.jboss.tools.cdi.seam.config.ui.configXML">
+			<contentType id="org.eclipse.core.runtime.xml">
+				<partitionType id="org.eclipse.wst.xml.XML_DEFAULT" />
+			</contentType>
+			<contentType id="org.eclipse.wst.xml.core.xmlsource">
+				<partitionType id="org.eclipse.wst.xml.XML_DEFAULT" />
+			</contentType>
+			<contentType id="org.jboss.tools.common.model.ui.xml">
+				<partitionType id="org.eclipse.wst.xml.XML_DEFAULT" />
+			</contentType>
+    </proposalComputer>
+   </extension>
+
+</plugin>


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/plugin.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/pom.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/pom.xml	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/pom.xml	2011-05-06 01:22:22 UTC (rev 31117)
@@ -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.0.0-SNAPSHOT</version>
+	<packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/pom.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIMessages.java	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIMessages.java	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.config.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CDISeamConfigUIMessages extends NLS{
+	private static final String BUNDLE_NAME = "org.jboss.tools.cdi.seam.text.ext.messages"; //$NON-NLS-1$
+
+	static {
+		NLS.initializeMessages(BUNDLE_NAME, CDISeamConfigUIMessages.class);
+	}
+	public static String NO_MESSAGE;
+}


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIMessages.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIPlugin.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIPlugin.java	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIPlugin.java	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.config.ui;
+
+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 CDISeamConfigUIPlugin  extends AbstractUIPlugin{
+	//The shared instance.
+	private static CDISeamConfigUIPlugin plugin;
+	//Resource bundle.
+	private ResourceBundle resourceBundle;
+	
+	public static final String PLUGIN_ID = "org.jboss.tools.cdi.seam.config.ui";  //$NON-NLS-1$
+
+	
+	/**
+	 * The constructor.
+	 */
+	public CDISeamConfigUIPlugin() {
+		plugin = this;
+	}
+
+	/**
+	 * Returns the shared instance.
+	 */
+	public static CDISeamConfigUIPlugin 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= CDISeamConfigUIPlugin.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) {
+		CDISeamConfigUIPlugin.getDefault().getLog().log(new Status(Status.INFO, PLUGIN_ID, Status.OK, msg, null));
+	}
+	
+	public static void log(IStatus status) {
+		CDISeamConfigUIPlugin.getDefault().getLog().log(status);
+	}
+	public static void log(String message, Exception exception) {
+		CDISeamConfigUIPlugin.getDefault().getLog().log(new Status(Status.ERROR, CDISeamConfigUIPlugin.PLUGIN_ID, Status.OK, message, exception));		
+	}
+	static public void log(Exception ex) {
+		CDISeamConfigUIPlugin.getDefault().getLog().log(new Status(Status.ERROR, CDISeamConfigUIPlugin.PLUGIN_ID, Status.OK, CDISeamConfigUIMessages.NO_MESSAGE, ex));
+	}
+
+}


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/CDISeamConfigUIPlugin.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,356 @@
+package org.jboss.tools.cdi.seam.config.ui.contentassist;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLModelQueryCompletionProposalComputer;
+import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
+import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.seam.config.core.CDISeamConfigConstants;
+import org.jboss.tools.cdi.seam.config.core.CDISeamConfigExtension;
+import org.jboss.tools.cdi.seam.config.core.util.Util;
+import org.jboss.tools.cdi.seam.config.core.xml.SAXElement;
+import org.jboss.tools.cdi.seam.config.ui.CDISeamConfigUIPlugin;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class SeamConfigXmlCompletionProposalComputer extends AbstractXMLModelQueryCompletionProposalComputer {
+	CompletionProposalInvocationContext context;
+	Node currentNode;
+	SAXElement sax;
+
+	IFile resource;
+	IProject project;
+	IJavaProject javaProject;
+	CDICoreNature cdi;
+	CDISeamConfigExtension extension;
+
+	Map<String, String> uriByPrefix = new HashMap<String, String>();
+	Map<String, String> prefixByUri = new HashMap<String, String>();
+	String eePrefix;
+	Map<String, String> prefixByPackage = new HashMap<String, String>();
+
+	public List computeCompletionProposals(
+			CompletionProposalInvocationContext context,
+			IProgressMonitor monitor) {
+		this.context = context;
+		currentNode = findNode();
+		sax = buildSAXElement(currentNode);
+	
+		fillNameSpaces(currentNode);
+		resource = findResource(getDocument());
+		if(resource != null) {
+			javaProject = EclipseResourceUtil.getJavaProject(resource.getProject());
+			cdi = CDICorePlugin.getCDI(resource.getProject(), true);
+			if(cdi != null) extension = CDISeamConfigExtension.getExtension(cdi);
+		}
+		//compute the completion proposals
+		return super.computeCompletionProposals(context, monitor);
+	}
+
+	protected boolean isActive() {
+		//Cannot work without resource.
+		//Have nothing to suggest without packages.
+		//can only add in context of an element.
+		return (resource != null && !prefixByPackage.isEmpty() && sax != null);
+	}
+	
+	protected IDocument getDocument() {
+		return context.getDocument();
+	}
+
+	private Node findNode() {
+		return (Node)ContentAssistUtils.getNodeAt(context.getViewer(), context.getInvocationOffset());
+	}
+
+	private IFile findResource(IDocument document) {
+		IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+		try {
+			if (sModel != null) {
+				String baseLocation = sModel.getBaseLocation();
+				IPath location = new Path(baseLocation).makeAbsolute();
+				return FileBuffers.getWorkspaceFileAtLocation(location);
+			}
+		} finally {
+			if (sModel != null) {
+				sModel.releaseFromRead();
+			}
+		}
+		return null;
+	}
+
+	private SAXElement buildSAXElement(Node node) {
+		while(node != null && !(node instanceof Element)) {
+			node = node.getParentNode();
+		}
+		if(node != null) {
+			SAXElement sax = new SAXElement(node);
+			SAXElement parent = buildSAXElement(node.getParentNode());
+			sax.setParent(parent);
+			return sax;
+		}
+		
+		return null;
+	}
+	
+	@Override
+	protected void addTagInsertionProposals(
+			ContentAssistRequest contentAssistRequest, int childPosition,
+			CompletionProposalInvocationContext context) {
+		if(!isActive()) {
+			return;
+		}
+
+		Node currentNode = contentAssistRequest.getNode();
+		Node parentElement = currentNode;
+		while(parentElement != null && !(parentElement instanceof Element)) parentElement = parentElement.getParentNode();
+		if(parentElement == null) {
+			//Can suggest nothing without parent context.
+			return;
+		}
+		String parentElementName = sax.getLocalName();
+		String parentElementPrefix = sax.getPrefix();
+
+		Set<TagData> tagData = new HashSet<TagData>();
+
+		if("beans".equals(parentElementName)) {
+			//suggest all classes in all packages.
+			addTypeNames(tagData, false);
+		} else if(parentElementPrefix != null && prefixByPackage.containsValue(parentElementPrefix)) {
+			// If we are not in <beans>, then we have to be in context of some seam package.
+			IType contextType = null;
+			if(Util.isEntry(sax)) {
+				//Inside entry - only <key> and <value>
+				if(eePrefix != null) {
+					addTagData(tagData, eePrefix, CDISeamConfigConstants.KEYWORD_KEY, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 1);
+					addTagData(tagData, eePrefix, CDISeamConfigConstants.KEYWORD_VALUE, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 1);
+				}
+			} else if(Util.isValue(sax) || Util.isKey(sax)) {
+				//Inside value or key we can define new bean.
+				addTypeNames(tagData, false);
+			} else if(Util.isParameters(sax)) {
+				//TODO find parent method name and type, and suggest parameter types. 
+			} else if((contextType = Util.resolveType(sax, cdi)) != null) {
+				//We are inside bean. Suggest members and annotations.
+				addTypeNames(tagData, true); //only annotations allowed here.
+				addTagData(tagData, getTagNamesForMembers(parentElementPrefix, contextType), XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 2);
+
+				if(eePrefix != null) {
+					TagData d = new TagData(eePrefix + ":" + CDISeamConfigConstants.KEYWORD_MODIFIES, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 1);
+					d.hasClosingTag = false;
+					tagData.add(d);
+					d = new TagData(eePrefix + ":" + CDISeamConfigConstants.KEYWORD_REPLACES, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 1);
+					tagData.add(d);
+				}
+			} else if(sax.getParent() != null && ((contextType = Util.resolveType(sax.getParent(), cdi)) != null)) {
+				IMember member = null;
+				try {
+					member = Util.resolveMember(contextType, sax);
+				} catch (JavaModelException e) {
+					CDISeamConfigUIPlugin.getDefault().log(e);
+				}
+				if(member != null) {
+					//We are inside bean member. Suggest annotations and <value>.
+					addTypeNames(tagData, true); //only annotations allowed here.
+					if(eePrefix != null) {
+						if(member instanceof IField) {
+							addTagData(tagData, eePrefix, CDISeamConfigConstants.KEYWORD_VALUE, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 1);
+						} else if(member instanceof IMethod) {
+							addTagData(tagData, eePrefix, CDISeamConfigConstants.KEYWORD_PARAMETERS, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 1);
+						}
+					}
+
+				}
+			}
+		}
+
+		int begin = contentAssistRequest.getReplacementBeginPosition();;
+		int length = contentAssistRequest.getReplacementLength();
+		for (TagData tag: tagData) {
+			String tagText = tag.getText();
+			String proposedInfo = null;
+			CustomCompletionProposal textProposal = new CustomCompletionProposal(
+					tagText, begin, length, tagText.length(),
+					XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC),
+					tag.getName(), null, proposedInfo, tag.getRelevance());
+			contentAssistRequest.addProposal(textProposal);
+		}
+	}
+
+	private void addTypeNames(Set<TagData> tagData, boolean annotationsOnly) {
+		try {
+			Set<String> tagNames = getAllTagNames(annotationsOnly);
+			addTagData(tagData, tagNames, XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME - 3);
+		} catch (JavaModelException e) {
+			CDISeamConfigUIPlugin.getDefault().log(e);
+		}
+	}
+
+	private void addTagData(Set<TagData> tagData, String prefix, String name, int relevance) {
+		tagData.add(new TagData(prefix + ":" + name, relevance));
+	}
+
+	private void addTagData(Set<TagData> tagData, Set<String> tagNames, int relevance) {
+		for (String tagName: tagNames) {
+			tagData.add(new TagData(tagName, relevance));
+		}
+	}
+
+	protected void addTagNameProposals(ContentAssistRequest contentAssistRequest,
+			int childPosition, CompletionProposalInvocationContext context) {
+		if(!isActive()) {
+			return;
+		}
+		//TODO
+	//	super.addTagNameProposals(contentAssistRequest, childPosition, context);
+	}
+
+	@Override
+	protected XMLContentModelGenerator getContentGenerator() {
+		return new XMLContentModelGenerator();
+	}
+
+	@Override
+	protected boolean validModelQueryNode(CMNode node) {
+		return false;
+	}
+
+	static String XMLNS_PREFIX = "xmlns:";
+
+	private void fillNameSpaces(Node node) {
+		uriByPrefix.clear();
+		prefixByUri.clear();
+		prefixByPackage.clear();
+		eePrefix = null;
+		while(node != null) {
+			if(node instanceof Element) {
+				Element element = (Element)node;
+				NamedNodeMap as = element.getAttributes();
+				for (int i = 0; i < as.getLength(); i++) {
+					Node a = as.item(i);
+					String nm = a.getNodeName();
+					if(nm.startsWith(XMLNS_PREFIX)) {
+						String prefix = nm.substring(XMLNS_PREFIX.length());
+						String uri = a.getNodeValue();
+						if(uri != null) {
+							uriByPrefix.put(prefix, uri);
+							prefixByUri.put(uri, prefix);
+							String[] packages = Util.getPackages(uri);
+							for (String pkg: packages) {
+								prefixByPackage.put(pkg, prefix);
+							}
+						}
+					}
+				}
+			}
+			eePrefix = prefixByPackage.get(CDISeamConfigConstants.PACKAGE_EE);
+			node = node.getParentNode();
+		}
+	}
+
+	Set<String> getAllTagNames(boolean annotationsOnly) throws JavaModelException {
+		Set<String> result = new HashSet<String>();
+		for (String packageName: prefixByPackage.keySet()) {
+			String prefix = prefixByPackage.get(packageName);
+			Set<String> typeNames = findTypeNamesByPackage(javaProject, packageName, annotationsOnly);
+			for (String typeName: typeNames) result.add(prefix + ":" + typeName);
+		}
+		return result;
+	}
+
+	Set<String> getTypeNamesByPrefix(String prefix, boolean annotationsOnly) throws JavaModelException {
+		Set<String> result = new HashSet<String>();
+		String uri = uriByPrefix.get(prefix);
+		for (String packageName: Util.getPackages(uri)) {
+			result.addAll(findTypeNamesByPackage(javaProject, packageName, annotationsOnly));
+		}
+		return result;
+	}
+
+	public static Set<String> findTypeNamesByPackage(IJavaProject javaProject, String packageName, boolean annotationsOnly) throws JavaModelException {
+		Set<String> result = new HashSet<String>();
+		if(CDISeamConfigConstants.PACKAGE_EE.equals(packageName)) {
+			result.addAll(Util.EE_TYPES.keySet());
+		} else if(javaProject != null) {
+			IPackageFragmentRoot[] rs = javaProject.getAllPackageFragmentRoots();
+			for (IPackageFragmentRoot r: rs) {
+				IPackageFragment pkg = r.getPackageFragment(packageName);
+				if(pkg != null && pkg.exists()) {
+					ICompilationUnit[] units = pkg.getCompilationUnits();
+					for (ICompilationUnit u: units) {
+						IType[] ts = u.getTypes();
+						for (IType t: ts) if(accept(t, annotationsOnly)) result.add(t.getElementName());
+					}
+					IClassFile[] cs = pkg.getClassFiles();
+					for (IClassFile cls: cs) {
+						if(accept(cls.getType(), annotationsOnly)) result.add(cls.getType().getElementName());
+					}
+				}
+			}
+			
+		}
+		return result;
+	}
+
+	private static boolean accept(IType type, boolean annotationOnly) throws JavaModelException {
+		if(type == null) return false;
+		if(annotationOnly && !type.isAnnotation()) return false;
+		return true;
+	}
+
+	private Set<String> getTagNamesForMembers(String prefix, IType type) {
+		Set<String> result = new HashSet<String>();
+		try {
+			IField[] fs = type.getFields();
+			for (IField f: fs) {
+				result.add(prefix + ":" + f.getElementName());
+			}
+			IMethod[] ms = type.getMethods();
+			for (IMethod m: ms) {
+				result.add(prefix + ":" + m.getElementName());
+			}
+		} catch (JavaModelException e) {
+			CDISeamConfigUIPlugin.getDefault().log(e);
+		}
+		return result;
+	}
+
+}
+


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/TagData.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/TagData.java	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/TagData.java	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1,25 @@
+package org.jboss.tools.cdi.seam.config.ui.contentassist;
+
+public class TagData {
+	String name;
+	boolean hasClosingTag = true;
+	int relevance;
+	
+	public TagData(String name, int relevance) {
+		this.name = name;
+		this.relevance = relevance;
+	}
+
+	public String getText() {
+		return hasClosingTag ? "<" + name + "></" + name + ">" : "<" + name + "/>";
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public int getRelevance() {
+		return relevance;
+	}
+
+}


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/TagData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/messages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/messages.properties	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/messages.properties	2011-05-06 01:22:22 UTC (rev 31117)
@@ -0,0 +1 @@
+NO_MESSAGE=No message


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/messages.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list