]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ui/src/org/argeo/cms/ui/jcr/model/SingleJcrNodeElem.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
.model
;
18 import javax
.jcr
.Node
;
19 import javax
.jcr
.NodeIterator
;
20 import javax
.jcr
.RepositoryException
;
21 import javax
.jcr
.Workspace
;
23 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
24 import org
.argeo
.eclipse
.ui
.TreeParent
;
27 * UI Tree component. Wraps a node of a JCR {@link Workspace}. It also keeps a
28 * reference to its parent node that can either be a {@link WorkspaceElem}, a
29 * {@link SingleJcrNodeElem} or null if the node is "mounted" as the root of the
32 public class SingleJcrNodeElem
extends TreeParent
{
34 private final Node node
;
35 private String alias
= null;
37 /** Creates a new UiNode in the UI Tree */
38 public SingleJcrNodeElem(TreeParent parent
, Node node
, String name
) {
45 * Creates a new UiNode in the UI Tree, keeping a reference to the alias of
46 * the corresponding repository in the current UI environment. It is useful
47 * to be able to mount nodes as roots of the UI tree.
49 public SingleJcrNodeElem(TreeParent parent
, Node node
, String name
, String alias
) {
56 /** Returns the node wrapped by the current UI object */
57 public Node
getNode() {
61 protected String
getRepositoryAlias() {
66 * Overrides normal behaviour to initialise children only when first
70 public synchronized Object
[] getChildren() {
72 return super.getChildren();
74 // initialize current object
76 NodeIterator ni
= node
.getNodes();
77 while (ni
.hasNext()) {
78 Node curNode
= ni
.nextNode();
79 addChild(new SingleJcrNodeElem(this, curNode
, curNode
.getName()));
81 return super.getChildren();
82 } catch (RepositoryException re
) {
83 throw new EclipseUiException("Cannot initialize SingleJcrNode children", re
);
89 public boolean hasChildren() {
91 if (node
.getSession().isLive())
92 return node
.hasNodes();
95 } catch (RepositoryException re
) {
96 throw new EclipseUiException("Cannot check children node existence", re
);