/** * Inserts an inline reply anchor element in the blip document. * * @param threadId id of the reply thread * @param location location at which to insert anchor */ private void createInlineReplyAnchor(final String threadId, final int location) { blip.getContent().with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { Point<N> point = doc.locate(location); doc.createElement(point, Blips.THREAD_INLINE_ANCHOR_TAGNAME, Collections.singletonMap(Blips.THREAD_INLINE_ANCHOR_ID_ATTR, threadId)); } }); }
/** * Deletes all inline reply anchor elements from the blip document. */ private void clearAllInlineReplyAnchors() { blip.getContent().with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { List<E> elementsToDelete = CollectionUtils.newArrayList(); for (E el : DocIterate.deepElements(doc, doc.getDocumentElement(), null)) { if (Blips.THREAD_INLINE_ANCHOR_TAGNAME.equals(doc.getTagName(el))) { elementsToDelete.add(el); } } // Reverse elements to delete so we always delete bottom up if one // contains another (which would be really weird anyway). Collections.reverse(elementsToDelete); for (E el : elementsToDelete) { doc.deleteNode(el); } } }); }
/** * Deletes all inline reply anchor elements for a set of threads from the blip * document. * * @param threadIds ids of the anchors to delete */ private void clearInlineReplyAnchors(final Set<String> threadIds) { blip.getContent().with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { List<E> elementsToDelete = CollectionUtils.newArrayList(); for (E el : DocIterate.deepElements(doc, doc.getDocumentElement(), null)) { if (Blips.THREAD_INLINE_ANCHOR_TAGNAME.equals(doc.getTagName(el))) { String elId = doc.getAttribute(el, Blips.THREAD_INLINE_ANCHOR_ID_ATTR); if (threadIds.contains(elId)) { elementsToDelete.add(el); } } } // Reverse elements to delete so we always delete bottom up if one // contains another (which would be really weird anyway). Collections.reverse(elementsToDelete); for (E el : elementsToDelete) { doc.deleteNode(el); } } }); }
/** * Finds all thread anchor elements in the blip document. * * @return thread ids and their anchor locations */ private Map<String, Integer> findAnchors() { final Map<String, Integer> anchors = CollectionUtils.newHashMap(); blip.getContent().with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { for (E el : DocIterate.deepElements(doc, doc.getDocumentElement(), null)) { if (Blips.THREAD_INLINE_ANCHOR_TAGNAME.equals(doc.getTagName(el))) { String threadId = doc.getAttribute(el, Blips.THREAD_INLINE_ANCHOR_ID_ATTR); if ((threadId != null) && !anchors.containsKey(threadId)) { anchors.put(threadId, doc.getLocation(el)); } } } } }); return anchors; }
WaveletBasedConversationBlip secondReplyFirstBlip = secondReply.appendBlip(); firstBlip.getContent().with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
WaveletBasedConversationBlip secondReplyFirstBlip = secondReply.appendBlip(); firstBlip.getContent().with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {