On Fri, Jun 26, 2009 at 20:52, Sergiu Dumitriu<sergiu(a)xwiki.com> wrote:
tmortagne (SVN) wrote:
Author: tmortagne
Date: 2009-06-21 12:34:49 +0200 (Sun, 21 Jun 2009)
New Revision: 21375
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/test/resources/macrotoc10.test
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SectionBlock.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocMacro.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/macro/toc/TocMacroParameters.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/test/java/org/xwiki/rendering/RenderingTests.java
Log:
XWIKI-4001: ToC macro with scope=local indents the ToC items to match the level of the
current section
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
2009-06-21 10:10:02 UTC (rev 21374)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
2009-06-21 10:34:49 UTC (rev 21375)
@@ -308,6 +308,23 @@
/**
* {@inheritDoc}
*
+ * @see org.xwiki.rendering.block.Block#getParentBlockByType(java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends Block> T getParentBlockByType(Class<T> blockClass)
+ {
+ Block parent = getParent();
+
+ if (parent == null || blockClass.isAssignableFrom(parent.getClass())) {
To get rid of the "unchecked" warning, do:
return blockClass.cast(parent);
Thanks, i did not know that.
+ return (T) parent;
+ }
+
+ return parent.getParentBlockByType(blockClass);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see EqualsBuilder#reflectionEquals(Object, Object)
*/
@Override
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java
2009-06-21 10:10:02 UTC (rev 21374)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java
2009-06-21 10:34:49 UTC (rev 21375)
@@ -148,6 +148,16 @@
Forward? Maybe upward...
+ * Look forward to find a block which
inherit or is provided type.
+ <T extends Block> T getParentBlockByType(Class<T> blockClass);
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/macro/toc/TocMacroParameters.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/macro/toc/TocMacroParameters.java
2009-06-21 10:10:02 UTC (rev 21374)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/macro/toc/TocMacroParameters.java
2009-06-21 10:34:49 UTC (rev 21375)
@@ -52,6 +52,11 @@
I'd rather call these customStart and hasCustomStart
+ private boolean startSet;
+ public boolean isStartSet()
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne