List of usage examples for com.google.gwt.dom.client SpanElement setId
@Override public void setId(String id)
From source file:org.xwiki.gwt.wysiwyg.client.plugin.sync.SyncPlugin.java
License:Open Source License
private void insertCursor(Document doc) { try {//from w w w. j a v a 2 s.c om int color = id - 10 * (int) Math.floor(id / 10); // insertCursor(element, id, color); SpanElement cursorNode = doc.createSpanElement(); cursorNode.setId("cursor-" + id); cursorNode.setClassName("cursor cursor-" + color); cursorNode.setAttribute("style", "background-color: #" + color + ";"); Range range = doc.getSelection().getRangeAt(0); try { if (range != null) { if (range.getStartContainer().equals(doc) && range.getEndContainer().equals(doc) && range.getStartOffset() == 0 && range.getEndOffset() == 0) { debugMessage("Cursor at start.. let's not handle it"); } else { debugMessage("Start container: " + range.getStartContainer()); debugMessage("Start offset: " + range.getStartOffset()); debugMessage("End container: " + range.getEndContainer()); debugMessage("End offset: " + range.getEndOffset()); range.surroundContents(cursorNode); debugMessage("surrounding range ok"); } } } catch (Exception e) { try { debugMessage("error surrounding range"); debugMessage("Exception: " + e.getMessage()); e.printStackTrace(); debugMessage(e.toString()); if (range != null) { debugMessage("Start container: " + range.getStartContainer()); debugMessage("Start offset: " + range.getStartOffset()); debugMessage("End container: " + range.getEndContainer()); debugMessage("End offset: " + range.getEndOffset()); try { debugMessage("Range content: " + range.cloneContents().getInnerHTML()); } catch (Exception e3) { } } Selection selection = doc.getSelection(); if (selection != null) { debugMessage("Selection range count: " + selection.getRangeCount()); } } catch (Exception e2) { debugMessage("Exception: " + e2.getMessage()); } } } catch (Exception e) { debugMessage("Uncaught exception in insertCursor: " + e.getMessage()); } }