From jbosstools-commits at lists.jboss.org Thu Jan 8 09:36:17 2009 Content-Type: multipart/mixed; boundary="===============1324358382884793087==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r12930 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3473 and 3 other directories. Date: Thu, 08 Jan 2009 09:36:17 -0500 Message-ID: --===============1324358382884793087== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: yradtsevich Date: 2009-01-08 09:36:16 -0500 (Thu, 08 Jan 2009) New Revision: 12930 Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebCo= ntent/pages/JBIDE/3473/ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebCo= ntent/pages/JBIDE/3473/JBIDE-3473.html trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/jbide/JBIDE3473Test.java Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/JsfAllTests.java trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/uti= l/VisualDomUtil.java Log: RESOLVED - issue JBIDE-3473: Something wrong with text processing inside ta= ble. https://jira.jboss.org/jira/browse/JBIDE-3473 JUnit test has been written. Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/W= ebContent/pages/JBIDE/3473/JBIDE-3473.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/3473/JBIDE-3473.html (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/3473/JBIDE-3473.html 2009-01-08 14:36:16 UTC (rev 12930) @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + +
+ 1JSF Testssssssssssssssssssssssssssssss + + 2JSF Testsssssssssssssssss +
+ 3JSF Testssssssssssss + + 4JSF Testssssssss +
+ + \ No newline at end of file Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/JsfAllTests.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2009-01-08 14:08:28 UTC (rev 12929) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2009-01-08 14:36:16 UTC (rev 12930) @@ -47,6 +47,7 @@ import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3376Test; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3396Test; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3441Test; +import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3473Test; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3482Test; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test; @@ -78,6 +79,7 @@ // $JUnit-BEGIN$ suite.addTestSuite(JsfComponentTest.class); suite.addTestSuite(Jsf20ComponentContentTest.class); + suite.addTestSuite(JBIDE3473Test.class); suite.addTestSuite(JBIDE3441Test.class); suite.addTestSuite(JsfJbide1467Test.class); suite.addTestSuite(JsfJbide1501Test.class); Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools= /jsf/vpe/jsf/test/jbide/JBIDE3473Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/JBIDE3473Test.java (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/JBIDE3473Test.java 2009-01-08 14:36:16 UTC (rev 12930) @@ -0,0 +1,109 @@ +package org.jboss.tools.jsf.vpe.jsf.test.jbide; + +import org.eclipse.core.resources.IFile; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; +import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; +import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests; +import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor; +import org.jboss.tools.vpe.editor.VpeController; +import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; +import org.jboss.tools.vpe.ui.test.TestUtil; +import org.jboss.tools.vpe.ui.test.VpeTest; +import org.mozilla.interfaces.nsIDOMDocument; +import org.mozilla.interfaces.nsIDOMElement; +import org.mozilla.interfaces.nsIDOMNode; +import org.w3c.dom.Node; + +/** + * @author yradtsevich + * + */ +public class JBIDE3473Test extends VpeTest { + private static final int INSERTING_POSITION =3D 179; + private static final String TABLE_ID =3D "table-id"; //$NON-NLS-1$ + private static final String TEST_PAGE_NAME =3D "JBIDE/3473/JBIDE-3473.htm= l"; //$NON-NLS-1$ + private static final String INSERTING_TEXT =3D " id=3D\"td-id\""; //$NON-= NLS-1$ = + + public JBIDE3473Test(String name) { + super(name); + } + + /** + * Adds 'id' attribute to TD tag inside a table and checks if + * there are not changes in the VPE view. = + * = + * @throws Throwable + */ + public void testNodeUpdate() throws Throwable { + TestUtil.waitForJobs(); + setException(null); + = + // get test page path + IFile file =3D (IFile) TestUtil.getComponentPath(TEST_PAGE_NAME, + JsfAllTests.IMPORT_PROJECT_NAME); + assertNotNull("Could not open specified file " + TEST_PAGE_NAME, file); = //$NON-NLS-1$ + + IEditorInput input =3D new FileEditorInput(file); + + assertNotNull("Editor input is null", input); //$NON-NLS-1$ + + // open and get editor + JSPMultiPageEditor jspEditor =3D openEditor(input); + + StyledText styledText =3D jspEditor.getSourceEditor().getTextViewer() + .getTextWidget(); + + styledText.setCaretOffset(INSERTING_POSITION); + IndexedRegion indexedRegion =3D ContentAssistUtils.getNodeAt(jspEditor + .getSourceEditor().getTextViewer(), INSERTING_POSITION); + Node tdTextEditorNode =3D (Node) indexedRegion; + assertNotNull(tdTextEditorNode); + assertTrue("Text under cursor is not TD node", HTML.TAG_TD.equalsIgnoreC= ase(tdTextEditorNode.getNodeName())); //$NON-NLS-1$ + + VpeController vpeController =3D TestUtil.getVpeController(jspEditor); + + Rectangle boundsBeforeInsert =3D getBoundsOfElementById(vpeController.ge= tXulRunnerEditor().getDOMDocument(), TABLE_ID); + assertNotNull("boundsBeforeInsert should be not null.", boundsBeforeInse= rt); //$NON-NLS-1$ + + styledText.insert(INSERTING_TEXT); //$NON-NLS-1$ + TestUtil.delay(450); + TestUtil.waitForJobs(); + + Rectangle boundsAfterInsert =3D getBoundsOfElementById(vpeController.get= XulRunnerEditor().getDOMDocument(), TABLE_ID); + assertNotNull("boundsAfterInsert should be not null.", boundsAfterInsert= ); //$NON-NLS-1$ + + assertEquals("Width of the table has been changed.", boundsBeforeInsert.= width, boundsAfterInsert.width); //$NON-NLS-1$ + assertEquals("Height of the table has been changed.", boundsBeforeInsert= .height, boundsAfterInsert.height); //$NON-NLS-1$ + + if(getException()!=3Dnull) { + throw getException(); + } + } + + /** + * Returns bounds of the element with given {@code id} + * from the {@code document} + * = + * @param document the document + * @param id ID of the DOM element which bounds is needed + * @return bounds of the element with given {@code id} + * or {@code null} if the element is not found or not accessible + * = + * @see VisualDomUtil#getBounds(nsIDOMNode) + */ + private Rectangle getBoundsOfElementById(nsIDOMDocument document, String = id) { + Rectangle bounds =3D null; + = + nsIDOMElement element =3D document.getElementById(id); + if (element !=3D null) { + bounds =3D VisualDomUtil.getBounds(element); + } + = + return bounds; + } = +} \ No newline at end of file Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/edi= tor/util/VisualDomUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ut= il/VisualDomUtil.java 2009-01-08 14:08:28 UTC (rev 12929) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ut= il/VisualDomUtil.java 2009-01-08 14:36:16 UTC (rev 12930) @@ -10,9 +10,14 @@ *************************************************************************= *****/ = package org.jboss.tools.vpe.editor.util; = +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; import java.util.List; = import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.mozilla.interfaces.nsIAccessibilityService; +import org.mozilla.interfaces.nsIAccessible; import org.mozilla.interfaces.nsIDOMElement; import org.mozilla.interfaces.nsIDOMEvent; import org.mozilla.interfaces.nsIDOMMouseEvent; @@ -22,6 +27,7 @@ import org.mozilla.interfaces.nsIDOMNodeList; import org.mozilla.interfaces.nsIDOMRange; import org.mozilla.interfaces.nsISelection; +import org.mozilla.xpcom.Mozilla; import org.mozilla.xpcom.XPCOMException; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -29,6 +35,8 @@ = = public class VisualDomUtil { + private static final String ACCESSIBILITY_SERVICE_CONTRACT_ID =3D "@mozil= la.org/accessibilityService;1"; + private static Reference accessibilityServiceCac= he =3D null; = static public nsIDOMNode getAncestorNode(nsIDOMNode visualNode, String ta= gName){ if (tagName =3D=3D null) return null; @@ -207,4 +215,52 @@ } = } + = + /** + * Returns instance of {@link nsIAccessibilityService}. + * = + * @author yradtsevich + */ + public static nsIAccessibilityService getAccessibilityService() { + nsIAccessibilityService accessibilityService =3D null; + if (accessibilityServiceCache !=3D null) { + // get accessibilityService from cache + accessibilityService =3D accessibilityServiceCache.get(); + } + if (accessibilityService =3D=3D null) { + accessibilityService =3D (nsIAccessibilityService) Mozilla.getInstance() + .getServiceManager() + .getServiceByContractID(ACCESSIBILITY_SERVICE_CONTRACT_ID, + nsIAccessibilityService.NS_IACCESSIBILITYSERVICE_IID); + = + // cache accessibilityService + accessibilityServiceCache =3D new SoftReference(accessibilityService); + } + return accessibilityService; + } + = + /** + * Returns on screen bounds of the {@code node} + * = + * @param node cannot be {@code null} + * @return bounds of the {@code node} or {@code null} if it is not access= ible + * = + * @author yradtsevich + */ + public static Rectangle getBounds(nsIDOMNode node) { + Rectangle bounds =3D null; + = + nsIAccessible accessible =3D getAccessibilityService().getAccessibleFor(= node); + if (accessible !=3D null) { + int[] xArray =3D new int[1]; // Left hand corner of the node + int[] yArray =3D new int[1]; // Top corner of the node + int[] widthArray =3D new int[1]; // Width of the node + int[] heightArray =3D new int[1]; // Height of the node + = + accessible.getBounds(xArray, yArray, widthArray, heightArray); + bounds =3D new Rectangle(xArray[0], yArray[0], widthArray[0], heightArr= ay[0]); + } + = + return bounds; + } } --===============1324358382884793087==--