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