Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * See the NOTICE file distributed with this work for additional
   * information regarding copyright ownership.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.xwiki.rendering.macro.box;
 
 import java.util.List;
 import java.util.Map;
 
 
Draw a box around provided content.

Parameters:
<P> the type of macro parameters bean.
Version:
$Id: c1fcf6b776bd34880a3758e72a643e7b4eb89448 $
Since:
1.7
 
 public abstract class AbstractBoxMacro<P extends BoxMacroParametersextends AbstractMacro<P>
 {
    
Parses untyped image references.
 
     @Inject
     @Named("image/untyped")
The parser used to parse box content and box title parameter.
 
     @Inject
     private MacroContentParser contentParser;

    
Creates a new box macro.

Parameters:
name the name of the macro
description string describing this macro.
contentDescriptor the org.xwiki.rendering.macro.descriptor.ContentDescriptor describing the content of this macro.
parametersBeanClass class of the parameters bean.
 
     protected AbstractBoxMacro(String nameString descriptionContentDescriptor contentDescriptor,
         Class<?> parametersBeanClass)
     {
         super(namedescriptioncontentDescriptorparametersBeanClass);
     }
 
     @Override
     public boolean supportsInlineMode()
     {
         return true;
     }
 
     @Override
     public List<Blockexecute(P parametersString contentMacroTransformationContext context)
         throws MacroExecutionException
     {
         // TODO: Refactor this when it'll possible to have a specific converter associated to a macro parameter.
         ResourceReference imageReference = parameters.getImage();
         // If the image reference is unknown then resolve it with the untyped resource reference parser
         // (this happens when the user doesn't specify a type for the image reference).
         if (imageReference != null && imageReference.getType().equals(.)) {
             imageReference = this..parse(imageReference.getReference());
         }
 
        String titleParameter = parameters.getTitle();
        List<? extends BlocktitleBlockList = parameters.getBlockTitle();
        // Use a linked hashmap to keep the parameters in the same order as we create them when they are retrieved
        // by renderers. This is useful for example in the Event renderer to control the order in which the params
        // are displayed.
        Map<StringStringboxParameters = new LinkedHashMap<StringString>();
        String classParameter = parameters.getCssClass();
        String cssClass =
            StringUtils.isEmpty(classParameter) ? getClassProperty() : getClassProperty() + " " + classParameter;
        boxParameters.put("class"cssClass);
        if (!StringUtils.isEmpty(parameters.getWidth())) {
            boxParameters.put("style""width:" + parameters.getWidth());
        }
        Block boxBlock;
        if (content != null) {
            if (context.isInline()) {
                List<BlockcontentBlocks = parseContent(parameterscontentcontext);
                FormatBlock spanBlock = new FormatBlock(contentBlocks.);
                spanBlock.setParameters(boxParameters);
                boxBlock = spanBlock;
            } else {
                boxBlock = new GroupBlock(boxParameters);
                // we add the image, if there is one
                if (imageReference != null) {
                    Block imageBlock = new ImageBlock(imageReferencetrue);
                    boxBlock.addChild(imageBlock);
                    boxBlock.addChild(new NewLineBlock());
                }
                // we add the title, if there is one
                if (!StringUtils.isEmpty(titleParameter)) {
                    // Don't execute transformations explicitly. They'll be executed on the generated content later on.
                    boxBlock.addChildren(this..parse(titleParametercontextfalsetrue).getChildren());
                }
                if (titleBlockList != null) {
                    boxBlock.addChildren(titleBlockList);
                }
                List<BlockcontentBlocks = parseContent(parameterscontentcontext);
                boxBlock.addChildren(contentBlocks);
            }
            return Collections.singletonList(boxBlock);
        } else {
            return Collections.emptyList();
        }
    }

    
Execute macro content and return the result. This methods is separated form execute(org.xwiki.rendering.macro.box.BoxMacroParameters,java.lang.String,org.xwiki.rendering.transformation.MacroTransformationContext) to be able to overwrite it in macro which need boxes.

Parameters:
parameters the parameters of the macro.
content the content of the macro.
context the context if the macros transformation.
Returns:
the result of the macro execution.
Throws:
org.xwiki.rendering.macro.MacroExecutionException error when executing the macro.
    protected abstract List<BlockparseContent(P parametersString contentMacroTransformationContext context)
        throws MacroExecutionException;

    

Returns:
the name of the CSS class to use when rendering, in case no cssClass parameter is specified.
    protected String getClassProperty()
    {
        return "box";
    }

    

Returns:
the macro content parser to use to parse content in wiki syntax
    {
        return this.;
    }
New to GrepCode? Check out our FAQ X