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.googlesitemap.app.subapp.sitemapdetail.contentviews.formatter; |
35 |
|
|
36 |
|
import info.magnolia.jcr.util.NodeTypes; |
37 |
|
import info.magnolia.jcr.util.NodeUtil; |
38 |
|
import info.magnolia.ui.vaadin.integration.jcr.JcrNodeAdapter; |
39 |
|
import info.magnolia.ui.workbench.column.AbstractColumnFormatter; |
40 |
|
import info.magnolia.ui.workbench.column.definition.PropertyColumnDefinition; |
41 |
|
|
42 |
|
import javax.inject.Inject; |
43 |
|
import javax.jcr.Node; |
44 |
|
import javax.jcr.RepositoryException; |
45 |
|
|
46 |
|
import org.slf4j.Logger; |
47 |
|
import org.slf4j.LoggerFactory; |
48 |
|
|
49 |
|
import com.vaadin.data.Item; |
50 |
|
import com.vaadin.ui.Table; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
56 |
|
public class FolderNameColumnFormatter extends AbstractColumnFormatter<PropertyColumnDefinition> { |
57 |
|
|
58 |
|
private Logger log = LoggerFactory.getLogger(getClass()); |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0
|
@Inject... |
61 |
|
public FolderNameColumnFormatter(PropertyColumnDefinition definition) { |
62 |
0
|
super(definition); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
65 |
0
|
@Override... |
66 |
|
public Object generateCell(Table source, Object itemId, Object columnId) { |
67 |
0
|
Item item = source.getItem(itemId); |
68 |
0
|
if (item instanceof JcrNodeAdapter) { |
69 |
0
|
JcrNodeAdapter nodeAdapter = (JcrNodeAdapter)item; |
70 |
0
|
Node node = nodeAdapter.getJcrItem(); |
71 |
0
|
try { |
72 |
0
|
if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) { |
73 |
0
|
return node.getName(); |
74 |
|
} |
75 |
|
} catch (RepositoryException e) { |
76 |
0
|
log.error("Failed to determine folder name: ", e); |
77 |
0
|
return "-"; |
78 |
|
} |
79 |
|
|
80 |
|
} |
81 |
0
|
return source.getItem(itemId).getItemProperty(columnId).getValue(); |
82 |
|
} |
83 |
|
} |