1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.macro.message; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
|
27 |
|
import org.apache.commons.lang3.StringUtils; |
28 |
|
import org.xwiki.rendering.block.Block; |
29 |
|
import org.xwiki.rendering.macro.AbstractMacro; |
30 |
|
import org.xwiki.rendering.macro.Macro; |
31 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
32 |
|
import org.xwiki.rendering.macro.box.BoxMacroParameters; |
33 |
|
import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor; |
34 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 5 |
Complexity Density: 0.42 |
|
42 |
|
public abstract class AbstractMessageMacro extends AbstractMacro<Object> |
43 |
|
{ |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
public static final String CONTENT_MISSING_ERROR = "The required content is missing."; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@Inject |
53 |
|
@Named("box") |
54 |
|
private Macro<BoxMacroParameters> boxMacro; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
@param |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
31 |
public AbstractMessageMacro(String macroName, String macroDescription)... |
63 |
|
{ |
64 |
31 |
super(macroName, macroDescription, new DefaultContentDescriptor(true)); |
65 |
|
} |
66 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
67 |
134 |
@Override... |
68 |
|
public List<Block> execute(Object parameters, String content, MacroTransformationContext context) |
69 |
|
throws MacroExecutionException |
70 |
|
{ |
71 |
134 |
if (StringUtils.isEmpty(content)) { |
72 |
0 |
throw new MacroExecutionException(CONTENT_MISSING_ERROR); |
73 |
|
} |
74 |
|
|
75 |
134 |
BoxMacroParameters boxParameters = new BoxMacroParameters(); |
76 |
|
|
77 |
134 |
boxParameters.setCssClass(context.getCurrentMacroBlock().getId() + "message"); |
78 |
|
|
79 |
134 |
List<Block> result; |
80 |
134 |
if (!context.isInline()) { |
81 |
130 |
boxParameters.setTitle(content); |
82 |
130 |
result = this.boxMacro.execute(boxParameters, StringUtils.EMPTY, context); |
83 |
|
} else { |
84 |
4 |
result = this.boxMacro.execute(boxParameters, content, context); |
85 |
|
} |
86 |
134 |
return result; |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
4 |
@Override... |
90 |
|
public boolean supportsInlineMode() |
91 |
|
{ |
92 |
4 |
return true; |
93 |
|
} |
94 |
|
} |