1 package org.argeo.eclipse.ui.jcr;
2
3 import javax.jcr.Node;
4 import javax.jcr.Property;
5 import javax.jcr.RepositoryException;
6 import javax.jcr.version.Version;
7
8 import org.eclipse.jface.viewers.ColumnLabelProvider;
9 import org.eclipse.swt.graphics.Image;
10
11
12 public class VersionColumnLabelProvider extends ColumnLabelProvider {
13 private static final long serialVersionUID = -6117690082313161159L;
14
15 protected String getVersionText(Version version) throws RepositoryException {
16 return super.getText(version);
17 }
18
19 protected String getVersionToolTipText(Version version) throws RepositoryException {
20 return super.getToolTipText(version);
21 }
22
23 protected Image getVersionImage(Version version) throws RepositoryException {
24 return super.getImage(version);
25 }
26
27 protected String getUserName(Version version) throws RepositoryException {
28 Node node = version.getFrozenNode();
29 if(node.hasProperty(Property.JCR_LAST_MODIFIED_BY))
30 return node.getProperty(Property.JCR_LAST_MODIFIED_BY).getString();
31 if(node.hasProperty(Property.JCR_CREATED_BY))
32 return node.getProperty(Property.JCR_CREATED_BY).getString();
33 return null;
34 }
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 @Override
54 public String getText(Object element) {
55 try {
56 return getVersionText((Version) element);
57 } catch (RepositoryException e) {
58 throw new RuntimeException("Runtime repository exception when accessing " + element, e);
59 }
60 }
61
62 @Override
63 public Image getImage(Object element) {
64 try {
65 return getVersionImage((Version) element);
66 } catch (RepositoryException e) {
67 throw new RuntimeException("Runtime repository exception when accessing " + element, e);
68 }
69 }
70
71 @Override
72 public String getToolTipText(Object element) {
73 try {
74 return getVersionToolTipText((Version) element);
75 } catch (RepositoryException e) {
76 throw new RuntimeException("Runtime repository exception when accessing " + element, e);
77 }
78 }
79
80 }