JBoss Tools SVN: r18138 - trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-10-16 13:00:41 -0400 (Fri, 16 Oct 2009)
New Revision: 18138
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
Log:
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-16 16:58:04 UTC (rev 18137)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-16 17:00:41 UTC (rev 18138)
@@ -180,12 +180,6 @@
bot.radio(type).click();
bot.comboBoxWithLabel("Connection profile:").setSelection(projectProperties.getProperty("connName"));
bot.button("Finish").click();
- /* All Jobs are executed inside New SeamProject Wizard so there is no reason to
- * find a way to track that all jobs or particular jobs are finished. Just wait
- * until active shell is closed. Move 30000 to constant or setup default timeout
- * for SWTBot long enough to be sure dialog is finished.
- */
- bot.waitUntil(Conditions.shellCloses(bot.activeShell()),30000);
}
/**Creates any Seam Action, Form etc. */
14 years, 8 months
JBoss Tools SVN: r18137 - trunk/seam/tests/org.jboss.tools.seam.ui.bot.test.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-10-16 12:58:04 -0400 (Fri, 16 Oct 2009)
New Revision: 18137
Removed:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/New_configuration.launch
Log:
Deleted: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/New_configuration.launch
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/New_configuration.launch 2009-10-16 16:35:27 UTC (rev 18136)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/New_configuration.launch 2009-10-16 16:58:04 UTC (rev 18137)
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.swtbot.eclipse.ui.launcher.JunitLaunchConfig">
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="askclear" value="false"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="true"/>
-<booleanAttribute key="clearws" value="true"/>
-<booleanAttribute key="clearwslog" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
-<booleanAttribute key="default" value="true"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/SeamTestLauncher.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.jboss.tools.seam.ui.bot.test.SeamAllBotTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.jboss.tools.seam.ui.bot.test"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms128m -Xmx512m -XX:MaxPermSize=256m -Djbosstools.test.jboss.home=/home/eskimo/jbdevstudio/jboss-eap/jboss-as -Djbosstools.test.seam.1.2.1.eap.home=/home/eskimo/jbdevstudio/jboss-eap/seam -Djbosstools.test.seam.2fp.eap.home=/home/eskimo/jbdevstudio/jboss-eap/seam -Djbosstools.test.seam.2.0.1.GA.home=/home/eskimo/Java/jboss-seam-2.0.1.GA -Djbosstools.test.seam.2.1.0.GA.home=/home/eskimo/Java/jboss-seam-2.1.1.GA"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
-<booleanAttribute key="run_in_ui_thread" value="true"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useDefaultConfig" value="true"/>
-<booleanAttribute key="useDefaultConfigArea" value="false"/>
-<booleanAttribute key="useProduct" value="false"/>
-</launchConfiguration>
14 years, 8 months
JBoss Tools SVN: r18136 - in trunk: jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-10-16 12:35:27 -0400 (Fri, 16 Oct 2009)
New Revision: 18136
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml
Log:
JBIDE-816: Resource bundle completion don't work in template clients
JBIDE-3563: Code assist for "class" and "styleClass" attributes for html and jsf tags.
The schema for included pages contexts is added (The schema is needed to create the contexts for all the pages included into the source. It allows to get an information on bundles declared in included pages as well as some other info that will be useful to calculate proposals on CSS-classes)
The included pages context are created and the following information is collected within the included contexts:
- namespaces declared within the included pages
- tag labraries used in the included pages
- resource bundles declared within the included pages
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml 2009-10-16 16:35:27 UTC (rev 18136)
@@ -108,4 +108,18 @@
</contentType>
</hyperlinkPartitioner>
</extension>
+
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include uri="http://java.sun.com/jsf/facelets">
+ <tag name="composition">
+ <attribute name="template" />
+ </tag>
+ <tag name="decorate">
+ <attribute name="template" />
+ </tag>
+ <tag name="include">
+ <attribute name="page" />
+ </tag>
+ </include>
+ </extension>
</plugin>
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-10-16 16:35:27 UTC (rev 18136)
@@ -344,4 +344,11 @@
</hyperlink>
</extension>
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include uri="http://richfaces.org/a4j">
+ <tag name="include">
+ <attribute name="viewId" />
+ </tag>
+ </include>
+ </extension>
</plugin>
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-10-16 16:35:27 UTC (rev 18136)
@@ -48,6 +48,7 @@
org.eclipse.core.databinding,
org.eclipse.jface.databinding,
org.jboss.tools.jst.web.kb,
- org.eclipse.core.databinding.property;bundle-version="1.2.0"
+ org.eclipse.core.databinding.property;bundle-version="1.2.0",
+ org.eclipse.emf.ecore;bundle-version="2.5.0"
Bundle-Version: 2.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -23,6 +23,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
@@ -30,6 +31,7 @@
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
import org.jboss.tools.jst.web.kb.internal.FaceletPageContextImpl;
@@ -75,9 +77,8 @@
context.setLibraries(getTagLibraries(context));
context.setResourceBundles(super.getResourceBundles(context));
-// IFaceletPageContext getParentContext();
-// Map<String, String> getParams();
-
+ PageContextFactory.createIncludedContexts(context);
+
return context;
}
@@ -141,7 +142,7 @@
start = domElement.getStartOffset();
length = (domElement.hasEndTag() ?
domElement.getEndStructuredDocumentRegion().getEnd() :
- domElement.getLength());
+ ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -10,12 +10,21 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.internal.resources.ICoreConstants;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -24,10 +33,14 @@
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.xml.core.internal.document.NodeContainer;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
@@ -44,11 +57,15 @@
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
@@ -72,6 +89,17 @@
protected ELContext createContextInstance() {
return new JspContextImpl();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
+ */
+ @Override
+ protected IPageContext createContext() {
+ IPageContext context = super.createContext();
+ PageContextFactory.createIncludedContexts(context);
+ return context;
+ }
/**
* Collects the namespaces over the JSP-page and sets them up to the context specified.
@@ -81,46 +109,24 @@
protected void setNameSpaces(XmlContextImpl context) {
super.setNameSpaces(context);
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return;
-
- Document xmlDocument = (sModel instanceof IDOMModel) ?
- ((IDOMModel) sModel).getDocument() :
- null;
-
- if (xmlDocument == null)
- return;
-
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(getDocument());
- List trackers = (manager == null? null : manager.getCMDocumentTrackers(getOffset()));
- for (int i = 0; trackers != null && i < trackers.size(); i++) {
- TaglibTracker tt = (TaglibTracker)trackers.get(i);
- final String prefix = tt.getPrefix();
- final String uri = tt.getURI();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- IRegion region = new Region(0, getDocument().getLength());
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- }
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(getDocument());
+ List trackers = (manager == null? null : manager.getCMDocumentTrackers(getOffset()));
+ for (int i = 0; trackers != null && i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ final String prefix = tt.getPrefix();
+ final String uri = tt.getURI();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ IRegion region = new Region(0, getDocument().getLength());
+ INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
+ context.addNameSpace(region, nameSpace);
}
-
- return;
}
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
+ return;
+ }
-
/**
* Returns the resource bundles
*
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -11,13 +11,16 @@
package org.jboss.tools.jst.jsp.contentassist;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables.User;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
@@ -25,6 +28,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
@@ -37,8 +41,11 @@
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
+import org.jboss.tools.jst.web.kb.include.IncludeContextDefinition;
import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -49,6 +56,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
*
@@ -81,10 +89,11 @@
setNameSpaces(context);
context.setLibraries(getTagLibraries(context));
context.setResourceBundles(getResourceBundles(context));
-
return context;
}
+
+
protected void setVars(ELContextImpl context, IFile file) {
// No vars can be set for this processor
}
@@ -505,7 +514,7 @@
start = domElement.getStartOffset();
length = (domElement.hasEndTag() ?
domElement.getEndStructuredDocumentRegion().getEnd() :
- domElement.getLength());
+ ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-16 16:35:27 UTC (rev 18136)
@@ -12,6 +12,12 @@
org.jboss.tools.common.el.core,
org.eclipse.jface.text,
org.eclipse.wst.sse.core,
+ org.eclipse.wst.sse.ui,
+ org.eclipse.jst.jsp.core,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.common.modulecore,
+ org.jboss.tools.common.text.ext,
+ org.eclipse.emf.ecore,
org.eclipse.wst.xml.ui,
org.eclipse.jdt.ui,
org.eclipse.wst.validation,
@@ -23,6 +29,7 @@
Export-Package: org.jboss.tools.jst.web.kb,
org.jboss.tools.jst.web.kb.action,
org.jboss.tools.jst.web.kb.el,
+ org.jboss.tools.jst.web.kb.include,
org.jboss.tools.jst.web.kb.internal,
org.jboss.tools.jst.web.kb.internal.scanner,
org.jboss.tools.jst.web.kb.internal.taglib,
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-16 16:35:27 UTC (rev 18136)
@@ -2,8 +2,9 @@
<?eclipse version="3.0"?>
<plugin>
<extension-point id="tagLib" name="Kb Custom Tag Lib" schema="schema/tagLib.exsd"/>
+ <extension-point id="KbIncludeContext" name="Kb Include Context Buillder" schema="schema/include.exsd" />
<extension-point id="validator" name="KB Validator" schema="schema/validator.exsd"/>
-
+
<extension
id="kbbuilder"
name="KB Builder"
@@ -69,7 +70,26 @@
<component-extension
location="taglibs/componentExtension.xml"/>
</extension>
+
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include uri="jsp">
+ <tag name="directive.include">
+ <attribute name="file" />
+ </tag>
+ <tag name="include">
+ <attribute name="page" />
+ </tag>
+ </include>
+ <contexttype id="JSP_PAGE_CONTEXT_TYPE">
+ <contenttype id="org.eclipse.jst.jsp.core.jspsource" />
+ </contexttype>
+
+ <contexttype id="FACELETS_PAGE_CONTEXT_TYPE">
+ <contenttype id="org.eclipse.wst.html.core.htmlsource" />
+ </contexttype>
+ </extension>
+
<extension id="kbproblemmarker" name="%KBProblemName" point="org.eclipse.core.resources.markers">
<super type="org.eclipse.core.resources.problemmarker">
</super>
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd 2009-10-16 16:35:27 UTC (rev 18136)
@@ -0,0 +1,205 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.jst.web.kb" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.jst.web.kb" id="KbIncludeContext" name="KbIncludeContext"/>
+ </appInfo>
+ <documentation>
+ The extension point allows the application to define URIs, tags and Attributes that allow the part of code to be included into the page content.
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ <documentation>
+ Defines an extension point for the Include definitions.
+
+ This extension point is used to add information on which tags/tag attributes are used to include a source into a JSP/XHTML page
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="include" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="contexttype" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique ID for this extension point. It is recommended that the plugin ID be used to prefix any extensions.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ A unique ID for this extension. It is recommended that the plugin ID be used to prefix any extensions.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ A brief name to show to the user.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="include">
+ <annotation>
+ <documentation>
+ Defines a include item.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="tag" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="uri" type="string" use="required">
+ <annotation>
+ <documentation>
+ An URI for this element.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="tag">
+ <annotation>
+ <documentation>
+ Defines a tag item. Contains information on tags that have the 'include-to-page-content' possibility.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ A Tag Name.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="attribute">
+ <annotation>
+ <documentation>
+ Defines an attribute item. Contains information on attributes that have the 'include-to-page-content' possibility.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ A Tag Attribute Name.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contexttype">
+ <annotation>
+ <documentation>
+ Defines a contexttype item.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="contenttype" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ An ID for this element.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contenttype">
+ <annotation>
+ <documentation>
+ Defines a contenttype item. Contains information on contenttype that is supported by a surrounding context type.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ An ID for this element.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ V3.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <pre>
+ <extension-point id="KbInclude" name="Kb Include Context Buillder" />
+
+ <extension point="org.jboss.tools.jst.web.kb.KbInclude">
+ <include uri="http://java.sun.com/jsf/core">
+ <tag name="jsp.include">
+ <attribute name="file" />
+ </tag>
+ </include>
+ </extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The baseline for API and extension point stability is RedHat Developer Studio
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ The supplied implementation of the include context functionality requires the WTP components.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ RedHat
+ </documentation>
+ </annotation>
+
+</schema>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -0,0 +1,25 @@
+package org.jboss.tools.jst.web.kb;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+
+public interface IIncludedContextSupport {
+ void addIncludedContext(IPageContext includedContext);
+ List<IPageContext> getIncludedContexts();
+
+ /**
+ * Returns Resource of the page
+ * @return
+ */
+ IFile getResource();
+
+ /**
+ * Returns map of name spaces which are set in particular offset.
+ * Key is URI of name space.
+ * @return
+ */
+ Map<String, List<INameSpace>> getNameSpaces(int offset);
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -23,7 +23,7 @@
* Page context
* @author Alexey Kazakov
*/
-public interface IPageContext extends ELContext {
+public interface IPageContext extends ELContext, IIncludedContextSupport {
/**
* Returns libraries which should be used in this context
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -10,24 +10,86 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.internal.resources.ICoreConstants;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
+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.IStructuredDocumentRegion;
+import org.eclipse.wst.xml.core.internal.document.NodeContainer;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.jboss.tools.common.el.core.GlobalELReferenceList;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.common.resref.core.ResourceReference;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
+import org.jboss.tools.jst.web.kb.internal.FaceletPageContextImpl;
import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
+import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
+import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
+import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
+import org.jboss.tools.jst.web.kb.taglib.CustomTagLibManager;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+import org.jboss.tools.jst.web.kb.taglib.TagLibriryManager;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.eclipse.ui.part.FileEditorInput;
/**
* @author Alexey Kazakov
*/
public class PageContextFactory {
+ public static String JSP_PAGE_CONTEXT_TYPE = "JSP_PAGE_CONTEXT_TYPE";
+ public static String FACELETS_PAGE_CONTEXT_TYPE = "FACELETS_PAGE_CONTEXT_TYPE";
+
/**
- * Creates a page context for given resource and offset.
- * @param file JSP or Facelet
- * @param offset
- * @return
+ * Creates a page context for the specified context type
+ * @
*/
- public static IPageContext createPageContext(IFile file, int offset) {
- // TODO
+ public static IPageContext createPageContext(IFile file, int offset, String contentType) {
+ String contextType = IncludeContextBuilder.getInstance().getContextType(contentType);
+ if (JSP_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return createJSPContext(file, offset);
+ }
+ else if (FACELETS_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return createFaceletPageContext(file, offset);
+ }
return null;
}
@@ -37,37 +99,720 @@
* @param offset
* @return
*/
- public static IPageContext createJSPContext(IFile file, int offset) {
+ private static IPageContext createJSPContext(IFile file, int offset) {
JspContextImpl context = new JspContextImpl();
-// context.s
- // TODO
- return null;
+
+
+ IEditorInput input = new FileEditorInput(file);
+ try {
+ ELResolver[] elResolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
+ context.setResource(file);
+ context.setDocument(getConnectedDocument(input));
+ context.setElResolvers(elResolvers);
+
+ setXMLNameSpaces(context, offset);
+ setJSPNameSpaces(context, offset);
+ context.setLibraries(getTagLibraries(context, offset));
+ context.setResourceBundles(getResourceBundles(context));
+ createIncludedContexts(context);
+ } finally {
+ releaseConnectedDocument(input);
+ context.setDocument(null);
+ }
+ return context;
}
/**
- * Creates a jsp context for given resource, document and offset.
- * @param file JSP
+ * Creates a facelet context for given resource and offset.
+ * @param file Facelet
* @param offset
- * @param document
* @return
*/
- public static IPageContext createJSPContext(IFile file, IDocument document, int offset) {
- JspContextImpl context = new JspContextImpl();
- context.setDocument(document);
- context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
-// context.s
- // TODO
- return null;
+ private static IFaceletPageContext createFaceletPageContext(IFile file, int offset) {
+ FaceletPageContextImpl context = new FaceletPageContextImpl();
+
+ IEditorInput input = new FileEditorInput(file);
+ try {
+ ELResolver[] elResolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
+ context.setResource(file);
+ context.setDocument(getConnectedDocument(input));
+ context.setElResolvers(elResolvers);
+
+ setXMLNameSpaces(context, offset);
+ setFaceletsNameSpaces(context, offset);
+ context.setLibraries(getTagLibraries(context, offset));
+ context.setResourceBundles(getResourceBundles(context));
+
+ PageContextFactory.createIncludedContexts(context);
+ } finally {
+ releaseConnectedDocument(input);
+ context.setDocument(null);
+ }
+ return context;
+
}
+
+ /* Utility functions */
+
+ public static void createIncludedContexts(IPageContext context) {
+ if (!(context instanceof IIncludedContextSupport))
+ return;
+
+ IStructuredModel sModel = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(context.getDocument());
+ try {
+ if (sModel == null)
+ return;
+
+ Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ if (xmlDocument == null)
+ return;
+
+ if (xmlDocument instanceof IDOMNode) {
+ createIncludedContextForNode((IDOMNode)xmlDocument, (IIncludedContextSupport)context);
+ }
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ }
+
+ private static void createIncludedContextForNode(IDOMNode node, IIncludedContextSupport context) {
+ String prefix = node.getPrefix() == null ? "" : node.getPrefix(); //$NON-NLS-1$
+ String tagName = node.getLocalName();
+ if (node instanceof IDOMElement) {
+ Map<String, List<INameSpace>> nsMap = context.getNameSpaces(node.getStartOffset());
+ String[] uris = getUrisByPrefix(nsMap, prefix);
+
+ if (uris != null) {
+ for (String uri : uris) {
+ String[] includeAttributes = IncludeContextBuilder.getIncludeAttributes(uri, tagName);
+ if (includeAttributes != null) {
+ for (String attr : includeAttributes) {
+ createIncludedContextFromAttribute((IDOMElement)node, attr, context);
+ }
+ }
+ }
+ }
+ }
+
+ NodeList children = node.getChildNodes();
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ if (children.item(i) instanceof IDOMElement) {
+ createIncludedContextForNode((IDOMElement)children.item(i), context);
+ }
+ }
+ }
+
+ private static void createIncludedContextFromAttribute(IDOMElement node, String attribute, IIncludedContextSupport context) {
+ String fileName = node.getAttribute(attribute);
+ if (fileName == null || fileName.trim().length() == 0)
+ return;
+
+ IFile file = getFileFromProject(fileName, context.getResource());
+ if (file == null)
+ return;
+
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(file);
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return;
+
+ try {
+ Document xmlDocument = (sModel instanceof IDOMModel) ?
+ ((IDOMModel) sModel).getDocument() : null;
+
+ if (xmlDocument == null)
+ return;
+
+ if (xmlDocument instanceof IDOMNode) {
+ String contentType = sModel.getContentTypeIdentifier();
+ IPageContext includedContext = PageContextFactory.createPageContext(file, ((IDOMNode) xmlDocument).getEndOffset() - 1, contentType);
+ context.addIncludedContext(includedContext);
+ }
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+
+ static Node findNodeForOffset(IDOMNode node, int offset) {
+ if(node == null) return null;
+ if (!node.contains(offset)) return null;
+
+ if (node.hasChildNodes()) {
+ // Try to find the node in children
+ NodeList children = node.getChildNodes();
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ IDOMNode child = (IDOMNode)children.item(i);
+ if (child.contains(offset)) {
+ return findNodeForOffset(child, offset);
+ }
+ }
+ }
+ // Not found in children or nave no children
+ if (node.hasAttributes()) {
+ // Try to find in the node attributes
+ NamedNodeMap attributes = node.getAttributes();
+
+ for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
+ IDOMNode attr = (IDOMNode)attributes.item(i);
+ if (attr.contains(offset)) {
+ return attr;
+ }
+ }
+ }
+ // Return the node itself
+ return node;
+ }
+
+ static Node findNodeForOffset(Node node, int offset) {
+ return (node instanceof IDOMNode) ? findNodeForOffset((IDOMNode)node, offset) : null;
+ }
+
+ private static IDocument getConnectedDocument(IEditorInput input) {
+ IDocumentProvider provider= DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ // Ignore. The provider probably will return null in this case
+ }
+ return provider.getDocument(input);
+ }
+
+ private static void releaseConnectedDocument(IEditorInput input) {
+ IDocumentProvider provider= DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ provider.disconnect(input);
+ }
+
+
+ private static Document getDocument(IFile file) {
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(file);
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return null;
+
+ try {
+ return (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+
/**
- * Creates a facelet context for given resource and offset.
- * @param file Facelet
- * @param offset
+ * Collects the namespaces over the XML-page and sets them up to the context specified.
+ *
+ * @param context
+ */
+ private static void setXMLNameSpaces(XmlContextImpl context, int offset) {
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(context.getResource());
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return;
+
+ try {
+ Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ if (xmlDocument == null)
+ return;
+
+ Node n = findNodeForOffset(xmlDocument, offset);
+ while (n != null) {
+ if (!(n instanceof Element)) {
+ if (n instanceof Attr) {
+ n = ((Attr) n).getOwnerElement();
+ } else {
+ n = n.getParentNode();
+ }
+ continue;
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+ for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
+ Attr a = (Attr) attrs.item(j);
+ String name = a.getName();
+ if (name.startsWith("xmlns:")) { //$NON-NLS-1$
+ final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
+ final String uri = a.getValue();
+ if (prefix != null && prefix.trim().length() > 0
+ && uri != null && uri.trim().length() > 0) {
+
+ int start = ((IndexedRegion) n).getStartOffset();
+ int length = ((IndexedRegion) n).getLength();
+
+ IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement) n
+ : null);
+ if (domElement != null) {
+ start = domElement.getStartOffset();
+ length = (domElement.hasEndTag() ? domElement
+ .getEndStructuredDocumentRegion()
+ .getEnd() : ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
+ }
+
+ Region region = new Region(start, length);
+ INameSpace nameSpace = new NameSpace(uri.trim(),
+ prefix.trim());
+ context.addNameSpace(region, nameSpace);
+ }
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ return;
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ }
+
+ /**
+ * Collects the namespaces over the JSP-page and sets them up to the context specified.
+ *
+ * @param context
+ */
+ private static void setJSPNameSpaces(JspContextImpl context, int offset) {
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(context.getDocument());
+ List trackers = (manager == null? null : manager.getCMDocumentTrackers(offset));
+ for (int i = 0; trackers != null && i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ final String prefix = tt.getPrefix();
+ final String uri = tt.getURI();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ IRegion region = new Region(0, context.getDocument().getLength());
+ INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
+ context.addNameSpace(region, nameSpace);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * Collects the namespaces over the Facelets-page and sets them up to the context specified.
+ *
+ * @param context
+ */
+ private static void setFaceletsNameSpaces(FaceletPageContextImpl context, int offset) {
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(context.getResource());
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return;
+
+
+ try {
+ Document xmlDocument = (sModel instanceof IDOMModel) ?
+ ((IDOMModel) sModel).getDocument() : null;
+
+ if (xmlDocument == null)
+ return;
+
+ Node n = findNodeForOffset(xmlDocument, offset);
+ while (n != null) {
+ if (!(n instanceof Element)) {
+ if (n instanceof Attr) {
+ n = ((Attr) n).getOwnerElement();
+ } else {
+ n = n.getParentNode();
+ }
+ continue;
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+ for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
+ Attr a = (Attr) attrs.item(j);
+ String name = a.getName();
+ if (name.startsWith("xmlns:")) { //$NON-NLS-1$
+ final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
+ final String uri = a.getValue();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ int start = ((IndexedRegion)n).getStartOffset();
+ int length = ((IndexedRegion)n).getLength();
+
+ IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement)n : null);
+ if (domElement != null) {
+ start = domElement.getStartOffset();
+ length = (domElement.hasEndTag() ?
+ domElement.getEndStructuredDocumentRegion().getEnd() :
+ ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
+
+ }
+
+ Region region = new Region(start, length);
+ INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
+ context.addNameSpace(region, nameSpace);
+ if (CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(uri)) {
+ nameSpace = new NameSpace(CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI, ""); //$NON-NLS-1$
+ context.addNameSpace(region, nameSpace);
+ }
+ }
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ return;
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+
+ private static final ITagLibrary[] EMPTY_LIBRARIES = new ITagLibrary[0];
+ private static final IResourceBundle[] EMPTY_RESOURCE_BUNDLES = new IResourceBundle[0];
+
+ /**
+ * Returns the Tag Libraries for the namespaces collected in the context.
+ * Important: The context must be created using createContext() method before using this method.
+ *
+ * @param context The context object instance
* @return
*/
- public static IFaceletPageContext createFaceletPageContext(IFile file, int offset) {
- // TODO
+ public static ITagLibrary[] getTagLibraries(IPageContext context, int offset) {
+ Map<String, List<INameSpace>> nameSpaces = context.getNameSpaces(offset);
+ if (nameSpaces == null || nameSpaces.isEmpty())
+ return EMPTY_LIBRARIES;
+
+ IProject project = context.getResource() == null ? null : context.getResource().getProject();
+ if (project == null)
+ return EMPTY_LIBRARIES;
+
+ List<ITagLibrary> tagLibraries = new ArrayList<ITagLibrary>();
+ for (List<INameSpace> nameSpace : nameSpaces.values()) {
+ for (INameSpace n : nameSpace) {
+ ITagLibrary[] libs = TagLibriryManager.getLibraries(project, n.getURI());
+ if (libs != null && libs.length > 0) {
+ for (ITagLibrary lib : libs) {
+ tagLibraries.add(lib);
+ }
+ }
+ }
+ }
+ return (tagLibraries.isEmpty() ? EMPTY_LIBRARIES :
+ (ITagLibrary[])tagLibraries.toArray(new ITagLibrary[tagLibraries.size()]));
+ }
+
+ /**
+ * Returns the resource bundles
+ *
+ * @return
+ */
+ private static IResourceBundle[] getResourceBundles(IPageContext context) {
+ List<IResourceBundle> list = new ArrayList<IResourceBundle>();
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager().getModelForRead(context.getResource());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (sModel == null)
+ return new IResourceBundle[0];
+ try {
+ Document dom = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() : null;
+ if (dom != null) {
+ Element element = dom.getDocumentElement();
+ NodeList children = (NodeContainer)dom.getChildNodes();
+ if (element != null) {
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ IDOMNode xmlnode = (IDOMNode)children.item(i);
+ update((IDOMNode)xmlnode, context, list);
+ }
+ }
+ }
+ }
+ finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ return list.toArray(new IResourceBundle[list.size()]);
+ }
+
+ private static void update(IDOMNode element, IPageContext context, List<IResourceBundle> list) {
+ if (element != null) {
+ registerBundleForNode(element, context, list);
+ for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child instanceof IDOMNode) {
+ update((IDOMNode)child, context, list);
+ }
+ }
+ }
+ }
+ private static void registerBundleForNode(IDOMNode node, IPageContext context, List<IResourceBundle> list) {
+ if (node == null) return;
+ String name = node.getNodeName();
+ if (name == null) return;
+ if (!name.endsWith("loadBundle")) return; //$NON-NLS-1$
+ if (name.indexOf(':') == -1) return;
+ String prefix = name.substring(0, name.indexOf(':'));
+
+ Map<String, List<INameSpace>> ns = context.getNameSpaces(node.getStartOffset());
+ if (!containsPrefix(ns, prefix)) return;
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes == null) return;
+ String basename = (attributes.getNamedItem("basename") == null ? null : attributes.getNamedItem("basename").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
+ String var = (attributes.getNamedItem("var") == null ? null : attributes.getNamedItem("var").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (basename == null || basename.length() == 0 ||
+ var == null || var.length() == 0) return;
+
+ list.add(new ResourceBundle(basename, var));
+ }
+
+ private static boolean containsPrefix(Map<String, List<INameSpace>> ns, String prefix) {
+ for (List<INameSpace> n: ns.values()) {
+ for (INameSpace nameSpace : n) {
+ if(prefix.equals(nameSpace.getPrefix())) return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Searches the namespace map and returns all the URIs for the specified prefix
+ *
+ * @param nsMap
+ * @param prefix
+ * @return
+ */
+ public static String[] getUrisByPrefix(Map<String, List<INameSpace>> nsMap, String prefix) {
+ if(nsMap == null || nsMap.isEmpty())
+ return null;
+ Set<String> uris = new HashSet<String>();
+ for (List<INameSpace> nsList : nsMap.values()) {
+ for (INameSpace ns : nsList) {
+ if (prefix.equals(ns.getPrefix())) {
+ uris.add(ns.getURI());
+ }
+ }
+ }
+
+ return uris.isEmpty() ? new String[] {prefix} : (String[])uris.toArray(new String[uris.size()]);
+ }
+
+ /**
+ * Searches the file with the name specified
+ *
+ * @param fileName
+ * @param documentFile
+ * @return
+ */
+ public static IFile getFileFromProject(String fileName, IFile documentFile) {
+ if(documentFile == null || !documentFile.isAccessible()) return null;
+
+ fileName = findAndReplaceElVariable(fileName);
+
+ IProject project = documentFile.getProject();
+ String name = Utils.trimFilePath(fileName);
+ IPath currentPath = documentFile.getLocation()
+ .removeLastSegments(1);
+ IResource member = null;
+ StructureEdit se = StructureEdit.getStructureEditForRead(project);
+ if (se == null) {
+ return null;
+ }
+ WorkbenchComponent[] modules = se.getWorkbenchModules();
+ for (int i = 0; i < modules.length; i++) {
+ if (name.startsWith("/")) { //$NON-NLS-1$
+ member = findFileByAbsolutePath(project, modules[i], name);
+ } else {
+ member = findFileByRelativePath(project, modules[i],
+ currentPath, name);
+ if (member == null && name.length() > 0) {
+ // in some cases path having no leading "/" is
+ // nevertheless absolute
+ member = findFileByAbsolutePath(project, modules[i],
+ "/" + name); //$NON-NLS-1$
+ }
+ }
+ if (member != null && (member instanceof IFile)) {
+ if (((IFile) member).exists())
+ return (IFile) member;
+ }
+ }
return null;
}
+
+ private static IFile findFileByRelativePath(IProject project,
+ WorkbenchComponent module, IPath basePath, String path) {
+
+ if (path == null || path.trim().length() == 0)
+ return null;
+
+ path = findAndReplaceElVariable(path);
+
+ ComponentResource[] resources = module.findResourcesBySourcePath(
+ new Path("/"), 0); //$NON-NLS-1$
+ IPath projectPath = project.getLocation();
+ IFile member = null;
+
+ for (int i = 0; resources != null && i < resources.length; i++) {
+ IPath runtimePath = resources[i].getRuntimePath();
+ IPath sourcePath = resources[i].getSourcePath();
+
+ // Look in source environment
+ IPath webRootPath = projectPath.append(sourcePath);
+ IPath relativePath = Utils.getRelativePath(webRootPath,
+ basePath);
+ IPath filePath = relativePath.append(path);
+ member = project.getFolder(sourcePath).getFile(filePath);
+ if (member.exists()) {
+ return member;
+ }
+
+ // Look in runtime environment
+ if (runtimePath.segmentCount() >= ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH - 1) {
+ webRootPath = projectPath.append(runtimePath);
+ relativePath = Utils.getRelativePath(webRootPath, basePath);
+ filePath = relativePath.append(path);
+ member = project.getFolder(runtimePath).getFile(filePath);
+ if (member.exists()) {
+ return member;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static IFile findFileByAbsolutePath(IProject project,
+ WorkbenchComponent module, String path) {
+ ComponentResource[] resources = module.findResourcesBySourcePath(
+ new Path("/"), 0); //$NON-NLS-1$
+
+ path = findAndReplaceElVariable(path);
+
+ IFile member = null;
+
+ for (int i = 0; resources != null && i < resources.length; i++) {
+ IPath runtimePath = resources[i].getRuntimePath();
+ IPath sourcePath = resources[i].getSourcePath();
+
+ // Look in source environment
+ member = project.getFolder(sourcePath).getFile(path);
+ if(member.exists()) {
+ return member;
+ }
+
+ // Look in runtime environment
+ if (runtimePath.segmentCount() >= ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH - 1) {
+ member = project.getFolder(runtimePath).getFile(path);
+ if (member.exists()) {
+ return member;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static final String DOLLAR_PREFIX = "${"; //$NON-NLS-1$
+
+ private static final String SUFFIX = "}"; //$NON-NLS-1$
+
+ private static final String SHARP_PREFIX = "#{"; //$NON-NLS-1$
+
+ // partly copied from org.jboss.tools.vpe.editor.util.ElService
+ public static String findAndReplaceElVariable(String fileName){
+ final IPath workspacePath = Platform.getLocation();
+
+ final ResourceReference[] gResources = GlobalELReferenceList.getInstance().getAllResources(workspacePath);
+ String result = fileName;
+
+ ResourceReference[] sortedReferences = sortReferencesByScope(gResources);
+
+ for (ResourceReference rf : sortedReferences) {
+ final String dollarEl = DOLLAR_PREFIX + rf.getLocation() + SUFFIX;
+ final String sharpEl = SHARP_PREFIX + rf.getLocation() + SUFFIX;
+
+ if (fileName.contains(dollarEl)) {
+ result = result.replace(dollarEl, rf.getProperties());
+ }
+ if (fileName.contains(sharpEl)) {
+ result = result.replace(sharpEl, rf.getProperties());
+ }
+ }
+ return result;
+ }
+
+ // copied from org.jboss.tools.vpe.editor.util.ElService
+ private static ResourceReference[] sortReferencesByScope(ResourceReference[] references) {
+ ResourceReference[] sortedReferences = references.clone();
+
+ Arrays.sort(sortedReferences, new Comparator<ResourceReference>() {
+ public int compare(ResourceReference r1, ResourceReference r2) {
+ return r1.getScope() - r2.getScope();
+ }
+ });
+
+ return sortedReferences;
+ }
}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -0,0 +1,226 @@
+package org.jboss.tools.jst.web.kb.include;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.internal.registry.RegistryReader;
+
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+public class IncludeContextBuilder extends RegistryReader {
+ // extension point ID
+ public static final String PL_INCLUDE = "KbIncludeContext"; //$NON-NLS-1$
+
+ public static final String TAG_INCLUDE = "include"; //$NON-NLS-1$
+ public static final String TAG_TAG = "tag"; //$NON-NLS-1$
+ public static final String TAG_ATTRIBUTE = "attribute"; //$NON-NLS-1$
+ public static final String TAG_CONTEXTTYPE = "contexttype"; //$NON-NLS-1$
+ public static final String TAG_CONTENTTYPE = "contenttype"; //$NON-NLS-1$
+
+ public static final String ATT_ID = "id"; //$NON-NLS-1$
+ public static final String ATT_URI = "uri"; //$NON-NLS-1$
+ public static final String ATT_NAME = "name"; //$NON-NLS-1$
+
+ protected String fTargetContributionElement;
+
+ private static IncludeContextBuilder fInstance;
+
+ private List<IncludeContextDefinition> fIncludeContextDefs = null;
+ private IncludeContextDefinition fCurrentIncludeDefinition = null;
+
+ /**
+ * returns singleton instance of HyperlinkBuilder
+ *
+ * @return HyperlinkBuilder
+ */
+ public synchronized static IncludeContextBuilder getInstance() {
+ if (fInstance == null) {
+ fInstance = new IncludeContextBuilder();
+ }
+ return fInstance;
+ }
+
+ /**
+ * Returns the name of the part ID attribute that is expected
+ * in the target extension.
+ *
+ * @param element
+ * @return String
+ */
+ public static String getId(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_ID);
+ return value;
+ }
+
+ public static String getUri(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_URI);
+ return value;
+ }
+
+ public static String getName(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_NAME);
+ return value;
+ }
+
+ /**
+ * Processes element which should be a configuration element specifying an
+ * open on object. Creates a new open on definition object and adds it to the
+ * list of open on definition objects
+ *
+ * @param element hyperlink configuration element
+ */
+ private void processIncludeElement(IConfigurationElement element) {
+ String theUri = getUri(element);
+// String theResolver = getIncludeResolver(element);
+
+ theUri = theUri == null ? "" : theUri; //$NON-NLS-1$
+
+ // start building new HyperlinkDefinition
+ fCurrentIncludeDefinition = new IncludeContextDefinition(theUri, element);
+
+ // create a new list of open on definitions if it hasnt been created yet
+ if (fIncludeContextDefs == null) {
+ fIncludeContextDefs = new ArrayList<IncludeContextDefinition>();
+ }
+ fIncludeContextDefs.add(fCurrentIncludeDefinition);
+ }
+
+ private void processTagElement(IConfigurationElement element) {
+ String theName = getName(element);
+
+ if (fCurrentIncludeDefinition != null && theName != null) {
+ fCurrentIncludeDefinition.addTag(theName, element);
+ }
+ }
+
+ private void processAttributeElement(IConfigurationElement element) {
+ String theName = getName(element);
+
+ if (fCurrentIncludeDefinition != null && theName != null) {
+ fCurrentIncludeDefinition.addTagAttribute(theName, element);
+ }
+ }
+
+ private void processContextTypeElement(IConfigurationElement element) {
+ String theId = getId(element);
+
+ if (fCurrentIncludeDefinition != null && theId != null) {
+ fCurrentIncludeDefinition.addContextType(theId, element);
+ }
+ }
+
+ private boolean processContentTypeElement(IConfigurationElement element) {
+ String theId = getId(element);
+
+ if (fCurrentIncludeDefinition != null && theId != null) {
+ return fCurrentIncludeDefinition.addContentType(theId, element);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.sse.editor.internal.extension.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ protected boolean readElement(IConfigurationElement element) {
+ String tag = element.getName();
+
+ if (tag.equals(fTargetContributionElement)) {
+ processIncludeElement(element);
+
+ // make sure processing of current open on tag resulted in a current open on definition
+ // before continue reading the children
+ if (fCurrentIncludeDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_TAG)) {
+ processTagElement(element);
+
+ // make sure processing of current open on tag resulted in a current open on definition
+ // before continue reading the children
+ if (fCurrentIncludeDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_ATTRIBUTE)) {
+ processAttributeElement(element);
+ return true;
+ }
+ else if (tag.equals(TAG_CONTEXTTYPE)) {
+ processContextTypeElement(element);
+
+ // make sure processing of current open on tag resulted in a current open on definition
+ // before continue reading the children
+ if (fCurrentIncludeDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_CONTENTTYPE)) {
+ return processContentTypeElement(element);
+ }
+
+ return false;
+ }
+
+ private void initCache() {
+ if (fIncludeContextDefs == null) {
+ readContributions(TAG_INCLUDE, PL_INCLUDE);
+ }
+ }
+
+
+ protected void readContributions(String element, String extensionPoint) {
+ fTargetContributionElement = element;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ readRegistry(registry, WebKbPlugin.PLUGIN_ID, extensionPoint);
+ }
+
+ /**
+ * Returns all the open on definition objects
+ * @return
+ */
+ public List<IncludeContextDefinition> getIncludeContextDefinitions() {
+ initCache();
+ return fIncludeContextDefs;
+ }
+
+ public static String[] getIncludeAttributes(String uri, String tag) {
+ if (uri == null)
+ return null;
+
+ List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+ if (defs == null)
+ return null;
+
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ return def.getTagAttributes(tag);
+ }
+ }
+
+ return null;
+ }
+
+ public static String getContextType(String contentType) {
+ if (contentType == null)
+ return null;
+
+ List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+ if (defs == null)
+ return null;
+
+ for (IncludeContextDefinition def : defs) {
+ String contextType = def.getContextType(contentType);
+ if (contextType != null)
+ return contextType;
+ }
+
+ return null;
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -0,0 +1,141 @@
+package org.jboss.tools.jst.web.kb.include;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.ui.internal.EarlyStartupRunnable;
+
+public class IncludeContextDefinition {
+ private IConfigurationElement fElement;
+ private String fUri;
+ private Map<String, Set<String>> fTags; // Map<TagName, Set<AttributeName>>
+ private Map<IConfigurationElement, String> fTagConfigurationElements;
+ private Map<String, Set<String>> fContexts; // Map<ContextType, Set<ContentType>>
+ private Map<IConfigurationElement, String> fContextConfigurationElements;
+
+ public IncludeContextDefinition(IConfigurationElement element) {
+ this.fElement = element;
+ }
+
+ public IncludeContextDefinition(String uri, IConfigurationElement element) {
+ this.fUri = uri;
+ this.fElement = element;
+ }
+
+ public String getUri() {
+ return fUri;
+ }
+
+ public void setUri(String uri) {
+ this.fUri = uri;
+ }
+
+ public void addTag(String tagName, IConfigurationElement element) {
+ if (fTags == null) {
+ fTags = new HashMap<String, Set<String>>();
+ }
+ Set<String> tagSet = fTags.get(tagName);
+ if (tagSet == null) {
+ tagSet = new HashSet<String>();
+ fTags.put(tagName, tagSet);
+ }
+
+ if (fTagConfigurationElements == null) {
+ fTagConfigurationElements = new HashMap<IConfigurationElement, String>();
+ }
+
+ fTagConfigurationElements.put(element, tagName);
+ }
+
+ public void addTagAttribute(String attributeName, IConfigurationElement element) {
+ IConfigurationElement parentTagElement = null;
+ if (element.getParent() instanceof IConfigurationElement) {
+ IConfigurationElement parentElement = (IConfigurationElement)element.getParent();
+ if (IncludeContextBuilder.TAG_TAG.equals(parentElement.getName())) {
+ parentTagElement = parentElement;
+ }
+ }
+
+ String parentTagName = null;
+ if (parentTagElement != null) {
+ parentTagName = IncludeContextBuilder.getName(parentTagElement);
+ }
+ parentTagName = parentTagName == null ? "" : parentTagName; //$NON-NLS-1$
+
+ if (fTags.get(parentTagName) == null) {
+ addTag(parentTagName, parentTagElement);
+ }
+
+ fTags.get(parentTagName).add(attributeName);
+ }
+
+ public void addContextType(String id, IConfigurationElement element) {
+ if (fContexts == null) {
+ fContexts = new HashMap<String, Set<String>>();
+ }
+ Set<String> contextSet = fContexts.get(id);
+ if (contextSet == null) {
+ contextSet = new HashSet<String>();
+ fContexts.put(id, contextSet);
+ }
+
+ if (fContextConfigurationElements == null) {
+ fContextConfigurationElements = new HashMap<IConfigurationElement, String>();
+ }
+
+ fContextConfigurationElements.put(element, id);
+ }
+
+ public boolean addContentType(String id, IConfigurationElement element) {
+ IConfigurationElement parentContextElement = null;
+ if (element.getParent() instanceof IConfigurationElement) {
+ IConfigurationElement parentElement = (IConfigurationElement)element.getParent();
+ if (IncludeContextBuilder.TAG_CONTEXTTYPE.equals(parentElement.getName())) {
+ parentContextElement = parentElement;
+ }
+ }
+
+ String parentContextId = null;
+ if (parentContextElement != null) {
+ parentContextId = IncludeContextBuilder.getId(parentContextElement);
+ }
+
+ if (fContexts.get(parentContextId) == null)
+ return false;
+
+ fContexts.get(parentContextId).add(id);
+ return true;
+ }
+
+ private static final String[] EMPTY_CHILDREN = new String[0];
+
+
+ public String[] getTags() {
+ return fTags == null ? EMPTY_CHILDREN :
+ (String[])fTags.keySet().toArray(new String[fTags.size()]);
+ }
+
+ public String[] getTagAttributes(String tagName) {
+ Set<String> attrSet = fTags.get(tagName);
+
+ return attrSet == null ? EMPTY_CHILDREN :
+ (String[])attrSet.toArray(new String[attrSet.size()]);
+ }
+
+ public String getContextType(String contentType) {
+ if (fContexts == null)
+ return null;
+
+ for (String contextType : fContexts.keySet()) {
+ if (fContexts.get(contextType).contains(contentType))
+ return contextType;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -11,9 +11,14 @@
package org.jboss.tools.jst.web.kb.internal;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -22,10 +27,24 @@
* @author Alexey Kazakov
*/
public class JspContextImpl extends XmlContextImpl {
+ protected List<IPageContext> fIncludedContexts = null;
@Override
+ public void addIncludedContext(IPageContext includedContext) {
+ if (fIncludedContexts == null) {
+ fIncludedContexts = new ArrayList<IPageContext>();
+ }
+ fIncludedContexts.add(includedContext);
+ }
+
+ @Override
+ public List<IPageContext> getIncludedContexts() {
+ return fIncludedContexts;
+ }
+
+ @Override
public Map<String, List<INameSpace>> getNameSpaces(int offset) {
Map<String, List<INameSpace>> superNameSpaces = super.getNameSpaces(offset);
@@ -36,5 +55,4 @@
return superNameSpaces;
}
-
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-10-16 16:35:27 UTC (rev 18136)
@@ -8,7 +8,9 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.part.IPage;
import org.jboss.tools.common.el.core.resolver.ELContextImpl;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -37,7 +39,26 @@
* @see org.jboss.tools.jst.web.kb.IPageContext#getResourceBundles()
*/
public IResourceBundle[] getResourceBundles() {
- return bundles;
+ List<IResourceBundle> resourceBundles = new ArrayList<IResourceBundle>();
+ if (bundles != null) {
+ for (IResourceBundle bundle : bundles) {
+ resourceBundles.add(bundle);
+ }
+ }
+
+ List<IPageContext> includedContexts = getIncludedContexts();
+ if (includedContexts != null) {
+ for (IPageContext includedContext : includedContexts) {
+ IResourceBundle[] includedBundles = includedContext.getResourceBundles();
+ if (includedBundles != null) {
+ for (IResourceBundle includedBundle : includedBundles) {
+ resourceBundles.add(includedBundle);
+ }
+ }
+ }
+ }
+
+ return (IResourceBundle[])resourceBundles.toArray(new IResourceBundle[resourceBundles.size()]);
}
/**
@@ -104,7 +125,7 @@
return result;
}
- private INameSpace findNameSpaceByPrefix(Set<INameSpace> namespaces, String prefix) {
+ public INameSpace findNameSpaceByPrefix(Set<INameSpace> namespaces, String prefix) {
if (namespaces != null && prefix != null) {
for (INameSpace ns : namespaces) {
if (prefix.equals(ns.getPrefix())) {
@@ -127,4 +148,15 @@
}
nameSpaces.get(region).put(nameSpace.getURI(), nameSpace);
}
+
+ public void addIncludedContext(IPageContext includedContext) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public List<IPageContext> getIncludedContexts() {
+ return null;
+ }
+
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml 2009-10-16 16:15:52 UTC (rev 18135)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml 2009-10-16 16:35:27 UTC (rev 18136)
@@ -398,5 +398,12 @@
</extension>
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include uri="http://jboss.com/products/seam/taglib">
+ <tag name="decorate">
+ <attribute name="template" />
+ </tag>
+ </include>
+ </extension>
</plugin>
14 years, 8 months
JBoss Tools SVN: r18135 - trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-10-16 12:15:52 -0400 (Fri, 16 Oct 2009)
New Revision: 18135
Modified:
trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java
Log:
Fix for waitForJobsAccomplished method.
Modified: trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java 2009-10-16 16:14:07 UTC (rev 18134)
+++ trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java 2009-10-16 16:15:52 UTC (rev 18135)
@@ -2,6 +2,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
@@ -14,7 +16,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
public abstract class JBTSWTBotTestCase extends SWTBotTestCase implements
- ILogListener{
+ ILogListener {
protected static final String BUILDING_WS = "Building workspace";
protected static final String VISUAL_UPDATE = "Visual Editor View Update";
@@ -24,52 +26,58 @@
public static final String PATH_TO_SWT_BOT_PROPERTIES = "SWTBot.properties";
protected SWTJBTBot bot = new SWTJBTBot();
private static int sleepTime = 1000;
-
- /* (non-Javadoc)
- * This static block read properties from
- * org.jboss.tools.ui.bot.test/resources/SWTBot.properties file
- * and set up parameters for SWTBot tests. You may change a number of parameters
- * in static block and their values in property file.
+
+ /*
+ * (non-Javadoc) This static block read properties from
+ * org.jboss.tools.ui.bot.test/resources/SWTBot.properties file and set up
+ * parameters for SWTBot tests. You may change a number of parameters in
+ * static block and their values in property file.
*/
-
+
static {
try {
- InputStream inputStream = JBTSWTBotTestCase.class.getResourceAsStream("/"+PATH_TO_SWT_BOT_PROPERTIES);
+ InputStream inputStream = JBTSWTBotTestCase.class
+ .getResourceAsStream("/" + PATH_TO_SWT_BOT_PROPERTIES);
SWT_BOT_PROPERTIES = new Properties();
SWT_BOT_PROPERTIES.load(inputStream);
SWTBotPreferences.PLAYBACK_DELAY = Long
- .parseLong(SWT_BOT_PROPERTIES
- .getProperty("SWTBotPreferences.PLAYBACK_DELAY"));
+ .parseLong(SWT_BOT_PROPERTIES
+ .getProperty("SWTBotPreferences.PLAYBACK_DELAY"));
SWTBotPreferences.TIMEOUT = Long.parseLong(SWT_BOT_PROPERTIES
- .getProperty("SWTBotPreferences.TIMEOUT"));
+ .getProperty("SWTBotPreferences.TIMEOUT"));
inputStream.close();
- }
- catch (IOException e) {
- IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Can't load properties from " + PATH_TO_SWT_BOT_PROPERTIES + " file", e);
+ } catch (IOException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Can't load properties from " + PATH_TO_SWT_BOT_PROPERTIES
+ + " file", e);
Activator.getDefault().getLog().log(status);
e.printStackTrace();
- }
- catch (IllegalStateException e) {
- IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Property file " + PATH_TO_SWT_BOT_PROPERTIES + " was not found", e);
+ } catch (IllegalStateException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Property file " + PATH_TO_SWT_BOT_PROPERTIES
+ + " was not found", e);
Activator.getDefault().getLog().log(status);
e.printStackTrace();
}
-// try {
-// InputStream swtPreferenceIS = Platform.getBundle(Activator.PLUGIN_ID).getResource(PATH_TO_SWT_BOT_PROPERTIES)
-// .openStream();
-// SWT_BOT_PROPERTIES = new Properties();
-// SWT_BOT_PROPERTIES.load(swtPreferenceIS);
-// SWTBotPreferences.PLAYBACK_DELAY = Long
-// .parseLong(SWT_BOT_PROPERTIES
-// .getProperty("SWTBotPreferences.PLAYBACK_DELAY"));
-// SWTBotPreferences.TIMEOUT = Long.parseLong(SWT_BOT_PROPERTIES
-// .getProperty("SWTBotPreferences.TIMEOUT"));
-// swtPreferenceIS.close();
-// } catch (IOException e) {
-// fail("Can't load properties from " + PATH_TO_SWT_BOT_PROPERTIES + " file");
-// } catch (IllegalStateException e) {
-// fail("Property file " + PATH_TO_SWT_BOT_PROPERTIES + " was not found");
-// }
+ // try {
+ // InputStream swtPreferenceIS =
+ // Platform.getBundle(Activator.PLUGIN_ID).getResource(PATH_TO_SWT_BOT_PROPERTIES)
+ // .openStream();
+ // SWT_BOT_PROPERTIES = new Properties();
+ // SWT_BOT_PROPERTIES.load(swtPreferenceIS);
+ // SWTBotPreferences.PLAYBACK_DELAY = Long
+ // .parseLong(SWT_BOT_PROPERTIES
+ // .getProperty("SWTBotPreferences.PLAYBACK_DELAY"));
+ // SWTBotPreferences.TIMEOUT = Long.parseLong(SWT_BOT_PROPERTIES
+ // .getProperty("SWTBotPreferences.TIMEOUT"));
+ // swtPreferenceIS.close();
+ // } catch (IOException e) {
+ // fail("Can't load properties from " + PATH_TO_SWT_BOT_PROPERTIES +
+ // " file");
+ // } catch (IllegalStateException e) {
+ // fail("Property file " + PATH_TO_SWT_BOT_PROPERTIES +
+ // " was not found");
+ // }
}
public void logging(IStatus status, String plugin) {
@@ -86,37 +94,42 @@
break;
}
}
-
+
/**
- * Getter method for exception that may be thrown during test
- * execution.<p>
- * You can call this method from any place of your methods
- * and verify if any exception was thrown during test executing
- * including Error Log.
+ * Getter method for exception that may be thrown during test execution.
+ * <p>
+ * You can call this method from any place of your methods and verify if any
+ * exception was thrown during test executing including Error Log.
+ *
* @return exception
* @see Throwable
*/
-
+
protected synchronized Throwable getException() {
return exception;
}
/**
- * Setter method for exception.
- * If param is not null test will fail and you will see stack trace in JUnit Error Log
- * @param e - exception, that can be frown during test executing
+ * Setter method for exception. If param is not null test will fail and you
+ * will see stack trace in JUnit Error Log
+ *
+ * @param e
+ * - exception, that can be frown during test executing
* @see Throwable
*/
-
+
protected synchronized void setException(Throwable e) {
this.exception = e;
}
/**
- * Delete .log file from junit-workspace .metadata, if it hadn't been deleted before<p>
- * So we can catch exceptions and errors, which were thrown during current test.
+ * Delete .log file from junit-workspace .metadata, if it hadn't been
+ * deleted before
+ * <p>
+ * So we can catch exceptions and errors, which were thrown during current
+ * test.
*/
-
+
private void deleteLog() {
try {
Platform.getLogFileLocation().toFile().delete();
@@ -126,6 +139,7 @@
/**
* Make a default preconditions before test launch
+ *
* @see #activePerspective()
* @see #openErrorLog()
* @see #openPackageExplorer()
@@ -133,7 +147,7 @@
* @see #deleteLog()
* @see #delay()
*/
-
+
@Override
protected void setUp() throws Exception {
activePerspective();
@@ -143,18 +157,19 @@
}
openErrorLog();
openPackageExplorer();
-// openProgressStatus();
+ // openProgressStatus();
deleteLog();
setException(null);
Platform.addLogListener(this);
-// delay();
+ // delay();
}
/**
* Tears down the fixture. Verify Error Log.
+ *
* @see #getException()
*/
-
+
@Override
protected void tearDown() throws Exception {
Platform.removeLogListener(this);
@@ -167,20 +182,21 @@
/**
* A little delay between test's steps. Use it where necessary.
*/
-
+
protected void delay() {
bot.sleep(sleepTime);
}
-
- /** Defines which kind of perspective should be activated before tests' run.
+
+ /**
+ * Defines which kind of perspective should be activated before tests' run.
*/
-
- abstract protected void activePerspective ();
-
+
+ abstract protected void activePerspective();
+
/**
* Open and activate Error Log view if it hadn't been opened before
*/
-
+
protected void openErrorLog() {
try {
bot.viewByTitle(WidgetVariables.ERROR_LOG);
@@ -193,11 +209,11 @@
bot.button("OK").click();
}
}
-
+
/**
* Open and activate Package Explorer view if it hadn't been opened before
*/
-
+
protected void openPackageExplorer() {
try {
bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).setFocus();
@@ -210,73 +226,91 @@
bot.button("OK").click();
}
}
-
-// protected void openProgressStatus() {
-// try {
-// bot.viewByTitle(WidgetVariables.PROGRESS_STATUS);
-// } catch (WidgetNotFoundException e) {
-// bot.menu("Window").menu("Show View").menu("Other...").click();
-// SWTBotTree viewTree = bot.tree();
-// delay();
-// viewTree.expandNode("General").expandNode(WidgetVariables.PROGRESS_STATUS).select();
-// bot.button("OK").click();
-// }
-// }
-
+
+ // protected void openProgressStatus() {
+ // try {
+ // bot.viewByTitle(WidgetVariables.PROGRESS_STATUS);
+ // } catch (WidgetNotFoundException e) {
+ // bot.menu("Window").menu("Show View").menu("Other...").click();
+ // SWTBotTree viewTree = bot.tree();
+ // delay();
+ // viewTree.expandNode("General").expandNode(WidgetVariables.PROGRESS_STATUS).select();
+ // bot.button("OK").click();
+ // }
+ // }
+
/**
* Use delay() method instead
+ *
* @see #delay()
*/
- @Deprecated
- protected final void waitForJobs(){
+ @Deprecated
+ protected final void waitForJobs() {
delay();
}
-
- protected final void waitForBlockingJobsAcomplished(long timeOut, String... jobNames) throws InterruptedException{
+
+ protected final void waitForBlockingJobsAcomplished(final long timeOut,
+ final String... jobNames) {
if (jobNames == null) {
- delay();
+ return;
} else {
- boolean isProcessStarted = false;
+ Map<String, Boolean> runningProcessesMap = new HashMap<String, Boolean>();
+ for (int i = 0; i < jobNames.length; i++) {
+ runningProcessesMap.put(jobNames[i], false);
+ }
+ boolean isRequiredProcessesStarted = false;
long startTime = System.currentTimeMillis();
- while (!isProcessStarted) {
+ while (!isRequiredProcessesStarted) {
Job[] jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
for (String jobName : jobNames) {
if (jobName.equalsIgnoreCase(job.getName())) {
- isProcessStarted = true;
+ if (!runningProcessesMap.get(jobName)) {
+ runningProcessesMap.remove(jobName);
+ runningProcessesMap.put(jobName, true);
+ }
}
}
}
- long endTime = System.currentTimeMillis();
- if (endTime-startTime>timeOut) {
- throw new InterruptedException(stringArrayToString(jobNames) + "job(s) has never appeared or already completed");
+ isRequiredProcessesStarted = true;
+ for (String jobName : jobNames) {
+ isRequiredProcessesStarted = isRequiredProcessesStarted
+ & runningProcessesMap.get(jobName);
}
+ if (!isRequiredProcessesStarted) {
+ long endTime = System.currentTimeMillis();
+ if (endTime - startTime > timeOut) {
+ System.out.println("Next processes are already started or finished: "+
+ runningProcessesToString(jobNames)+" called in " + getName() + " class");
+ return;
+ }
+ }
}
- while (isProcessStarted) {
- isProcessStarted = false;
+ while (isRequiredProcessesStarted) {
+ isRequiredProcessesStarted = false;
Job[] jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
for (String jobName : jobNames) {
if (jobName.equalsIgnoreCase(job.getName())) {
+ isRequiredProcessesStarted = true;
delay();
- isProcessStarted = true;
}
}
}
}
}
}
-
- protected final void waitForBlockingJobsAcomplished(String... jobNames) throws InterruptedException{
- waitForBlockingJobsAcomplished(5*1000L, jobNames);
+
+ protected final void waitForBlockingJobsAcomplished(String... jobNames) {
+ waitForBlockingJobsAcomplished(5 * 1000L, jobNames);
}
-
- private String stringArrayToString (String... strings){
- StringBuffer buffer = new StringBuffer("");
- for (String string : strings) {
- buffer.append(string+", ");
+
+ private String runningProcessesToString (String ... processes){
+ String process = "";
+ for (String processRunning : processes) {
+ process = process + processRunning + ", ";
}
- return buffer.toString();
+ return process;
}
}
14 years, 8 months
JBoss Tools SVN: r18134 - in trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test: editor and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-10-16 12:14:07 -0400 (Fri, 16 Oct 2009)
New Revision: 18134
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpacesTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/AddSubstitutedELExpressionFolderScopeTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/SubstitutedELTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/BorderForUnknownTagsTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowNonVisualTagsTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java
Log:
SWTBot VPE Tests correction. Speed of tests execution was increased.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -143,10 +143,7 @@
} catch (WidgetNotFoundException e2) {
}
}
- try {
- waitForBlockingJobsAcomplished(60*1000L, BUILDING_WS);
- } catch (InterruptedException e) {
- }
+ waitForBlockingJobsAcomplished(60*1000L, BUILDING_WS);
setException(null);
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -60,10 +60,7 @@
}
void checkVPE(String testPage) throws Throwable{
- try {
- waitForBlockingJobsAcomplished("Save", VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+ waitForBlockingJobsAcomplished(VISUAL_UPDATE);
performContentTestByDocument(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
@@ -77,10 +74,6 @@
bot.menu("Edit").menu("Delete").click();
editor.setText(editorText);
editor.save();
- try {
- waitForBlockingJobsAcomplished("Save");
- } catch (InterruptedException e) {
- }
super.tearDown();
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpacesTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpacesTest.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpacesTest.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -29,10 +29,7 @@
getEditor().setText(testText);
getEditor().save();
- try {
- waitForBlockingJobsAcomplished("Save", VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+ waitForBlockingJobsAcomplished(VISUAL_UPDATE);
performContentTestByDocument("VerificationOfNameSpaces.xml", bot.multiPageEditorByTitle(TEST_PAGE));
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/AddSubstitutedELExpressionFolderScopeTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/AddSubstitutedELExpressionFolderScopeTest.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/AddSubstitutedELExpressionFolderScopeTest.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -89,10 +89,7 @@
//Test close Design Options
bot.button("OK").click();
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH,VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+ // waitForBlockingJobsAcomplished(VISUAL_REFRESH);
//Check page content
@@ -149,10 +146,7 @@
.expandNode("WebContent").expandNode(TEST_FOLDER)
.getNode(TEST_PAGE_FOR_FOLDER+".jsp").doubleClick();
SWTBotEditor editor = bot.editorByTitle(TEST_PAGE_FOR_FOLDER+".jsp");
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+ // waitForBlockingJobsAcomplished(VISUAL_REFRESH);
//Check page content
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/SubstitutedELTestCase.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/SubstitutedELTestCase.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/SubstitutedELTestCase.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -54,10 +54,7 @@
void checkVPEForTestPage(String testPage) throws Throwable{
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+ // waitForBlockingJobsAcomplished(VISUAL_REFRESH);
performContentTestByDocument(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
@@ -101,10 +98,7 @@
tree.expandNode(JBT_TEST_PROJECT_NAME)
.expandNode("WebContent").expandNode("pages").getNode("hello.jsp").doubleClick();
SWTBotEditor editor = bot.editorByTitle("hello.jsp");
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+ // waitForBlockingJobsAcomplished(VISUAL_REFRESH);
//Check page content
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/BorderForUnknownTagsTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/BorderForUnknownTagsTest.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/BorderForUnknownTagsTest.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -46,10 +46,7 @@
}
private void checkVPE(String testPage) throws Throwable{
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+// waitForBlockingJobsAcomplished(VISUAL_REFRESH);
performContentTestByDocument(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
@@ -70,10 +67,6 @@
bot.menu("Edit").menu("Delete").click();
editor.setText(textEditor);
editor.save();
- try {
- waitForBlockingJobsAcomplished("Save");
- } catch (InterruptedException e) {
- }
super.tearDown();
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowNonVisualTagsTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowNonVisualTagsTest.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowNonVisualTagsTest.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -22,10 +22,7 @@
}
private void checkVPE(String testPage) throws Throwable{
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+// waitForBlockingJobsAcomplished(VISUAL_REFRESH);
performContentTestByDocument(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java 2009-10-16 16:11:16 UTC (rev 18133)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/preferences/ShowResourceBundlesUsageasELexpressionsTest.java 2009-10-16 16:14:07 UTC (rev 18134)
@@ -34,18 +34,11 @@
bot.menu("Edit").menu("Delete").click();
editor.setText(textEditor);
editor.save();
- try {
- waitForBlockingJobsAcomplished("Save");
- } catch (InterruptedException e) {
- }
super.tearDown();
}
private void checkVPE(String testPage) throws Throwable{
- try {
- waitForBlockingJobsAcomplished(VISUAL_REFRESH, VISUAL_UPDATE);
- } catch (InterruptedException e) {
- }
+// waitForBlockingJobsAcomplished(VISUAL_REFRESH);
performContentTestByDocument(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
14 years, 8 months
JBoss Tools SVN: r18133 - in trunk/seam/tests/org.jboss.tools.seam.ui.bot.test: src/org/jboss/tools/seam/ui/bot/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-10-16 12:11:16 -0400 (Fri, 16 Oct 2009)
New Revision: 18133
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/resources/seam21Settings.properties
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java
Log:
SWT Bot Seam tests were corrected.
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/resources/seam21Settings.properties
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/resources/seam21Settings.properties 2009-10-16 13:50:15 UTC (rev 18132)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/resources/seam21Settings.properties 2009-10-16 16:11:16 UTC (rev 18133)
@@ -1,4 +1,4 @@
seamRuntimeName=Seam 2.1.1.GA
seamRuntimePath=${jbosstools.test.seam.2.1.0.GA.home}
testProjectName=seamTest21
-configName=Dynamic Web Project with Seam 2.1 (technology preview)
+configName=Dynamic Web Project with Seam 2.1
\ No newline at end of file
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-16 13:50:15 UTC (rev 18132)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/TestControl.java 2009-10-16 16:11:16 UTC (rev 18133)
@@ -26,6 +26,9 @@
private static final String SEAM_SET_12 = "seam12Settings.properties";
private static final String SEAM_SET_2FP = "seam2fpSettings.properties";
private static final String SEAM_SET_21 = "seam21Settings.properties";
+ protected static final String VALIDATION = "Validation";
+ protected static final String DEPLOY_SOURCE = "Deploying datasource to server";
+ protected static final String REG_IN_SERVER = "Register in server";
public static String JBOSS_EAP_HOME;
public static String SEAM_12_SETTINGS_HOME;
@@ -148,6 +151,7 @@
protected void createSeamRuntime(Properties runtimeSet, String homeFolder){
bot.menu("Window").menu("Preferences").click();
SWTBotTree tree = bot.tree();
+ delay();
tree.expandNode("JBoss Tools")
.expandNode("Web")
.expandNode("Seam")
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java 2009-10-16 13:50:15 UTC (rev 18132)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/create/CreateSeamProjects.java 2009-10-16 16:11:16 UTC (rev 18133)
@@ -5,48 +5,44 @@
public class CreateSeamProjects extends TestControl{
public void testCreateSeamProject12war(){
- createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_WAR);
-// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS, VALIDATION +
+ " " + seam12Settings.getProperty("testProjectName")
+ +TYPE_WAR, DEPLOY_SOURCE, REG_IN_SERVER);
}
-// public void testCreateSeamProject12ear(){
-// createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_EAR);
-// try {
-// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
-// } catch (InterruptedException e) {
-// }
-// }
-//
-// public void testCreateSeamProject2fpwar(){
-// createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_WAR);
-// try {
-// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
-// } catch (InterruptedException e) {
-// }
-// }
-//
-// public void testCreateSeamProject2fpear(){
-// createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_EAR);
-// try {
-// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
-// } catch (InterruptedException e) {
-// }
-// }
-//
-// public void testCreateSeamProject21war(){
-// createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_WAR);
-// try {
-// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
-// } catch (InterruptedException e) {
-// }
-// }
-//
-// public void testCreateSeamProject21ear(){
-// createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_EAR);
-// try {
-// waitForBlockingJobsAcomplished(180000, BUILDING_WS);
-// } catch (InterruptedException e) {
-// }
-// }
+ public void testCreateSeamProject12ear(){
+ createSeamProject(seam12Settings, jbossEAPRuntime, TYPE_EAR);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS, VALIDATION +
+ " " + seam12Settings.getProperty("testProjectName")
+ +TYPE_EAR, DEPLOY_SOURCE, REG_IN_SERVER);
+ }
+ public void testCreateSeamProject2fpwar(){
+ createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_WAR);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS, VALIDATION +
+ " " + seam2fpSettings.getProperty("testProjectName")
+ +TYPE_WAR, DEPLOY_SOURCE, REG_IN_SERVER);
+ }
+
+ public void testCreateSeamProject2fpear(){
+ createSeamProject(seam2fpSettings, jbossEAPRuntime, TYPE_EAR);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS, VALIDATION +
+ " " + seam2fpSettings.getProperty("testProjectName")
+ +TYPE_EAR, DEPLOY_SOURCE, REG_IN_SERVER);
+ }
+
+ public void testCreateSeamProject21war(){
+ createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_WAR);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS, VALIDATION +
+ " " + seam21Settings.getProperty("testProjectName")
+ +TYPE_WAR, DEPLOY_SOURCE, REG_IN_SERVER);
+ }
+
+ public void testCreateSeamProject21ear(){
+ createSeamProject(seam21Settings, jbossEAPRuntime, TYPE_EAR);
+ waitForBlockingJobsAcomplished(180000, BUILDING_WS, VALIDATION +
+ " " + seam21Settings.getProperty("testProjectName")
+ +TYPE_EAR, DEPLOY_SOURCE, REG_IN_SERVER);
+ }
+
}
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r18132 - in trunk/common/plugins: org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-10-16 09:50:15 -0400 (Fri, 16 Oct 2009)
New Revision: 18132
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4856
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-10-16 12:45:51 UTC (rev 18131)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-10-16 13:50:15 UTC (rev 18132)
@@ -379,7 +379,7 @@
}
// TODO: move to util class
- public boolean isGetter(IMethod method) {
+ public static boolean isGetter(IMethod method) {
String name = method.getElementName();
int numberOfParameters = method.getNumberOfParameters();
@@ -387,13 +387,31 @@
}
// TODO: move to util class
- public boolean isSetter(IMethod method) {
+ public static boolean isSetter(IMethod method) {
String name = method.getElementName();
int numberOfParameters = method.getNumberOfParameters();
return ((name.startsWith(SET) && !name.equals(SET)) && numberOfParameters == 1);
}
+ // TODO: move to util class
+ public static String getPropertyName(IMethod method, String methodName){
+ if (isGetter(method) || isSetter(method)) {
+ StringBuffer name = new StringBuffer(methodName);
+ if(methodName.startsWith("i")) { //$NON-NLS-1$
+ name.delete(0, 2);
+ } else {
+ name.delete(0, 3);
+ }
+ if(name.length()<2 || Character.isLowerCase(name.charAt(1))) {
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ }
+ String propertyName = name.toString();
+ return propertyName;
+ }
+ return methodName;
+ }
+
private boolean containsInSearchScope(IProject project){
if(searchScope == null)
return true;
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-16 12:45:51 UTC (rev 18131)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-16 13:50:15 UTC (rev 18132)
@@ -90,7 +90,7 @@
oldName = method.getElementName();
- newName = getArguments().getNewName();
+ newName = RefactorSearcher.getPropertyName(method, getArguments().getNewName());
searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
added = false;
return true;
14 years, 8 months
JBoss Tools SVN: r18131 - in trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui: refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-10-16 08:45:51 -0400 (Fri, 16 Oct 2009)
New Revision: 18131
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4856
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java 2009-10-16 12:39:29 UTC (rev 18130)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUiCoreMessages.java 2009-10-16 12:45:51 UTC (rev 18131)
@@ -14,5 +14,6 @@
public static String RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE;
public static String RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE;
public static String RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES;
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-10-16 12:39:29 UTC (rev 18130)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-10-16 12:45:51 UTC (rev 18131)
@@ -3,4 +3,5 @@
RENAME_METHOD_PARTICIPANT_SETTER_WARNING=Be sure, may be you also should rename getter method to avoid compilation problems.
RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}'' is not in sync.
RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE=Cannot change phantom file: ''{0}''.
-RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE=Cannot change read-only file: ''{0}''.
\ No newline at end of file
+RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE=Cannot change read-only file: ''{0}''.
+RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES=Update method references in EL
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-16 12:39:29 UTC (rev 18130)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-16 12:45:51 UTC (rev 18131)
@@ -85,7 +85,7 @@
if(element instanceof IMethod){
status = new RefactoringStatus();
- rootChange = new CompositeChange("");
+ rootChange = new CompositeChange(ElUiCoreMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
method = (IMethod)element;
oldName = method.getElementName();
14 years, 8 months
JBoss Tools SVN: r18130 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-10-16 08:39:29 -0400 (Fri, 16 Oct 2009)
New Revision: 18130
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4978
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-10-16 12:38:51 UTC (rev 18129)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-10-16 12:39:29 UTC (rev 18130)
@@ -122,12 +122,21 @@
return JSFSeverityPreferences.shouldValidateEL(project);
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#init(org.eclipse.core.resources.IProject, org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper, org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.jboss.tools.jst.web.kb.validation.IValidationContext)
+ */
+ @Override
protected void init(IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter, IValidationContext validationContext) {
super.init(project, validationHelper, manager, reporter, validationContext);
resolvers = ELResolverFactoryManager.getInstance().getResolvers(project);
mainFactory = ELParserUtil.getDefaultFactory();
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#validate(java.util.Set, org.eclipse.core.resources.IProject, org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper, org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.jboss.tools.jst.web.kb.validation.IValidationContext)
+ */
public IStatus validate(Set<IFile> changedFiles, IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter, IValidationContext validationContext) throws ValidationException {
init(project, validationHelper, manager, reporter, validationContext);
webRootFolder = null;
14 years, 8 months
JBoss Tools SVN: r18129 - in trunk/seam/plugins/org.jboss.tools.seam.core: src/org/jboss/tools/seam/internal/core/validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-10-16 08:38:51 -0400 (Fri, 16 Oct 2009)
New Revision: 18129
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator2.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator2.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
Log:
https://jira.jboss.org/jira/browse/JBIDE-4978
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2009-10-16 12:36:12 UTC (rev 18128)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2009-10-16 12:38:51 UTC (rev 18129)
@@ -33,7 +33,8 @@
org.eclipse.jst.jsf.facesconfig,
org.eclipse.jst.j2ee.core,
org.eclipse.jst.common.frameworks,
- org.jboss.tools.jst.web.kb;visibility:=reexport
+ org.jboss.tools.jst.web.kb;visibility:=reexport,
+ org.jboss.tools.jsf
Bundle-Version: 2.0.0
Export-Package:
org.jboss.tools.seam.core,
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator2.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator2.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator2.java 2009-10-16 12:38:51 UTC (rev 18129)
@@ -0,0 +1,1181 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.seam.internal.core.validation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.Flags;
+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.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.project.ext.ITextSourceReference;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.internal.KbProject;
+import org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatingProjectSet;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
+import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
+import org.jboss.tools.jst.web.kb.validation.IValidationContext;
+import org.jboss.tools.jst.web.kb.validation.IValidator;
+import org.jboss.tools.seam.core.BijectedAttributeType;
+import org.jboss.tools.seam.core.IBijectedAttribute;
+import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamComponentMethod;
+import org.jboss.tools.seam.core.ISeamContextVariable;
+import org.jboss.tools.seam.core.ISeamElement;
+import org.jboss.tools.seam.core.ISeamFactory;
+import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamJavaSourceReference;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ISeamProperty;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamXmlFactory;
+import org.jboss.tools.seam.core.ScopeType;
+import org.jboss.tools.seam.core.SeamComponentMethodType;
+import org.jboss.tools.seam.core.SeamCoreMessages;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamPreferences;
+import org.jboss.tools.seam.core.SeamProjectsSet;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.internal.core.AbstractContextVariable;
+import org.jboss.tools.seam.internal.core.DataModelSelectionAttribute;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamProject;
+import org.jboss.tools.seam.internal.core.SeamTextSourceReference;
+
+/**
+ * Validator for Java and XML files.
+ * @author Alexey Kazakov
+ */
+public class SeamCoreValidator2 extends ValidationErrorManager implements IValidator {
+
+ public static final String ID = "org.jboss.tools.seam.core.CoreValidator";
+
+ protected static final String NONUNIQUE_COMPONENT_NAME_MESSAGE_ID = "NONUNIQUE_COMPONENT_NAME_MESSAGE"; //$NON-NLS-1$
+ protected static final String UNKNOWN_VARIABLE_NAME_MESSAGE_ID = "UNKNOWN_VARIABLE_NAME"; //$NON-NLS-1$
+ protected static final String STATEFUL_COMPONENT_DOES_NOT_CONTAIN_METHOD_SUFIX_MESSAGE_ID = "STATEFUL_COMPONENT_DOES_NOT_CONTAIN_"; //$NON-NLS-1$
+ protected static final String DUPLICATE_METHOD_PREFIX_MESSAGE_ID = "DUPLICATE_"; //$NON-NLS-1$
+ protected static final String REMOVE_METHOD_SUFIX_MESSAGE_ID = "REMOVE"; //$NON-NLS-1$
+ protected static final String DESTROY_METHOD_SUFIX_MESSAGE_ID = "DESTROY"; //$NON-NLS-1$
+ protected static final String CREATE_METHOD_SUFIX_MESSAGE_ID = "CREATE"; //$NON-NLS-1$
+ protected static final String UNWRAP_METHOD_SUFIX_MESSAGE_ID = "UNWRAP"; //$NON-NLS-1$
+ protected static final String OBSERVER_METHOD_SUFIX_MESSAGE_ID = "OBSERVER"; //$NON-NLS-1$
+ protected static final String DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_ID = "DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN"; //$NON-NLS-1$
+ protected static final String NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID = "_DOESNT_BELONG_TO_COMPONENT"; //$NON-NLS-1$
+ protected static final String STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID = "STATEFUL_COMPONENT_WRONG_SCOPE"; //$NON-NLS-1$
+ protected static final String ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID = "ENTITY_COMPONENT_WRONG_SCOPE"; //$NON-NLS-1$
+ protected static final String UNKNOWN_FACTORY_NAME_MESSAGE_ID = "UNKNOWN_FACTORY_NAME"; //$NON-NLS-1$
+ protected static final String MULTIPLE_DATA_BINDER_MESSAGE_ID = "MULTIPLE_DATA_BINDER"; //$NON-NLS-1$
+ protected static final String DUPLICATE_VARIABLE_NAME_MESSAGE_ID = "DUPLICATE_VARIABLE_NAME"; //$NON-NLS-1$
+ protected static final String UNKNOWN_DATA_MODEL_MESSAGE_ID = "UNKNOWN_DATA_MODEL"; //$NON-NLS-1$
+ protected static final String UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID = "UNKNOWN_COMPONENT_CLASS_NAME"; //$NON-NLS-1$
+ protected static final String UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID = "UNKNOWN_COMPONENT_PROPERTY"; //$NON-NLS-1$
+
+ protected static final String SEARCHING_RESOURCES_MESSAGE_ID = "SEARCHING_RESOURCES"; //$NON-NLS-1$
+ protected static final String VALIDATING_COMPONENT_MESSAGE_ID = "VALIDATING_COMPONENT"; //$NON-NLS-1$
+ protected static final String VALIDATING_FACTORY_MESSAGE_ID = "VALIDATING_FACTORY"; //$NON-NLS-1$
+ protected static final String VALIDATING_RESOURCE_MESSAGE_ID = "VALIDATING_RESOURCE"; //$NON-NLS-1$
+ protected static final String VALIDATING_CLASS_MESSAGE_ID = "VALIDATING_CLASS"; //$NON-NLS-1$
+
+ protected static final String INVALID_XML_VERSION = "INVALID_XML_VERSION"; //$NON-NLS-1$
+
+ private ISeamProject seamProject;
+ private String projectName;
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#getPreference(org.eclipse.core.resources.IProject, java.lang.String)
+ */
+ @Override
+ protected String getPreference(IProject project, String preferenceKey) {
+ return SeamPreferences.getProjectPreference(project, preferenceKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#getId()
+ */
+ public String getId() {
+ return ID;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#getValidatingProjects(org.eclipse.core.resources.IProject)
+ */
+ public IValidatingProjectSet getValidatingProjects(IProject project) {
+ return getSeamValidatingProjects(project);
+ }
+
+ public static IValidatingProjectSet getSeamValidatingProjects(IProject project) {
+ SeamProjectsSet set = new SeamProjectsSet(project);
+ IProject war = set.getWarProject();
+ IValidationContext rootContext = null;
+ if(war!=null) {
+ IKbProject kbProject = KbProjectFactory.getKbProject(war, false);
+ if(kbProject!=null) {
+ rootContext = kbProject.getValidationContext();
+ } else {
+ KbProject.checkKBBuilderInstalled(war);
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(war, false);
+ if(seamProject!=null) {
+ // TODO
+// rootContext = seamProject.getValidationContext();
+ }
+ }
+ }
+ if(rootContext==null) {
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ if(seamProject!=null) {
+ // TODO
+// rootContext = seamProject.getValidationContext();
+ }
+ }
+
+ List<IProject> projects = new ArrayList<IProject>();
+ IProject[] array = set.getAllProjects();
+ for (int i = 0; i < array.length; i++) {
+ projects.add(array[i]);
+ }
+ return new ValidatingProjectSet(project, projects, rootContext);
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#shouldValidate(org.eclipse.core.resources.IProject)
+ */
+ public boolean shouldValidate(IProject project) {
+ try {
+ return project.hasNature(ISeamProject.NATURE_ID);
+ // TODO check preferences
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#init(org.eclipse.core.resources.IProject, org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper, org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.jboss.tools.jst.web.kb.validation.IValidationContext)
+ */
+ @Override
+ protected void init(IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter, IValidationContext validationContext) {
+ super.init(project, validationHelper, manager, reporter, validationContext);
+
+ SeamProjectsSet set = new SeamProjectsSet(project);
+ IProject warProject = set.getWarProject();
+ seamProject = SeamCorePlugin.getSeamProject(warProject, false);
+ projectName = seamProject.getProject().getName();
+ }
+
+ private boolean isPreferencesEnabled(IProject project) {
+ return SeamPreferences.shouldValidateCore(project);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidator#validate(java.util.Set, org.eclipse.core.resources.IProject, org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper, org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.jboss.tools.jst.web.kb.validation.IValidationContext)
+ */
+ public IStatus validate(Set<IFile> changedFiles, IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter, IValidationContext validationContext) throws ValidationException {
+ init(project, validationHelper, manager, reporter, validationContext);
+ displaySubtask(SEARCHING_RESOURCES_MESSAGE_ID);
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Set<ISeamComponent> checkedComponents = new HashSet<ISeamComponent>();
+ Set<String> markedDuplicateFactoryNames = new HashSet<String>();
+ // Collect all resources which we must validate.
+ Set<IPath> resources = new HashSet<IPath>(); // Resources which we have to validate.
+ Set<IPath> newResources = new HashSet<IPath>(); // New (unlinked) resources file
+ boolean validateUnnamedResources = false;
+ for(IFile currentFile : changedFiles) {
+ if(reporter.isCancelled()) {
+ break;
+ }
+ if(!validateUnnamedResources) {
+ String fileName = currentFile.getName().toLowerCase();
+ // We need to check only file names here.
+ validateUnnamedResources = fileName.endsWith(".java") || fileName.endsWith(".properties") || fileName.equals("components.xml"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ if (checkFileExtension(currentFile)) {
+ resources.add(currentFile.getFullPath());
+ // Get new variable names from model
+ Set<String> newVariableNamesOfChangedFile = getVariablesNameByResource(currentFile.getFullPath());
+ Set<String> oldDeclarationsOfChangedFile = validationContext.getVariableNamesByCoreResource(currentFile.getFullPath(), true);
+ for (String newVariableName : newVariableNamesOfChangedFile) {
+ // Collect resources with new variable name.
+ Set<IPath> linkedResources = validationContext.getCoreResourcesByVariableName(newVariableName, false);
+ if(linkedResources!=null) {
+ resources.addAll(linkedResources);
+ }
+ resources.addAll(getAllResourceOfComponent(currentFile.getFullPath()));
+ }
+ // Get old variable names which were linked with this resource.
+ Set<String> oldVariablesNamesOfChangedFile = validationContext.getVariableNamesByCoreResource(currentFile.getFullPath(), false);
+ if(oldVariablesNamesOfChangedFile!=null) {
+ for (String name : oldVariablesNamesOfChangedFile) {
+ Set<IPath> linkedResources = validationContext.getCoreResourcesByVariableName(name, false);
+ if(linkedResources!=null) {
+ resources.addAll(linkedResources);
+ }
+ }
+ }
+ // Save old declarations for EL validation. We need to validate all EL resources which use this variable name but only if the variable has been changed.
+ if(oldDeclarationsOfChangedFile!=null) {
+ for (String name : oldDeclarationsOfChangedFile) {
+ validationContext.addVariableNameForELValidation(name);
+ }
+ }
+ newResources.add(currentFile.getFullPath());
+ }
+ }
+ // Validate all collected linked resources.
+ // Remove all links between collected resources and variables names because they will be linked again during validation.
+ validationContext.removeLinkedCoreResources(resources);
+
+ IFile[] filesToValidate = new IFile[resources.size()];
+ int i = 0;
+ // We have to remove markers from all collected source files first
+ for (IPath linkedResource : resources) {
+ filesToValidate[i] = root.getFile(linkedResource);
+ removeAllMessagesFromResource(filesToValidate[i++]);
+ }
+ i = 0;
+ // Then we can validate them
+ for (IPath linkedResource : resources) {
+ validateComponent(linkedResource, checkedComponents, newResources);
+ validateFactory(linkedResource, markedDuplicateFactoryNames);
+ validateXMLVersion(filesToValidate[i++]);
+ }
+
+ // If changed files are *.java or component.xml then re-validate all unnamed resources.
+ if(validateUnnamedResources) {
+ Set<IPath> unnamedResources = validationContext.getUnnamedCoreResources();
+ newResources.addAll(unnamedResources);
+ for (IPath path : newResources) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if(file!=null && file.exists()) {
+ if(!resources.contains(path)) {
+ removeAllMessagesFromResource(file);
+ }
+ displaySubtask(VALIDATING_RESOURCE_MESSAGE_ID, new String[]{projectName, path.toString()});
+ Set<ISeamJavaComponentDeclaration> declarations = ((SeamProject)seamProject).findJavaDeclarations(path);
+ for (ISeamJavaComponentDeclaration d : declarations) {
+ validateMethodsOfUnknownComponent(d);
+ }
+ }
+ }
+ }
+
+ return OK_STATUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.internal.core.validation.ISeamValidator#validateAll()
+ */
+ public IStatus validateAll(IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter, IValidationContext validationContext) throws ValidationException {
+ init(project, validationHelper, manager, reporter, validationContext);
+ removeAllMessagesFromResource(seamProject.getProject());
+ ISeamComponent[] components = seamProject.getComponents();
+ for (ISeamComponent component : components) {
+ if(reporter.isCancelled()) {
+ return OK_STATUS;
+ }
+ Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
+ for (ISeamComponentDeclaration seamComponentDeclaration : declarations) {
+ validateComponent(component);
+ break;
+ }
+ }
+ ISeamFactory[] factories = seamProject.getFactories();
+ Set<String> markedDuplicateFactoryNames = new HashSet<String>();
+ for (ISeamFactory factory : factories) {
+ if(reporter.isCancelled()) {
+ return OK_STATUS;
+ }
+ validateFactory(factory, markedDuplicateFactoryNames);
+ }
+
+ ISeamJavaComponentDeclaration[] values = ((SeamProject)seamProject).getAllJavaComponentDeclarations();
+ for (ISeamJavaComponentDeclaration d : values) {
+ if(reporter.isCancelled()) {
+ return OK_STATUS;
+ }
+ displaySubtask(VALIDATING_CLASS_MESSAGE_ID, new String[]{projectName, d.getClassName()});
+ validateMethodsOfUnknownComponent(d);
+ }
+
+ return OK_STATUS;
+ }
+
+ private void validateFactory(IPath sourceFilePath, Set<String> markedDuplicateFactoryNames) {
+ Set<ISeamFactory> factories = seamProject.getFactoriesByPath(sourceFilePath);
+ for (ISeamFactory factory : factories) {
+ validateFactory(factory, markedDuplicateFactoryNames);
+ }
+ }
+
+ private void validateFactory(ISeamFactory factory, Set<String> markedDuplicateFactoryNames) {
+ if(isJar(factory.getSourcePath())) {
+ return;
+ }
+ String factoryName = factory.getName();
+ if(factoryName!=null) {
+ displaySubtask(VALIDATING_FACTORY_MESSAGE_ID, new String[]{projectName, factoryName});
+ }
+ if(factory instanceof ISeamAnnotatedFactory) {
+ validateAnnotatedFactory((ISeamAnnotatedFactory)factory, markedDuplicateFactoryNames);
+ } else {
+ validateXmlFactory((ISeamXmlFactory)factory, markedDuplicateFactoryNames);
+ }
+ }
+
+ private void validateXmlFactory(ISeamXmlFactory factory, Set<String> markedDuplicateFactoryNames) {
+ String name = factory.getName();
+ if(name==null) {
+ SeamCorePlugin.getDefault().logError(NLS.bind(SeamCoreMessages.SEAM_CORE_VALIDATOR_FACTORY_METHOD_MUST_HAVE_NAME,factory.getResource()));
+ return;
+ }
+ validateFactoryName(factory, name, markedDuplicateFactoryNames, false);
+ }
+
+ private void validateAnnotatedFactory(ISeamAnnotatedFactory factory, Set<String> markedDuplicateFactoryNames) {
+ IMember sourceMember = factory.getSourceMember();
+ if(sourceMember instanceof IMethod) {
+ String factoryName = factory.getName();
+ if(factoryName==null) {
+ // Unknown factory name
+ SeamCorePlugin.getDefault().logError(NLS.bind(SeamCoreMessages.SEAM_CORE_VALIDATOR_FACTORY_METHOD_MUST_HAVE_NAME,factory.getResource()));
+ return;
+ }
+ validateFactoryName(factory, factoryName, markedDuplicateFactoryNames, true);
+ } else {
+ // factory must be java method!
+ // JDT should mark it.
+ }
+ }
+
+ private void validateFactoryName(ISeamFactory factory, String factoryName, Set<String> markedDuplicateFactoryNames, boolean validateUnknownName) {
+ ScopeType factoryScope = factory.getScope();
+ Set<ISeamContextVariable> variables = seamProject.getVariablesByName(factoryName);
+ boolean unknownVariable = true;
+ boolean firstDuplicateVariableWasMarked = false;
+ for (ISeamContextVariable variable : variables) {
+ if(variable instanceof ISeamFactory) {
+ if(variable!=factory && !markedDuplicateFactoryNames.contains(factoryName) &&
+ (factoryScope == variable.getScope() || factoryScope.getPriority()>variable.getScope().getPriority())) {
+ // Duplicate factory name. Mark it.
+ // Save link to factory resource.
+ ITextSourceReference location = null;
+ if(!firstDuplicateVariableWasMarked) {
+ firstDuplicateVariableWasMarked = true;
+ // mark original factory
+ validationContext.addLinkedCoreResource(factoryName, factory.getSourcePath(), true);
+ location = getLocationOfName(factory);
+ this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location, factory.getResource());
+ }
+ // Mark duplicate variable.
+ if(!isJar(variable.getSourcePath())) {
+ IResource resource = getComponentResourceWithName(variable);
+ validationContext.addLinkedCoreResource(factoryName, resource.getFullPath(), true);
+ location = getLocationOfName(variable);
+ this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location, resource);
+ }
+ }
+ } else {
+ // We know that variable name
+ unknownVariable = false;
+ }
+ }
+ if(firstDuplicateVariableWasMarked) {
+ markedDuplicateFactoryNames.add(factoryName);
+ }
+ boolean voidReturnType = false;
+ if(factory instanceof ISeamAnnotatedFactory) {
+ IMember sourceMember = ((ISeamAnnotatedFactory)factory).getSourceMember();
+ if(sourceMember instanceof IMethod) {
+ IMethod method = (IMethod)sourceMember;
+ try {
+ String returnType = method.getReturnType();
+ if("V".equals(returnType)) { //$NON-NLS-1$
+ // return type is void
+ voidReturnType = true;
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_CORE_VALIDATOR_ERROR_VALIDATING_SEAM_CORE, e);
+ }
+ }
+ }
+ if(unknownVariable && validateUnknownName && voidReturnType) {
+ // mark unknown factory name
+ // save link to factory resource
+ validationContext.addLinkedCoreResource(factoryName, factory.getSourcePath(), true);
+ this.addError(UNKNOWN_FACTORY_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_FACTORY_NAME, new String[]{factoryName}, getLocationOfName(factory), factory.getResource());
+ }
+ }
+
+ private void validateComponent(IPath sourceFilePath, Set<ISeamComponent> checkedComponents, Set<IPath> unnamedResources) {
+ Set<ISeamComponent> components = seamProject.getComponentsByPath(sourceFilePath);
+ if(components.isEmpty()) {
+ unnamedResources.add(sourceFilePath);
+ return;
+ }
+ for (ISeamComponent component : components) {
+ // Don't validate one component twice.
+ if(!checkedComponents.contains(component)) {
+ validateComponent(component);
+ checkedComponents.add(component);
+ }
+ }
+ }
+
+ /*
+ * Returns set of variables which are linked with this resource
+ */
+ private Set<String> getVariablesNameByResource(IPath resourcePath) {
+ Set<ISeamContextVariable> variables = seamProject.getVariablesByPath(resourcePath);
+ Set<String> result = new HashSet<String>();
+ if(variables!=null) {
+ for (ISeamContextVariable variable : variables) {
+ String name = variable.getName();
+ result.add(name);
+ }
+ }
+ return result;
+ }
+
+ /*
+ * Collect all resources of all declarations of all components which is declared in the source.
+ */
+ private Set<IPath> getAllResourceOfComponent(IPath sourceComponentFilePath) {
+ Set<IPath> result = new HashSet<IPath>();
+ Set<ISeamComponent> components = seamProject.getComponentsByPath(sourceComponentFilePath);
+ for (ISeamComponent component : components) {
+ Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
+ for (ISeamComponentDeclaration seamComponentDeclaration : declarations) {
+ result.add(seamComponentDeclaration.getResource().getFullPath());
+ }
+ }
+ return result;
+ }
+
+ /*
+ * Validates the component
+ */
+ private void validateComponent(ISeamComponent component) {
+ ISeamJavaComponentDeclaration firstJavaDeclaration = component.getJavaDeclaration();
+ if(firstJavaDeclaration!=null) {
+ String componentName = component.getName();
+ if(componentName!=null) {
+ displaySubtask(VALIDATING_COMPONENT_MESSAGE_ID, new String[]{projectName, componentName});
+ }
+ HashMap<Integer, ISeamJavaComponentDeclaration> usedPrecedences = new HashMap<Integer, ISeamJavaComponentDeclaration>();
+ Set<ISeamJavaComponentDeclaration> markedDeclarations = new HashSet<ISeamJavaComponentDeclaration>();
+ int firstJavaDeclarationPrecedence = firstJavaDeclaration.getPrecedence();
+ usedPrecedences.put(firstJavaDeclarationPrecedence, firstJavaDeclaration);
+ Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
+ for (ISeamComponentDeclaration declaration : declarations) {
+ if(declaration instanceof ISeamJavaComponentDeclaration) {
+ ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
+
+ //do not check files declared in another project
+// if(jd.getSeamProject() != seamProject) continue;
+
+ IType type = (IType)jd.getSourceMember();
+ boolean sourceJavaDeclaration = !type.isBinary();
+ if(sourceJavaDeclaration) {
+ // Save link between component name and java source file.
+ validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath(), true);
+ // Save link between component name and all supers of java declaration.
+ try {
+ IType[] superTypes = TypeInfoCollector.getSuperTypes(type).getSuperTypes();
+ for (int i = 0; superTypes != null && i < superTypes.length; i++) {
+ if(!superTypes[i].isBinary()) {
+ IPath path = superTypes[i].getResource().getFullPath();
+ validationContext.addLinkedCoreResource(componentName, path, true);
+ }
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ if(declaration!=firstJavaDeclaration) {
+ // Validate @Name
+ // Component class with the same component name. Check precedence.
+ ISeamJavaComponentDeclaration javaDeclaration = (ISeamJavaComponentDeclaration)declaration;
+ int javaDeclarationPrecedence = javaDeclaration.getPrecedence();
+ ISeamJavaComponentDeclaration checkedDeclaration = usedPrecedences.get(javaDeclarationPrecedence);
+ if(checkedDeclaration==null) {
+ usedPrecedences.put(javaDeclarationPrecedence, javaDeclaration);
+ } else if(sourceJavaDeclaration) {
+ boolean sourceCheckedDeclaration = !((IType)checkedDeclaration.getSourceMember()).isBinary();
+ IResource javaDeclarationResource = javaDeclaration.getResource();
+ // Mark nonunique name.
+ if(!markedDeclarations.contains(checkedDeclaration) && sourceCheckedDeclaration) {
+ // Mark first wrong declaration with that name
+ IResource checkedDeclarationResource = checkedDeclaration.getResource();
+ ITextSourceReference location = ((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(!isEmptyLocation(location)) {
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location, checkedDeclarationResource);
+ }
+ markedDeclarations.add(checkedDeclaration);
+ }
+ // Mark next wrong declaration with that name
+ markedDeclarations.add(javaDeclaration);
+ ITextSourceReference location = ((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(!isEmptyLocation(location)) {
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location, javaDeclarationResource);
+ }
+ }
+ }
+ }
+ }
+ boolean source = !((IType)firstJavaDeclaration.getSourceMember()).isBinary();
+ if(source) {
+ // Validate all elements in first java declaration but @Name.
+ validateJavaDeclaration(component, firstJavaDeclaration);
+ }
+ }
+ validateXmlComponentDeclarations(component);
+ }
+
+ private void validateXmlComponentDeclarations(ISeamComponent component) {
+ String componentName = component.getName();
+ if(componentName!=null) {
+ HashMap<String, ISeamXmlComponentDeclaration> usedPrecedences = new HashMap<String, ISeamXmlComponentDeclaration>();
+ Set<ISeamXmlComponentDeclaration> markedDeclarations = new HashSet<ISeamXmlComponentDeclaration>();
+ Set<ISeamJavaComponentDeclaration> markedJavaDeclarations = new HashSet<ISeamJavaComponentDeclaration>();
+ Set<ISeamXmlComponentDeclaration> declarations = component.getXmlDeclarations();
+ ISeamXmlComponentDeclaration firstNamedDeclaration = null;
+ for (ISeamXmlComponentDeclaration declaration : declarations) {
+ if(isJar(declaration)) {
+ return;
+ }
+ //do not check files declared in another project
+// if(declaration.getSeamProject() != seamProject) continue;
+
+ validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath(), true);
+
+ String precedence = declaration.getPrecedence();
+ if(firstNamedDeclaration == null && declaration.getName()!=null) {
+ firstNamedDeclaration = declaration;
+ usedPrecedences.put(precedence, declaration);
+ }
+ if(declaration.getName()!=null && firstNamedDeclaration!=declaration) {
+ // Check precedence
+ ISeamXmlComponentDeclaration checkedDeclaration = usedPrecedences.get(precedence);
+ if(checkedDeclaration==null) {
+ usedPrecedences.put(precedence, declaration);
+ } else {
+ // Mark not-unique name.
+ if(!markedDeclarations.contains(checkedDeclaration)) {
+ // Mark first wrong declaration with that name
+ IResource checkedDeclarationResource = checkedDeclaration.getResource();
+ ITextSourceReference location = ((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(!isEmptyLocation(location)) {
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location, checkedDeclarationResource);
+ }
+ markedDeclarations.add(checkedDeclaration);
+ }
+ // Mark next wrong declaration with that name
+ markedDeclarations.add(declaration);
+ ITextSourceReference location = ((SeamComponentDeclaration)declaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(!isEmptyLocation(location)) {
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location, declaration.getResource());
+ }
+ }
+ }
+
+ // Check Java declarations with the same name
+ Set<ISeamContextVariable> vars = seamProject.getVariablesByName(componentName);
+ for (ISeamContextVariable variable : vars) {
+ if(variable instanceof ISeamComponent) {
+ ISeamComponent c = (ISeamComponent)variable;
+ Set<ISeamComponentDeclaration> decls = c.getAllDeclarations();
+ for (ISeamComponentDeclaration dec : decls) {
+ if(dec instanceof ISeamJavaComponentDeclaration) {
+ ISeamJavaComponentDeclaration javaDec = (ISeamJavaComponentDeclaration)dec;
+ // Check names
+ if(javaDec.getName()!=null && javaDec.getName().equals(declaration.getName())) {
+ // Check precedences
+ String javaPrecedence = "" + javaDec.getPrecedence();
+ if(javaPrecedence.equals(precedence)) {
+ if(!markedJavaDeclarations.contains(javaDec)) {
+ markedJavaDeclarations.add(javaDec);
+ ITextSourceReference location = ((SeamComponentDeclaration)javaDec).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location, javaDec.getResource());
+ }
+ if(!markedDeclarations.contains(declaration)) {
+ markedDeclarations.add(declaration);
+ ITextSourceReference location = ((SeamComponentDeclaration)declaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location, declaration.getResource());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ String className = declaration.getClassName();
+ if(className!=null) {
+ IType type = null;
+ // validate class name
+ try {
+ IProject p = seamProject.getProject();
+// type = EclipseJavaUtil.findType(EclipseResourceUtil.getJavaProject(p), className);
+ type = EclipseResourceUtil.getJavaProject(p).findType(className);
+ if(type==null) {
+ // Mark wrong class name
+ ITextSourceReference location = ((SeamComponentDeclaration)declaration).getLocationFor(ISeamXmlComponentDeclaration.CLASS);
+ if(isEmptyLocation(location)) {
+ location = ((SeamComponentDeclaration)declaration).getLocationFor(ISeamXmlComponentDeclaration.NAME);
+ }
+ if(isEmptyLocation(location)) {
+ location = declaration;
+ }
+ if(!declaration.isClassNameGuessed()) {
+ addError(UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_COMPONENT_CLASS_NAME, new String[]{className}, location, declaration.getResource());
+ } else {
+ addError(UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_COMPONENT_CLASS_NAME_GUESS, new String[]{className}, location, declaration.getResource());
+ }
+ return;
+ } else if(!type.isBinary()) {
+ validationContext.addLinkedCoreResource(componentName, type.getResource().getFullPath(), true);
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_CORE_VALIDATOR_ERROR_VALIDATING_SEAM_CORE, e);
+ }
+ // validate properties
+ Collection<ISeamProperty> properties = declaration.getProperties();
+ for (ISeamProperty property : properties) {
+ if(isJar(property)) {
+ return;
+ }
+ String name = property.getName();
+ if(name==null) {
+ return;
+ }
+ boolean ok = type.isBinary() || findProperty(type, name)!=null;
+ if(!ok) {
+ addError(UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID, SeamPreferences.UNKNOWN_COMPONENT_PROPERTY, new String[]{type.getElementName(), componentName, name}, property, declaration.getResource());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ static boolean isEmptyLocation(ITextSourceReference location) {
+ return (location == null
+ //is dead location, we cannot now change provider to return null
+ //because it may give rise to other errors.
+ //In the future, null should be returned instead of 'dead' location
+ //and correctly processed
+ || location.getStartPosition() == 0 && location.getLength() == 0);
+ }
+
+ private void validateEntityComponent(ISeamComponent component) {
+ if(component.isEntity()) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ ScopeType scope = component.getScope();
+ if(scope == ScopeType.STATELESS) {
+ ITextSourceReference location = getScopeLocation(component);
+ addError(ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID, SeamPreferences.ENTITY_COMPONENT_WRONG_SCOPE, new String[]{component.getName()}, location, javaDeclaration.getResource());
+ }
+ }
+ }
+
+ private ITextSourceReference getScopeLocation(ISeamComponent component) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ ITextSourceReference location = ((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_SCOPE);
+ if(isEmptyLocation(location)) {
+ location = getNameLocation(javaDeclaration);
+ }
+ return location;
+ }
+
+ private ITextSourceReference getNameLocation(ISeamJavaSourceReference source) {
+ int length = 0;
+ int offset = 0;
+ try {
+ length = source.getSourceMember().getNameRange().getLength();
+ offset = source.getSourceMember().getNameRange().getOffset();
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_CORE_VALIDATOR_ERROR_VALIDATING_SEAM_CORE, e);
+ }
+ return new SeamTextSourceReference(length, offset);
+ }
+
+ private void validateStatefulComponent(ISeamComponent component) {
+ if(component.isStateful()) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ validateStatefulComponentMethods(SeamComponentMethodType.DESTROY, component, DESTROY_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY);
+ validateStatefulComponentMethods(SeamComponentMethodType.REMOVE, component, REMOVE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE);
+ ScopeType scope = component.getScope();
+ if(scope == ScopeType.PAGE || scope == ScopeType.STATELESS) {
+ ITextSourceReference location = getScopeLocation(component);
+ addError(STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID, SeamPreferences.STATEFUL_COMPONENT_WRONG_SCOPE, new String[]{component.getName()}, location, javaDeclaration.getResource());
+ }
+ validateDuplicateComponentMethod(SeamComponentMethodType.REMOVE, component, REMOVE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_REMOVE);
+ }
+ }
+
+ private void validateStatefulComponentMethods(SeamComponentMethodType methodType, ISeamComponent component, String postfixMessageId, String preferenceKey) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ ITextSourceReference classNameLocation = getNameLocation(javaDeclaration);
+ Set<ISeamComponentMethod> methods = javaDeclaration.getMethodsByType(methodType);
+ if(methods==null || methods.isEmpty()) {
+ addError(STATEFUL_COMPONENT_DOES_NOT_CONTAIN_METHOD_SUFIX_MESSAGE_ID + postfixMessageId, preferenceKey, new String[]{component.getName()}, classNameLocation, javaDeclaration.getResource());
+ }
+ }
+
+ private void validateDuplicateComponentMethods(ISeamComponent component) {
+ validateDuplicateComponentMethod(SeamComponentMethodType.DESTROY, component, DESTROY_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_DESTROY);
+ validateDuplicateComponentMethod(SeamComponentMethodType.CREATE, component, CREATE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_CREATE);
+ validateDuplicateComponentMethod(SeamComponentMethodType.UNWRAP, component, UNWRAP_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DUPLICATE_UNWRAP);
+ }
+
+ private void validateDuplicateComponentMethod(SeamComponentMethodType methodType, ISeamComponent component, String postfixMessageId, String preferenceKey) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ Set<ISeamComponentMethod> methods = javaDeclaration.getMethodsByType(methodType);
+ if(methods!=null && methods.size()>1) {
+ for (ISeamComponentMethod method : methods) {
+ if(javaDeclaration.getSourcePath().equals(method.getSourcePath())) {
+ IMethod javaMethod = (IMethod)method.getSourceMember();
+ String methodName = javaMethod.getElementName();
+ ITextSourceReference methodNameLocation = getNameLocation(method);
+ addError(DUPLICATE_METHOD_PREFIX_MESSAGE_ID + postfixMessageId, preferenceKey, new String[]{methodName}, methodNameLocation, javaDeclaration.getResource());
+ }
+ }
+ }
+ }
+
+ private void validateJavaDeclaration(ISeamComponent component, ISeamJavaComponentDeclaration declaration) {
+ validateBijections(declaration);
+ validateStatefulComponent(component);
+ validateDuplicateComponentMethods(component);
+ validateEntityComponent(component);
+ validateDestroyMethod(component);
+ }
+
+ private void validateBijections(ISeamJavaComponentDeclaration declaration) {
+ Set<IBijectedAttribute> bijections = declaration.getBijectedAttributes();
+ if(bijections==null) {
+ return;
+ }
+ for (IBijectedAttribute bijection : bijections) {
+ if(bijection.isOfType(BijectedAttributeType.DATA_MODEL_SELECTION) || bijection.isOfType(BijectedAttributeType.DATA_MODEL_SELECTION_INDEX)) {
+ validateDataModelSelection(declaration, bijection);
+ } else {
+ validateInAndOut(declaration, bijection);
+ }
+ }
+ }
+
+ private void validateInAndOut(ISeamJavaComponentDeclaration declaration, IBijectedAttribute bijection) {
+ String name = bijection.getName();
+ if(name==null || name.startsWith("#{") || name.startsWith("${")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+ // Validate @In
+ if(bijection.isOfType(BijectedAttributeType.IN)) {
+ // save link between java source and variable name
+ validationContext.addLinkedCoreResource(name, declaration.getSourcePath(), false);
+
+ Set<ISeamContextVariable> variables = seamProject.getVariablesByName(name);
+ if(variables==null || variables.size()<1) {
+ ISeamProject parentProject = seamProject.getParentProject();
+ if(parentProject != null) {
+ variables = parentProject.getVariablesByName(name);
+ }
+ }
+ if(variables==null || variables.size()<1) {
+ // Injection has unknown name. Mark it.
+ IResource declarationResource = declaration.getResource();
+ ITextSourceReference nameRef = getNameLocation(bijection);
+ if(nameRef == null) {
+ nameRef = bijection;
+ }
+ addError(UNKNOWN_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_VARIABLE_NAME, new String[]{name}, nameRef, declarationResource);
+ }
+ } else {
+ // save link between java source and variable name
+ validationContext.addLinkedCoreResource(name, declaration.getSourcePath(), true);
+ }
+ }
+
+ private void validateDataModelSelection(ISeamJavaComponentDeclaration declaration, IBijectedAttribute bijection) {
+ String dataModelName = bijection.getValue();
+ String selectionName = bijection.getName();
+ // save link between java source and variable name
+ validationContext.addLinkedCoreResource(selectionName, declaration.getSourcePath(), false);
+ if(dataModelName==null) {
+ // here must be the only one @DataModel in the component
+ Set<IBijectedAttribute> dataBinders = declaration.getBijectedAttributesByType(BijectedAttributeType.DATA_BINDER);
+ if(dataBinders!=null && dataBinders.size()>1) {
+ for (IBijectedAttribute dataBinder : dataBinders) {
+ addError(MULTIPLE_DATA_BINDER_MESSAGE_ID, SeamPreferences.MULTIPLE_DATA_BINDER, dataBinder, declaration.getResource());
+ }
+ }
+ } else {
+ // save link between java source and Data Model name
+ validationContext.addLinkedCoreResource(dataModelName, declaration.getSourcePath(), true);
+ Set<IBijectedAttribute> dataBinders = declaration.getBijectedAttributesByName(dataModelName);
+ if(dataBinders!=null) {
+ for (IBijectedAttribute dataBinder : dataBinders) {
+ if(dataBinder.isOfType(BijectedAttributeType.DATA_BINDER) || dataBinder.isOfType(BijectedAttributeType.OUT)) {
+ return;
+ }
+ }
+ }
+ addError(UNKNOWN_DATA_MODEL_MESSAGE_ID, SeamPreferences.UNKNOWN_DATA_MODEL, new String[]{dataModelName}, getLocationOfAttribute(bijection, DataModelSelectionAttribute.VALUE), declaration.getResource());
+ }
+ }
+
+ /*
+ * Validates methods of java classes. They must belong components.
+ */
+ private void validateMethodsOfUnknownComponent(ISeamJavaComponentDeclaration declaration) {
+ if(seamProject.getComponentsByPath(declaration.getSourcePath()).isEmpty()) {
+ IMember member = declaration.getSourceMember();
+ try {
+ if(member!=null && !Flags.isAbstract(member.getFlags())) {
+ validateMethodOfUnknownComponent(SeamComponentMethodType.CREATE, declaration, CREATE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.CREATE_DOESNT_BELONG_TO_COMPONENT);
+ validateMethodOfUnknownComponent(SeamComponentMethodType.UNWRAP, declaration, UNWRAP_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.UNWRAP_DOESNT_BELONG_TO_COMPONENT);
+ validateMethodOfUnknownComponent(SeamComponentMethodType.OBSERVER, declaration, OBSERVER_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.OBSERVER_DOESNT_BELONG_TO_COMPONENT);
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ validationContext.removeUnnamedCoreResource(declaration.getSourcePath());
+ }
+
+ private void validateDestroyMethod(ISeamComponent component) {
+ if(component.isStateless()) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ Set<ISeamComponentMethod> methods = javaDeclaration.getMethodsByType(SeamComponentMethodType.DESTROY);
+ if(methods==null) {
+ return;
+ }
+ for (ISeamComponentMethod method : methods) {
+ IMethod javaMethod = (IMethod)method.getSourceMember();
+ String methodName = javaMethod.getElementName();
+ if(javaDeclaration.getSourcePath().equals(javaMethod.getPath())) {
+ validationContext.addLinkedCoreResource(component.getName(), javaDeclaration.getSourcePath(), true);
+ ITextSourceReference methodNameLocation = getNameLocation(method);
+ addError(DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_ID, SeamPreferences.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN, new String[]{methodName}, methodNameLocation, method.getResource());
+ }
+ }
+ }
+ }
+
+ private void validateMethodOfUnknownComponent(SeamComponentMethodType methodType, ISeamJavaComponentDeclaration declaration, String sufixMessageId, String preferenceKey) {
+ Set<ISeamComponentMethod> methods = declaration.getMethodsByType(methodType);
+ if(methods!=null && !methods.isEmpty()) {
+ for (ISeamComponentMethod method : methods) {
+ IMethod javaMethod = (IMethod)method.getSourceMember();
+ String methodName = javaMethod.getElementName();
+ if(declaration.getSourcePath().equals(javaMethod.getPath())) {
+ ITextSourceReference methodNameLocation = getNameLocation(method);
+ addError(sufixMessageId + NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID, preferenceKey, new String[]{methodName}, methodNameLocation, method.getResource());
+ validationContext.addUnnamedCoreResource(declaration.getSourcePath());
+ }
+ }
+ } else {
+ validationContext.removeUnnamedCoreResource(declaration.getSourcePath());
+ }
+ }
+
+ private void validateXMLVersion(IFile file) {
+ String ext = file.getFileExtension();
+ if(!"xml".equals(ext)) return;
+
+ XModelObject o = EclipseResourceUtil.createObjectForResource(file);
+
+ if(o == null) return;
+ if(!o.getModelEntity().getName().startsWith("FileSeamComponent")) return;
+
+ Set<String> vs = getXMLVersions(o);
+
+ SeamRuntime runtime = seamProject.getRuntime();
+ if(runtime == null) return;
+
+ String version = runtime.getVersion().toString();
+ String wrongVersion = null;
+ for (String v: vs) {
+ if(!v.startsWith(version)) {
+ wrongVersion = v;
+ break;
+ }
+ }
+ if(wrongVersion != null) {
+ addError(
+ INVALID_XML_VERSION,
+ SeamPreferences.INVALID_XML_VERSION,
+ new String[]{wrongVersion, version},
+ file);
+ }
+ }
+
+ private Set<String> getXMLVersions(XModelObject o) {
+ Set<String> result = new HashSet<String>();
+ if(o.getModelEntity().getName().endsWith("11")) {
+ result.add("1.1");
+ return result;
+ }
+ String sl = o.getAttributeValue("xsi:schemaLocation");
+ int i = 0;
+ while(i >= 0 && i < sl.length()) {
+ int j = sl.indexOf('-', i);
+ if(j < 0) break;
+ int k = sl.indexOf(".xsd", j);
+ if(k < 0) break;
+ String v = sl.substring(j + 1, k);
+ if(isVersion(v)) result.add(v);
+ i = k;
+ }
+
+ return result;
+ }
+
+ private boolean isVersion(String s) {
+ if(s.length() == 0) return false;
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if(c != '.' && !Character.isDigit(c)) return false;
+ }
+ return true;
+ }
+
+ private final static String[] extns = new String[]{"java", "xml"}; //$NON-NLS-1$ //$NON-NLS-2$
+
+ private boolean checkFileExtension(IFile file) {
+ String ext = file.getFileExtension();
+ for (int i = 0; i < extns.length; i++) {
+ if(extns[i].equalsIgnoreCase(ext)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param element
+ * @return Resource of seam model element
+ */
+ private IResource getComponentResourceWithName(ISeamElement element) {
+ if(element instanceof ISeamComponent) {
+ Set<ISeamComponentDeclaration> declarations = ((ISeamComponent)element).getAllDeclarations();
+ for (Object o : declarations) {
+ SeamComponentDeclaration d = (SeamComponentDeclaration)o;
+ ITextSourceReference location = d.getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(!SeamCoreValidator.isEmptyLocation(location)) {
+ return d.getResource();
+ }
+ }
+ }
+ return element.getResource();
+ }
+
+ /**
+ * @param seam model element
+ * @return location of name attribute
+ */
+ private ITextSourceReference getLocationOfName(ISeamElement element) {
+ return getLocationOfAttribute(element, SeamComponentDeclaration.PATH_OF_NAME);
+ }
+
+ /**
+ * @param seam model element
+ * @return location of attribute
+ */
+ private ITextSourceReference getLocationOfAttribute(ISeamElement element, String attributeName) {
+ ITextSourceReference location = null;
+ if(element instanceof AbstractContextVariable) {
+ location = ((AbstractContextVariable)element).getLocationFor(attributeName);
+ } else if(element instanceof ISeamComponent) {
+ Set<ISeamComponentDeclaration> declarations = ((ISeamComponent)element).getAllDeclarations();
+ for (ISeamComponentDeclaration d : declarations) {
+ location = ((SeamComponentDeclaration)d).getLocationFor(attributeName);
+ if(!SeamCoreValidator.isEmptyLocation(location)) {
+ break;
+ }
+ }
+ } else if(element instanceof SeamComponentDeclaration) {
+ location = ((SeamComponentDeclaration)element).getLocationFor(attributeName);
+ }
+ if(SeamCoreValidator.isEmptyLocation(location) && element instanceof ITextSourceReference) {
+ location = (ITextSourceReference)element;
+ }
+ return location;
+ }
+
+ /**
+ * @param resource
+ * @return true if resource is Jar file
+ */
+ private boolean isJar(IPath path) {
+ if(path == null) {
+ throw new IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_HELPER_RESOURCE_MUST_NOT_BE_NULL);
+ }
+ String ext = path.getFileExtension();
+ return ext != null && ext.equalsIgnoreCase("jar"); //$NON-NLS-1$
+ }
+
+ /**
+ * @param element
+ * @return true if seam element packed in Jar file
+ */
+ private boolean isJar(ISeamElement element) {
+ return isJar(element.getSourcePath());
+ }
+
+ /**
+ * @param componentXmlFile
+ * @return IType of component for <ComponentName>.component.xml
+ */
+ private IType getClassTypeForComponentXml(IFile componentXmlFile) {
+ String className = getClassNameForComponentXml(componentXmlFile);
+ if(className==null) {
+ return null;
+ }
+ return findType(className);
+ }
+
+ /**
+ * @param type name
+ * @return IType
+ */
+ public IType findType(String fullyQualifiedName) {
+ IProject p = rootProject;
+ try {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
+ return jp.findType(fullyQualifiedName);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+
+ /**
+ * @param componentXmlFile
+ * @return name of component class for <ComponentName>.component.xml
+ */
+ private String getClassNameForComponentXml(IFile componentXmlFile) {
+ String fileName = componentXmlFile.getName();
+ int firstDot = fileName.indexOf('.');
+ if(firstDot==-1) {
+ return null;
+ }
+ String className = fileName.substring(0, firstDot);
+ IProject p = this.rootProject;
+ try {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
+ IPackageFragment packageFragment = jp.findPackageFragment(componentXmlFile.getFullPath().removeLastSegments(1));
+ if(packageFragment==null) {
+ return null;
+ }
+ return packageFragment.getElementName() + "." + className; //$NON-NLS-1$
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+
+ /**
+ * Find a setter or a field for a property.
+ * @param type
+ * @param propertyName
+ * @return IMethod (setter) or IFiled (field)
+ */
+ private IMember findProperty(IType type, String propertyName) {
+ if(propertyName == null || propertyName.length()==0) {
+ return null;
+ }
+ try {
+ return findPropertyInHierarchy(type, propertyName);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ return null;
+ }
+
+ private IMember findPropertyInHierarchy(IType type, String propertyName) throws JavaModelException {
+ String firstLetter = propertyName.substring(0, 1).toUpperCase();
+ String nameWithoutFirstLetter = propertyName.substring(1);
+ String setterName = "set" + firstLetter + nameWithoutFirstLetter; //$NON-NLS-1$
+
+ IMethod[] methods = type.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if(methods[i].getElementName().equals(setterName) && methods[i].getParameterNames().length==1) {
+ return methods[i];
+ }
+ }
+ IField[] fields = type.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ if(fields[i].getElementName().equals(propertyName)) {
+ return fields[i];
+ }
+ }
+
+ String superclassName = type.getSuperclassName();
+ if(superclassName!=null) {
+ String[][] packages = type.resolveType(superclassName);
+ if(packages!=null) {
+ for (int i = 0; i < packages.length; i++) {
+ String packageName = packages[i][0];
+ if(packageName!=null && packageName.length()>0) {
+ packageName = packageName + "."; //$NON-NLS-1$
+ } else {
+ packageName = ""; //$NON-NLS-1$
+ }
+ String qName = packageName + packages[i][1];
+ IType superclass = type.getJavaProject().findType(qName);
+ if(superclass!=null) {
+ IMember property = findPropertyInHierarchy(superclass, propertyName);
+ if(property!=null) {
+ return property;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator2.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator2.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator2.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator2.java 2009-10-16 12:38:51 UTC (rev 18129)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.seam.internal.core.validation;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.jsf.web.validation.ELValidator;
+import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class SeamELValidator2 extends ELValidator {
+
+ public static final String ID = "org.jboss.tools.seam.core.ELValidator";
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jsf.web.validation.ELValidator#getId()
+ */
+ @Override
+ public String getId() {
+ return ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jsf.web.validation.ELValidator#getValidatingProjects(org.eclipse.core.resources.IProject)
+ */
+ @Override
+ public IValidatingProjectSet getValidatingProjects(IProject project) {
+ try {
+ if(project.hasNature(ISeamProject.NATURE_ID)) {
+ return super.getValidatingProjects(project);
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+
+ return SeamCoreValidator2.getSeamValidatingProjects(project);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jsf.web.validation.ELValidator#shouldValidate(org.eclipse.core.resources.IProject)
+ */
+ @Override
+ public boolean shouldValidate(IProject project) {
+ try {
+ return super.shouldValidate(project) || project.hasNature(ISeamProject.NATURE_ID);
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+}
\ No newline at end of file
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator2.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 8 months