]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - cms/ui/internal/JcrContentProvider.java
1 package org
.argeo
.cms
.ui
.internal
;
3 import java
.util
.ArrayList
;
6 import javax
.jcr
.NodeIterator
;
7 import javax
.jcr
.RepositoryException
;
9 import org
.argeo
.cms
.swt
.CmsException
;
10 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
11 import org
.eclipse
.jface
.viewers
.Viewer
;
14 class JcrContentProvider
implements ITreeContentProvider
{
15 private static final long serialVersionUID
= -1333678161322488674L;
18 public void dispose() {
22 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
25 if (!(newInput
instanceof Node
))
26 throw new CmsException("Input " + newInput
+ " must be a node");
30 public Object
[] getElements(Object inputElement
) {
32 Node node
= (Node
) inputElement
;
33 ArrayList
<Node
> arr
= new ArrayList
<Node
>();
34 NodeIterator nit
= node
.getNodes();
35 while (nit
.hasNext()) {
36 arr
.add(nit
.nextNode());
39 } catch (RepositoryException e
) {
40 throw new CmsException("Cannot get elements", e
);
45 public Object
[] getChildren(Object parentElement
) {
47 Node node
= (Node
) parentElement
;
48 ArrayList
<Node
> arr
= new ArrayList
<Node
>();
49 NodeIterator nit
= node
.getNodes();
50 while (nit
.hasNext()) {
51 arr
.add(nit
.nextNode());
54 } catch (RepositoryException e
) {
55 throw new CmsException("Cannot get elements", e
);
60 public Object
getParent(Object element
) {
62 Node node
= (Node
) element
;
63 if (node
.getName().equals(""))
66 return node
.getParent();
67 } catch (RepositoryException e
) {
68 throw new CmsException("Cannot get elements", e
);
73 public boolean hasChildren(Object element
) {
75 Node node
= (Node
) element
;
76 return node
.hasNodes();
77 } catch (RepositoryException e
) {
78 throw new CmsException("Cannot get elements", e
);