1 package org
.argeo
.slc
.client
.contentprovider
;
3 import java
.util
.SortedMap
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
8 import org
.argeo
.slc
.core
.test
.tree
.PartSubList
;
9 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
10 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
11 import org
.eclipse
.jface
.viewers
.Viewer
;
14 * Basic tree view of the chosen process details
16 public class ResultDetailContentProvider
implements ITreeContentProvider
{
17 private final static Log log
= LogFactory
18 .getLog(ResultDetailContentProvider
.class);
20 private TreeTestResult treeTestResult
;
22 public Object
[] getChildren(Object parent
) {
23 if (parent
instanceof TreeTestResult
) {
24 treeTestResult
= (TreeTestResult
) parent
;
26 SortedMap
<TreeSPath
, PartSubList
> parts
= treeTestResult
29 for (TreeSPath key
: parts
.keySet()) {
30 log
.debug("Test[" + key
.toString() + "] isPassed = "
31 + parts
.get(key
).getIsPassed());
34 return parts
.keySet().toArray();
36 // if (parent instanceof ExecutionModuleNode) {
37 // ExecutionModuleNode executionModuleNode = (ExecutionModuleNode)
39 // ExecutionModuleDescriptor emd =
40 // executionModuleNode.getDescriptor();
41 // emd = executionModuleNode.getAgentNode().getAgent()
42 // .getExecutionModuleDescriptor(emd.getName(),
44 // executionModuleNode.cacheDescriptor(emd);
45 // // for (String flowName :
46 // executionModuleNode.getFlowDescriptors()
48 // // executionModuleNode.addChild(new FlowNode(flowName,
49 // // executionModuleNode));
51 // return executionModuleNode.getChildren();
52 // } else if (parent instanceof AgentNode) {
53 // AgentNode agentNode = (AgentNode) parent;
55 // if (log.isTraceEnabled())
56 // log.trace("Scan agent " + agentNode);
58 // agentNode.clearChildren();
59 // for (ExecutionModuleDescriptor desc : agentNode.getAgent()
60 // .listExecutionModuleDescriptors()) {
61 // agentNode.addChild(new ExecutionModuleNode(agentNode, desc));
64 // return agentNode.getChildren();
65 // } else if (parent instanceof TreeParent) {
66 // return ((TreeParent) parent).getChildren();
67 // } else if (parent instanceof FlowNode) {
68 // return new Object[0];
70 // List<AgentNode> agentNodes = new ArrayList<AgentNode>();
71 // for (SlcAgent slcAgent : slcAgents) {
72 // agentNodes.add(new AgentNode(slcAgent));
74 // return agentNodes.toArray();
79 public Object
getParent(Object node
) {
80 // if (node instanceof TreeObject) {
81 // return ((TreeObject) node).getParent();
86 public boolean hasChildren(Object parent
) {
87 // if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded())
89 // return ((TreeParent) parent).hasChildren();
90 // } else if (parent instanceof AgentNode) {
92 // } else if (parent instanceof ExecutionModuleNode) {
98 public void inputChanged(Viewer v
, Object oldInput
, Object newInput
) {
101 public void dispose() {
104 public Object
[] getElements(Object parent
) {
105 if (parent
instanceof TreeTestResult
) {
106 treeTestResult
= (TreeTestResult
) parent
;
108 SortedMap
<TreeSPath
, PartSubList
> parts
= treeTestResult
111 for (TreeSPath key
: parts
.keySet()) {
112 log
.debug("Test[" + key
.toString() + "] isPassed = "
113 + parts
.get(key
).getIsPassed());
116 return parts
.keySet().toArray();
118 // return getChildren(parent);
122 // public class AgentNode extends TreeParent {
123 // private final SlcAgent agent;
125 // public AgentNode(SlcAgent agent) {
126 // super(agent.toString());
127 // this.agent = agent;
130 // public SlcAgent getAgent() {
135 // public class ExecutionModuleNode extends TreeParent {
136 // private final AgentNode agentNode;
137 // private ExecutionModuleDescriptor descriptor;
138 // private Map<String, ExecutionFlowDescriptor> flowDescriptors;
140 // public ExecutionModuleNode(AgentNode agentNode,
141 // ExecutionModuleDescriptor descriptor) {
142 // super(descriptor.toString());
143 // this.agentNode = agentNode;
144 // this.descriptor = descriptor;
148 // public AgentNode getAgentNode() {
152 // public ExecutionModuleDescriptor getDescriptor() {
153 // return descriptor;
155 // Object o = thisJoinPoint.getArgs()[0];
157 // public void cacheDescriptor(ExecutionModuleDescriptor descriptor) {
158 // this.descriptor = descriptor;
160 // SortedMap<String, FolderNode> folderNodes = new TreeMap<String,
163 // flowDescriptors = new HashMap<String, ExecutionFlowDescriptor>();
164 // for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) {
165 // // if (log.isTraceEnabled())
166 // // log.trace("fd.path=" + fd.getPath() + ", fd.name="
167 // // + fd.getName());
169 // // find path and label
172 // int lastSlash = fd.getName().lastIndexOf('/');
173 // if ((fd.getPath() == null || fd.getPath().trim().equals(""))
174 // && lastSlash >= 0) {
175 // path = fd.getName().substring(0, lastSlash);
176 // label = fd.getName().substring(lastSlash + 1);
178 // path = fd.getPath();
179 // label = fd.getName();
181 // // if (log.isTraceEnabled())
182 // // log.trace("path=" + path + ", label=" + label);
184 // if (path == null || path.trim().equals("")
185 // || path.trim().equals("/")) {
186 // // directChildren.put(name, new FlowNode(name, this));
187 // addChild(new FlowNode(label, fd.getName(), this));
189 // FolderNode folderNode = mkdirs(this, path, folderNodes);
191 // .addChild(new FlowNode(label, fd.getName(), this));
194 // flowDescriptors.put(fd.getName(), fd);
196 // // TODO: make it readonly
199 // protected FolderNode mkdirs(TreeParent root, String path,
200 // SortedMap<String, FolderNode> folderNodes) {
202 // if (path.charAt(0) != '/')
203 // path = '/' + path;
204 // if (path.charAt(path.length() - 1) == '/')
205 // path = path.substring(0, path.length() - 1);
207 // if (folderNodes.containsKey(path))
208 // return folderNodes.get(path);
210 // int lastIndx = path.lastIndexOf('/');
211 // String folderName;
212 // String parentPath;
213 // if (lastIndx >= 0) {
214 // folderName = path.substring(lastIndx + 1);
215 // parentPath = path.substring(0, lastIndx);
217 // folderName = path;
221 // TreeParent parent;
222 // if (parentPath.equals(""))
225 // parent = mkdirs(root, parentPath, folderNodes);
226 // FolderNode newFolder = new FolderNode(folderName);
227 // parent.addChild(newFolder);
228 // folderNodes.put(path, newFolder);
232 // public Map<String, ExecutionFlowDescriptor> getFlowDescriptors() {
233 // return flowDescriptors;
238 // public class FlowNode extends TreeObject {
239 // private final String flowName;
240 // private final ExecutionModuleNode executionModuleNode;
242 // public FlowNode(String label, String flowName,
243 // ExecutionModuleNode executionModuleNode) {
245 // this.flowName = flowName;
246 // this.executionModuleNode = executionModuleNode;
249 // public String getFlowName() {
253 // public ExecutionModuleNode getExecutionModuleNode() {
254 // return executionModuleNode;
259 // public class FolderNode extends TreeParent {
260 // public FolderNode(String name) {