Author: yradtsevich
Date: 2009-10-15 18:51:53 -0400 (Thu, 15 Oct 2009)
New Revision: 18117
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
Log:
JUnit test for
https://jira.jboss.org/jira/browse/JBIDE-3473 has been fixed.
nsiAccessible is no more available in the XULRunner 1.9.
XULRunner 1.9 related issue (
https://jira.jboss.org/jira/browse/JBIDE-2248 ).
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2009-10-15
17:58:55 UTC (rev 18116)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2009-10-15
22:51:53 UTC (rev 18117)
@@ -2,10 +2,12 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Point;
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.StructuredTextViewer;
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;
@@ -14,6 +16,7 @@
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.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -24,7 +27,7 @@
*
*/
public class JBIDE3473Test extends VpeTest {
- private static final int INSERTING_POSITION = 179;
+ private static final Point INSERTION_POSITION = new Point(15, 12);
private static final String TABLE_ID = "table-id"; //$NON-NLS-1$
private static final String TEST_PAGE_NAME = "JBIDE/3473/JBIDE-3473.html";
//$NON-NLS-1$
private static final String INSERTING_TEXT = " id=\"td-id\"";
//$NON-NLS-1$
@@ -55,12 +58,13 @@
// open and get editor
JSPMultiPageEditor jspEditor = openEditor(input);
- StyledText styledText = jspEditor.getSourceEditor().getTextViewer()
- .getTextWidget();
+ final StructuredTextViewer textViewer = jspEditor.getSourceEditor().getTextViewer();
+ StyledText styledText = textViewer.getTextWidget();
- styledText.setCaretOffset(INSERTING_POSITION);
- IndexedRegion indexedRegion = ContentAssistUtils.getNodeAt(jspEditor
- .getSourceEditor().getTextViewer(), INSERTING_POSITION);
+ final int offset = TestUtil.getLinePositionOffcet(textViewer,
+ INSERTION_POSITION.x, INSERTION_POSITION.y);
+ styledText.setCaretOffset(offset);
+ IndexedRegion indexedRegion = ContentAssistUtils.getNodeAt(textViewer, offset);
Node tdTextEditorNode = (Node) indexedRegion;
assertNotNull(tdTextEditorNode);
assertTrue("Text under cursor is not TD node",
HTML.TAG_TD.equalsIgnoreCase(tdTextEditorNode.getNodeName())); //$NON-NLS-1$
@@ -94,14 +98,15 @@
* @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)
+ * @see XulRunnerVpeUtils#getElementBounds(nsIDOMNode)
*/
private Rectangle getBoundsOfElementById(nsIDOMDocument document, String id) {
Rectangle bounds = null;
nsIDOMElement element = document.getElementById(id);
if (element != null) {
- bounds = VisualDomUtil.getBounds(element);
+ //bounds = VisualDomUtil.getBounds(element);
+ bounds = XulRunnerVpeUtils.getElementBounds(element);
}
return bounds;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2009-10-15
17:58:55 UTC (rev 18116)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2009-10-15
22:51:53 UTC (rev 18117)
@@ -14,11 +14,10 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.mozilla.interfaces.nsIAccessible;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMEvent;
@@ -249,30 +248,32 @@
// 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 accessible
- *
- * @author yradtsevich
- */
- public static Rectangle getBounds(nsIDOMNode node) {
- Rectangle bounds = null;
-
- nsIAccessible accessible = (nsIAccessible)
node.queryInterface(nsIAccessible.NS_IACCESSIBLE_IID);
- if (accessible != null) {
- int[] xArray = new int[1]; // Left hand corner of the node
- int[] yArray = new int[1]; // Top corner of the node
- int[] widthArray = new int[1]; // Width of the node
- int[] heightArray = new int[1]; // Height of the node
-
- accessible.getBounds(xArray, yArray, widthArray, heightArray);
- bounds = new Rectangle(xArray[0], yArray[0], widthArray[0], heightArray[0]);
- }
-
- return bounds;
- }
+// XULRunner 1.9 throws an error when we try to get nsIAccessible.
+// Use XulRunnerVpeUtils#getElementBounds(nsIDOMNode) instead.
+// /**
+// * 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 accessible
+// *
+// * @author yradtsevich
+// */
+// public static Rectangle getBounds(nsIDOMNode node) {
+// Rectangle bounds = null;
+//
+// nsIAccessible accessible = (nsIAccessible)
node.queryInterface(nsIAccessible.NS_IACCESSIBLE_IID);
+// if (accessible != null) {
+// int[] xArray = new int[1]; // Left hand corner of the node
+// int[] yArray = new int[1]; // Top corner of the node
+// int[] widthArray = new int[1]; // Width of the node
+// int[] heightArray = new int[1]; // Height of the node
+//
+// accessible.getBounds(xArray, yArray, widthArray, heightArray);
+// bounds = new Rectangle(xArray[0], yArray[0], widthArray[0], heightArray[0]);
+// }
+//
+// return bounds;
+// }
/**
* Creates HTML container (element) borders of that are