]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/VirtualFolder.java
c69e562d9e33ae9630e4a7d6676c372b871b8c4d
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / model / VirtualFolder.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
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 javax.jcr.Node;
19 import javax.jcr.NodeIterator;
20 import javax.jcr.RepositoryException;
21
22 import org.argeo.ArgeoException;
23 import org.argeo.slc.jcr.SlcNames;
24 import org.argeo.slc.jcr.SlcTypes;
25
26 /**
27 * UI Tree component. Virtual folder to list either other folders and/or a list
28 * of results. Keeps a reference to its parent that might be null if the .
29 */
30 public class VirtualFolder extends ResultParent {
31
32 private Node node = null;
33 private boolean isPassed = true;
34
35 public VirtualFolder(VirtualFolder parent, Node node, String name) {
36 super(name);
37 setParent(parent);
38 this.node = node;
39 }
40
41 @Override
42 public synchronized void dispose() {
43 super.dispose();
44 }
45
46 /** Override normal behavior to initialize display */
47 @Override
48 public synchronized Object[] getChildren() {
49 if (isLoaded()) {
50 return super.getChildren();
51 } else {
52 // initialize current object
53 try {
54 if (node != null) {
55 NodeIterator ni = node.getNodes();
56 while (ni.hasNext()) {
57 Node currNode = ni.nextNode();
58 if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT))
59 addChild(new SingleResultNode(this, node, node
60 .getProperty(SlcNames.SLC_TEST_CASE)
61 .getString()));
62 else if (currNode
63 .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
64 addChild(new VirtualFolder(this, node,
65 node.getName()));
66 }
67 }
68 return super.getChildren();
69 } catch (RepositoryException e) {
70 throw new ArgeoException(
71 "Cannot initialize WorkspaceNode UI object."
72 + getName(), e);
73 }
74 }
75 }
76
77 // @Override
78 // public boolean refreshPassedStatus() {
79 // Object[] children = getChildren();
80 // isPassed = true;
81 // checkChildrenStatus: for (int i = 0; i <= children.length; i++) {
82 // if (children[i] instanceof VirtualFolder) {
83 //
84 // }
85 // if (!((ResultParent) children[i]).isPassed()) {
86 // isPassed = false;
87 // break checkChildrenStatus;
88 // }
89 // }
90 // return isPassed;
91 // }
92
93 @Override
94 protected void initialize() {
95 // TODO Auto-generated method stub
96 }
97
98 }