本文整理了Java中org.xwiki.rendering.block.Block.replaceChild()
方法的一些代码示例,展示了Block.replaceChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.replaceChild()
方法的具体详情如下:
包路径:org.xwiki.rendering.block.Block
类名称:Block
方法名:replaceChild
[英]Replaces an existing children block with the passed new blocks. Also sets the new block's parents to be the current block.
[中]用传递的新块替换现有子块。还将新块的父对象设置为当前块。
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-transformation-macro
private void generateError(MacroBlock macroToReplace, String message, String description)
{
List<Block> errorBlocks = new ArrayList<Block>();
Map<String, String> errorBlockParams = Collections.singletonMap("class", "xwikirenderingerror");
Map<String, String> errorDescriptionBlockParams =
Collections.singletonMap("class", "xwikirenderingerrordescription hidden");
Block descriptionBlock = new VerbatimBlock(description, macroToReplace.isInline());
if (macroToReplace.isInline()) {
errorBlocks.add(new FormatBlock(Arrays.<Block> asList(new WordBlock(message)), Format.NONE,
errorBlockParams));
errorBlocks.add(new FormatBlock(Arrays.asList(descriptionBlock), Format.NONE, errorDescriptionBlockParams));
} else {
errorBlocks.add(new GroupBlock(Arrays.<Block> asList(new WordBlock(message)), errorBlockParams));
errorBlocks.add(new GroupBlock(Arrays.asList(descriptionBlock), errorDescriptionBlockParams));
}
macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace);
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-footnotes
continue;
} else if (PutFootnotesMacro.MACRO_NAME.equals(macro.getId())) {
macro.getParent().replaceChild(Collections.<Block>emptyList(), macro);
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-macro
/**
* Generates Blocks to signify that the passed Macro Block has failed to execute.
*
* @param macroToReplace the block for the macro that failed to execute and that we'll replace with Block
* showing to the user that macro has failed
* @param message the message to display to the user in place of the macro result
* @param description the long description of the error to display to the user in place of the macro result
*/
public void generateError(MacroBlock macroToReplace, String message, String description)
{
List<Block> errorBlocks =
this.errorBlockGenerator.generateErrorBlocks(message, description, macroToReplace.isInline());
macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace);
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-macro
/**
* Generates Blocks to signify that the passed Macro Block has failed to execute.
*
* @param macroToReplace the block for the macro that failed to execute and that we'll replace with Block
* showing to the user that macro has failed
* @param message the message to display to the user in place of the macro result
* @param throwable the exception for the failed macro execution to display to the user in place of the macro result
*/
public void generateError(MacroBlock macroToReplace, String message, Throwable throwable)
{
List<Block> errorBlocks =
this.errorBlockGenerator.generateErrorBlocks(message, throwable, macroToReplace.isInline());
macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace);
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-wikiword
@Override
public void transform(Block block, TransformationContext transformationContext) throws TransformationException
{
// Find all Word blocks and for each of them check if they're a wiki word or not
for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) {
Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord());
if (matcher.matches()) {
ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord());
wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false),
wordBlock);
}
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-transformation-wikiword
/**
* {@inheritDoc}
* @see AbstractTransformation#transform(Block, TransformationContext)
*/
public void transform(Block block, TransformationContext transformationContext) throws TransformationException
{
// Find all Word blocks and for each of them check if they're a wiki word or not
for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) {
Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord());
if (matcher.matches()) {
ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord());
wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false),
wordBlock);
}
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-office-viewer
imgBlock.getParent().replaceChild(Arrays.asList(newImgBlock), imgBlock);
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
section.getParent().replaceChild(blocks, section);
代码示例来源:origin: org.xwiki.platform/xwiki-platform-office-viewer
private void maybeFixExpandedMacroAncestor(Block block)
{
ExpandedMacroBlock expandedMacro =
block.getFirstBlock(new ClassBlockMatcher(ExpandedMacroBlock.class), Block.Axes.ANCESTOR_OR_SELF);
if (expandedMacro != null) {
Block parent = expandedMacro.getParent();
if (!(parent instanceof MetaDataBlock) || !((MetaDataBlock) parent).getMetaData().contains(MODULE_NAME)) {
MetaDataBlock metaData = new MetaDataBlock(Collections.<Block>emptyList());
// Use a syntax that supports relative path resource references (we use relative paths to include the
// temporary files).
metaData.getMetaData().addMetaData(MetaData.SYNTAX, Syntax.XWIKI_2_1);
metaData.getMetaData().addMetaData(MODULE_NAME, true);
parent.replaceChild(metaData, expandedMacro);
metaData.addChild(expandedMacro);
}
}
}
代码示例来源:origin: org.wikbook/wikbook.xwiki
header.getId()
);
header.getParent().replaceChild(nheader, header);
substitution.src.getParent().replaceChild(substitution.dst, substitution.src);
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-html
htmlMacroBlock.getParent().replaceChild(htmlMacroMarker, htmlMacroBlock);
} finally {
htmlMacroMarker.getParent().replaceChild(htmlMacroBlock, htmlMacroMarker);
代码示例来源:origin: org.xwiki.platform/xwiki-platform-rendering-wikimacro-store
wikiMacroBlock.getParent().replaceChild(syncMetaDataBlock, wikiMacroBlock);
if (syncMetaDataBlock != null) {
syncMetaDataBlock.getParent().replaceChild(this.syncContext.getCurrentMacroBlock(),
syncMetaDataBlock);
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-transformation-macro
macroHolder.macroBlock.getParent().replaceChild(resultBlock, macroHolder.macroBlock);
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-transformation-macro
macroBlock.getParent().replaceChild(resultBlock, macroBlock);
内容来源于网络,如有侵权,请联系作者删除!