/** * {@inheritDoc} * * @see org.xwiki.rendering.block.Block#insertChildAfter(org.xwiki.rendering.block.Block, * org.xwiki.rendering.block.Block) */ public void insertChildAfter(Block blockToInsert, Block previousBlock) { if (previousBlock == null) { insertChildBefore(blockToInsert, null); } else { // If there's a next block to previousBlock then get it to set its previous sibling Block nextBlock = previousBlock.getNextSibling(); if (nextBlock != null) { nextBlock.setPreviousSiblingBlock(blockToInsert); blockToInsert.setNextSiblingBlock(nextBlock); } else { blockToInsert.setNextSiblingBlock(null); } blockToInsert.setPreviousSiblingBlock(previousBlock); previousBlock.setNextSiblingBlock(blockToInsert); this.childrenBlocks.add(indexOfChild(previousBlock) + 1, blockToInsert); } }