com.atlassian.renderer.v2.macro
Class BaseMacro

java.lang.Object
  extended by com.atlassian.renderer.v2.macro.BaseMacro
All Implemented Interfaces:
Macro
Direct Known Subclasses:
AbstractPanelMacro, BasicAnchorMacro, ColorMacro, InlineHtmlMacro, LoremIpsumMacro, QuoteMacro, RadeoxCompatibilityMacro

public abstract class BaseMacro
extends java.lang.Object
implements Macro

Abstract implementation of Macro which should be extended by all plugin macros. New methods added to the Macro interface have default implementation added to this class, so Macros that extend BaseMacro are to some extend future-proofed to API changes.


Field Summary
 
Fields inherited from interface com.atlassian.renderer.v2.macro.Macro
RAW_PARAMS_KEY
 
Constructor Summary
BaseMacro()
           
 
Method Summary
 TokenType getTokenType(java.util.Map parameters, java.lang.String body, RenderContext context)
          Declares what sort of html elements are returned by the macro.
 WysiwygBodyType getWysiwygBodyType()
          Defines how the Macro's body should be rendered for Wysiwyg editors.
 boolean isInline()
          Deprecated. override getTokenType(java.util.Map, java.lang.String, com.atlassian.renderer.RenderContext) to indicate inline or strict block behaviour. However, for macros to be backwardly compatible they will still need to implement isInline() too.
 boolean suppressMacroRenderingDuringWysiwyg()
          Suppress the rendering of the macro -- the macro's body may still be rendered (depending on the render mode of the macro), but the HTML the macro adds will not be created.
 boolean suppressSurroundingTagDuringWysiwygRendering()
          Suppress surrounding div/span during Wysiwyg rendering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.renderer.v2.macro.Macro
execute, getBodyRenderMode, hasBody
 

Constructor Detail

BaseMacro

public BaseMacro()
Method Detail

getTokenType

public TokenType getTokenType(java.util.Map parameters,
                              java.lang.String body,
                              RenderContext context)
Declares what sort of html elements are returned by the macro. TokenType.INLINE elements will have paragraphs drawn around them, or be incorporated into paragraphs they are included in. TokenType.BLOCK elements will be treated as their own paragraph, splitting any paragraphs they would otherwise be in. TokenType.INLINE_BLOCK elements will not have paragraphs drawn around them, but they won't split any paragraphs they appear in either.

Macros that contain elements that shouldn't appear in a paragraph, such as pre, should return TokenType.BLOCK. If it produces a span, replacement text or text decoration, return TokenType.INLINE. If it affects logic of whether its children are displayed but doesn't add its own content, or you aren't sure what to return, return TokenType.INLINE_BLOCK.

The default implementation tries to maintain backward compatibility with most macros. It returns TokenType.INLINE for macros that return true from isInline() and TokenType.INLINE_BLOCK for macros that return false.

Specified by:
getTokenType in interface Macro
Parameters:
parameters - ignored
body - ignored
context - ignored
Returns:
the TokenType that matches the content produced by this macro

isInline

public boolean isInline()
Deprecated. override getTokenType(java.util.Map, java.lang.String, com.atlassian.renderer.RenderContext) to indicate inline or strict block behaviour. However, for macros to be backwardly compatible they will still need to implement isInline() too.

Determine if the macro is an "inline" element in the resulting HTML. Inline elements will have paragraphs drawn around them, or be incorporated into paragraphs they are included in. As a rule of thumb, if your macro produces a paragraph, table or div (or so on), you should return false. If it produces a span, replacement text or text decoration, return true.

Most macros will want to return false here.

The default implementation now returns false, which has been a defacto default previously.

Specified by:
isInline in interface Macro
Returns:
false

suppressSurroundingTagDuringWysiwygRendering

public boolean suppressSurroundingTagDuringWysiwygRendering()
Description copied from interface: Macro
Suppress surrounding div/span during Wysiwyg rendering. This should return true if the macro provides it's own Wysiwyg processing HTML.

Specified by:
suppressSurroundingTagDuringWysiwygRendering in interface Macro

suppressMacroRenderingDuringWysiwyg

public boolean suppressMacroRenderingDuringWysiwyg()
Description copied from interface: Macro
Suppress the rendering of the macro -- the macro's body may still be rendered (depending on the render mode of the macro), but the HTML the macro adds will not be created.

Specified by:
suppressMacroRenderingDuringWysiwyg in interface Macro
Returns:

getWysiwygBodyType

public WysiwygBodyType getWysiwygBodyType()
Defines how the Macro's body should be rendered for Wysiwyg editors. This method is only relevant for macros that return false from Macro.suppressSurroundingTagDuringWysiwygRendering(), true from Macro.suppressMacroRenderingDuringWysiwyg() and true from Macro.hasBody().

The default implementation returns WysiwygBodyType.WIKI_MARKUP for most macros, but WysiwygBodyType.PREFORMAT for macros that have a Macro.getBodyRenderMode() of RenderMode.NO_RENDER.

Specified by:
getWysiwygBodyType in interface Macro
Returns:
WysiwygBodyType.WIKI_MARKUP or WysiwygBodyType.PREFORMAT


Copyright © 2012 Atlassian. All Rights Reserved.