X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.jcr.ui.explorer%2Fsrc%2Forg%2Fargeo%2Fjcr%2Fui%2Fexplorer%2Fmodel%2FSingleJcrNodeElem.java;fp=org.argeo.jcr.ui.explorer%2Fsrc%2Forg%2Fargeo%2Fjcr%2Fui%2Fexplorer%2Fmodel%2FSingleJcrNodeElem.java;h=0000000000000000000000000000000000000000;hb=21a4ea1fb5380ce1dd763c1ea09067cdd2dfd0f3;hp=7b588f83b23eb22f768c56f4467da8567c38d5e4;hpb=d9c415444754b60b586ee0145d7a382ed132178d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.jcr.ui.explorer/src/org/argeo/jcr/ui/explorer/model/SingleJcrNodeElem.java b/org.argeo.jcr.ui.explorer/src/org/argeo/jcr/ui/explorer/model/SingleJcrNodeElem.java deleted file mode 100644 index 7b588f83b..000000000 --- a/org.argeo.jcr.ui.explorer/src/org/argeo/jcr/ui/explorer/model/SingleJcrNodeElem.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2007-2012 Argeo GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.jcr.ui.explorer.model; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.RepositoryException; -import javax.jcr.Workspace; - -import org.argeo.ArgeoException; -import org.argeo.eclipse.ui.TreeParent; - -/** - * UI Tree component. Wraps a node of a JCR {@link Workspace}. It also keeps a - * reference to its parent node that can either be a {@link WorkspaceElem}, a - * {@link SingleJcrNodeElem} or null if the node is "mounted" as the root of the UI - * tree. - */ - -public class SingleJcrNodeElem extends TreeParent { - - private final Node node; - private String alias = null; - - // keeps a local reference to the node's name to avoid exception when the - // session is lost - // private final String name; - - /** Creates a new UiNode in the UI Tree */ - public SingleJcrNodeElem(TreeParent parent, Node node, String name) { - super(name); - setParent(parent); - this.node = node; - } - - /** - * Creates a new UiNode in the UI Tree, keeping a reference to the alias of - * the corresponding repository in the current UI environment. It is useful - * to be able to mount nodes as roots of the UI tree. - */ - public SingleJcrNodeElem(TreeParent parent, Node node, String name, String alias) { - super(name); - setParent(parent); - this.node = node; - this.alias = alias; - } - - /** returns the node wrapped by the current Ui object */ - public Node getNode() { - return node; - } - - protected String getRepositoryAlias() { - return alias; - } - - /** - * Override normal behavior to initialize children only when first requested - */ - @Override - public synchronized Object[] getChildren() { - if (isLoaded()) { - return super.getChildren(); - } else { - // initialize current object - try { - NodeIterator ni = node.getNodes(); - while (ni.hasNext()) { - Node curNode = ni.nextNode(); - addChild(new SingleJcrNodeElem(this, curNode, curNode.getName())); - } - return super.getChildren(); - } catch (RepositoryException re) { - throw new ArgeoException( - "Unexcpected error while initializing children SingleJcrNode", - re); - } - } - } - - @Override - public boolean hasChildren() { - try { - if (node.getSession().isLive()) - return node.hasNodes(); - else - return false; - } catch (RepositoryException re) { - throw new ArgeoException( - "Unexpected error while checking children node existence", - re); - } - } - -}