本文整理了Java中org.xwiki.rendering.block.Block
类的一些代码示例,展示了Block
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block
类的具体详情如下:
包路径:org.xwiki.rendering.block.Block
类名称:Block
[英]Represents an element of a XWiki Document's content. For example there are Blocks for Paragraphs, Bold parts, Sections, Links, etc. A block has a parent and can have children too for Blocks which are wrapper around other blocks (e.g. Paragraph blocks, List blocks, Bold blocks).
[中]表示XWiki文档内容的元素。例如,段落、粗体部分、章节、链接等都有块。一个块有一个父块,并且对于包装在其他块(例如段落块、列表块、粗体块)周围的块也可以有子块。
代码示例来源:origin: org.xwiki.platform/xwiki-platform-dashboard-macro
private boolean isMacroMarkerBlockAndEmpty(Block block)
{
return block instanceof MacroMarkerBlock && block.getChildren().isEmpty();
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
for (Block childBlock : this.childrenBlocks) {
if (blockFilter != null) {
Block clonedChildBlocks = childBlock.clone(blockFilter);
filteredBlocks = clonedChildBlocks.getChildren();
block.addChildren(filteredBlocks);
} else {
block.addChild(childBlock.clone());
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-toc
currentBlock = currentBlock.getParent().getParent();
--currentLevel;
currentBlock = currentBlock.getParent();
tocBlock = currentBlock.getRoot();
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see org.xwiki.rendering.block.Block#getChildrenByType(java.lang.Class, boolean)
*/
public <T extends Block> List<T> getChildrenByType(Class<T> blockClass, boolean recurse)
{
List<T> typedBlocks = new ArrayList<T>();
for (Block block : getChildren()) {
if (blockClass.isAssignableFrom(block.getClass())) {
typedBlocks.add(blockClass.cast(block));
}
if (recurse && !block.getChildren().isEmpty()) {
typedBlocks.addAll(block.getChildrenByType(blockClass, true));
}
}
return typedBlocks;
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-footnotes
@Override
public List<Block> execute(FootnoteMacroParameters parameters, String content, MacroTransformationContext context)
throws MacroExecutionException
{
Block root = context.getXDOM();
Block matchingBlock = root.getFirstBlock(MACRO_BLOCK_MATCHER, Block.Axes.DESCENDANT);
if (matchingBlock != null) {
return Collections.emptyList();
}
Block putFootnotesMacro =
new MacroBlock(PutFootnotesMacro.MACRO_NAME, Collections.<String, String>emptyMap(), false);
root.addChild(putFootnotesMacro);
return Collections.emptyList();
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
int sectionLevel = header.getLevel().getAsInt();
for (int level = 1; level < sectionLevel && blocks.size() == 1 && blocks.get(0) instanceof SectionBlock; ++level) {
blocks = blocks.get(0).getChildren();
section.getParent().replaceChild(blocks, section);
代码示例来源: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.platform/xwiki-platform-rendering-wikimacro-store
wikiMacroBlock.getParent().replaceChild(syncMetaDataBlock, wikiMacroBlock);
wikiMacroBlock.setParent(syncMetaDataBlock.getParent());
wikiMacroBlock.setNextSiblingBlock(syncMetaDataBlock.getNextSibling());
wikiMacroBlock.setPreviousSiblingBlock(syncMetaDataBlock.getPreviousSibling());
if (syncMetaDataBlock != null) {
syncMetaDataBlock.getParent().replaceChild(this.syncContext.getCurrentMacroBlock(),
syncMetaDataBlock);
代码示例来源: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.xwiki.platform/xwiki-platform-refactoring-api
Block firstBlock = block.getChildren().get(0);
if (firstBlock instanceof HeaderBlock) {
DocumentResourceReference reference = new DocumentResourceReference(target);
Block clonedHeaderBlock = firstBlock.clone(new BlockFilter()
return new LinkBlock(clonedHeaderBlock.getChildren(), reference, false);
} else if (firstBlock instanceof SectionBlock) {
return createLink(firstBlock, target);
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-footnotes
reference.setAnchor(FOOTNOTE_REFERENCE_ID_PREFIX + counter);
result = new LinkBlock(Collections.singletonList(result), reference, false);
result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_ID_PREFIX + counter);
result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteBackRef");
result = new ListItemBlock(Collections.singletonList(result));
result.addChild(new SpaceBlock());
result.addChildren(parsedContent);
return (ListItemBlock) result;
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-toc
parameters.rootBlock.getBlocks(new ClassBlockMatcher(HeaderBlock.class), Block.Axes.DESCENDANT);
Block block = parameters.rootBlock.getChildren().get(0);
代码示例来源:origin: org.xwiki.platform/xwiki-platform-rendering-macro-container
container.getBlocks(new ClassBlockMatcher(GroupBlock.class), Block.Axes.CHILD);
String oldClass = container.getParameter(CLASS_ATTRIBUTE);
String newClass = "container-columns container-columns-" + count;
container.setParameter(CLASS_ATTRIBUTE, StringUtils.isEmpty(oldClass) ? newClass : oldClass + " " + newClass);
container.addChild(new GroupBlock(clearFloatsParams));
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-html
htmlMacroBlock.getParent().replaceChild(htmlMacroMarker, htmlMacroBlock);
} finally {
htmlMacroMarker.getParent().replaceChild(htmlMacroBlock, htmlMacroMarker);
PrintRenderer renderer = this.xhtmlRendererFactory.createRenderer(printer);
for (Block block : htmlMacroMarker.getChildren()) {
block.traverse(renderer);
代码示例来源:origin: org.wikbook/wikbook.xwiki
header.getId()
);
header.getParent().replaceChild(nheader, header);
substitution.src.getParent().replaceChild(substitution.dst, substitution.src);
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see org.xwiki.rendering.block.Block#getPreviousBlockByType(java.lang.Class, boolean)
*/
public <T extends Block> T getPreviousBlockByType(Class<T> blockClass, boolean recurse)
{
if (getParent() == null) {
return null;
}
int index = indexOfBlock(this, getParent().getChildren());
// test previous brothers
List<Block> blocks = getParent().getChildren();
for (int i = index - 1; i >= 0; --i) {
Block previousBlock = blocks.get(i);
if (blockClass.isAssignableFrom(previousBlock.getClass())) {
return blockClass.cast(previousBlock);
}
}
// test parent
if (blockClass.isAssignableFrom(getParent().getClass())) {
return blockClass.cast(getParent());
}
// recurse
return recurse ? getParent().getPreviousBlockByType(blockClass, true) : null;
}
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-api
/**
* {@inheritDoc}
*
* @see BlockRenderer#render(java.util.Collection, org.xwiki.rendering.renderer.printer.WikiPrinter)
*/
public void render(Collection<Block> blocks, WikiPrinter printer)
{
PrintRenderer renderer = getPrintRendererFactory().createRenderer(printer);
for (Block block : blocks) {
block.traverse(renderer);
}
}
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-macro-footnotes
root.getBlocks(new ClassBlockMatcher(MacroMarkerBlock.class), Block.Axes.DESCENDANT);
for (ListIterator<MacroMarkerBlock> it = footnotes.listIterator(); it.hasNext();) {
MacroMarkerBlock macro = it.next();
continue;
} else if (PutFootnotesMacro.MACRO_NAME.equals(macro.getId())) {
macro.getParent().replaceChild(Collections.<Block>emptyList(), macro);
代码示例来源:origin: org.xwiki.platform/xwiki-core-rendering-macro-box
boxBlock.addChild(imageBlock);
boxBlock.addChild(new NewLineBlock());
boxBlock.addChildren(this.contentParser.parse(titleParameter, context.getSyntax(), true));
boxBlock.addChildren(titleBlockList);
boxBlock.addChildren(contentBlocks);
代码示例来源:origin: org.xwiki.platform/xwiki-platform-dashboard-macro
@Override
public List<Block> decorateGadget(Gadget gadget)
{
List<Block> viewBlock = super.decorateGadget(gadget);
if (viewBlock.size() > 0) {
viewBlock.get(0).addChild(getGadgetEditMetadata(gadget));
}
return viewBlock;
}
}
内容来源于网络,如有侵权,请联系作者删除!