1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.macro.container

File ContainerMacro.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
3
3
1
94
42
3
1
1
3
1

Classes

Class Line # Actions
ContainerMacro 48 3 0% 3 6
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.macro.container;
21   
22    import java.util.List;
23   
24    import javax.inject.Inject;
25    import javax.inject.Named;
26    import javax.inject.Singleton;
27   
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.rendering.block.Block;
30    import org.xwiki.rendering.macro.MacroContentParser;
31    import org.xwiki.rendering.macro.MacroExecutionException;
32    import org.xwiki.rendering.macro.container.AbstractContainerMacro;
33    import org.xwiki.rendering.macro.container.ContainerMacroParameters;
34    import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor;
35    import org.xwiki.rendering.transformation.MacroTransformationContext;
36   
37    /**
38    * Macro to hold a list groups and style them together, for example laying them out as indicated by the styleLayout
39    * parameter. For the moment this macro handles only the layouting, and only the columns layout. When it will be
40    * enhanced with other layout styles, it should be split in multiple classes, one to handle each.
41    *
42    * @version $Id: 9cc6eb638676623475448ac04221fd1038433ae5 $
43    * @since 2.5M2
44    */
45    @Component
46    @Named(ContainerMacro.MACRO_NAME)
47    @Singleton
 
48    public class ContainerMacro extends AbstractContainerMacro<ContainerMacroParameters>
49    {
50    /**
51    * The name of this macro.
52    */
53    public static final String MACRO_NAME = "container";
54   
55    /**
56    * The description of this macro.
57    */
58    private static final String DESCRIPTION = "A macro to enclose multiple groups and add decoration, such as layout.";
59   
60    /**
61    * The description of the content of this macro.
62    */
63    private static final String CONTENT_DESCRIPTION =
64    "The content to enclose in this container (wiki syntax). "
65    + "For the \"columns\" layout, a group should be added for each column.";
66   
67    /**
68    * Used to parse the macro content.
69    */
70    @Inject
71    private MacroContentParser contentParser;
72   
73    /**
74    * Creates a container macro.
75    */
 
76  0 toggle public ContainerMacro()
77    {
78  0 super("Container", DESCRIPTION, new DefaultContentDescriptor(CONTENT_DESCRIPTION, false),
79    ContainerMacroParameters.class);
80    }
81   
 
82  0 toggle @Override
83    protected List<Block> getContent(ContainerMacroParameters parameters, String content,
84    MacroTransformationContext context) throws MacroExecutionException
85    {
86  0 return this.contentParser.parse(content, context, false, false).getChildren();
87    }
88   
 
89  0 toggle @Override
90    public int getPriority()
91    {
92  0 return 750;
93    }
94    }