1 package org.argeo.documents.ui;
2
3 import javax.jcr.Node;
4 import javax.jcr.RepositoryException;
5 import javax.jcr.nodetype.NodeType;
6
7 import org.argeo.connect.ui.AppWorkbenchService;
8 import org.argeo.connect.util.ConnectUtils;
9 import org.argeo.documents.DocumentsException;
10 import org.eclipse.jface.viewers.LabelProvider;
11 import org.eclipse.swt.graphics.Image;
12
13
14
15
16
17 public class DocumentsSingleColumnLP extends LabelProvider {
18 private static final long serialVersionUID = 4514040809538981909L;
19
20 private AppWorkbenchService appWbService;
21
22 public DocumentsSingleColumnLP(AppWorkbenchService appWbService) {
23 this.appWbService = appWbService;
24 }
25
26 @Override
27 public String getText(Object element) {
28 try {
29 Node entity = (Node) element;
30 String result;
31 if (entity.isNodeType(NodeType.NT_FILE))
32 result = entity.getName();
33
34 else if (entity.isNodeType(NodeType.NT_FOLDER))
35 result = entity.getName();
36
37 else
38 result = "";
39 return ConnectUtils.replaceAmpersand(result);
40 } catch (RepositoryException re) {
41 throw new DocumentsException("Unable to get formatted value for node", re);
42 }
43 }
44
45
46 @Override
47 public Image getImage(Object element) {
48 return appWbService.getIconForType((Node) element);
49 }
50
51 }