]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - ui/jcr/DefaultNodeLabelProvider.java
1 package org
.argeo
.eclipse
.ui
.jcr
;
4 import javax
.jcr
.Property
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.nodetype
.NodeType
;
8 import org
.argeo
.ArgeoException
;
9 import org
.argeo
.jcr
.ArgeoTypes
;
10 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
11 import org
.eclipse
.swt
.graphics
.Image
;
13 /** Provides reasonable overridable defaults for know JCR types. */
14 public class DefaultNodeLabelProvider
extends ColumnLabelProvider
{
16 public final static Image NODE
= JcrUiPlugin
.getImageDescriptor(
17 "icons/node.gif").createImage();
18 public final static Image FOLDER
= JcrUiPlugin
.getImageDescriptor(
19 "icons/folder.gif").createImage();
20 public final static Image FILE
= JcrUiPlugin
.getImageDescriptor(
21 "icons/file.gif").createImage();
22 public final static Image BINARY
= JcrUiPlugin
.getImageDescriptor(
23 "icons/binary.png").createImage();
24 public final static Image HOME
= JcrUiPlugin
.getImageDescriptor(
25 "icons/home.gif").createImage();
27 public String
getText(Object element
) {
29 if (element
instanceof Node
) {
30 return getText((Node
) element
);
31 } else if (element
instanceof WrappedNode
) {
32 return getText(((WrappedNode
) element
).getNode());
33 } else if (element
instanceof NodesWrapper
) {
34 return getText(((NodesWrapper
) element
).getNode());
36 return super.getText(element
);
37 } catch (RepositoryException e
) {
38 throw new ArgeoException("Cannot get text for of " + element
, e
);
42 protected String
getText(Node node
) throws RepositoryException
{
43 if (node
.isNodeType(NodeType
.MIX_TITLE
)
44 && node
.hasProperty(Property
.JCR_TITLE
))
45 return node
.getProperty(Property
.JCR_TITLE
).getString();
47 return node
.getName();
51 public Image
getImage(Object element
) {
53 if (element
instanceof Node
) {
54 return getImage((Node
) element
);
55 } else if (element
instanceof WrappedNode
) {
56 return getImage(((WrappedNode
) element
).getNode());
57 } else if (element
instanceof NodesWrapper
) {
58 return getImage(((NodesWrapper
) element
).getNode());
60 } catch (RepositoryException e
) {
61 throw new ArgeoException("Cannot retrieve image for " + element
, e
);
63 return super.getImage(element
);
66 protected Image
getImage(Node node
) throws RepositoryException
{
68 if (node
.getPrimaryNodeType().isNodeType(NodeType
.NT_FILE
))
70 else if (node
.getPrimaryNodeType().isNodeType(NodeType
.NT_FOLDER
))
72 else if (node
.getPrimaryNodeType().isNodeType(NodeType
.NT_RESOURCE
))
74 else if (node
.isNodeType(ArgeoTypes
.ARGEO_USER_HOME
))
81 public String
getToolTipText(Object element
) {
83 if (element
instanceof Node
) {
84 return getToolTipText((Node
) element
);
85 } else if (element
instanceof WrappedNode
) {
86 return getToolTipText(((WrappedNode
) element
).getNode());
87 } else if (element
instanceof NodesWrapper
) {
88 return getToolTipText(((NodesWrapper
) element
).getNode());
90 } catch (RepositoryException e
) {
91 throw new ArgeoException("Cannot get tooltip for " + element
, e
);
93 return super.getToolTipText(element
);
96 protected String
getToolTipText(Node node
) throws RepositoryException
{