Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 167521 Details for
Bug 252861
[WPE] Add tag converter transform operation in WPE to support generating markup depending on view mode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
additional patch containing the junit test
patch-junit-bug252861.txt (text/plain), 16.11 KB, created by
Carlin Rogers
on 2010-05-07 14:18:33 EDT
(
hide
)
Description:
additional patch containing the junit test
Filename:
MIME Type:
Creator:
Carlin Rogers
Created:
2010-05-07 14:18:33 EDT
Size:
16.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.pagedesigner.tests >Index: metadata/checkmodeop_dti.xml >=================================================================== >RCS file: metadata/checkmodeop_dti.xml >diff -N metadata/checkmodeop_dti.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ metadata/checkmodeop_dti.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<md:metadatamodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" >+ xmlns:md="http://org.eclipse.jst.jsf.common.metadata/metadata.ecore" >+ xmlns:dti="http://org.eclipse.jsf.pagedesigner/dtinfo.ecore" >+ id="org.eclipse.jst.pagedesigner.tests.testCheckModeOperation" >+ type="tagFile"> >+ >+ <entity id="testTagOne" type="tag"> >+ <trait id="dt-info"> >+ <value xsi:type="dti:DTInfo"> >+ <tag-convert-info> >+ <operation id="org.eclipse.jst.pagedesigner.CheckModeOperation"> >+ <parameter value="design"/> >+ <operation id="org.eclipse.jst.pagedesigner.CreateElementOperation"> >+ <parameter value="div"/> >+ </operation> >+ <operation id="org.eclipse.jst.pagedesigner.CopyChildrenOperation"/> >+ </operation> >+ </tag-convert-info> >+ <tag-decorate-info id="vpd-decorate-preview" >+ nonVisual="true" >+ /> >+ </value> >+ </trait> >+ </entity> >+ >+ <entity id="testTagTwo" type="tag"> >+ <trait id="dt-info"> >+ <value xsi:type="dti:DTInfo"> >+ <tag-convert-info> >+ <operation id="org.eclipse.jst.pagedesigner.CreateElementOperation"> >+ <parameter value="div"/> >+ </operation> >+ <operation id="org.eclipse.jst.pagedesigner.CheckModeOperation"> >+ <parameter value="design"/> >+ <operation id="org.eclipse.jst.pagedesigner.CopyAttributeOperation"> >+ <parameter value="requiredAttr1"/> >+ </operation> >+ <operation id="org.eclipse.jst.pagedesigner.RenameAttributeOperation"> >+ <parameter value="requiredAttr1"/> >+ <parameter value="id"/> >+ </operation> >+ </operation> >+ <operation id="org.eclipse.jst.pagedesigner.CheckModeOperation"> >+ <parameter value="preview"/> >+ <operation id="org.eclipse.jst.pagedesigner.CopyAttributeOperation"> >+ <parameter value="requiredAttr2"/> >+ </operation> >+ <operation id="org.eclipse.jst.pagedesigner.RenameAttributeOperation"> >+ <parameter value="requiredAttr2"/> >+ <parameter value="id"/> >+ </operation> >+ </operation> >+ </tag-convert-info> >+ </value> >+ </trait> >+ </entity> >+ >+</md:metadatamodel> >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/tests/org.eclipse.jst.pagedesigner.tests/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 27 Mar 2009 19:38:30 -0000 1.4 >+++ plugin.xml 7 May 2010 18:06:39 -0000 >@@ -4,6 +4,10 @@ > <extension > point="org.eclipse.jst.jsf.common.standardMetaDataFiles"> > <standardMetaDataFile >+ location="/metadata/checkmodeop_dti.xml" >+ uri="org.eclipse.jst.pagedesigner.tests.testCheckModeOperation"> >+ </standardMetaDataFile> >+ <standardMetaDataFile > location="/metadata/test-metadata.xml" > uri="org.eclipse.jst.pagedesigner.tests.tagCreatorFactory1"> > </standardMetaDataFile> >Index: src/org/eclipse/jst/pagedesigner/tests/Test_TransformOperations.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/tests/org.eclipse.jst.pagedesigner.tests/src/org/eclipse/jst/pagedesigner/tests/Test_TransformOperations.java,v >retrieving revision 1.2 >diff -u -r1.2 Test_TransformOperations.java >--- src/org/eclipse/jst/pagedesigner/tests/Test_TransformOperations.java 4 Sep 2007 18:14:18 -0000 1.2 >+++ src/org/eclipse/jst/pagedesigner/tests/Test_TransformOperations.java 7 May 2010 18:06:40 -0000 >@@ -180,6 +180,122 @@ > } > > /** >+ * Test "CheckModeOperation". >+ */ >+ public void testCheckModeOperation() { >+ try { >+ webProjectTestEnv.loadResourceInWebRoot >+ (PageDesignerTestsPlugin.getDefault().getBundle() >+ , "/testdata/checkmodeop/checkModeOp.tld.data" >+ , "/META-INF/checkModeOp.tld"); >+ >+ webProjectTestEnv.loadResourceInWebRoot( >+ PageDesignerTestsPlugin.getDefault().getBundle() >+ ,"/testdata/checkmodeop/testCheckModeOperation.jsp.data" >+ ,"/testCheckModeOperation.jsp"); >+ >+ ContextWrapper wrapper = null; >+ >+ // First converter is simple use of CheckModeOperation >+ // containing child operations. >+ // Exercises both design and preview mode, but there should >+ // only be conversion for design view based on the design >+ // time info traits in the meta-data for this test. >+ try { >+ wrapper = >+ getDocumentContext("/WebContent/testCheckModeOperation.jsp", 365); >+ >+ String prefix = "cmo"; >+ String localName = "testTagOne"; >+ ITagConverter tagConverter = >+ getTagConverter(wrapper, prefix, localName, IConverterFactory.MODE_DESIGNER); >+ assertNotNull(tagConverter); >+ >+ // invoke ITagConverter instance >+ tagConverter.convertRefresh(null); >+ >+ // get and test result element >+ Element resultElement = tagConverter.getResultElement(); >+ assertNotNull(resultElement); >+ assertEquals("div", resultElement.getLocalName()); >+ >+ // Ensure correct child element was copied to child node list. >+ // First child is text node, look at second child. >+ List<?> childNodes = tagConverter.getChildModeList(); >+ assertTrue(childNodes.size() > 1); >+ Node secondChildNode = (Node)childNodes.get(1); >+ assertTrue(secondChildNode instanceof Element); >+ Element secondChildElement = (Element)secondChildNode; >+ assertEquals("span", secondChildElement.getLocalName()); >+ assertEquals("t1ChildSpan", secondChildElement.getAttribute("id")); >+ >+ // now try in preview mode >+ tagConverter = >+ getTagConverter(wrapper, prefix, localName, IConverterFactory.MODE_PREVIEW); >+ assertNotNull(tagConverter); >+ >+ // invoke ITagConverter instance >+ tagConverter.convertRefresh(null); >+ >+ // get and test result element >+ resultElement = tagConverter.getResultElement(); >+ assertNull(resultElement); >+ } finally { >+ if (wrapper != null) { >+ wrapper.dispose(); >+ } >+ } >+ >+ // Second tag converter has the CheckModeOperation >+ // as a sibling operation for additional transforms. >+ // Exercises both design and preview mode. >+ try { >+ wrapper = >+ getDocumentContext("/WebContent/testCheckModeOperation.jsp", 531); >+ >+ String prefix = "cmo"; >+ String localName = "testTagTwo"; >+ >+ // test conversion for design mode >+ ITagConverter tagConverter = >+ getTagConverter(wrapper, prefix, localName, IConverterFactory.MODE_DESIGNER); >+ assertNotNull(tagConverter); >+ >+ // invoke ITagConverter instance >+ tagConverter.convertRefresh(null); >+ >+ // get and test result element >+ Element resultElement = tagConverter.getResultElement(); >+ assertNotNull(resultElement); >+ assertEquals("div", resultElement.getLocalName()); >+ assertEquals("designId", resultElement.getAttribute("id")); >+ >+ // now try in preview mode >+ tagConverter = >+ getTagConverter(wrapper, prefix, localName, IConverterFactory.MODE_PREVIEW); >+ assertNotNull(tagConverter); >+ >+ // invoke ITagConverter instance >+ tagConverter.convertRefresh(null); >+ >+ // get and test result element >+ resultElement = tagConverter.getResultElement(); >+ assertNotNull(resultElement); >+ assertEquals("div", resultElement.getLocalName()); >+ assertEquals("previewId", resultElement.getAttribute("id")); >+ } finally { >+ if (wrapper != null) { >+ wrapper.dispose(); >+ } >+ } >+ } catch(Exception ex) { >+ ex.printStackTrace(); >+ fail(ex.getLocalizedMessage()); >+ } >+ } >+ >+ >+ /** > * Test "ConvertAttributeToTextOperation". > */ > public void testConvertAttributeToTextOperation() { >@@ -519,41 +635,15 @@ > ContextWrapper wrapper = null; > try { > wrapper = getDocumentContext("/WebContent/Test_TransformOperations.jsp", docOffset); >- IStructuredDocumentContext context = wrapper.getContext(); >- IDOMContextResolver resolver = >- IStructuredDocumentContextResolverFactory.INSTANCE. >- getDOMContextResolver(context); >- >- //get Element >- Node node = resolver.getNode(); >- if ( >- node instanceof Element && >- node.getPrefix().equals(prefix) && >- node.getLocalName().equals(localName)) { >- >- Element element = (Element)node; >- >- //get IDOMDocument >- IStructuredModel model = wrapper.getModel(); >- if (model instanceof IDOMModel) { >- IDOMDocument document = ((IDOMModel)model).getDocument(); >- if (document != null) { >- >- //get ITagConverter instance >- ITagConverter tagConverter = DTManager.getInstance().getTagConverter( >- element, >- IConverterFactory.MODE_DESIGNER, >- document); >- if (tagConverter != null) { >- >- //invoke ITagConverter instance >- tagConverter.convertRefresh(null); >- >- //get result element >- resultElement = tagConverter.getResultElement(); >- } >- } >- } >+ ITagConverter tagConverter = >+ getTagConverter(wrapper, prefix, localName, IConverterFactory.MODE_DESIGNER); >+ if (tagConverter != null) { >+ >+ //invoke ITagConverter instance >+ tagConverter.convertRefresh(null); >+ >+ //get result element >+ resultElement = tagConverter.getResultElement(); > } > } finally { > if (wrapper != null) { >@@ -563,6 +653,41 @@ > return resultElement; > } > >+ private ITagConverter getTagConverter(ContextWrapper wrapper, String prefix, >+ String localName, int mode) throws Exception { >+ ITagConverter tagConverter = null; >+ IStructuredDocumentContext context = wrapper.getContext(); >+ IDOMContextResolver resolver = >+ IStructuredDocumentContextResolverFactory.INSTANCE. >+ getDOMContextResolver(context); >+ >+ //get Element >+ Node node = resolver.getNode(); >+ if ( >+ node instanceof Element && >+ node.getPrefix().equals(prefix) && >+ node.getLocalName().equals(localName)) { >+ >+ Element element = (Element)node; >+ >+ //get IDOMDocument >+ IStructuredModel model = wrapper.getModel(); >+ if (model instanceof IDOMModel) { >+ IDOMDocument document = ((IDOMModel)model).getDocument(); >+ if (document != null) { >+ >+ //get ITagConverter instance >+ tagConverter = DTManager.getInstance().getTagConverter( >+ element, >+ mode, >+ document); >+ } >+ } >+ } >+ >+ return tagConverter; >+ } >+ > private ContextWrapper getDocumentContext(String path, int offset) throws Exception { > IProject project = webProjectTestEnv.getTestProject(); > IFile jspFile = project.getFile(new Path(path)); >@@ -597,5 +722,4 @@ > model.releaseFromRead(); > } > } >- > } >Index: testdata/checkmodeop/checkModeOp.tld.data >=================================================================== >RCS file: testdata/checkmodeop/checkModeOp.tld.data >diff -N testdata/checkmodeop/checkModeOp.tld.data >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ testdata/checkmodeop/checkModeOp.tld.data 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+<?xml version="1.0" encoding="ISO-8859-1" ?> >+ >+<!DOCTYPE taglib >+ PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" >+ "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> >+ >+ >+<taglib> >+ >+ >+ <!-- ========== Tag Library Description Elements ========================= --> >+ >+ >+ <tlib-version>1.0</tlib-version> >+ <jsp-version>1.2</jsp-version> >+ <short-name>testCheckModeOperation</short-name> >+ <uri>org.eclipse.jst.pagedesigner.tests.testCheckModeOperation</uri> >+ <description> >+ A test tld used for verifying the CheckModeOperation. >+ </description> >+ >+ <!-- ========== Tag Descriptions ========================================= --> >+ >+ >+ <tag> >+ <name>testTagOne</name> >+ <tag-class>com.foo.SomeClassOne</tag-class> >+ <body-content>JSP</body-content> >+ <description> >+ A simple test tag. This test includes design time metadata mapped to >+ this tag to exercise the CheckModeOperation. >+ </description> >+ >+ <attribute> >+ <name>notRequiredAttr1</name> >+ <required>false</required> >+ <rtexprvalue>false</rtexprvalue> >+ <description> >+ This attribute is optional. >+ </description> >+ </attribute> >+ </tag> >+ >+ <tag> >+ <name>testTagTwo</name> >+ <tag-class>com.foo.SomeClassTwo</tag-class> >+ <body-content>JSP</body-content> >+ <description> >+ A simple test tag. This test includes design time metadata mapped to >+ this tag to exercise the CheckModeOperation. >+ </description> >+ >+ <attribute> >+ <name>requiredAttr1</name> >+ <required>true</required> >+ <rtexprvalue>false</rtexprvalue> >+ <description> >+ This attribute is required. >+ </description> >+ </attribute> >+ >+ <attribute> >+ <name>requiredAttr2</name> >+ <required>true</required> >+ <rtexprvalue>false</rtexprvalue> >+ <description> >+ This attribute is required. >+ </description> >+ </attribute> >+ </tag> >+ >+</taglib> >Index: testdata/checkmodeop/testCheckModeOperation.jsp.data >=================================================================== >RCS file: testdata/checkmodeop/testCheckModeOperation.jsp.data >diff -N testdata/checkmodeop/testCheckModeOperation.jsp.data >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ testdata/checkmodeop/testCheckModeOperation.jsp.data 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> >+<%@taglib uri="org.eclipse.jst.pagedesigner.tests.testCheckModeOperation" prefix="cmo"%> >+ >+<html> >+<head> >+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> >+ <title>Test CheckModeOperation</title> >+</head> >+<body> >+ <div id="t1Div"> >+ <cmo:testTagOne> >+ <span id="t1ChildSpan"> >+ some text >+ </span> >+ </cmo:testTagOne> >+ </div> >+ >+ <div id="t2Div"> >+ <cmo:testTagTwo requiredAttr1="designId" >+ requiredAttr2="previewId"> >+ <span id="t2ChildSpan"> >+ some text >+ </span> >+ </cmo:testTagTwo> >+ </div> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 252861
:
167352
| 167521