1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.templatingcomponents.freemarker;
35
36 import freemarker.core.Environment;
37 import freemarker.template.TemplateDirectiveBody;
38 import freemarker.template.TemplateModel;
39 import freemarker.template.TemplateModelException;
40 import info.magnolia.cms.beans.config.ServerConfiguration;
41 import info.magnolia.cms.core.AggregationState;
42 import info.magnolia.cms.core.Content;
43 import info.magnolia.module.templatingcomponents.AuthoringUiComponent;
44 import info.magnolia.module.templatingcomponents.components.EditBar;
45
46 import java.io.IOException;
47 import java.util.Map;
48
49
50
51
52
53
54 public class EditBarDirective extends AbstractDirective {
55
56 @Override
57 protected AuthoringUiComponent prepareUIComponent(ServerConfiguration serverCfg, AggregationState aggState, Environment env, Map<String, TemplateModel> params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateModelException, IOException {
58 checkBody(body, false);
59 final String editButtonLabel = string(params, "editLabel", null);
60 final boolean enableMoveButton = bool(params, "move", true);
61 final boolean enableDeleteButton = bool(params, "delete", true);
62 final String specificDialogName = string(params, "dialog", null);
63 final Content target = content(params, "content", null);
64
65 return EditBar.make(serverCfg, aggState, target, specificDialogName, editButtonLabel, enableMoveButton, enableDeleteButton);
66 }
67 }