]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ui/src/org/argeo/cms/ui/jcr/VersionLabelProvider.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
.cms
.ui
.jcr
;
18 import javax
.jcr
.Node
;
19 import javax
.jcr
.RepositoryException
;
20 import javax
.jcr
.version
.Version
;
22 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
23 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
26 * Simple wrapping of the ColumnLabelProvider class to provide text display in
27 * order to build a tree for version. The getText() method does not assume that
28 * {@link Version} extends {@link Node} class to respect JCR 2.0 specification
31 public class VersionLabelProvider
extends ColumnLabelProvider
{
32 private static final long serialVersionUID
= 5270739851193688238L;
34 public String
getText(Object element
) {
36 if (element
instanceof Version
) {
37 Version version
= (Version
) element
;
38 return version
.getName();
39 } else if (element
instanceof Node
) {
40 return ((Node
) element
).getName();
42 } catch (RepositoryException re
) {
43 throw new EclipseUiException(
44 "Unexpected error while getting element name", re
);
46 return super.getText(element
);