]> git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailContentProvider.java
First draft of TestResult Detail Implementation
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.client.core / src / main / java / org / argeo / slc / client / contentprovider / ResultDetailContentProvider.java
1 package org.argeo.slc.client.contentprovider;
2
3 import java.util.SortedMap;
4
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;
12
13 /**
14 * Basic tree view of the chosen process details
15 */
16 public class ResultDetailContentProvider implements ITreeContentProvider {
17 private final static Log log = LogFactory
18 .getLog(ResultDetailContentProvider.class);
19
20 private TreeTestResult treeTestResult;
21
22 public Object[] getChildren(Object parent) {
23 if (parent instanceof TreeTestResult) {
24 treeTestResult = (TreeTestResult) parent;
25
26 SortedMap<TreeSPath, PartSubList> parts = treeTestResult
27 .getResultParts();
28
29 for (TreeSPath key : parts.keySet()) {
30 log.debug("Test[" + key.toString() + "] isPassed = "
31 + parts.get(key).getIsPassed());
32 }
33
34 return parts.keySet().toArray();
35 }
36 // if (parent instanceof ExecutionModuleNode) {
37 // ExecutionModuleNode executionModuleNode = (ExecutionModuleNode)
38 // parent;
39 // ExecutionModuleDescriptor emd =
40 // executionModuleNode.getDescriptor();
41 // emd = executionModuleNode.getAgentNode().getAgent()
42 // .getExecutionModuleDescriptor(emd.getName(),
43 // emd.getVersion());
44 // executionModuleNode.cacheDescriptor(emd);
45 // // for (String flowName :
46 // executionModuleNode.getFlowDescriptors()
47 // // .keySet()) {
48 // // executionModuleNode.addChild(new FlowNode(flowName,
49 // // executionModuleNode));
50 // // }
51 // return executionModuleNode.getChildren();
52 // } else if (parent instanceof AgentNode) {
53 // AgentNode agentNode = (AgentNode) parent;
54 //
55 // if (log.isTraceEnabled())
56 // log.trace("Scan agent " + agentNode);
57 //
58 // agentNode.clearChildren();
59 // for (ExecutionModuleDescriptor desc : agentNode.getAgent()
60 // .listExecutionModuleDescriptors()) {
61 // agentNode.addChild(new ExecutionModuleNode(agentNode, desc));
62 // }
63 //
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];
69 // } else {
70 // List<AgentNode> agentNodes = new ArrayList<AgentNode>();
71 // for (SlcAgent slcAgent : slcAgents) {
72 // agentNodes.add(new AgentNode(slcAgent));
73 // }
74 // return agentNodes.toArray();
75 // }
76 return null;
77 }
78
79 public Object getParent(Object node) {
80 // if (node instanceof TreeObject) {
81 // return ((TreeObject) node).getParent();
82 // }
83 return null;
84 }
85
86 public boolean hasChildren(Object parent) {
87 // if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded())
88 // {
89 // return ((TreeParent) parent).hasChildren();
90 // } else if (parent instanceof AgentNode) {
91 // return true;
92 // } else if (parent instanceof ExecutionModuleNode) {
93 // return true;
94 // }
95 return false;
96 }
97
98 public void inputChanged(Viewer v, Object oldInput, Object newInput) {
99 }
100
101 public void dispose() {
102 }
103
104 public Object[] getElements(Object parent) {
105 if (parent instanceof TreeTestResult) {
106 treeTestResult = (TreeTestResult) parent;
107
108 SortedMap<TreeSPath, PartSubList> parts = treeTestResult
109 .getResultParts();
110
111 for (TreeSPath key : parts.keySet()) {
112 log.debug("Test[" + key.toString() + "] isPassed = "
113 + parts.get(key).getIsPassed());
114 }
115
116 return parts.keySet().toArray();
117 }
118 // return getChildren(parent);
119 return null;
120 }
121
122 // public class AgentNode extends TreeParent {
123 // private final SlcAgent agent;
124 //
125 // public AgentNode(SlcAgent agent) {
126 // super(agent.toString());
127 // this.agent = agent;
128 // }
129
130 // public SlcAgent getAgent() {
131 // return agent;
132 // }
133 // }
134
135 // public class ExecutionModuleNode extends TreeParent {
136 // private final AgentNode agentNode;
137 // private ExecutionModuleDescriptor descriptor;
138 // private Map<String, ExecutionFlowDescriptor> flowDescriptors;
139 //
140 // public ExecutionModuleNode(AgentNode agentNode,
141 // ExecutionModuleDescriptor descriptor) {
142 // super(descriptor.toString());
143 // this.agentNode = agentNode;
144 // this.descriptor = descriptor;
145 //
146 // }
147 //
148 // public AgentNode getAgentNode() {
149 // return agentNode;
150 // }
151 //
152 // public ExecutionModuleDescriptor getDescriptor() {
153 // return descriptor;
154 // }
155 // Object o = thisJoinPoint.getArgs()[0];
156
157 // public void cacheDescriptor(ExecutionModuleDescriptor descriptor) {
158 // this.descriptor = descriptor;
159 //
160 // SortedMap<String, FolderNode> folderNodes = new TreeMap<String,
161 // FolderNode>();
162 //
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());
168 //
169 // // find path and label
170 // String path;
171 // String 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);
177 // } else {
178 // path = fd.getPath();
179 // label = fd.getName();
180 // }
181 // // if (log.isTraceEnabled())
182 // // log.trace("path=" + path + ", label=" + label);
183 //
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));
188 // } else {
189 // FolderNode folderNode = mkdirs(this, path, folderNodes);
190 // folderNode
191 // .addChild(new FlowNode(label, fd.getName(), this));
192 // }
193 //
194 // flowDescriptors.put(fd.getName(), fd);
195 // }
196 // // TODO: make it readonly
197 // }
198 //
199 // protected FolderNode mkdirs(TreeParent root, String path,
200 // SortedMap<String, FolderNode> folderNodes) {
201 // // Normalize
202 // if (path.charAt(0) != '/')
203 // path = '/' + path;
204 // if (path.charAt(path.length() - 1) == '/')
205 // path = path.substring(0, path.length() - 1);
206 //
207 // if (folderNodes.containsKey(path))
208 // return folderNodes.get(path);
209 //
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);
216 // } else {
217 // folderName = path;
218 // parentPath = "";
219 // }
220 //
221 // TreeParent parent;
222 // if (parentPath.equals(""))
223 // parent = root;
224 // else
225 // parent = mkdirs(root, parentPath, folderNodes);
226 // FolderNode newFolder = new FolderNode(folderName);
227 // parent.addChild(newFolder);
228 // folderNodes.put(path, newFolder);
229 // return newFolder;
230 // }
231 //
232 // public Map<String, ExecutionFlowDescriptor> getFlowDescriptors() {
233 // return flowDescriptors;
234 // }
235 //
236 // }
237 //
238 // public class FlowNode extends TreeObject {
239 // private final String flowName;
240 // private final ExecutionModuleNode executionModuleNode;
241 //
242 // public FlowNode(String label, String flowName,
243 // ExecutionModuleNode executionModuleNode) {
244 // super(label);
245 // this.flowName = flowName;
246 // this.executionModuleNode = executionModuleNode;
247 // }
248 //
249 // public String getFlowName() {
250 // return flowName;
251 // }
252 //
253 // public ExecutionModuleNode getExecutionModuleNode() {
254 // return executionModuleNode;
255 // }
256 //
257 // }
258 //
259 // public class FolderNode extends TreeParent {
260 // public FolderNode(String name) {
261 // super(name);
262 // }
263 //
264 // }
265 }