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.forum.app.column;
35
36 import info.magnolia.jcr.util.NodeUtil;
37 import info.magnolia.module.forum.DefaultForumManager;
38 import info.magnolia.ui.workbench.column.AbstractColumnFormatter;
39
40 import javax.jcr.Item;
41 import javax.jcr.Node;
42 import javax.jcr.Property;
43
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47 import com.vaadin.v7.ui.Table;
48
49
50
51
52 public class ValidatedColumnFormatter extends AbstractColumnFormatter<ValidatedColumnDefinition> {
53
54 private static final Logger log = LoggerFactory.getLogger(LockedColumnFormatter.class);
55
56 public ValidatedColumnFormatter(ValidatedColumnDefinition definition) {
57 super(definition);
58 }
59
60
61 @Override
62 public Object generateCell(Table source, Object itemId, Object columnId) {
63 Object cellValue = " ";
64 Node node = null;
65 try {
66 Item jcrItem = getJcrItem(source, itemId);
67 node = (Node) jcrItem;
68 if (node!=null && NodeUtil.isNodeType(node, DefaultForumManager.MESSAGE_NODETYPE)) {
69 Property property = null;
70 try {
71 property = node.getProperty(DefaultForumManager.VALIDATED_PROPERTY);
72 } catch (Exception ex) { }
73 if (property != null) {
74 if("true".equals(property.getString())){
75 cellValue = "<span class=\"icon-mark column-icon\"></span>";
76 }else{
77 cellValue = "<span class=\"icon-unmark column-icon\"></span>";
78 }
79 }
80 }
81 } catch (Exception ex) {
82 log.info("Failed to retrieve the selected node.", ex);
83 }
84 return cellValue;
85 }
86
87 }