List of usage examples for com.google.gwt.dom.client LocalDom nodeFor
public static <T extends Node> T nodeFor(NodeRemote remote)
From source file:rocket.selection.client.support.FireFoxSelectionSupport.java
License:Apache License
@Override public SelectionEndPoint getEnd(final Selection selection) { int debugInfo = 0; try {/*www .jav a2 s. c om*/ final SelectionEndPoint end = new SelectionEndPoint(); NodeRemote nodeRemote = JavaScript.getObject(selection, Constants.FOCUS_NODE).cast(); if (nodeRemote == null) { return null; } end.setNode(LocalDom.nodeFor(nodeRemote)); end.setOffset(JavaScript.getInteger(selection, Constants.FOCUS_OFFSET)); debugInfo = 1; if (end.getNode() == null) { return null; } if (end.getNode().getNodeType() == Node.ELEMENT_NODE) { debugInfo = 2; Element parent = (Element) end.getNode().cast(); if (parent.getChildNodes().getLength() <= end.getOffset()) { return null; } debugInfo = 3; Node node = parent.getChildNodes().getItem(end.getOffset()); debugInfo = 4; if (node.getNodeType() == Node.TEXT_NODE) { debugInfo = 5; end.setTextNode((Text) node); end.setOffset(0); } else { debugInfo = 6; TextRemote textRemote = getFirstTextDepthFirstWithParent( ((Element) node).implAccess().typedRemote(), 1); Text text = LocalDom.nodeFor(textRemote); end.setTextNode(text); end.setOffset(0); } } else { debugInfo = 7; end.setTextNode((Text) end.getNode().cast()); } return end; } catch (Exception e) { SelectionSupport.selectionDebugTopic().publish(debugInfo); return null; } }
From source file:rocket.selection.client.support.FireFoxSelectionSupport.java
License:Apache License
@Override public SelectionEndPoint getStart(final Selection selection) { int debugInfo = 0; try {//from w ww. j av a2 s.c o m final SelectionEndPoint start = new SelectionEndPoint(); NodeRemote nodeRemote = JavaScript.getObject(selection, Constants.ANCHOR_NODE).cast(); if (nodeRemote == null) { return null; } debugInfo = 1; start.setNode(LocalDom.nodeFor(nodeRemote)); debugInfo = 2; start.setOffset(JavaScript.getInteger(selection, Constants.ANCHOR_OFFSET)); debugInfo = 3; if (start.getNode().getNodeType() == Node.ELEMENT_NODE) { Element parent = (Element) start.getNode().cast(); debugInfo = 4; Node node = parent.getChildNodes().getItem(start.getOffset()); debugInfo = 5; if (node.getNodeType() == Node.TEXT_NODE) { start.setTextNode((Text) node); debugInfo = 6; start.setOffset(0); } else { debugInfo = 7; TextRemote textRemote = getFirstTextDepthFirstWithParent( ((Element) node).implAccess().typedRemote(), 1); debugInfo = 8; Text text = LocalDom.nodeFor(textRemote); debugInfo = 9; start.setTextNode(text); start.setOffset(0); } } else { debugInfo = 11; start.setTextNode((Text) start.getNode().cast()); } return start; } catch (Exception e) { SelectionSupport.selectionDebugTopic().publish(debugInfo); return null; } }
From source file:rocket.selection.client.support.SelectionSupport.java
License:Apache License
public SelectionEndPoint getEnd(final Selection selection) { int debugInfo = 0; try {//w w w.j av a2 s. c o m final SelectionEndPoint end = new SelectionEndPoint(); NodeRemote nodeRemote = JavaScript.getObject(selection, Constants.FOCUS_NODE).cast(); if (nodeRemote == null) { return null; } end.setNode(LocalDom.nodeFor(nodeRemote)); end.setOffset(JavaScript.getInteger(selection, Constants.FOCUS_OFFSET)); if (end.getNode() == null) { return null; } if (end.getNode().getNodeType() == Node.ELEMENT_NODE) { Element parent = (Element) end.getNode().cast(); if (parent.getChildNodes().getLength() <= end.getOffset()) { return null; } Node node = parent.getChildNodes().getItem(end.getOffset()); if (node.getNodeType() == Node.TEXT_NODE) { end.setTextNode((Text) node); end.setOffset(0); } else { TextRemote textRemote = getFirstTextDepthFirstWithParent( ((Element) node).implAccess().ensureRemote(), 1); Text text = LocalDom.nodeFor(textRemote); end.setTextNode(text); end.setOffset(0); } } else { end.setTextNode((Text) end.getNode().cast()); } return end; } catch (Exception e) { selectionDebugTopic().publish(debugInfo); return null; } }
From source file:rocket.selection.client.support.SelectionSupport.java
License:Apache License
public SelectionEndPoint getStart(final Selection selection) { int debugInfo = 0; try {//w w w . j av a2 s . co m final SelectionEndPoint start = new SelectionEndPoint(); NodeRemote nodeRemote = JavaScript.getObject(selection, Constants.ANCHOR_NODE).cast(); if (nodeRemote == null) { return null; } debugInfo = 1; start.setNode(LocalDom.nodeFor(nodeRemote)); debugInfo = 2; start.setOffset(JavaScript.getInteger(selection, Constants.ANCHOR_OFFSET)); debugInfo = 3; if (start.getNode().getNodeType() == Node.ELEMENT_NODE) { Element parent = (Element) start.getNode().cast(); debugInfo = 4; Node node = parent.getChildNodes().getItem(start.getOffset()); if (node.getNodeType() == Node.TEXT_NODE) { start.setTextNode((Text) node); debugInfo = 5; start.setOffset(0); } else { TextRemote textRemote = getFirstTextDepthFirstWithParent( ((Element) node).implAccess().ensureRemote(), 1); debugInfo = 6; Text text = LocalDom.nodeFor(textRemote); start.setTextNode(text); debugInfo = 7; start.setOffset(0); } } else { debugInfo = 8; start.setTextNode((Text) start.getNode().cast()); debugInfo = 9; start.setOffset(JavaScript.getInteger(selection, Constants.ANCHOR_OFFSET)); } return start; } catch (Exception e) { selectionDebugTopic().publish(debugInfo); return null; } }