]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - jcr/DefaultNodeLabelProvider.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.eclipse
.ui
.jcr
;
18 import javax
.jcr
.Node
;
19 import javax
.jcr
.Property
;
20 import javax
.jcr
.RepositoryException
;
21 import javax
.jcr
.nodetype
.NodeType
;
23 import org
.argeo
.ArgeoException
;
24 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
25 import org
.eclipse
.swt
.graphics
.Image
;
27 /** Provides reasonable overridable defaults for know JCR types. */
28 public class DefaultNodeLabelProvider
extends ColumnLabelProvider
{
29 private static final long serialVersionUID
= 1216182332792151235L;
31 public String
getText(Object element
) {
33 if (element
instanceof Node
) {
34 return getText((Node
) element
);
35 } else if (element
instanceof WrappedNode
) {
36 return getText(((WrappedNode
) element
).getNode());
37 } else if (element
instanceof NodesWrapper
) {
38 return getText(((NodesWrapper
) element
).getNode());
40 return super.getText(element
);
41 } catch (RepositoryException e
) {
42 throw new ArgeoException("Cannot get text for of " + element
, e
);
46 protected String
getText(Node node
) throws RepositoryException
{
47 if (node
.isNodeType(NodeType
.MIX_TITLE
)
48 && node
.hasProperty(Property
.JCR_TITLE
))
49 return node
.getProperty(Property
.JCR_TITLE
).getString();
51 return node
.getName();
55 public Image
getImage(Object element
) {
57 if (element
instanceof Node
) {
58 return getImage((Node
) element
);
59 } else if (element
instanceof WrappedNode
) {
60 return getImage(((WrappedNode
) element
).getNode());
61 } else if (element
instanceof NodesWrapper
) {
62 return getImage(((NodesWrapper
) element
).getNode());
64 } catch (RepositoryException e
) {
65 throw new ArgeoException("Cannot retrieve image for " + element
, e
);
67 return super.getImage(element
);
70 protected Image
getImage(Node node
) throws RepositoryException
{
71 // FIXME who uses that?
76 public String
getToolTipText(Object element
) {
78 if (element
instanceof Node
) {
79 return getToolTipText((Node
) element
);
80 } else if (element
instanceof WrappedNode
) {
81 return getToolTipText(((WrappedNode
) element
).getNode());
82 } else if (element
instanceof NodesWrapper
) {
83 return getToolTipText(((NodesWrapper
) element
).getNode());
85 } catch (RepositoryException e
) {
86 throw new ArgeoException("Cannot get tooltip for " + element
, e
);
88 return super.getToolTipText(element
);
91 protected String
getToolTipText(Node node
) throws RepositoryException
{