Class AbstractMacro<P>

  • Type Parameters:
    P - the type of the macro parameters bean
    All Implemented Interfaces:
    Comparable<Macro<?>>, org.xwiki.component.phase.Initializable, Macro<P>
    Direct Known Subclasses:
    AbstractNoParameterMacro

    public abstract class AbstractMacro<P>
    extends Object
    implements Macro<P>, org.xwiki.component.phase.Initializable
    Helper to implement Macro, providing some default implementation. We recommend Macro writers to extend this class.
    Since:
    1.5M2
    Version:
    $Id: f033175abc3f9c205ec22241a760271b7e88dc64 $
    • Field Detail

      • DEFAULT_CATEGORY_FORMATTING

        public static final String DEFAULT_CATEGORY_FORMATTING
        "Formatting" default macro category.
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_DEVELOPMENT

        public static final String DEFAULT_CATEGORY_DEVELOPMENT
        "Development" default macro category.
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_CONTENT

        public static final String DEFAULT_CATEGORY_CONTENT
        "Content" default macro category.
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_NAVIGATION

        public static final String DEFAULT_CATEGORY_NAVIGATION
        "Navigation" default macro category.
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_INTERNAL

        public static final String DEFAULT_CATEGORY_INTERNAL
        "Internal" default macro category.
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_DEPRECATED

        @Unstable
        public static final String DEFAULT_CATEGORY_DEPRECATED
        "Deprecated" default macro category.
        Since:
        14.8RC1
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_LAYOUT

        public static final String DEFAULT_CATEGORY_LAYOUT
        "Layout" default macro category.
        See Also:
        Constant Field Values
      • beanManager

        @Inject
        protected org.xwiki.properties.BeanManager beanManager
        The BeanManager component.
    • Constructor Detail

      • AbstractMacro

        public AbstractMacro​(String name)
        Creates a new Macro instance.
        Parameters:
        name - the name of the macro (eg "Table Of Contents" for the TOC macro)
        Since:
        2.0M3
      • AbstractMacro

        public AbstractMacro​(String name,
                             String description)
        Creates a new Macro instance.
        Parameters:
        name - the name of the macro (eg "Table Of Contents" for the TOC macro)
        description - a string describing this macro.
        Since:
        2.0M3
      • AbstractMacro

        public AbstractMacro​(String name,
                             String description,
                             ContentDescriptor contentDescriptor)
        Creates a new Macro instance.
        Parameters:
        name - the name of the macro (eg "Table Of Contents" for the TOC macro)
        description - a string describing this macro.
        contentDescriptor - ContentDescriptor for this macro.
        Since:
        2.0M3
      • AbstractMacro

        public AbstractMacro​(String name,
                             String description,
                             Class<?> parametersBeanClass)
        Creates a new Macro instance.
        Parameters:
        name - the name of the macro (eg "Table Of Contents" for the TOC macro)
        description - a string describing this macro.
        parametersBeanClass - class of the parameters bean of this macro.
        Since:
        2.0M3
      • AbstractMacro

        public AbstractMacro​(String name,
                             String description,
                             ContentDescriptor contentDescriptor,
                             Class<?> parametersBeanClass)
        Creates a new Macro instance.
        Parameters:
        name - the name of the macro (eg "Table Of Contents" for the TOC macro)
        description - string describing this macro.
        contentDescriptor - the ContentDescriptor describing the content of this macro.
        parametersBeanClass - class of the parameters bean.
        Since:
        2.0M3
    • Method Detail

      • initialize

        public void initialize()
                        throws org.xwiki.component.phase.InitializationException
        Specified by:
        initialize in interface org.xwiki.component.phase.Initializable
        Throws:
        org.xwiki.component.phase.InitializationException
      • getPriority

        public int getPriority()
        Description copied from interface: Macro
        The priority of execution relative to the other Macros. The lowest values have the highest priorities and execute first. For example a Macro with a priority of 100 will execute before one with a priority of 500.
        Specified by:
        getPriority in interface Macro<P>
        Returns:
        the execution priority
      • setPriority

        public void setPriority​(int priority)
        Parameters:
        priority - the macro priority to use (lower means execute before others)
      • setDescriptor

        protected void setDescriptor​(MacroDescriptor descriptor)
        Allows macro classes extending other macro classes to override the macro descriptor with their own.
        Parameters:
        descriptor - the overriding descriptor to set
      • setDefaultCategories

        @Unstable
        protected void setDefaultCategories​(Set<String> defaultCategories)
        Allows sub-classes to set default macro categories. This method only has an effect of the internal MacroDescriptor is of type AbstractMacroDescriptor.
        Parameters:
        defaultCategories - the default macro categories to set
        Since:
        14.6RC1
      • getNonGeneratedContentMetaData

        public static MetaData getNonGeneratedContentMetaData​(ContentDescriptor contentDescriptor)
        Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation). This content can be used for inline editing.
        Parameters:
        contentDescriptor - the ContentDescriptor from which to get the type for the metadata.
        Returns:
        the new metadata with the content type for the content represented as a string (e.g. java.util.List<org.xwiki.rendering.block.Block> for content of type List<Block>
        Since:
        11.4RC1
      • getNonGeneratedContentMetaData

        protected MetaData getNonGeneratedContentMetaData()
        Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation). This content can be used for inline editing.
        Returns:
        the new metadata with the content type for the content represented as a string (e.g. java.util.List<org.xwiki.rendering.block.Block> for content of type List<Block>
        Since:
        10.10
      • getNonGeneratedContentMetaData

        public static MetaData getNonGeneratedContentMetaData​(Map<String,​ParameterDescriptor> parameterDescriptorMap,
                                                              String name)
        Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation) for a specific parameter. This content can be used for inline editing.
        Parameters:
        parameterDescriptorMap - the descriptor map of the parameters
        name - the name of the parameter for which to get the metadata
        Returns:
        the new metadata with the content type for the content represented as a string (e.g. java.util.List<org.xwiki.rendering.block.Block> for content of type List<Block>
        Since:
        11.4RC1
      • getNonGeneratedContentMetaData

        protected MetaData getNonGeneratedContentMetaData​(String parameterName)
        Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation) for a specific parameter. This content can be used for inline editing.
        Parameters:
        parameterName - the name of the parameter as defined in the macro
        Returns:
        the new metadata with the content type for the content represented as a string (e.g. java.util.List<org.xwiki.rendering.block.Block> for content of type List<Block>
        Since:
        11.1RC1