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
.slc
.akb
.ui
.providers
;
18 import java
.util
.List
;
20 import javax
.jcr
.Node
;
21 import javax
.jcr
.RepositoryException
;
23 import org
.argeo
.jcr
.JcrUtils
;
24 import org
.argeo
.slc
.akb
.AkbException
;
25 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
26 import org
.eclipse
.jface
.viewers
.Viewer
;
28 /** Basic content provider for a tree of AKB environment templates */
29 public class TemplatesTreeContentProvider
implements ITreeContentProvider
{
33 * Pass current user home as parameter
36 public Object
[] getElements(Object parent
) {
37 if (parent
instanceof Object
[])
38 return (Object
[]) parent
;
43 public Object
getParent(Object child
) {
45 return ((Node
) child
).getParent();
46 } catch (RepositoryException e
) {
47 throw new AkbException("Error while getting parent node", e
);
51 public Object
[] getChildren(Object parent
) {
53 List
<Node
> nodes
= JcrUtils
.nodeIteratorToList(((Node
) parent
)
55 return nodes
.toArray();
56 } catch (RepositoryException e
) {
57 throw new AkbException("Error while getting children nodes", e
);
61 public boolean hasChildren(Object parent
) {
63 return ((Node
) parent
).hasNodes();
64 } catch (RepositoryException e
) {
65 throw new AkbException("Error while checking children nodes", e
);
69 public void dispose() {
70 // FIXME implement if needed
73 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {