]> git.argeo.org Git - gpl/argeo-slc.git/blob - VirtualFolder.java
d6b7a3b5d46b9e59a495cc82f0c84e4a40c6ec07
[gpl/argeo-slc.git] / VirtualFolder.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package org.argeo.slc.client.ui.model;
17
18 import java.util.List;
19
20 import javax.jcr.Node;
21 import javax.jcr.RepositoryException;
22
23 import org.argeo.slc.SlcException;
24 import org.argeo.slc.SlcNames;
25 import org.argeo.slc.SlcTypes;
26
27 /**
28 * UI Tree component. Virtual folder to list a list of results. Keeps a
29 * reference to its parent that might be null. It also keeps a reference to all
30 * nodes that must be displayed as children of the current virtual folder.
31 */
32 public class VirtualFolder extends ResultParent {
33 List<Node> displayedNodes;
34
35 public VirtualFolder(VirtualFolder parent, List<Node> displayedNodes,
36 String name) {
37 super(name);
38 setParent(parent);
39 this.displayedNodes = displayedNodes;
40 }
41
42 @Override
43 protected void initialize() {
44 try {
45 for (Node currNode : displayedNodes) {
46 if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
47 SingleResultNode srn = new SingleResultNode(this, currNode,
48 currNode.getProperty(SlcNames.SLC_TEST_CASE)
49 .getString());
50 addChild(srn);
51 }
52 }
53 } catch (RepositoryException re) {
54 throw new SlcException(
55 "Unexpected error while initializing ParentNodeFolder : "
56 + getName(), re);
57 }
58 }
59 }