]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/jcr/model/SingleJcrNodeElem.java
859deee974d77dcf8812f4e60726dcc6c99b56ca
1 package org
.argeo
.cms
.ui
.jcr
.model
;
4 import javax
.jcr
.NodeIterator
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.Workspace
;
8 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
9 import org
.argeo
.eclipse
.ui
.TreeParent
;
12 * UI Tree component. Wraps a node of a JCR {@link Workspace}. It also keeps a
13 * reference to its parent node that can either be a {@link WorkspaceElem}, a
14 * {@link SingleJcrNodeElem} or null if the node is "mounted" as the root of the
17 public class SingleJcrNodeElem
extends TreeParent
{
19 private final Node node
;
20 private String alias
= null;
22 /** Creates a new UiNode in the UI Tree */
23 public SingleJcrNodeElem(TreeParent parent
, Node node
, String name
) {
30 * Creates a new UiNode in the UI Tree, keeping a reference to the alias of
31 * the corresponding repository in the current UI environment. It is useful
32 * to be able to mount nodes as roots of the UI tree.
34 public SingleJcrNodeElem(TreeParent parent
, Node node
, String name
, String alias
) {
41 /** Returns the node wrapped by the current UI object */
42 public Node
getNode() {
46 protected String
getRepositoryAlias() {
51 * Overrides normal behaviour to initialise children only when first
55 public synchronized Object
[] getChildren() {
57 return super.getChildren();
59 // initialize current object
61 NodeIterator ni
= node
.getNodes();
62 while (ni
.hasNext()) {
63 Node curNode
= ni
.nextNode();
64 addChild(new SingleJcrNodeElem(this, curNode
, curNode
.getName()));
66 return super.getChildren();
67 } catch (RepositoryException re
) {
68 throw new EclipseUiException("Cannot initialize SingleJcrNode children", re
);
74 public boolean hasChildren() {
76 if (node
.getSession().isLive())
77 return node
.hasNodes();
80 } catch (RepositoryException re
) {
81 throw new EclipseUiException("Cannot check children node existence", re
);